Skip to content

A platform for community discussion. Free, open, simple.

DEV: Simplifying rendering of secondary nav links for group inbox (#19164)

Alan Guo Xiang Tan470b8b898462
diff --git a/app/assets/javascripts/discourse/app/components/user-nav/messages-nav.hbs b/app/assets/javascripts/discourse/app/components/user-nav/messages-nav.hbs
index 565e6c336c9..622d9823b0a 100644
--- a/app/assets/javascripts/discourse/app/components/user-nav/messages-nav.hbs
+++ b/app/assets/javascripts/discourse/app/components/user-nav/messages-nav.hbs
@@ -7,7 +7,7 @@
</ol>
{{/if}}
- <HorizontalOverflowNav>
+ <HorizontalOverflowNav @className="messages-nav">
{{#if @isPersonal}}
<li class="messages-latest">
<LinkTo @route="userPrivateMessages.index" @model={{@user}}>
@@ -47,39 +47,37 @@
</li>
{{/if}}
- {{#each @user.groups as |group|}}
- {{#if (and @isGroup (eq @groupFilter group.name))}}
- {{#if @viewingSelf}}
- <li class="messages-group-latest">
- <LinkTo @route="userPrivateMessages.group" @model={{group.name}}>
- {{d-icon "envelope"}}
- <span>{{i18n "categories.latest"}}</span>
- </LinkTo>
- </li>
+ {{#if @isGroup}}
+ <li class="messages-group-latest">
+ <LinkTo @route="userPrivateMessages.group" @model={{@group.name}}>
+ {{d-icon "envelope"}}
+ <span>{{i18n "categories.latest"}}</span>
+ </LinkTo>
+ </li>
- <li class="messages-group-new">
- <LinkTo @route="userPrivateMessages.groupNew" @model={{group.name}} class="new">
- {{d-icon "exclamation-circle"}}
- <span>{{@newLinkText}}</span>
- </LinkTo>
- </li>
+ {{#if @viewingSelf}}
+ <li class="messages-group-new">
+ <LinkTo @route="userPrivateMessages.groupNew" @model={{@group.name}} class="new">
+ {{d-icon "exclamation-circle"}}
+ <span>{{@newLinkText}}</span>
+ </LinkTo>
+ </li>
- <li class="messages-group-unread">
- <LinkTo @route="userPrivateMessages.groupUnread" @model={{group.name}} class="unread">
- {{d-icon "plus-circle"}}
- <span>{{@unreadLinkText}}</span>
- </LinkTo>
- </li>
- {{/if}}
+ <li class="messages-group-unread">
+ <LinkTo @route="userPrivateMessages.groupUnread" @model={{@group.name}} class="unread">
+ {{d-icon "plus-circle"}}
+ <span>{{@unreadLinkText}}</span>
+ </LinkTo>
+ </li>
<li class="messages-group-archive">
- <LinkTo @route="userPrivateMessages.groupArchive" @model={{group.name}}>
+ <LinkTo @route="userPrivateMessages.groupArchive" @model={{@group.name}}>
{{d-icon "archive"}}
<span>{{i18n "user.messages.archive"}}</span>
</LinkTo>
</li>
{{/if}}
- {{/each}}
+ {{/if}}
{{#if this.displayTags}}
<li class="tags">
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-private-messages-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-private-messages-test.js
index 4535451cb53..a25a434b0f9 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-private-messages-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-private-messages-test.js
@@ -55,609 +55,610 @@ acceptance(
}
);
-acceptance(
- "User Private Messages - user with group messages",
- function (needs) {
- let fetchedNew;
- let fetchUserNew;
- let fetchedGroupNew;
-
- needs.user({
- id: 5,
- username: "charlie",
- groups: [{ id: 14, name: "awesome_group", has_messages: true }],
- });
+function testUserPrivateMessagesWithGroupMessages(needs, customUserProps) {
+ let fetchedNew;
+ let fetchUserNew;
+ let fetchedGroupNew;
+
+ needs.user({
+ id: 5,
+ username: "charlie",
+ groups: [{ id: 14, name: "awesome_group", has_messages: true }],
+ ...(customUserProps || {}),
+ });
- needs.site({
- can_tag_pms: true,
+ needs.site({
+ can_tag_pms: true,
+ });
+
+ needs.hooks.afterEach(() => {
+ fetchedNew = false;
+ fetchedGroupNew = false;
+ fetchUserNew = false;
+ });
+
+ needs.pretender((server, helper) => {
+ server.get("/tags/personal_messages/:username.json", () => {
+ return helper.response({ tags: [] });
});
- needs.hooks.afterEach(() => {
- fetchedNew = false;
- fetchedGroupNew = false;
- fetchUserNew = false;
+ server.get("/t/13.json", () => {
+ const response = cloneJSON(fixturesByUrl["/t/12/1.json"]);
+ response.suggested_group_name = "awesome_group";
+ return helper.response(response);
});
- needs.pretender((server, helper) => {
- server.get("/tags/personal_messages/:username.json", () => {
- return helper.response({ tags: [] });
+ server.get("/topics/private-messages/:username.json", () => {
+ return helper.response({
+ topic_list: {
+ topics: [
+ { id: 1, posters: [] },
+ { id: 2, posters: [] },
+ { id: 3, posters: [] },
+ ],
+ },
});
+ });
- server.get("/t/13.json", () => {
- const response = cloneJSON(fixturesByUrl["/t/12/1.json"]);
- response.suggested_group_name = "awesome_group";
- return helper.response(response);
- });
+ [
+ "/topics/private-messages-new/:username.json",
+ "/topics/private-messages-unread/:username.json",
+ "/topics/private-messages-archive/:username.json",
+ "/topics/private-messages-group/:username/:group_name/new.json",
+ "/topics/private-messages-group/:username/:group_name/unread.json",
+ "/topics/private-messages-group/:username/:group_name/archive.json",
+ ].forEach((url) => {
+ server.get(url, () => {
+ let topics;
+
+ if (fetchedNew || fetchedGroupNew || fetchUserNew) {
+ topics = [];
+ } else {
+ topics = [
+ { id: 1, posters: [] },
+ { id: 2, posters: [] },
+ { id: 3, posters: [] },
+ ];
+ }
- server.get("/topics/private-messages/:username.json", () => {
return helper.response({
topic_list: {
- topics: [
- { id: 1, posters: [] },
- { id: 2, posters: [] },
- { id: 3, posters: [] },
- ],
+ topics,
},
});
});
+ });
- [
- "/topics/private-messages-new/:username.json",
- "/topics/private-messages-unread/:username.json",
- "/topics/private-messages-archive/:username.json",
- "/topics/private-messages-group/:username/:group_name/new.json",
- "/topics/private-messages-group/:username/:group_name/unread.json",
- "/topics/private-messages-group/:username/:group_name/archive.json",
- ].forEach((url) => {
- server.get(url, () => {
- let topics;
-
- if (fetchedNew || fetchedGroupNew || fetchUserNew) {
- topics = [];
- } else {
- topics = [
+ server.get(
+ "/topics/private-messages-group/:username/:group_name.json",
+ () => {
+ return helper.response({
+ topic_list: {
+ topics: [
{ id: 1, posters: [] },
{ id: 2, posters: [] },
- { id: 3, posters: [] },
- ];
- }
-
- return helper.response({
- topic_list: {
- topics,
- },
- });
+ ],
+ },
});
- });
-
- server.get(
- "/topics/private-messages-group/:username/:group_name.json",
- () => {
- return helper.response({
- topic_list: {
- topics: [
- { id: 1, posters: [] },
- { id: 2, posters: [] },
- ],
- },
- });
- }
- );
-
- server.put("/topics/pm-reset-new", (request) => {
- const requestBody = request.requestBody;
- // No easy way to do this https://github.com/pretenderjs/pretender/issues/159
- if (requestBody === "inbox=group&group_name=awesome_group") {
- fetchedGroupNew = true;
- }
-
- if (requestBody === "inbox=user") {
- fetchUserNew = true;
- }
-
- if (requestBody === "inbox=all") {
- fetchedNew = true;
- }
-
- return helper.response({ topic_ids: [1, 2, 3] });
- });
-
- server.put("/topics/bulk", (request) => {
- const requestBody = request.requestBody;
+ }
+ );
- if (requestBody.includes("private_message_inbox=all")) {
- fetchedNew = true;
- }
+ server.put("/topics/pm-reset-new", (request) => {
+ const requestBody = request.requestBody;
+ // No easy way to do this https://github.com/pretenderjs/pretender/issues/159
+ if (requestBody === "inbox=group&group_name=awesome_group") {
+ fetchedGroupNew = true;
+ }
- if (
- requestBody.includes(
- "private_message_inbox=group&group_name=awesome_group"
- )
- ) {
- fetchedGroupNew = true;
- }
+ if (requestBody === "inbox=user") {
+ fetchUserNew = true;
+ }
- if (requestBody.includes("private_message_inbox=user")) {
- fetchUserNew = true;
- }
+ if (requestBody === "inbox=all") {
+ fetchedNew = true;
+ }
- return helper.response({
- topic_ids: [1, 2, 3],
- });
- });
+ return helper.response({ topic_ids: [1, 2, 3] });
});
- const publishReadToMessageBus = function (opts = {}) {
- return publishToMessageBus(
- `/private-message-topic-tracking-state/user/${opts.userId || 5}`,
- {
- topic_id: opts.topicId,
- message_type: "read",
- payload: {
- last_read_post_number: 2,
- highest_post_number: 2,
- notification_level: 2,
- },
- }
- );
- };
-
- const publishUnreadToMessageBus = function (opts = {}) {
- return publishToMessageBus(
- `/private-message-topic-tracking-state/user/${opts.userId || 5}`,
- {
- topic_id: opts.topicId,
- message_type: "unread",
- payload: {
- last_read_post_number: 1,
- highest_post_number: 2,
- notification_level: 2,
- group_ids: opts.groupIds || [],
- },
- }
- );
- };
-
- const publishNewToMessageBus = function (opts = {}) {
- return publishToMessageBus(
- `/private-message-topic-tracking-state/user/${opts.userId || 5}`,
- {
- topic_id: opts.topicId,
- message_type: "new_topic",
- payload: {
- last_read_post_number: null,
- highest_post_number: 1,
- group_ids: opts.groupIds || [],
- },
- }
- );
- };
-
- const publishGroupArchiveToMessageBus = function (opts) {
- return publishToMessageBus(
- `/private-message-topic-tracking-state/group/${opts.groupIds[0]}`,
- {
- topic_id: opts.topicId,
- message_type: "group_archive",
- payload: {
- group_ids: opts.groupIds,
- acting_user_id: opts.actingUserId,
- },
- }
- );
- };
+ server.put("/topics/bulk", (request) => {
+ const requestBody = request.requestBody;
- const publishGroupUnreadToMessageBus = function (opts) {
- return publishToMessageBus(
- `/private-message-topic-tracking-state/group/${opts.groupIds[0]}`,
- {
- topic_id: opts.topicId,
- message_type: "unread",
- payload: {
- last_read_post_number: 1,
- highest_post_number: 2,
- notification_level: 2,
- group_ids: opts.groupIds || [],
- },
- }
- );
- };
-
- const publishGroupNewToMessageBus = function (opts) {
- return publishToMessageBus(
- `/private-message-topic-tracking-state/group/${opts.groupIds[0]}`,
- {
- topic_id: opts.topicId,
- message_type: "new_topic",
- payload: {
- last_read_post_number: null,
- highest_post_number: 1,
- group_ids: opts.groupIds || [],
- },
- }
- );
- };
-
- test("viewing messages filtered by tags", async function (assert) {
- await visit("/u/charlie/messages/tags");
+ if (requestBody.includes("private_message_inbox=all")) {
+ fetchedNew = true;
+ }
- assert.strictEqual(
- count(".action-list li"),
- 3,
- "it does not expand personal or group inbox"
- );
- });
+ if (
+ requestBody.includes(
+ "private_message_inbox=group&group_name=awesome_group"
+ )
+ ) {
+ fetchedGroupNew = true;
+ }
- test("incoming group archive message acted by current user", async function (assert) {
- await visit("/u/charlie/messages");
+ if (requestBody.includes("private_message_inbox=user")) {
+ fetchUserNew = true;
+ }
- await publishGroupArchiveToMessageBus({
- groupIds: [14],
- topicId: 1,
- actingUserId: 5,
+ return helper.response({
+ topic_ids: [1, 2, 3],
});
-
- assert.ok(
- !exists(".show-mores"),
- `does not display the topic incoming info`
- );
});
+ });
- test("incoming group archive message on inbox and archive filter", async function (assert) {
- for (const url of [
- "/u/charlie/messages/group/awesome_group",
- "/u/charlie/messages/group/awesome_group/archive",
- ]) {
- await visit(url);
-
- await publishGroupArchiveToMessageBus({ groupIds: [14], topicId: 1 });
-
- assert.ok(
- exists(".show-mores"),
- `${url} displays the topic incoming info`
- );
+ const publishReadToMessageBus = function (opts = {}) {
+ return publishToMessageBus(
+ `/private-message-topic-tracking-state/user/${opts.userId || 5}`,
+ {
+ topic_id: opts.topicId,
+ message_type: "read",
+ payload: {
+ last_read_post_number: 2,
+ highest_post_number: 2,
+ notification_level: 2,
+ },
}
-
- for (const url of [
- "/u/charlie/messages",
- "/u/charlie/messages/archive",
- ]) {
- await visit(url);
-
- await publishGroupArchiveToMessageBus({ groupIds: [14], topicId: 1 });
-
- assert.ok(
- !exists(".show-mores"),
- `${url} does not display the topic incoming info`
- );
+ );
+ };
+
+ const publishUnreadToMessageBus = function (opts = {}) {
+ return publishToMessageBus(
+ `/private-message-topic-tracking-state/user/${opts.userId || 5}`,
+ {
+ topic_id: opts.topicId,
+ message_type: "unread",
+ payload: {
+ last_read_post_number: 1,
+ highest_post_number: 2,
+ notification_level: 2,
+ group_ids: opts.groupIds || [],
+ },
}
- });
-
- test("incoming unread and new messages on all filter", async function (assert) {
- await visit("/u/charlie/messages");
-
- await publishUnreadToMessageBus({ topicId: 1 });
- await publishNewToMessageBus({ topicId: 2 });
+ );
+ };
+
+ const publishNewToMessageBus = function (opts = {}) {
+ return publishToMessageBus(
+ `/private-message-topic-tracking-state/user/${opts.userId || 5}`,
+ {
+ topic_id: opts.topicId,
+ message_type: "new_topic",
+ payload: {
+ last_read_post_number: null,
+ highest_post_number: 1,
+ group_ids: opts.groupIds || [],
+ },
+ }
+ );
+ };
+
+ const publishGroupArchiveToMessageBus = function (opts) {
+ return publishToMessageBus(
+ `/private-message-topic-tracking-state/group/${opts.groupIds[0]}`,
+ {
+ topic_id: opts.topicId,
+ message_type: "group_archive",
+ payload: {
+ group_ids: opts.groupIds,
+ acting_user_id: opts.actingUserId,
+ },
+ }
+ );
+ };
+
+ const publishGroupUnreadToMessageBus = function (opts) {
+ return publishToMessageBus(
+ `/private-message-topic-tracking-state/group/${opts.groupIds[0]}`,
+ {
+ topic_id: opts.topicId,
+ message_type: "unread",
+ payload: {
+ last_read_post_number: 1,
+ highest_post_number: 2,
+ notification_level: 2,
+ group_ids: opts.groupIds || [],
+ },
+ }
+ );
+ };
+
+ const publishGroupNewToMessageBus = function (opts) {
+ return publishToMessageBus(
+ `/private-message-topic-tracking-state/group/${opts.groupIds[0]}`,
+ {
+ topic_id: opts.topicId,
+ message_type: "new_topic",
+ payload: {
+ last_read_post_number: null,
+ highest_post_number: 1,
+ group_ids: opts.groupIds || [],
+ },
+ }
+ );
+ };
- assert.strictEqual(
- query(".messages-nav li a.new").innerText.trim(),
- I18n.t("user.messages.new_with_count", { count: 1 }),
- "displays the right count"
- );
+ test("incoming group archive message acted by current user", async function (assert) {
+ await visit("/u/charlie/messages");
- assert.strictEqual(
- query(".messages-nav li a.unread").innerText.trim(),
- I18n.t("user.messages.unread_with_count", { count: 1 }),
- "displays the right count"
- );
+ await publishGroupArchiveToMessageBus({
+ groupIds: [14],
+ topicId: 1,
+ actingUserId: 5,
});
- test("incoming new messages while viewing new", async function (assert) {
- await visit("/u/charlie/messages/new");
+ assert.ok(
+ !exists(".show-mores"),
+ `does not display the topic incoming info`
+ );
+ });
- await publishNewToMessageBus({ topicId: 1 });
+ test("incoming group archive message on inbox and archive filter", async function (assert) {
+ for (const url of [
+ "/u/charlie/messages/group/awesome_group",
+ "/u/charlie/messages/group/awesome_group/archive",
+ ]) {
+ await visit(url);
- assert.strictEqual(
- query(".messages-nav li a.new").innerText.trim(),
- I18n.t("user.messages.new_with_count", { count: 1 }),
- "displays the right count"
- );
+ await publishGroupArchiveToMessageBus({ groupIds: [14], topicId: 1 });
- assert.ok(exists(".show-mores"), "displays the topic incoming info");
- });
+ assert.ok(
+ exists(".show-mores"),
+ `${url} displays the topic incoming info`
+ );
+ }
- test("incoming unread messages while viewing unread", async function (assert) {
- await visit("/u/charlie/messages/unread");
+ for (const url of ["/u/charlie/messages", "/u/charlie/messages/archive"]) {
+ await visit(url);
- await publishUnreadToMessageBus();
+ await publishGroupArchiveToMessageBus({ groupIds: [14], topicId: 1 });
- assert.strictEqual(
- query(".messages-nav li a.unread").innerText.trim(),
- I18n.t("user.messages.unread_with_count", { count: 1 }),
- "displays the right count"
+ assert.ok(
+ !exists(".show-mores"),
+ `${url} does not display the topic incoming info`
);
+ }
+ });
- assert.ok(exists(".show-mores"), "displays the topic incoming info");
- });
-
- test("incoming unread and new messages while viewing group unread", async function (assert) {
- await visit("/u/charlie/messages/group/awesome_group/unread");
+ test("incoming unread and new messages on all filter", async function (assert) {
+ await visit("/u/charlie/messages");
- await publishUnreadToMessageBus({ groupIds: [14], topicId: 1 });
- await publishNewToMessageBus({ groupIds: [14], topicId: 2 });
+ await publishUnreadToMessageBus({ topicId: 1 });
+ await publishNewToMessageBus({ topicId: 2 });
- assert.strictEqual(
- query(".messages-nav li a.unread").innerText.trim(),
- I18n.t("user.messages.unread_with_count", { count: 1 }),
- "displays the right count"
- );
+ assert.strictEqual(
+ query(".messages-nav li a.new").innerText.trim(),
+ I18n.t("user.messages.new_with_count", { count: 1 }),
+ "displays the right count"
+ );
- assert.strictEqual(
- query(".messages-nav li a.new").innerText.trim(),
- I18n.t("user.messages.new_with_count", { count: 1 }),
- "displays the right count"
- );
+ assert.strictEqual(
+ query(".messages-nav li a.unread").innerText.trim(),
+ I18n.t("user.messages.unread_with_count", { count: 1 }),
+ "displays the right count"
+ );
+ });
- assert.ok(exists(".show-mores"), "displays the topic incoming info");
+ test("incoming new messages while viewing new", async function (assert) {
+ await visit("/u/charlie/messages/new");
- await visit("/u/charlie/messages/unread");
+ await publishNewToMessageBus({ topicId: 1 });
- assert.strictEqual(
- query(".messages-nav li a.unread").innerText.trim(),
- I18n.t("user.messages.unread"),
- "displays the right count"
- );
+ assert.strictEqual(
+ query(".messages-nav li a.new").innerText.trim(),
+ I18n.t("user.messages.new_with_count", { count: 1 }),
+ "displays the right count"
+ );
- assert.strictEqual(
- query(".messages-nav li a.new").innerText.trim(),
- I18n.t("user.messages.new"),
- "displays the right count"
- );
- });
+ assert.ok(exists(".show-mores"), "displays the topic incoming info");
+ });
- test("incoming messages is not tracked on non user messages route", async function (assert) {
- await visit("/u/charlie/messages");
- await visit("/t/13");
+ test("incoming unread messages while viewing unread", async function (assert) {
+ await visit("/u/charlie/messages/unread");
- await publishNewToMessageBus({ topicId: 1, userId: 5 });
+ await publishUnreadToMessageBus();
- await visit("/u/charlie/messages");
+ assert.strictEqual(
+ query(".messages-nav li a.unread").innerText.trim(),
+ I18n.t("user.messages.unread_with_count", { count: 1 }),
+ "displays the right count"
+ );
- assert.ok(
- !exists(".show-mores"),
- "does not display the topic incoming info"
- );
- });
+ assert.ok(exists(".show-mores"), "displays the topic incoming info");
+ });
- test("dismissing all unread messages", async function (assert) {
- await visit("/u/charlie/messages/unread");
+ test("incoming unread and new messages while viewing group unread", async function (assert) {
+ await visit("/u/charlie/messages/group/awesome_group/unread");
- await publishUnreadToMessageBus({ topicId: 1, userId: 5 });
- await publishUnreadToMessageBus({ topicId: 2, userId: 5 });
- await publishUnreadToMessageBus({ topicId: 3, userId: 5 });
+ await publishUnreadToMessageBus({ groupIds: [14], topicId: 1 });
+ await publishNewToMessageBus({ groupIds: [14], topicId: 2 });
- assert.strictEqual(
- count(".topic-list-item"),
- 3,
- "displays the right topic list"
- );
+ assert.strictEqual(
+ query(".messages-nav li a.unread").innerText.trim(),
+ I18n.t("user.messages.unread_with_count", { count: 1 }),
+ "displays the right count"
+ );
- await click(".btn.dismiss-read");
- await click("#dismiss-read-confirm");
+ assert.strictEqual(
+ query(".messages-nav li a.new").innerText.trim(),
+ I18n.t("user.messages.new_with_count", { count: 1 }),
+ "displays the right count"
+ );
- assert.strictEqual(
- query(".messages-nav li a.unread").innerText.trim(),
- I18n.t("user.messages.unread"),
- "displays the right count"
- );
+ assert.ok(exists(".show-mores"), "displays the topic incoming info");
- assert.strictEqual(
- count(".topic-list-item"),
- 0,
- "displays the right topic list"
- );
- });
+ await visit("/u/charlie/messages/unread");
- test("dismissing personal unread messages", async function (assert) {
- await visit("/u/charlie/messages/unread");
+ assert.strictEqual(
+ query(".messages-nav li a.unread").innerText.trim(),
+ I18n.t("user.messages.unread"),
+ "displays the right count"
+ );
+
+ assert.strictEqual(
+ query(".messages-nav li a.new").innerText.trim(),
+ I18n.t("user.messages.new"),
+ "displays the right count"
+ );
+ });
- assert.strictEqual(
- count(".topic-list-item"),
- 3,
- "displays the right topic list"
- );
+ test("incoming messages is not tracked on non user messages route", async function (assert) {
+ await visit("/u/charlie/messages");
+ await visit("/t/13");
- await click(".btn.dismiss-read");
- await click("#dismiss-read-confirm");
+ await publishNewToMessageBus({ topicId: 1, userId: 5 });
- assert.strictEqual(
- count(".topic-list-item"),
- 0,
- "displays the right topic list"
- );
- });
+ await visit("/u/charlie/messages");
- test("dismissing group unread messages", async function (assert) {
- await visit("/u/charlie/messages/group/awesome_group/unread");
+ assert.ok(
+ !exists(".show-mores"),
+ "does not display the topic incoming info"
+ );
+ });
- assert.strictEqual(
- count(".topic-list-item"),
- 3,
- "displays the right topic list"
- );
+ test("dismissing all unread messages", async function (assert) {
+ await visit("/u/charlie/messages/unread");
- await click(".btn.dismiss-read");
- await click("#dismiss-read-confirm");
+ await publishUnreadToMessageBus({ topicId: 1, userId: 5 });
+ await publishUnreadToMessageBus({ topicId: 2, userId: 5 });
+ await publishUnreadToMessageBus({ topicId: 3, userId: 5 });
+
+ assert.strictEqual(
+ count(".topic-list-item"),
+ 3,
+ "displays the right topic list"
+ );
+
+ await click(".btn.dismiss-read");
+ await click("#dismiss-read-confirm");
+
+ assert.strictEqual(
+ query(".messages-nav li a.unread").innerText.trim(),
+ I18n.t("user.messages.unread"),
+ "displays the right count"
+ );
+
+ assert.strictEqual(
+ count(".topic-list-item"),
+ 0,
+ "displays the right topic list"
+ );
+ });
- assert.strictEqual(
- count(".topic-list-item"),
- 0,
- "displays the right topic list"
- );
- });
+ test("dismissing personal unread messages", async function (assert) {
+ await visit("/u/charlie/messages/unread");
- test("dismissing new messages", async function (assert) {
- await visit("/u/charlie/messages/new");
+ assert.strictEqual(
+ count(".topic-list-item"),
+ 3,
+ "displays the right topic list"
+ );
- await publishNewToMessageBus({ topicId: 1, userId: 5 });
- await publishNewToMessageBus({ topicId: 2, userId: 5 });
- await publishNewToMessageBus({ topicId: 3, userId: 5 });
+ await click(".btn.dismiss-read");
+ await click("#dismiss-read-confirm");
- assert.strictEqual(
- count(".topic-list-item"),
- 3,
- "displays the right topic list"
- );
+ assert.strictEqual(
+ count(".topic-list-item"),
+ 0,
+ "displays the right topic list"
+ );
+ });
- await click(".btn.dismiss-read");
+ test("dismissing group unread messages", async function (assert) {
+ await visit("/u/charlie/messages/group/awesome_group/unread");
- assert.strictEqual(
- query(".messages-nav li a.new").innerText.trim(),
- I18n.t("user.messages.new"),
- "displays the right count"
- );
+ assert.strictEqual(
+ count(".topic-list-item"),
+ 3,
+ "displays the right topic list"
+ );
- assert.strictEqual(
- count(".topic-list-item"),
- 0,
- "displays the right topic list"
- );
- });
+ await click(".btn.dismiss-read");
+ await click("#dismiss-read-confirm");
- test("dismissing personal new messages", async function (assert) {
- await visit("/u/charlie/messages/new");
+ assert.strictEqual(
+ count(".topic-list-item"),
+ 0,
+ "displays the right topic list"
+ );
+ });
- assert.strictEqual(
- count(".topic-list-item"),
- 3,
- "displays the right topic list"
- );
+ test("dismissing new messages", async function (assert) {
+ await visit("/u/charlie/messages/new");
- await click(".btn.dismiss-read");
+ await publishNewToMessageBus({ topicId: 1, userId: 5 });
+ await publishNewToMessageBus({ topicId: 2, userId: 5 });
+ await publishNewToMessageBus({ topicId: 3, userId: 5 });
+
+ assert.strictEqual(
+ count(".topic-list-item"),
+ 3,
+ "displays the right topic list"
+ );
+
+ await click(".btn.dismiss-read");
+
+ assert.strictEqual(
+ query(".messages-nav li a.new").innerText.trim(),
+ I18n.t("user.messages.new"),
+ "displays the right count"
+ );
+
+ assert.strictEqual(
+ count(".topic-list-item"),
+ 0,
+ "displays the right topic list"
+ );
+ });
- assert.strictEqual(
- count(".topic-list-item"),
- 0,
- "displays the right topic list"
- );
- });
+ test("dismissing personal new messages", async function (assert) {
+ await visit("/u/charlie/messages/new");
- test("dismissing new group messages", async function (assert) {
- await visit("/u/charlie/messages/group/awesome_group/new");
+ assert.strictEqual(
+ count(".topic-list-item"),
+ 3,
+ "displays the right topic list"
+ );
- assert.strictEqual(
- count(".topic-list-item"),
- 3,
- "displays the right topic list"
- );
+ await click(".btn.dismiss-read");
- await click(".btn.dismiss-read");
+ assert.strictEqual(
+ count(".topic-list-item"),
+ 0,
+ "displays the right topic list"
+ );
+ });
- assert.strictEqual(
- count(".topic-list-item"),
- 0,
- "displays the right topic list"
- );
- });
+ test("dismissing new group messages", async function (assert) {
+ await visit("/u/charlie/messages/group/awesome_group/new");
- test("viewing messages", async function (assert) {
- await visit("/u/charlie/messages");
+ assert.strictEqual(
+ count(".topic-list-item"),
+ 3,
+ "displays the right topic list"
+ );
- assert.strictEqual(
- count(".topic-list-item"),
- 3,
- "displays the right topic list"
- );
+ await click(".btn.dismiss-read");
- await visit("/u/charlie/messages/group/awesome_group");
+ assert.strictEqual(
+ count(".topic-list-item"),
+ 0,
+ "displays the right topic list"
+ );
+ });
- assert.strictEqual(
- count(".topic-list-item"),
- 2,
- "displays the right topic list"
- );
+ test("viewing messages", async function (assert) {
+ await visit("/u/charlie/messages");
- assert.ok(
- exists(".group-notifications-button"),
- "displays the group notifications button"
- );
- });
+ assert.strictEqual(
+ count(".topic-list-item"),
+ 3,
+ "displays the right topic list"
+ );
- test("suggested messages without new or unread", async function (assert) {
- await visit("/t/12");
+ await visit("/u/charlie/messages/group/awesome_group");
- assert.strictEqual(
- query(".suggested-topics-message").innerText.trim(),
- "Want to read more? Browse other messages in personal messages.",
- "displays the right browse more message"
- );
- });
+ assert.strictEqual(
+ count(".topic-list-item"),
+ 2,
+ "displays the right topic list"
+ );
- test("suggested messages with new and unread", async function (assert) {
- await visit("/t/12");
+ assert.ok(
+ exists(".group-notifications-button"),
+ "displays the group notifications button"
+ );
+ });
- await publishNewToMessageBus({ userId: 5, topicId: 1 });
+ test("suggested messages without new or unread", async function (assert) {
+ await visit("/t/12");
- assert.strictEqual(
- query(".suggested-topics-message").innerText.trim(),
- "There is 1 new message remaining, or browse other personal messages",
- "displays the right browse more message"
- );
+ assert.strictEqual(
+ query(".suggested-topics-message").innerText.trim(),
+ "Want to read more? Browse other messages in personal messages.",
+ "displays the right browse more message"
+ );
+ });
- await publishUnreadToMessageBus({ userId: 5, topicId: 2 });
+ test("suggested messages with new and unread", async function (assert) {
+ await visit("/t/12");
- assert.strictEqual(
- query(".suggested-topics-message").innerText.trim(),
- "There is 1 unread and 1 new message remaining, or browse other personal messages",
- "displays the right browse more message"
- );
+ await publishNewToMessageBus({ userId: 5, topicId: 1 });
- await publishReadToMessageBus({ userId: 5, topicId: 2 });
+ assert.strictEqual(
+ query(".suggested-topics-message").innerText.trim(),
+ "There is 1 new message remaining, or browse other personal messages",
+ "displays the right browse more message"
+ );
- assert.strictEqual(
- query(".suggested-topics-message").innerText.trim(),
- "There is 1 new message remaining, or browse other personal messages",
- "displays the right browse more message"
- );
- });
+ await publishUnreadToMessageBus({ userId: 5, topicId: 2 });
- test("suggested messages for group messages without new or unread", async function (assert) {
- await visit("/t/13");
+ assert.strictEqual(
+ query(".suggested-topics-message").innerText.trim(),
+ "There is 1 unread and 1 new message remaining, or browse other personal messages",
+ "displays the right browse more message"
+ );
- assert.ok(
- query(".suggested-topics-message")
- .innerText.trim()
- .match(
- /Want to read more\? Browse other messages in\s+awesome_group\./
- ),
- "displays the right browse more message"
- );
- });
+ await publishReadToMessageBus({ userId: 5, topicId: 2 });
- test("suggested messages for group messages with new and unread", async function (assert) {
- await visit("/t/13");
+ assert.strictEqual(
+ query(".suggested-topics-message").innerText.trim(),
+ "There is 1 new message remaining, or browse other personal messages",
+ "displays the right browse more message"
+ );
+ });
- await publishGroupNewToMessageBus({ groupIds: [14], topicId: 1 });
+ test("suggested messages for group messages without new or unread", async function (assert) {
+ await visit("/t/13");
+
+ assert.ok(
+ query(".suggested-topics-message")
+ .innerText.trim()
+ .match(
+ /Want to read more\? Browse other messages in\s+awesome_group\./
+ ),
+ "displays the right browse more message"
+ );
+ });
- assert.ok(
- query(".suggested-topics-message")
- .innerText.trim()
- .match(
- /There is 1 new message remaining, or browse other messages in\s+awesome_group/
- ),
- "displays the right browse more message"
- );
+ test("suggested messages for group messages with new and unread", async function (assert) {
+ await visit("/t/13");
+
+ await publishGroupNewToMessageBus({ groupIds: [14], topicId: 1 });
+
+ assert.ok(
+ query(".suggested-topics-message")
+ .innerText.trim()
+ .match(
+ /There is 1 new message remaining, or browse other messages in\s+awesome_group/
+ ),
+ "displays the right browse more message"
+ );
+
+ await publishGroupUnreadToMessageBus({ groupIds: [14], topicId: 2 });
+
+ assert.ok(
+ query(".suggested-topics-message")
+ .innerText.trim()
+ .match(
+ /There is 1 unread and 1 new message remaining, or browse other messages in\s+awesome_group/
+ ),
+ "displays the right browse more message"
+ );
+ });
+}
- await publishGroupUnreadToMessageBus({ groupIds: [14], topicId: 2 });
+acceptance(
+ "User Private Messages - user with group messages",
+ function (needs) {
+ return testUserPrivateMessagesWithGroupMessages(needs);
+ }
+);
- assert.ok(
- query(".suggested-topics-message")
- .innerText.trim()
- .match(
- /There is 1 unread and 1 new message remaining, or browse other messages in\s+awesome_group/
- ),
- "displays the right browse more message"
- );
+acceptance(
+ "User Private Messages - user with group messages - redesigned user page nav enabled",
+ function (needs) {
+ return testUserPrivateMessagesWithGroupMessages(needs, {
+ redesigned_user_page_nav_enabled: true,
});
}
);