2022-06-20 10:07:06 +08:00
|
|
|
import { test } from "qunit";
|
2022-06-22 11:01:37 +08:00
|
|
|
import I18n from "I18n";
|
2022-07-25 01:55:58 +08:00
|
|
|
import { click, currentURL, visit } from "@ember/test-helpers";
|
2022-06-14 15:56:20 +08:00
|
|
|
import {
|
|
|
|
acceptance,
|
2022-07-14 01:29:19 +08:00
|
|
|
count,
|
2022-06-14 15:56:20 +08:00
|
|
|
exists,
|
2022-06-22 11:01:37 +08:00
|
|
|
publishToMessageBus,
|
|
|
|
query,
|
2022-10-10 14:47:55 +08:00
|
|
|
queryAll,
|
2022-06-16 13:33:40 +08:00
|
|
|
updateCurrentUser,
|
2022-06-14 15:56:20 +08:00
|
|
|
} from "discourse/tests/helpers/qunit-helpers";
|
2022-06-22 11:01:37 +08:00
|
|
|
import { NotificationLevels } from "discourse/lib/notification-levels";
|
2022-06-14 15:56:20 +08:00
|
|
|
|
2022-06-16 13:33:40 +08:00
|
|
|
acceptance(
|
2022-09-26 11:58:40 +08:00
|
|
|
"Sidebar - Logged on user - Messages Section - user not in personal_message_enabled_groups",
|
2022-06-16 13:33:40 +08:00
|
|
|
function (needs) {
|
2022-09-26 11:58:40 +08:00
|
|
|
needs.user({ moderator: false, admin: false });
|
2022-06-14 15:56:20 +08:00
|
|
|
|
2022-06-16 13:33:40 +08:00
|
|
|
needs.settings({
|
2022-07-27 13:42:26 +08:00
|
|
|
enable_experimental_sidebar_hamburger: true,
|
|
|
|
enable_sidebar: true,
|
2022-09-26 11:58:40 +08:00
|
|
|
personal_message_enabled_groups: "13", // trust_level_3 auto group ID;
|
2022-06-16 13:33:40 +08:00
|
|
|
});
|
2022-06-14 15:56:20 +08:00
|
|
|
|
2022-06-20 10:07:06 +08:00
|
|
|
test("clicking on section header button", async function (assert) {
|
|
|
|
await visit("/");
|
2022-06-14 15:56:20 +08:00
|
|
|
|
2022-06-20 10:07:06 +08:00
|
|
|
assert.ok(
|
|
|
|
!exists(".sidebar-section-messages"),
|
|
|
|
"does not display messages section in sidebar"
|
|
|
|
);
|
|
|
|
});
|
2022-06-16 13:33:40 +08:00
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
acceptance(
|
2022-09-26 11:58:40 +08:00
|
|
|
"Sidebar - Logged on user - Messages Section - user in personal_message_enabled_groups",
|
2022-06-16 13:33:40 +08:00
|
|
|
function (needs) {
|
2022-07-27 13:42:26 +08:00
|
|
|
needs.user();
|
|
|
|
|
|
|
|
needs.settings({
|
|
|
|
enable_experimental_sidebar_hamburger: true,
|
|
|
|
enable_sidebar: true,
|
2022-06-16 13:33:40 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
needs.pretender((server, helper) => {
|
|
|
|
[
|
|
|
|
"/topics/private-messages-new/:username.json",
|
|
|
|
"/topics/private-messages-unread/:username.json",
|
|
|
|
"/topics/private-messages-archive/:username.json",
|
|
|
|
"/topics/private-messages-sent/:username.json",
|
|
|
|
"/topics/private-messages-group/:username/:group_name/new.json",
|
|
|
|
"/topics/private-messages-group/:username/:group_name.json",
|
|
|
|
"/topics/private-messages-group/:username/:group_name/unread.json",
|
|
|
|
"/topics/private-messages-group/:username/:group_name/archive.json",
|
|
|
|
].forEach((url) => {
|
|
|
|
server.get(url, () => {
|
|
|
|
const topics = [
|
|
|
|
{ id: 1, posters: [] },
|
|
|
|
{ id: 2, posters: [] },
|
|
|
|
{ id: 3, posters: [] },
|
|
|
|
];
|
|
|
|
|
|
|
|
return helper.response({
|
|
|
|
topic_list: {
|
|
|
|
topics,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-06-20 10:07:06 +08:00
|
|
|
test("clicking on section header button", async function (assert) {
|
|
|
|
await visit("/");
|
|
|
|
await click(".sidebar-section-messages .sidebar-section-header-button");
|
2022-06-16 13:33:40 +08:00
|
|
|
|
2022-06-20 10:07:06 +08:00
|
|
|
assert.ok(
|
|
|
|
exists("#reply-control.private-message"),
|
|
|
|
"it opens the composer"
|
|
|
|
);
|
|
|
|
});
|
2022-06-16 13:33:40 +08:00
|
|
|
|
2022-06-20 10:07:06 +08:00
|
|
|
test("clicking on section header link", async function (assert) {
|
|
|
|
await visit("/");
|
2022-08-18 15:03:28 +08:00
|
|
|
await click(".sidebar-section-messages .sidebar-section-header");
|
2022-06-16 13:33:40 +08:00
|
|
|
|
2022-08-18 15:03:28 +08:00
|
|
|
assert.notOk(
|
|
|
|
exists(".sidebar-section-messages .sidebar-section-content"),
|
|
|
|
"hides the content of the section"
|
2022-06-20 10:07:06 +08:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("personal messages section links", async function (assert) {
|
|
|
|
await visit("/");
|
|
|
|
|
|
|
|
assert.ok(
|
|
|
|
exists(
|
|
|
|
".sidebar-section-messages .sidebar-section-link-personal-messages-inbox"
|
|
|
|
),
|
|
|
|
"displays the personal message inbox link"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.strictEqual(
|
2022-07-14 01:29:19 +08:00
|
|
|
count(".sidebar-section-messages .sidebar-section-link"),
|
2022-06-20 10:07:06 +08:00
|
|
|
1,
|
|
|
|
"only displays the personal message inbox link"
|
|
|
|
);
|
|
|
|
|
|
|
|
await click(
|
|
|
|
".sidebar-section-messages .sidebar-section-link-personal-messages-inbox"
|
|
|
|
);
|
2022-06-16 13:33:40 +08:00
|
|
|
|
2022-06-20 10:07:06 +08:00
|
|
|
assert.ok(
|
|
|
|
exists(
|
|
|
|
".sidebar-section-messages .sidebar-section-link-personal-messages-inbox.active"
|
|
|
|
),
|
|
|
|
"personal message inbox link is marked as active"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.strictEqual(
|
2022-07-14 01:29:19 +08:00
|
|
|
count(".sidebar-section-messages .sidebar-section-link"),
|
2022-06-20 10:07:06 +08:00
|
|
|
5,
|
|
|
|
"expands and displays the links for personal messages"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
["new", "archive", "sent", "unread"].forEach((type) => {
|
|
|
|
test(`${type} personal messages section link`, async function (assert) {
|
2022-06-16 13:33:40 +08:00
|
|
|
await visit("/");
|
|
|
|
|
2022-06-20 10:07:06 +08:00
|
|
|
await click(
|
|
|
|
".sidebar-section-messages .sidebar-section-link-personal-messages-inbox"
|
|
|
|
);
|
|
|
|
|
|
|
|
await click(
|
|
|
|
`.sidebar-section-messages .sidebar-section-link-personal-messages-${type}`
|
2022-06-16 13:33:40 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
assert.strictEqual(
|
2022-06-20 10:07:06 +08:00
|
|
|
currentURL(),
|
|
|
|
`/u/eviltrout/messages/${type}`,
|
|
|
|
`it should transition to user's ${type} personal messages`
|
2022-06-16 13:33:40 +08:00
|
|
|
);
|
|
|
|
|
2022-06-20 10:07:06 +08:00
|
|
|
assert.strictEqual(
|
2022-07-14 01:29:19 +08:00
|
|
|
count(".sidebar-section-messages .sidebar-section-link.active"),
|
2022-06-20 10:07:06 +08:00
|
|
|
2,
|
|
|
|
"only two links are marked as active in the sidebar"
|
2022-06-16 13:33:40 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
assert.ok(
|
|
|
|
exists(
|
|
|
|
".sidebar-section-messages .sidebar-section-link-personal-messages-inbox.active"
|
|
|
|
),
|
|
|
|
"personal message inbox link is marked as active"
|
|
|
|
);
|
|
|
|
|
2022-06-20 10:07:06 +08:00
|
|
|
assert.ok(
|
|
|
|
exists(
|
|
|
|
`.sidebar-section-messages .sidebar-section-link-personal-messages-${type}.active`
|
|
|
|
),
|
|
|
|
`personal message ${type} link is marked as active`
|
2022-06-16 13:33:40 +08:00
|
|
|
);
|
2022-10-05 17:59:50 +08:00
|
|
|
|
|
|
|
assert.notOk(
|
|
|
|
exists(
|
|
|
|
`.sidebar-section-messages .sidebar-section-link-personal-messages-${type} .sidebar-section-link-prefix`
|
|
|
|
),
|
|
|
|
`prefix is not displayed for ${type} personal message section link`
|
|
|
|
);
|
2022-06-20 10:07:06 +08:00
|
|
|
});
|
|
|
|
});
|
2022-06-16 13:33:40 +08:00
|
|
|
|
2022-06-20 10:07:06 +08:00
|
|
|
test("group messages section links", async function (assert) {
|
|
|
|
updateCurrentUser({
|
|
|
|
groups: [
|
|
|
|
{
|
2022-10-10 14:47:55 +08:00
|
|
|
name: "group3",
|
2022-06-20 10:07:06 +08:00
|
|
|
has_messages: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "group2",
|
|
|
|
has_messages: false,
|
|
|
|
},
|
|
|
|
{
|
2022-10-10 14:47:55 +08:00
|
|
|
name: "group1",
|
2022-06-20 10:07:06 +08:00
|
|
|
has_messages: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
await visit("/");
|
|
|
|
|
2022-10-10 14:47:55 +08:00
|
|
|
const groupSectionLinks = queryAll(
|
|
|
|
".sidebar-section-messages .sidebar-section-link"
|
2022-06-20 10:07:06 +08:00
|
|
|
);
|
|
|
|
|
2022-10-10 14:47:55 +08:00
|
|
|
assert.deepEqual(
|
|
|
|
groupSectionLinks
|
|
|
|
.toArray()
|
|
|
|
.map((sectionLink) => sectionLink.textContent.trim()),
|
|
|
|
["Inbox", "group1", "group3"],
|
|
|
|
"displays group section links sorted by name"
|
2022-06-20 10:07:06 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
await visit("/u/eviltrout/messages/group/GrOuP1");
|
|
|
|
|
|
|
|
assert.strictEqual(
|
2022-07-14 01:29:19 +08:00
|
|
|
count(".sidebar-section-messages .sidebar-section-link"),
|
2022-06-20 10:07:06 +08:00
|
|
|
6,
|
|
|
|
"expands and displays the links for group1 group messages"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.strictEqual(
|
2022-07-14 01:29:19 +08:00
|
|
|
count(".sidebar-section-messages .sidebar-section-link.group1"),
|
2022-06-20 10:07:06 +08:00
|
|
|
4,
|
|
|
|
"expands the links for group1 group messages"
|
|
|
|
);
|
|
|
|
|
|
|
|
await click(
|
|
|
|
".sidebar-section-messages .sidebar-section-link-group-messages-inbox.group3"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.strictEqual(
|
2022-07-14 01:29:19 +08:00
|
|
|
count(".sidebar-section-messages .sidebar-section-link.group1"),
|
2022-06-20 10:07:06 +08:00
|
|
|
1,
|
|
|
|
"collapses the links for group1 group messages"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.strictEqual(
|
2022-07-14 01:29:19 +08:00
|
|
|
count(".sidebar-section-messages .sidebar-section-link.group3"),
|
2022-06-20 10:07:06 +08:00
|
|
|
4,
|
|
|
|
"expands the links for group3 group messages"
|
2022-06-14 15:56:20 +08:00
|
|
|
);
|
2022-06-16 13:33:40 +08:00
|
|
|
});
|
|
|
|
|
2022-06-20 10:07:06 +08:00
|
|
|
["new", "archive", "unread"].forEach((type) => {
|
|
|
|
test(`${type} group messages section link`, async function (assert) {
|
2022-06-16 13:33:40 +08:00
|
|
|
updateCurrentUser({
|
|
|
|
groups: [
|
|
|
|
{
|
|
|
|
name: "group1",
|
|
|
|
has_messages: true,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "group2",
|
|
|
|
has_messages: false,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "group3",
|
|
|
|
has_messages: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
await visit("/");
|
|
|
|
|
2022-06-20 10:07:06 +08:00
|
|
|
await click(
|
|
|
|
`.sidebar-section-messages .sidebar-section-link-group-messages-inbox.group1`
|
2022-06-16 13:33:40 +08:00
|
|
|
);
|
|
|
|
|
2022-06-20 10:07:06 +08:00
|
|
|
await click(
|
|
|
|
`.sidebar-section-messages .sidebar-section-link-group-messages-${type}.group1`
|
2022-06-16 13:33:40 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
assert.strictEqual(
|
2022-06-20 10:07:06 +08:00
|
|
|
currentURL(),
|
|
|
|
`/u/eviltrout/messages/group/group1/${type}`,
|
|
|
|
`it should transition to user's ${type} personal messages`
|
2022-06-16 13:33:40 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
assert.strictEqual(
|
2022-07-14 01:29:19 +08:00
|
|
|
count(".sidebar-section-messages .sidebar-section-link.active"),
|
2022-06-20 10:07:06 +08:00
|
|
|
2,
|
|
|
|
"only two links are marked as active in the sidebar"
|
2022-06-16 13:33:40 +08:00
|
|
|
);
|
|
|
|
|
2022-06-20 10:07:06 +08:00
|
|
|
assert.ok(
|
|
|
|
exists(
|
|
|
|
".sidebar-section-messages .sidebar-section-link-group-messages-inbox.group1.active"
|
|
|
|
),
|
|
|
|
"group1 group message inbox link is marked as active"
|
2022-06-16 13:33:40 +08:00
|
|
|
);
|
|
|
|
|
2022-06-20 10:07:06 +08:00
|
|
|
assert.ok(
|
|
|
|
exists(
|
|
|
|
`.sidebar-section-messages .sidebar-section-link-group-messages-${type}.group1.active`
|
|
|
|
),
|
|
|
|
`group1 group message ${type} link is marked as active`
|
2022-06-16 13:33:40 +08:00
|
|
|
);
|
2022-06-20 10:07:06 +08:00
|
|
|
});
|
2022-06-16 13:33:40 +08:00
|
|
|
});
|
2022-06-20 11:43:01 +08:00
|
|
|
|
|
|
|
test("viewing personal message topic with a group the user is a part of", async function (assert) {
|
|
|
|
updateCurrentUser({
|
|
|
|
groups: [
|
|
|
|
{
|
|
|
|
name: "foo_group", // based on fixtures
|
|
|
|
has_messages: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
await visit("/t/130");
|
|
|
|
|
|
|
|
assert.strictEqual(
|
2022-07-14 01:29:19 +08:00
|
|
|
count(".sidebar-section-messages .sidebar-section-link"),
|
2022-06-20 11:43:01 +08:00
|
|
|
5,
|
|
|
|
"5 section links are displayed"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.strictEqual(
|
2022-07-14 01:29:19 +08:00
|
|
|
count(
|
2022-06-20 11:43:01 +08:00
|
|
|
".sidebar-section-messages .sidebar-section-link.personal-messages"
|
2022-07-14 01:29:19 +08:00
|
|
|
),
|
2022-06-20 11:43:01 +08:00
|
|
|
1,
|
|
|
|
"personal messages inbox filter links are not shown"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.strictEqual(
|
2022-07-14 01:29:19 +08:00
|
|
|
count(".sidebar-section-messages .sidebar-section-link.foo_group"),
|
2022-06-20 11:43:01 +08:00
|
|
|
4,
|
|
|
|
"foo_group messages inbox filter links are shown"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("viewing personal message topic", async function (assert) {
|
|
|
|
updateCurrentUser({
|
|
|
|
groups: [
|
|
|
|
{
|
|
|
|
name: "foo_group", // based on fixtures
|
|
|
|
has_messages: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
await visit("/t/34");
|
|
|
|
|
|
|
|
assert.strictEqual(
|
2022-07-14 01:29:19 +08:00
|
|
|
count(".sidebar-section-messages .sidebar-section-link"),
|
2022-06-20 11:43:01 +08:00
|
|
|
6,
|
|
|
|
"6 section links are displayed"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.strictEqual(
|
2022-07-14 01:29:19 +08:00
|
|
|
count(
|
2022-06-20 11:43:01 +08:00
|
|
|
".sidebar-section-messages .sidebar-section-link.personal-messages"
|
2022-07-14 01:29:19 +08:00
|
|
|
),
|
2022-06-20 11:43:01 +08:00
|
|
|
5,
|
|
|
|
"personal messages inbox filter links are shown"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.strictEqual(
|
2022-07-14 01:29:19 +08:00
|
|
|
count(".sidebar-section-messages .sidebar-section-link.foo_group"),
|
2022-06-20 11:43:01 +08:00
|
|
|
1,
|
|
|
|
"foo_group messages inbox filter links are not shown"
|
|
|
|
);
|
|
|
|
});
|
2022-06-22 11:01:37 +08:00
|
|
|
|
|
|
|
test("new and unread counts for group messages", async function (assert) {
|
|
|
|
updateCurrentUser({
|
|
|
|
groups: [
|
|
|
|
{
|
|
|
|
id: 1,
|
|
|
|
name: "group1",
|
|
|
|
has_messages: true,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
await visit("/");
|
|
|
|
|
|
|
|
const pmTopicTrackingState = this.container.lookup(
|
2022-07-27 20:00:43 +08:00
|
|
|
"service:pm-topic-tracking-state"
|
2022-06-22 11:01:37 +08:00
|
|
|
);
|
|
|
|
|
2022-07-25 01:55:58 +08:00
|
|
|
await publishToMessageBus(pmTopicTrackingState.groupChannel(1), {
|
2022-06-22 11:01:37 +08:00
|
|
|
topic_id: 1,
|
|
|
|
message_type: "unread",
|
|
|
|
payload: {
|
|
|
|
last_read_post_number: 1,
|
|
|
|
highest_post_number: 2,
|
|
|
|
notification_level: NotificationLevels.TRACKING,
|
|
|
|
group_ids: [1],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2022-07-25 01:55:58 +08:00
|
|
|
await publishToMessageBus(pmTopicTrackingState.groupChannel(1), {
|
2022-06-22 11:01:37 +08:00
|
|
|
topic_id: 2,
|
|
|
|
message_type: "new_topic",
|
|
|
|
payload: {
|
|
|
|
last_read_post_number: null,
|
|
|
|
highest_post_number: 1,
|
|
|
|
notification_level: NotificationLevels.TRACKING,
|
|
|
|
group_ids: [1],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
await click(
|
|
|
|
".sidebar-section-messages .sidebar-section-link-group-messages-inbox.group1"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.strictEqual(
|
|
|
|
query(
|
|
|
|
".sidebar-section-messages .sidebar-section-link-group-messages-unread.group1"
|
|
|
|
).textContent.trim(),
|
|
|
|
I18n.t("sidebar.sections.messages.links.unread_with_count", {
|
|
|
|
count: 1,
|
|
|
|
}),
|
|
|
|
"displays 1 count for group1 unread inbox filter link"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.strictEqual(
|
|
|
|
query(
|
|
|
|
".sidebar-section-messages .sidebar-section-link-group-messages-new.group1"
|
|
|
|
).textContent.trim(),
|
|
|
|
I18n.t("sidebar.sections.messages.links.new_with_count", {
|
|
|
|
count: 1,
|
|
|
|
}),
|
|
|
|
"displays 1 count for group1 new inbox filter link"
|
|
|
|
);
|
|
|
|
|
2022-07-25 01:55:58 +08:00
|
|
|
await publishToMessageBus(pmTopicTrackingState.groupChannel(1), {
|
2022-06-22 11:01:37 +08:00
|
|
|
topic_id: 2,
|
|
|
|
message_type: "read",
|
|
|
|
payload: {
|
|
|
|
last_read_post_number: 1,
|
|
|
|
highest_post_number: 1,
|
|
|
|
notification_level: NotificationLevels.TRACKING,
|
|
|
|
group_ids: [1],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
assert.strictEqual(
|
|
|
|
query(
|
|
|
|
".sidebar-section-messages .sidebar-section-link-group-messages-new.group1"
|
|
|
|
).textContent.trim(),
|
|
|
|
I18n.t("sidebar.sections.messages.links.new"),
|
|
|
|
"removes count for group1 new inbox filter link"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("new and unread counts for personal messages", async function (assert) {
|
|
|
|
await visit("/");
|
|
|
|
|
|
|
|
const pmTopicTrackingState = this.container.lookup(
|
2022-07-27 20:00:43 +08:00
|
|
|
"service:pm-topic-tracking-state"
|
2022-06-22 11:01:37 +08:00
|
|
|
);
|
|
|
|
|
2022-07-25 01:55:58 +08:00
|
|
|
await publishToMessageBus(pmTopicTrackingState.userChannel(), {
|
2022-06-22 11:01:37 +08:00
|
|
|
topic_id: 1,
|
|
|
|
message_type: "unread",
|
|
|
|
payload: {
|
|
|
|
last_read_post_number: 1,
|
|
|
|
highest_post_number: 2,
|
|
|
|
notification_level: NotificationLevels.TRACKING,
|
|
|
|
group_ids: [],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
await click(
|
|
|
|
".sidebar-section-messages .sidebar-section-link-personal-messages-inbox"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.strictEqual(
|
|
|
|
query(
|
|
|
|
".sidebar-section-messages .sidebar-section-link-personal-messages-unread"
|
|
|
|
).textContent.trim(),
|
|
|
|
I18n.t("sidebar.sections.messages.links.unread_with_count", {
|
|
|
|
count: 1,
|
|
|
|
}),
|
|
|
|
"displays 1 count for the unread inbox filter link"
|
|
|
|
);
|
|
|
|
|
2022-07-25 01:55:58 +08:00
|
|
|
await publishToMessageBus(pmTopicTrackingState.userChannel(), {
|
2022-06-22 11:01:37 +08:00
|
|
|
topic_id: 2,
|
|
|
|
message_type: "unread",
|
|
|
|
payload: {
|
|
|
|
last_read_post_number: 1,
|
|
|
|
highest_post_number: 2,
|
|
|
|
notification_level: NotificationLevels.TRACKING,
|
|
|
|
group_ids: [],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
assert.strictEqual(
|
|
|
|
query(
|
|
|
|
".sidebar-section-messages .sidebar-section-link-personal-messages-unread"
|
|
|
|
).textContent.trim(),
|
|
|
|
I18n.t("sidebar.sections.messages.links.unread_with_count", {
|
|
|
|
count: 2,
|
|
|
|
}),
|
|
|
|
"displays 2 count for the unread inbox filter link"
|
|
|
|
);
|
|
|
|
|
2022-07-25 01:55:58 +08:00
|
|
|
await publishToMessageBus(pmTopicTrackingState.userChannel(), {
|
2022-06-22 11:01:37 +08:00
|
|
|
topic_id: 3,
|
|
|
|
message_type: "new_topic",
|
|
|
|
payload: {
|
|
|
|
last_read_post_number: null,
|
|
|
|
highest_post_number: 1,
|
|
|
|
notification_level: NotificationLevels.TRACKING,
|
|
|
|
group_ids: [],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
assert.strictEqual(
|
|
|
|
query(
|
|
|
|
".sidebar-section-messages .sidebar-section-link-personal-messages-new"
|
|
|
|
).textContent.trim(),
|
|
|
|
I18n.t("sidebar.sections.messages.links.new_with_count", {
|
|
|
|
count: 1,
|
|
|
|
}),
|
|
|
|
"displays 1 count for the new inbox filter link"
|
|
|
|
);
|
|
|
|
|
2022-07-25 01:55:58 +08:00
|
|
|
await publishToMessageBus(pmTopicTrackingState.userChannel(), {
|
2022-06-22 11:01:37 +08:00
|
|
|
topic_id: 3,
|
|
|
|
message_type: "read",
|
|
|
|
payload: {
|
|
|
|
last_read_post_number: 1,
|
|
|
|
highest_post_number: 1,
|
|
|
|
notification_level: NotificationLevels.TRACKING,
|
|
|
|
group_ids: [],
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
assert.strictEqual(
|
|
|
|
query(
|
|
|
|
".sidebar-section-messages .sidebar-section-link-personal-messages-new"
|
|
|
|
).textContent.trim(),
|
|
|
|
I18n.t("sidebar.sections.messages.links.new"),
|
|
|
|
"removes the count from the new inbox filter link"
|
|
|
|
);
|
|
|
|
});
|
2022-06-16 13:33:40 +08:00
|
|
|
}
|
|
|
|
);
|