parent
ff16ba1fc0
commit
6cae26c499
|
@ -19,7 +19,7 @@ acceptance("User Notifications", function (needs) {
|
|||
|
||||
// set older notifications to read
|
||||
|
||||
publishToMessageBus("/notification/19", {
|
||||
await publishToMessageBus("/notification/19", {
|
||||
unread_notifications: 5,
|
||||
unread_private_messages: 0,
|
||||
unread_high_priority_notifications: 0,
|
||||
|
@ -35,13 +35,11 @@ acceptance("User Notifications", function (needs) {
|
|||
seen_notification_id: null,
|
||||
});
|
||||
|
||||
await visit("/"); // wait for re-render
|
||||
|
||||
assert.strictEqual(count("#quick-access-notifications li"), 6);
|
||||
|
||||
// high priority, unread notification - should be first
|
||||
|
||||
publishToMessageBus("/notification/19", {
|
||||
await publishToMessageBus("/notification/19", {
|
||||
unread_notifications: 6,
|
||||
unread_private_messages: 0,
|
||||
unread_high_priority_notifications: 1,
|
||||
|
@ -79,8 +77,6 @@ acceptance("User Notifications", function (needs) {
|
|||
seen_notification_id: null,
|
||||
});
|
||||
|
||||
await visit("/"); // wait for re-render
|
||||
|
||||
assert.strictEqual(count("#quick-access-notifications li"), 6);
|
||||
assert.strictEqual(
|
||||
query("#quick-access-notifications li span[data-topic-id]").innerText,
|
||||
|
@ -89,7 +85,7 @@ acceptance("User Notifications", function (needs) {
|
|||
|
||||
// high priority, read notification - should be second
|
||||
|
||||
publishToMessageBus("/notification/19", {
|
||||
await publishToMessageBus("/notification/19", {
|
||||
unread_notifications: 7,
|
||||
unread_private_messages: 0,
|
||||
unread_high_priority_notifications: 1,
|
||||
|
@ -128,8 +124,6 @@ acceptance("User Notifications", function (needs) {
|
|||
seen_notification_id: null,
|
||||
});
|
||||
|
||||
await visit("/"); // wait for re-render
|
||||
|
||||
assert.strictEqual(count("#quick-access-notifications li"), 7);
|
||||
assert.strictEqual(
|
||||
queryAll("#quick-access-notifications li span[data-topic-id]")[1]
|
||||
|
@ -139,7 +133,7 @@ acceptance("User Notifications", function (needs) {
|
|||
|
||||
// updates existing notifications
|
||||
|
||||
publishToMessageBus("/notification/19", {
|
||||
await publishToMessageBus("/notification/19", {
|
||||
unread_notifications: 8,
|
||||
unread_private_messages: 0,
|
||||
unread_high_priority_notifications: 1,
|
||||
|
@ -179,7 +173,6 @@ acceptance("User Notifications", function (needs) {
|
|||
seen_notification_id: null,
|
||||
});
|
||||
|
||||
await visit("/"); // wait for re-render
|
||||
assert.strictEqual(count("#quick-access-notifications li"), 8);
|
||||
const texts = [];
|
||||
queryAll("#quick-access-notifications li").each((_, el) =>
|
||||
|
@ -204,7 +197,7 @@ acceptance("Category Notifications", function (needs) {
|
|||
test("New category is muted when parent category is muted", async function (assert) {
|
||||
await visit("/");
|
||||
const user = User.current();
|
||||
publishToMessageBus("/categories", {
|
||||
await publishToMessageBus("/categories", {
|
||||
categories: [
|
||||
{
|
||||
id: 3,
|
||||
|
@ -217,7 +210,7 @@ acceptance("Category Notifications", function (needs) {
|
|||
});
|
||||
assert.deepEqual(user.indirectly_muted_category_ids, [2]);
|
||||
|
||||
publishToMessageBus("/categories", {
|
||||
await publishToMessageBus("/categories", {
|
||||
categories: [
|
||||
{
|
||||
id: 4,
|
||||
|
|
|
@ -221,15 +221,13 @@ acceptance("Review", function (needs) {
|
|||
);
|
||||
assert.ok(!exists(".stale-help"));
|
||||
|
||||
publishToMessageBus("/reviewable_counts", {
|
||||
await publishToMessageBus("/reviewable_counts", {
|
||||
review_count: 1,
|
||||
updates: {
|
||||
1234: { last_performing_username: "foo", status: 1 },
|
||||
},
|
||||
});
|
||||
|
||||
await visit("/review"); // wait for re-render
|
||||
|
||||
assert.ok(reviewable.className.includes("reviewable-stale"));
|
||||
assert.strictEqual(count("[data-reviewable-id=1234] .status .approved"), 1);
|
||||
assert.strictEqual(count(".stale-help"), 1);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import I18n from "I18n";
|
||||
import { test } from "qunit";
|
||||
import { click, currentURL, settled, visit } from "@ember/test-helpers";
|
||||
import { click, currentURL, visit } from "@ember/test-helpers";
|
||||
import {
|
||||
acceptance,
|
||||
count,
|
||||
|
@ -333,7 +333,7 @@ acceptance("Sidebar - Categories Section", function (needs) {
|
|||
`displays 2 unread count for ${category2.slug} section link`
|
||||
);
|
||||
|
||||
publishToMessageBus("/unread", {
|
||||
await publishToMessageBus("/unread", {
|
||||
topic_id: 2,
|
||||
message_type: "read",
|
||||
payload: {
|
||||
|
@ -342,8 +342,6 @@ acceptance("Sidebar - Categories Section", function (needs) {
|
|||
},
|
||||
});
|
||||
|
||||
await settled();
|
||||
|
||||
assert.strictEqual(
|
||||
query(
|
||||
`.sidebar-section-link-${category1.slug} .sidebar-section-link-content-badge`
|
||||
|
@ -352,7 +350,7 @@ acceptance("Sidebar - Categories Section", function (needs) {
|
|||
`displays 1 new count for ${category1.slug} section link`
|
||||
);
|
||||
|
||||
publishToMessageBus("/unread", {
|
||||
await publishToMessageBus("/unread", {
|
||||
topic_id: 1,
|
||||
message_type: "read",
|
||||
payload: {
|
||||
|
@ -361,8 +359,6 @@ acceptance("Sidebar - Categories Section", function (needs) {
|
|||
},
|
||||
});
|
||||
|
||||
await settled();
|
||||
|
||||
assert.ok(
|
||||
!exists(
|
||||
`.sidebar-section-link-${category1.slug} .sidebar-section-link-content-badge`
|
||||
|
@ -370,7 +366,7 @@ acceptance("Sidebar - Categories Section", function (needs) {
|
|||
`does not display any badge ${category1.slug} section link`
|
||||
);
|
||||
|
||||
publishToMessageBus("/unread", {
|
||||
await publishToMessageBus("/unread", {
|
||||
topic_id: 3,
|
||||
message_type: "read",
|
||||
payload: {
|
||||
|
@ -379,8 +375,6 @@ acceptance("Sidebar - Categories Section", function (needs) {
|
|||
},
|
||||
});
|
||||
|
||||
await settled();
|
||||
|
||||
assert.strictEqual(
|
||||
query(
|
||||
`.sidebar-section-link-${category2.slug} .sidebar-section-link-content-badge`
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import I18n from "I18n";
|
||||
|
||||
import { test } from "qunit";
|
||||
import { click, currentURL, settled, visit } from "@ember/test-helpers";
|
||||
import { click, currentURL, visit } from "@ember/test-helpers";
|
||||
import {
|
||||
acceptance,
|
||||
count,
|
||||
|
@ -238,12 +237,10 @@ acceptance("Sidebar - Community Section", function (needs) {
|
|||
test("clicking on my posts link when user has a draft", async function (assert) {
|
||||
await visit("/t/280");
|
||||
|
||||
publishToMessageBus(`/user-drafts/${loggedInUser().id}`, {
|
||||
await publishToMessageBus(`/user-drafts/${loggedInUser().id}`, {
|
||||
draft_count: 1,
|
||||
});
|
||||
|
||||
await settled();
|
||||
|
||||
await click(".sidebar-section-community .sidebar-section-link-my-posts");
|
||||
|
||||
assert.strictEqual(
|
||||
|
@ -386,7 +383,7 @@ acceptance("Sidebar - Community Section", function (needs) {
|
|||
);
|
||||
|
||||
// simulate reading topic 2
|
||||
publishToMessageBus("/unread", {
|
||||
await publishToMessageBus("/unread", {
|
||||
topic_id: 2,
|
||||
message_type: "read",
|
||||
payload: {
|
||||
|
@ -396,8 +393,6 @@ acceptance("Sidebar - Community Section", function (needs) {
|
|||
},
|
||||
});
|
||||
|
||||
await settled();
|
||||
|
||||
assert.strictEqual(
|
||||
query(
|
||||
".sidebar-section-link-everything .sidebar-section-link-content-badge"
|
||||
|
@ -407,7 +402,7 @@ acceptance("Sidebar - Community Section", function (needs) {
|
|||
);
|
||||
|
||||
// simulate reading topic 3
|
||||
publishToMessageBus("/unread", {
|
||||
await publishToMessageBus("/unread", {
|
||||
topic_id: 3,
|
||||
message_type: "read",
|
||||
payload: {
|
||||
|
@ -418,7 +413,7 @@ acceptance("Sidebar - Community Section", function (needs) {
|
|||
});
|
||||
|
||||
// simulate reading topic 4
|
||||
publishToMessageBus("/unread", {
|
||||
await publishToMessageBus("/unread", {
|
||||
topic_id: 4,
|
||||
message_type: "read",
|
||||
payload: {
|
||||
|
@ -428,8 +423,6 @@ acceptance("Sidebar - Community Section", function (needs) {
|
|||
},
|
||||
});
|
||||
|
||||
await settled();
|
||||
|
||||
assert.strictEqual(
|
||||
query(
|
||||
".sidebar-section-link-everything .sidebar-section-link-content-badge"
|
||||
|
@ -443,7 +436,7 @@ acceptance("Sidebar - Community Section", function (needs) {
|
|||
"it links to new filter"
|
||||
);
|
||||
|
||||
publishToMessageBus("/unread", {
|
||||
await publishToMessageBus("/unread", {
|
||||
topic_id: 1,
|
||||
message_type: "read",
|
||||
payload: {
|
||||
|
@ -453,8 +446,6 @@ acceptance("Sidebar - Community Section", function (needs) {
|
|||
},
|
||||
});
|
||||
|
||||
await settled();
|
||||
|
||||
assert.ok(
|
||||
!exists(
|
||||
".sidebar-section-link-everything .sidebar-section-link-content-badge"
|
||||
|
@ -600,7 +591,7 @@ acceptance("Sidebar - Community Section", function (needs) {
|
|||
);
|
||||
|
||||
// simulate reading topic id 2
|
||||
publishToMessageBus("/unread", {
|
||||
await publishToMessageBus("/unread", {
|
||||
topic_id: 2,
|
||||
message_type: "read",
|
||||
payload: {
|
||||
|
@ -609,8 +600,6 @@ acceptance("Sidebar - Community Section", function (needs) {
|
|||
},
|
||||
});
|
||||
|
||||
await settled();
|
||||
|
||||
assert.strictEqual(
|
||||
query(
|
||||
".sidebar-section-link-tracked .sidebar-section-link-content-badge"
|
||||
|
@ -620,7 +609,7 @@ acceptance("Sidebar - Community Section", function (needs) {
|
|||
);
|
||||
|
||||
// simulate reading topic id 3
|
||||
publishToMessageBus("/unread", {
|
||||
await publishToMessageBus("/unread", {
|
||||
topic_id: 3,
|
||||
message_type: "read",
|
||||
payload: {
|
||||
|
@ -630,7 +619,7 @@ acceptance("Sidebar - Community Section", function (needs) {
|
|||
});
|
||||
|
||||
// simulate reading topic id 6
|
||||
publishToMessageBus("/unread", {
|
||||
await publishToMessageBus("/unread", {
|
||||
topic_id: 6,
|
||||
message_type: "read",
|
||||
payload: {
|
||||
|
@ -653,7 +642,7 @@ acceptance("Sidebar - Community Section", function (needs) {
|
|||
);
|
||||
|
||||
// simulate reading topic id 1
|
||||
publishToMessageBus("/unread", {
|
||||
await publishToMessageBus("/unread", {
|
||||
topic_id: 1,
|
||||
message_type: "read",
|
||||
payload: {
|
||||
|
@ -662,8 +651,6 @@ acceptance("Sidebar - Community Section", function (needs) {
|
|||
},
|
||||
});
|
||||
|
||||
await settled();
|
||||
|
||||
assert.ok(
|
||||
!exists(
|
||||
".sidebar-section-link-tracked .sidebar-section-link-content-badge"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { test } from "qunit";
|
||||
import I18n from "I18n";
|
||||
import { click, currentURL, settled, visit } from "@ember/test-helpers";
|
||||
import { click, currentURL, visit } from "@ember/test-helpers";
|
||||
import {
|
||||
acceptance,
|
||||
count,
|
||||
|
@ -367,7 +367,7 @@ acceptance(
|
|||
"pm-topic-tracking-state:main"
|
||||
);
|
||||
|
||||
publishToMessageBus(pmTopicTrackingState.groupChannel(1), {
|
||||
await publishToMessageBus(pmTopicTrackingState.groupChannel(1), {
|
||||
topic_id: 1,
|
||||
message_type: "unread",
|
||||
payload: {
|
||||
|
@ -378,7 +378,7 @@ acceptance(
|
|||
},
|
||||
});
|
||||
|
||||
publishToMessageBus(pmTopicTrackingState.groupChannel(1), {
|
||||
await publishToMessageBus(pmTopicTrackingState.groupChannel(1), {
|
||||
topic_id: 2,
|
||||
message_type: "new_topic",
|
||||
payload: {
|
||||
|
@ -413,7 +413,7 @@ acceptance(
|
|||
"displays 1 count for group1 new inbox filter link"
|
||||
);
|
||||
|
||||
publishToMessageBus(pmTopicTrackingState.groupChannel(1), {
|
||||
await publishToMessageBus(pmTopicTrackingState.groupChannel(1), {
|
||||
topic_id: 2,
|
||||
message_type: "read",
|
||||
payload: {
|
||||
|
@ -424,8 +424,6 @@ acceptance(
|
|||
},
|
||||
});
|
||||
|
||||
await settled();
|
||||
|
||||
assert.strictEqual(
|
||||
query(
|
||||
".sidebar-section-messages .sidebar-section-link-group-messages-new.group1"
|
||||
|
@ -442,7 +440,7 @@ acceptance(
|
|||
"pm-topic-tracking-state:main"
|
||||
);
|
||||
|
||||
publishToMessageBus(pmTopicTrackingState.userChannel(), {
|
||||
await publishToMessageBus(pmTopicTrackingState.userChannel(), {
|
||||
topic_id: 1,
|
||||
message_type: "unread",
|
||||
payload: {
|
||||
|
@ -453,8 +451,6 @@ acceptance(
|
|||
},
|
||||
});
|
||||
|
||||
await settled();
|
||||
|
||||
await click(
|
||||
".sidebar-section-messages .sidebar-section-link-personal-messages-inbox"
|
||||
);
|
||||
|
@ -469,7 +465,7 @@ acceptance(
|
|||
"displays 1 count for the unread inbox filter link"
|
||||
);
|
||||
|
||||
publishToMessageBus(pmTopicTrackingState.userChannel(), {
|
||||
await publishToMessageBus(pmTopicTrackingState.userChannel(), {
|
||||
topic_id: 2,
|
||||
message_type: "unread",
|
||||
payload: {
|
||||
|
@ -480,8 +476,6 @@ acceptance(
|
|||
},
|
||||
});
|
||||
|
||||
await settled();
|
||||
|
||||
assert.strictEqual(
|
||||
query(
|
||||
".sidebar-section-messages .sidebar-section-link-personal-messages-unread"
|
||||
|
@ -492,7 +486,7 @@ acceptance(
|
|||
"displays 2 count for the unread inbox filter link"
|
||||
);
|
||||
|
||||
publishToMessageBus(pmTopicTrackingState.userChannel(), {
|
||||
await publishToMessageBus(pmTopicTrackingState.userChannel(), {
|
||||
topic_id: 3,
|
||||
message_type: "new_topic",
|
||||
payload: {
|
||||
|
@ -503,8 +497,6 @@ acceptance(
|
|||
},
|
||||
});
|
||||
|
||||
await settled();
|
||||
|
||||
assert.strictEqual(
|
||||
query(
|
||||
".sidebar-section-messages .sidebar-section-link-personal-messages-new"
|
||||
|
@ -515,7 +507,7 @@ acceptance(
|
|||
"displays 1 count for the new inbox filter link"
|
||||
);
|
||||
|
||||
publishToMessageBus(pmTopicTrackingState.userChannel(), {
|
||||
await publishToMessageBus(pmTopicTrackingState.userChannel(), {
|
||||
topic_id: 3,
|
||||
message_type: "read",
|
||||
payload: {
|
||||
|
@ -526,8 +518,6 @@ acceptance(
|
|||
},
|
||||
});
|
||||
|
||||
await settled();
|
||||
|
||||
assert.strictEqual(
|
||||
query(
|
||||
".sidebar-section-messages .sidebar-section-link-personal-messages-new"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import I18n from "I18n";
|
||||
import { test } from "qunit";
|
||||
import { click, currentURL, settled, visit } from "@ember/test-helpers";
|
||||
import { click, currentURL, visit } from "@ember/test-helpers";
|
||||
import {
|
||||
acceptance,
|
||||
count,
|
||||
|
@ -9,9 +9,7 @@ import {
|
|||
query,
|
||||
updateCurrentUser,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
|
||||
import { undockSidebar } from "discourse/tests/helpers/sidebar-helpers";
|
||||
|
||||
import discoveryFixture from "discourse/tests/fixtures/discovery-fixtures";
|
||||
import { cloneJSON } from "discourse-common/lib/object";
|
||||
|
||||
|
@ -283,7 +281,7 @@ acceptance("Sidebar - Tags section", function (needs) {
|
|||
"does not display any badge for tag3 section link"
|
||||
);
|
||||
|
||||
publishToMessageBus("/unread", {
|
||||
await publishToMessageBus("/unread", {
|
||||
topic_id: 2,
|
||||
message_type: "read",
|
||||
payload: {
|
||||
|
@ -292,8 +290,6 @@ acceptance("Sidebar - Tags section", function (needs) {
|
|||
},
|
||||
});
|
||||
|
||||
await settled();
|
||||
|
||||
assert.strictEqual(
|
||||
query(
|
||||
`.sidebar-section-link-tag1 .sidebar-section-link-content-badge`
|
||||
|
@ -302,7 +298,7 @@ acceptance("Sidebar - Tags section", function (needs) {
|
|||
`displays 1 new count for tag1 section link`
|
||||
);
|
||||
|
||||
publishToMessageBus("/unread", {
|
||||
await publishToMessageBus("/unread", {
|
||||
topic_id: 1,
|
||||
message_type: "read",
|
||||
payload: {
|
||||
|
@ -311,8 +307,6 @@ acceptance("Sidebar - Tags section", function (needs) {
|
|||
},
|
||||
});
|
||||
|
||||
await settled();
|
||||
|
||||
assert.ok(
|
||||
!exists(`.sidebar-section-link-tag1 .sidebar-section-link-content-badge`),
|
||||
`does not display any badge tag1 section link`
|
||||
|
|
|
@ -110,7 +110,7 @@ acceptance("Topic Discovery", function (needs) {
|
|||
"shows the topic unread"
|
||||
);
|
||||
|
||||
publishToMessageBus("/latest", {
|
||||
await publishToMessageBus("/latest", {
|
||||
message_type: "read",
|
||||
topic_id: 11995,
|
||||
payload: {
|
||||
|
@ -121,8 +121,6 @@ acceptance("Topic Discovery", function (needs) {
|
|||
},
|
||||
});
|
||||
|
||||
await visit("/"); // We're already there, but use this to wait for re-render
|
||||
|
||||
assert.ok(
|
||||
exists(".topic-list-item.visited a[data-topic-id='11995']"),
|
||||
"shows the topic read"
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import { settled, visit } from "@ember/test-helpers";
|
||||
import { visit } from "@ember/test-helpers";
|
||||
import I18n from "I18n";
|
||||
import { test } from "qunit";
|
||||
|
||||
import {
|
||||
acceptance,
|
||||
exists,
|
||||
|
@ -198,7 +197,7 @@ acceptance("Topic Discovery Tracked", function (needs) {
|
|||
);
|
||||
|
||||
// simulate reading topic id 1
|
||||
publishToMessageBus("/unread", {
|
||||
await publishToMessageBus("/unread", {
|
||||
topic_id: 1,
|
||||
message_type: "read",
|
||||
payload: {
|
||||
|
@ -208,7 +207,7 @@ acceptance("Topic Discovery Tracked", function (needs) {
|
|||
});
|
||||
|
||||
// simulate reading topic id 3
|
||||
publishToMessageBus("/unread", {
|
||||
await publishToMessageBus("/unread", {
|
||||
topic_id: 3,
|
||||
message_type: "read",
|
||||
payload: {
|
||||
|
@ -217,8 +216,6 @@ acceptance("Topic Discovery Tracked", function (needs) {
|
|||
},
|
||||
});
|
||||
|
||||
await settled();
|
||||
|
||||
assert.strictEqual(
|
||||
query("#navigation-bar li.unread").textContent.trim(),
|
||||
I18n.t("filters.unread.title_with_count", { count: 2 }),
|
||||
|
@ -243,11 +240,11 @@ acceptance("Topic Discovery Tracked", function (needs) {
|
|||
notification_level: null,
|
||||
created_in_new_period: true,
|
||||
treat_as_new_topic_start_date: "2022-05-09T03:17:34.286Z",
|
||||
tags: ["someothertag"],
|
||||
tags: ["some-other-tag"],
|
||||
},
|
||||
]);
|
||||
|
||||
await visit("/tag/someothertag");
|
||||
await visit("/tag/some-other-tag");
|
||||
|
||||
assert.strictEqual(
|
||||
query("#navigation-bar li.unread").textContent.trim(),
|
||||
|
@ -261,7 +258,7 @@ acceptance("Topic Discovery Tracked", function (needs) {
|
|||
"displays the right content on new link"
|
||||
);
|
||||
|
||||
await visit("/tag/someothertag?f=tracked");
|
||||
await visit("/tag/some-other-tag?f=tracked");
|
||||
|
||||
assert.strictEqual(
|
||||
query("#navigation-bar li.unread").textContent.trim(),
|
||||
|
|
|
@ -12,7 +12,6 @@ import {
|
|||
click,
|
||||
currentURL,
|
||||
fillIn,
|
||||
settled,
|
||||
triggerKeyEvent,
|
||||
visit,
|
||||
} from "@ember/test-helpers";
|
||||
|
@ -664,9 +663,8 @@ acceptance("Topic stats update automatically", function () {
|
|||
};
|
||||
|
||||
// simulate the topic like_count being changed
|
||||
publishToMessageBus("/topic/280", likesChangedFixture);
|
||||
await publishToMessageBus("/topic/280", likesChangedFixture);
|
||||
|
||||
await settled();
|
||||
const newLikes = likesDisplay.textContent;
|
||||
|
||||
assert.notEqual(
|
||||
|
@ -701,9 +699,8 @@ acceptance("Topic stats update automatically", function () {
|
|||
const oldReplies = repliesDisplay.textContent;
|
||||
|
||||
// simulate the topic posts_count being changed
|
||||
publishToMessageBus("/topic/280", postsChangedFixture);
|
||||
await publishToMessageBus("/topic/280", postsChangedFixture);
|
||||
|
||||
await settled();
|
||||
const newLikes = repliesDisplay.textContent;
|
||||
|
||||
assert.notEqual(
|
||||
|
@ -726,9 +723,7 @@ acceptance("Topic stats update automatically", function () {
|
|||
const oldAvatarSrc = avatarImg.src;
|
||||
|
||||
// simulate the topic posts_count being changed
|
||||
publishToMessageBus("/topic/280", postsChangedFixture);
|
||||
|
||||
await settled();
|
||||
await publishToMessageBus("/topic/280", postsChangedFixture);
|
||||
|
||||
const newAvatarTitle = avatarImg.title;
|
||||
const newAvatarSrc = avatarImg.src;
|
||||
|
@ -764,9 +759,7 @@ acceptance("Topic stats update automatically", function () {
|
|||
const oldTime = lastRepliedAtDisplay.dataset.time;
|
||||
|
||||
// simulate the topic posts_count being changed
|
||||
publishToMessageBus("/topic/280", postsChangedFixture);
|
||||
|
||||
await settled();
|
||||
await publishToMessageBus("/topic/280", postsChangedFixture);
|
||||
|
||||
const newTime = lastRepliedAtDisplay.dataset.time;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { click, currentURL, fillIn, settled, visit } from "@ember/test-helpers";
|
||||
import { click, currentURL, fillIn, visit } from "@ember/test-helpers";
|
||||
import { test } from "qunit";
|
||||
import I18n from "I18n";
|
||||
import {
|
||||
|
@ -188,7 +188,7 @@ acceptance(
|
|||
});
|
||||
|
||||
const publishReadToMessageBus = function (opts = {}) {
|
||||
publishToMessageBus(
|
||||
return publishToMessageBus(
|
||||
`/private-message-topic-tracking-state/user/${opts.userId || 5}`,
|
||||
{
|
||||
topic_id: opts.topicId,
|
||||
|
@ -203,7 +203,7 @@ acceptance(
|
|||
};
|
||||
|
||||
const publishUnreadToMessageBus = function (opts = {}) {
|
||||
publishToMessageBus(
|
||||
return publishToMessageBus(
|
||||
`/private-message-topic-tracking-state/user/${opts.userId || 5}`,
|
||||
{
|
||||
topic_id: opts.topicId,
|
||||
|
@ -219,7 +219,7 @@ acceptance(
|
|||
};
|
||||
|
||||
const publishNewToMessageBus = function (opts = {}) {
|
||||
publishToMessageBus(
|
||||
return publishToMessageBus(
|
||||
`/private-message-topic-tracking-state/user/${opts.userId || 5}`,
|
||||
{
|
||||
topic_id: opts.topicId,
|
||||
|
@ -234,7 +234,7 @@ acceptance(
|
|||
};
|
||||
|
||||
const publishGroupArchiveToMessageBus = function (opts) {
|
||||
publishToMessageBus(
|
||||
return publishToMessageBus(
|
||||
`/private-message-topic-tracking-state/group/${opts.groupIds[0]}`,
|
||||
{
|
||||
topic_id: opts.topicId,
|
||||
|
@ -248,7 +248,7 @@ acceptance(
|
|||
};
|
||||
|
||||
const publishGroupUnreadToMessageBus = function (opts) {
|
||||
publishToMessageBus(
|
||||
return publishToMessageBus(
|
||||
`/private-message-topic-tracking-state/group/${opts.groupIds[0]}`,
|
||||
{
|
||||
topic_id: opts.topicId,
|
||||
|
@ -264,7 +264,7 @@ acceptance(
|
|||
};
|
||||
|
||||
const publishGroupNewToMessageBus = function (opts) {
|
||||
publishToMessageBus(
|
||||
return publishToMessageBus(
|
||||
`/private-message-topic-tracking-state/group/${opts.groupIds[0]}`,
|
||||
{
|
||||
topic_id: opts.topicId,
|
||||
|
@ -291,14 +291,12 @@ acceptance(
|
|||
test("incoming group archive message acted by current user", async function (assert) {
|
||||
await visit("/u/charlie/messages");
|
||||
|
||||
publishGroupArchiveToMessageBus({
|
||||
await publishGroupArchiveToMessageBus({
|
||||
groupIds: [14],
|
||||
topicId: 1,
|
||||
actingUserId: 5,
|
||||
});
|
||||
|
||||
await visit("/u/charlie/messages"); // wait for re-render
|
||||
|
||||
assert.ok(
|
||||
!exists(".show-mores"),
|
||||
`does not display the topic incoming info`
|
||||
|
@ -312,9 +310,7 @@ acceptance(
|
|||
]) {
|
||||
await visit(url);
|
||||
|
||||
publishGroupArchiveToMessageBus({ groupIds: [14], topicId: 1 });
|
||||
|
||||
await visit(url); // wait for re-render
|
||||
await publishGroupArchiveToMessageBus({ groupIds: [14], topicId: 1 });
|
||||
|
||||
assert.ok(
|
||||
exists(".show-mores"),
|
||||
|
@ -328,9 +324,7 @@ acceptance(
|
|||
]) {
|
||||
await visit(url);
|
||||
|
||||
publishGroupArchiveToMessageBus({ groupIds: [14], topicId: 1 });
|
||||
|
||||
await visit(url); // wait for re-render
|
||||
await publishGroupArchiveToMessageBus({ groupIds: [14], topicId: 1 });
|
||||
|
||||
assert.ok(
|
||||
!exists(".show-mores"),
|
||||
|
@ -342,10 +336,8 @@ acceptance(
|
|||
test("incoming unread and new messages on all filter", async function (assert) {
|
||||
await visit("/u/charlie/messages");
|
||||
|
||||
publishUnreadToMessageBus({ topicId: 1 });
|
||||
publishNewToMessageBus({ topicId: 2 });
|
||||
|
||||
await visit("/u/charlie/messages"); // wait for re-render
|
||||
await publishUnreadToMessageBus({ topicId: 1 });
|
||||
await publishNewToMessageBus({ topicId: 2 });
|
||||
|
||||
assert.strictEqual(
|
||||
query(".messages-nav li a.new").innerText.trim(),
|
||||
|
@ -363,9 +355,7 @@ acceptance(
|
|||
test("incoming new messages while viewing new", async function (assert) {
|
||||
await visit("/u/charlie/messages/new");
|
||||
|
||||
publishNewToMessageBus({ topicId: 1 });
|
||||
|
||||
await visit("/u/charlie/messages/new"); // wait for re-render
|
||||
await publishNewToMessageBus({ topicId: 1 });
|
||||
|
||||
assert.strictEqual(
|
||||
query(".messages-nav li a.new").innerText.trim(),
|
||||
|
@ -379,9 +369,7 @@ acceptance(
|
|||
test("incoming unread messages while viewing unread", async function (assert) {
|
||||
await visit("/u/charlie/messages/unread");
|
||||
|
||||
publishUnreadToMessageBus();
|
||||
|
||||
await visit("/u/charlie/messages/unread"); // wait for re-render
|
||||
await publishUnreadToMessageBus();
|
||||
|
||||
assert.strictEqual(
|
||||
query(".messages-nav li a.unread").innerText.trim(),
|
||||
|
@ -395,10 +383,8 @@ acceptance(
|
|||
test("incoming unread and new messages while viewing group unread", async function (assert) {
|
||||
await visit("/u/charlie/messages/group/awesome_group/unread");
|
||||
|
||||
publishUnreadToMessageBus({ groupIds: [14], topicId: 1 });
|
||||
publishNewToMessageBus({ groupIds: [14], topicId: 2 });
|
||||
|
||||
await visit("/u/charlie/messages/group/awesome_group/unread"); // wait for re-render
|
||||
await publishUnreadToMessageBus({ groupIds: [14], topicId: 1 });
|
||||
await publishNewToMessageBus({ groupIds: [14], topicId: 2 });
|
||||
|
||||
assert.strictEqual(
|
||||
query(".messages-nav li a.unread").innerText.trim(),
|
||||
|
@ -433,9 +419,8 @@ acceptance(
|
|||
await visit("/u/charlie/messages");
|
||||
await visit("/t/13");
|
||||
|
||||
publishNewToMessageBus({ topicId: 1, userId: 5 });
|
||||
await publishNewToMessageBus({ topicId: 1, userId: 5 });
|
||||
|
||||
await settled();
|
||||
await visit("/u/charlie/messages");
|
||||
|
||||
assert.ok(
|
||||
|
@ -447,9 +432,9 @@ acceptance(
|
|||
test("dismissing all unread messages", async function (assert) {
|
||||
await visit("/u/charlie/messages/unread");
|
||||
|
||||
publishUnreadToMessageBus({ topicId: 1, userId: 5 });
|
||||
publishUnreadToMessageBus({ topicId: 2, userId: 5 });
|
||||
publishUnreadToMessageBus({ topicId: 3, userId: 5 });
|
||||
await publishUnreadToMessageBus({ topicId: 1, userId: 5 });
|
||||
await publishUnreadToMessageBus({ topicId: 2, userId: 5 });
|
||||
await publishUnreadToMessageBus({ topicId: 3, userId: 5 });
|
||||
|
||||
assert.strictEqual(
|
||||
count(".topic-list-item"),
|
||||
|
@ -514,9 +499,9 @@ acceptance(
|
|||
test("dismissing new messages", async function (assert) {
|
||||
await visit("/u/charlie/messages/new");
|
||||
|
||||
publishNewToMessageBus({ topicId: 1, userId: 5 });
|
||||
publishNewToMessageBus({ topicId: 2, userId: 5 });
|
||||
publishNewToMessageBus({ topicId: 3, userId: 5 });
|
||||
await publishNewToMessageBus({ topicId: 1, userId: 5 });
|
||||
await publishNewToMessageBus({ topicId: 2, userId: 5 });
|
||||
await publishNewToMessageBus({ topicId: 3, userId: 5 });
|
||||
|
||||
assert.strictEqual(
|
||||
count(".topic-list-item"),
|
||||
|
@ -611,9 +596,7 @@ acceptance(
|
|||
test("suggested messages with new and unread", async function (assert) {
|
||||
await visit("/t/12");
|
||||
|
||||
publishNewToMessageBus({ userId: 5, topicId: 1 });
|
||||
|
||||
await settled();
|
||||
await publishNewToMessageBus({ userId: 5, topicId: 1 });
|
||||
|
||||
assert.strictEqual(
|
||||
query(".suggested-topics-message").innerText.trim(),
|
||||
|
@ -621,9 +604,7 @@ acceptance(
|
|||
"displays the right browse more message"
|
||||
);
|
||||
|
||||
publishUnreadToMessageBus({ userId: 5, topicId: 2 });
|
||||
|
||||
await settled();
|
||||
await publishUnreadToMessageBus({ userId: 5, topicId: 2 });
|
||||
|
||||
assert.strictEqual(
|
||||
query(".suggested-topics-message").innerText.trim(),
|
||||
|
@ -631,9 +612,7 @@ acceptance(
|
|||
"displays the right browse more message"
|
||||
);
|
||||
|
||||
publishReadToMessageBus({ userId: 5, topicId: 2 });
|
||||
|
||||
await settled();
|
||||
await publishReadToMessageBus({ userId: 5, topicId: 2 });
|
||||
|
||||
assert.strictEqual(
|
||||
query(".suggested-topics-message").innerText.trim(),
|
||||
|
@ -658,9 +637,7 @@ acceptance(
|
|||
test("suggested messages for group messages with new and unread", async function (assert) {
|
||||
await visit("/t/13");
|
||||
|
||||
publishGroupNewToMessageBus({ groupIds: [14], topicId: 1 });
|
||||
|
||||
await settled();
|
||||
await publishGroupNewToMessageBus({ groupIds: [14], topicId: 1 });
|
||||
|
||||
assert.ok(
|
||||
query(".suggested-topics-message")
|
||||
|
@ -671,9 +648,7 @@ acceptance(
|
|||
"displays the right browse more message"
|
||||
);
|
||||
|
||||
publishGroupUnreadToMessageBus({ groupIds: [14], topicId: 2 });
|
||||
|
||||
await settled();
|
||||
await publishGroupUnreadToMessageBus({ groupIds: [14], topicId: 2 });
|
||||
|
||||
assert.ok(
|
||||
query(".suggested-topics-message")
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { publishToMessageBus } from "discourse/tests/helpers/qunit-helpers";
|
||||
import User from "discourse/models/user";
|
||||
import { settled } from "@ember/test-helpers";
|
||||
|
||||
let channels = {};
|
||||
|
||||
|
@ -41,13 +40,13 @@ export function getChannelInfo(name) {
|
|||
);
|
||||
}
|
||||
|
||||
export function joinChannel(name, user) {
|
||||
export async function joinChannel(name, user) {
|
||||
const channel = getChannelInfo(name);
|
||||
if (!channel.users.any((u) => u.id === user.id)) {
|
||||
channel.users.push(user);
|
||||
channel.count += 1;
|
||||
channel.last_message_id += 1;
|
||||
publishToMessageBus(
|
||||
await publishToMessageBus(
|
||||
`/presence${name}`,
|
||||
{
|
||||
entering_users: [Object.assign({}, user)],
|
||||
|
@ -56,16 +55,15 @@ export function joinChannel(name, user) {
|
|||
channel.last_message_id
|
||||
);
|
||||
}
|
||||
return settled();
|
||||
}
|
||||
|
||||
export function leaveChannel(name, user) {
|
||||
export async function leaveChannel(name, user) {
|
||||
const channel = getChannelInfo(name);
|
||||
if (channel.users.any((u) => u.id === user.id)) {
|
||||
channel.users = channel.users.reject((u) => u.id === user.id);
|
||||
channel.count -= 1;
|
||||
channel.last_message_id += 1;
|
||||
publishToMessageBus(
|
||||
await publishToMessageBus(
|
||||
`/presence${name}`,
|
||||
{
|
||||
leaving_user_ids: [user.id],
|
||||
|
@ -74,7 +72,6 @@ export function leaveChannel(name, user) {
|
|||
channel.last_message_id
|
||||
);
|
||||
}
|
||||
return settled();
|
||||
}
|
||||
|
||||
export function presentUserIds(channelName) {
|
||||
|
|
|
@ -7,7 +7,6 @@ import {
|
|||
publishToMessageBus,
|
||||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { hbs } from "ember-cli-htmlbars";
|
||||
import discourseLater from "discourse-common/lib/later";
|
||||
|
||||
module("Integration | Component | software-update-prompt", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
@ -20,16 +19,12 @@ module("Integration | Component | software-update-prompt", function (hooks) {
|
|||
"it does not have the class to show the prompt"
|
||||
);
|
||||
|
||||
publishToMessageBus("/global/asset-version", "somenewversion");
|
||||
await publishToMessageBus("/global/asset-version", "somenewversion");
|
||||
|
||||
const done = assert.async();
|
||||
discourseLater(() => {
|
||||
assert.strictEqual(
|
||||
count("div.software-update-prompt.require-software-refresh"),
|
||||
1,
|
||||
"it does have the class to show the prompt"
|
||||
);
|
||||
done();
|
||||
}, 10);
|
||||
assert.strictEqual(
|
||||
count("div.software-update-prompt.require-software-refresh"),
|
||||
1,
|
||||
"it does have the class to show the prompt"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -58,27 +58,30 @@ discourseModule(
|
|||
function (hooks) {
|
||||
let pmTopicTrackingState;
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
hooks.beforeEach(async function () {
|
||||
setupPretender();
|
||||
pmTopicTrackingState = PrivateMessageTopicTrackingState.create({
|
||||
messageBus: MessageBus,
|
||||
currentUser: User.create({ id: 77889, username: "test" }),
|
||||
});
|
||||
pmTopicTrackingState.startTracking();
|
||||
await pmTopicTrackingState.startTracking();
|
||||
});
|
||||
|
||||
test("modifies the topic state only if the topic was not created by the current user", function (assert) {
|
||||
test("modifies the topic state only if the topic was not created by the current user", async function (assert) {
|
||||
let payload = {
|
||||
last_read_post_number: null,
|
||||
highest_post_number: 1,
|
||||
group_ids: [],
|
||||
created_by_user_id: 5,
|
||||
};
|
||||
publishToMessageBus("/private-message-topic-tracking-state/user/77889", {
|
||||
message_type: "new_topic",
|
||||
topic_id: 4398,
|
||||
payload,
|
||||
});
|
||||
await publishToMessageBus(
|
||||
"/private-message-topic-tracking-state/user/77889",
|
||||
{
|
||||
message_type: "new_topic",
|
||||
topic_id: 4398,
|
||||
payload,
|
||||
}
|
||||
);
|
||||
assert.deepEqual(
|
||||
pmTopicTrackingState.findState(4398),
|
||||
payload,
|
||||
|
@ -91,11 +94,14 @@ discourseModule(
|
|||
group_ids: [],
|
||||
created_by_user_id: 77889,
|
||||
};
|
||||
publishToMessageBus("/private-message-topic-tracking-state/user/77889", {
|
||||
message_type: "new_topic",
|
||||
topic_id: 4400,
|
||||
payload,
|
||||
});
|
||||
await publishToMessageBus(
|
||||
"/private-message-topic-tracking-state/user/77889",
|
||||
{
|
||||
message_type: "new_topic",
|
||||
topic_id: 4400,
|
||||
payload,
|
||||
}
|
||||
);
|
||||
assert.deepEqual(
|
||||
pmTopicTrackingState.findState(4400),
|
||||
undefined,
|
||||
|
@ -110,16 +116,16 @@ discourseModule(
|
|||
function (hooks) {
|
||||
let pmTopicTrackingState;
|
||||
|
||||
hooks.beforeEach(function () {
|
||||
hooks.beforeEach(async function () {
|
||||
setupPretender();
|
||||
pmTopicTrackingState = PrivateMessageTopicTrackingState.create({
|
||||
messageBus: MessageBus,
|
||||
currentUser: User.create({ id: 77889, username: "test" }),
|
||||
});
|
||||
pmTopicTrackingState.startTracking();
|
||||
await pmTopicTrackingState.startTracking();
|
||||
});
|
||||
|
||||
test("modifies the last_read_post_number and highest_post_number", function (assert) {
|
||||
test("modifies the last_read_post_number and highest_post_number", async function (assert) {
|
||||
let payload = {
|
||||
last_read_post_number: 12,
|
||||
highest_post_number: 13,
|
||||
|
@ -127,11 +133,14 @@ discourseModule(
|
|||
group_ids: [],
|
||||
created_by_user_id: 5,
|
||||
};
|
||||
publishToMessageBus("/private-message-topic-tracking-state/user/77889", {
|
||||
message_type: "unread",
|
||||
topic_id: 123,
|
||||
payload,
|
||||
});
|
||||
await publishToMessageBus(
|
||||
"/private-message-topic-tracking-state/user/77889",
|
||||
{
|
||||
message_type: "unread",
|
||||
topic_id: 123,
|
||||
payload,
|
||||
}
|
||||
);
|
||||
|
||||
let state = pmTopicTrackingState.findState(123);
|
||||
assert.deepEqual(
|
||||
|
@ -152,11 +161,14 @@ discourseModule(
|
|||
group_ids: [],
|
||||
created_by_user_id: 77889,
|
||||
};
|
||||
publishToMessageBus("/private-message-topic-tracking-state/user/77889", {
|
||||
message_type: "unread",
|
||||
topic_id: 123,
|
||||
payload,
|
||||
});
|
||||
await publishToMessageBus(
|
||||
"/private-message-topic-tracking-state/user/77889",
|
||||
{
|
||||
message_type: "unread",
|
||||
topic_id: 123,
|
||||
payload,
|
||||
}
|
||||
);
|
||||
|
||||
state = pmTopicTrackingState.findState(123);
|
||||
assert.deepEqual(
|
||||
|
|
|
@ -518,8 +518,8 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {
|
|||
]);
|
||||
});
|
||||
|
||||
test("message count is incremented", function (assert) {
|
||||
publishToMessageBus(`/unread`, unreadTopicPayload);
|
||||
test("message count is incremented", async function (assert) {
|
||||
await publishToMessageBus(`/unread`, unreadTopicPayload);
|
||||
|
||||
assert.strictEqual(
|
||||
trackingState.messageCount,
|
||||
|
@ -528,14 +528,14 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {
|
|||
);
|
||||
});
|
||||
|
||||
test("state is modified and callback is called", function (assert) {
|
||||
test("state is modified and callback is called", async function (assert) {
|
||||
let stateCallbackCalled = 0;
|
||||
|
||||
trackingState.onStateChange(() => {
|
||||
stateCallbackCalled += 1;
|
||||
});
|
||||
|
||||
publishToMessageBus(`/unread`, unreadTopicPayload);
|
||||
await publishToMessageBus(`/unread`, unreadTopicPayload);
|
||||
|
||||
assert.deepEqual(
|
||||
trackingState.findState(111),
|
||||
|
@ -560,9 +560,10 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {
|
|||
);
|
||||
});
|
||||
|
||||
test("adds incoming so it is counted in topic lists", function (assert) {
|
||||
test("adds incoming so it is counted in topic lists", async function (assert) {
|
||||
trackingState.trackIncoming("all");
|
||||
publishToMessageBus(`/unread`, unreadTopicPayload);
|
||||
await publishToMessageBus(`/unread`, unreadTopicPayload);
|
||||
|
||||
assert.deepEqual(
|
||||
trackingState.newIncoming,
|
||||
[111],
|
||||
|
@ -597,8 +598,8 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {
|
|||
assert.strictEqual(trackingState.filter, "latest");
|
||||
});
|
||||
|
||||
test("correctly infers missing information", function (assert) {
|
||||
publishToMessageBus(`/unread`, {
|
||||
test("correctly infers missing information", async function (assert) {
|
||||
await publishToMessageBus(`/unread`, {
|
||||
...unreadTopicPayload,
|
||||
topic_id: 999,
|
||||
});
|
||||
|
@ -618,14 +619,17 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {
|
|||
);
|
||||
});
|
||||
|
||||
test("adds incoming in the categories latest topics list", function (assert) {
|
||||
test("adds incoming in the categories latest topics list", async function (assert) {
|
||||
trackingState.trackIncoming("categories");
|
||||
const unreadCategoriesLatestTopicsPayload = {
|
||||
...unreadTopicPayload,
|
||||
message_type: "latest",
|
||||
};
|
||||
|
||||
publishToMessageBus(`/latest`, unreadCategoriesLatestTopicsPayload);
|
||||
await publishToMessageBus(
|
||||
`/latest`,
|
||||
unreadCategoriesLatestTopicsPayload
|
||||
);
|
||||
assert.deepEqual(
|
||||
trackingState.newIncoming,
|
||||
[111],
|
||||
|
@ -638,7 +642,7 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {
|
|||
);
|
||||
});
|
||||
|
||||
test("dismisses new topic", function (assert) {
|
||||
test("dismisses new topic", async function (assert) {
|
||||
trackingState.loadStates([
|
||||
{
|
||||
last_read_post_number: null,
|
||||
|
@ -650,7 +654,7 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {
|
|||
},
|
||||
]);
|
||||
|
||||
publishToMessageBus(`/unread/${currentUser.id}`, {
|
||||
await publishToMessageBus(`/unread/${currentUser.id}`, {
|
||||
message_type: "dismiss_new",
|
||||
payload: { topic_ids: [112] },
|
||||
});
|
||||
|
@ -658,7 +662,7 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {
|
|||
assert.strictEqual(trackingState.findState(112).is_seen, true);
|
||||
});
|
||||
|
||||
test("marks a topic as read", function (assert) {
|
||||
test("marks a topic as read", async function (assert) {
|
||||
trackingState.loadStates([
|
||||
{
|
||||
last_read_post_number: null,
|
||||
|
@ -669,7 +673,7 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {
|
|||
tags: ["foo"],
|
||||
},
|
||||
]);
|
||||
publishToMessageBus(`/unread/${currentUser.id}`, {
|
||||
await publishToMessageBus(`/unread/${currentUser.id}`, {
|
||||
message_type: "read",
|
||||
topic_id: 112,
|
||||
payload: {
|
||||
|
@ -678,6 +682,7 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {
|
|||
notification_level: NotificationLevels.TRACKING,
|
||||
},
|
||||
});
|
||||
|
||||
assert.propEqual(
|
||||
getProperties(
|
||||
trackingState.findState(112),
|
||||
|
@ -729,9 +734,10 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {
|
|||
trackingState.establishChannels();
|
||||
});
|
||||
|
||||
test("topics in muted categories do not get added to the state", function (assert) {
|
||||
test("topics in muted categories do not get added to the state", async function (assert) {
|
||||
trackingState.currentUser.set("muted_category_ids", [123]);
|
||||
publishToMessageBus("/new", newTopicPayload);
|
||||
await publishToMessageBus("/new", newTopicPayload);
|
||||
|
||||
assert.strictEqual(
|
||||
trackingState.findState(222),
|
||||
undefined,
|
||||
|
@ -739,12 +745,13 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {
|
|||
);
|
||||
});
|
||||
|
||||
test("topics in indirectly muted categories do not get added to the state", function (assert) {
|
||||
test("topics in indirectly muted categories do not get added to the state", async function (assert) {
|
||||
trackingState.currentUser.setProperties({
|
||||
muted_category_ids: [],
|
||||
indirectly_muted_category_ids: [123],
|
||||
});
|
||||
publishToMessageBus("/new", newTopicPayload);
|
||||
await publishToMessageBus("/new", newTopicPayload);
|
||||
|
||||
assert.strictEqual(
|
||||
trackingState.findState(222),
|
||||
undefined,
|
||||
|
@ -752,10 +759,10 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {
|
|||
);
|
||||
});
|
||||
|
||||
test("topics in muted tags do not get added to the state", function (assert) {
|
||||
test("topics in muted tags do not get added to the state", async function (assert) {
|
||||
trackingState.currentUser.set("muted_tags", ["pending"]);
|
||||
|
||||
publishToMessageBus("/new", newTopicPayload);
|
||||
await publishToMessageBus("/new", newTopicPayload);
|
||||
|
||||
assert.strictEqual(
|
||||
trackingState.findState(222),
|
||||
|
@ -764,8 +771,8 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {
|
|||
);
|
||||
});
|
||||
|
||||
test("message count is incremented", function (assert) {
|
||||
publishToMessageBus("/new", newTopicPayload);
|
||||
test("message count is incremented", async function (assert) {
|
||||
await publishToMessageBus("/new", newTopicPayload);
|
||||
|
||||
assert.strictEqual(
|
||||
trackingState.messageCount,
|
||||
|
@ -774,12 +781,13 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {
|
|||
);
|
||||
});
|
||||
|
||||
test("state is modified and callback is called", function (assert) {
|
||||
test("state is modified and callback is called", async function (assert) {
|
||||
let stateCallbackCalled = false;
|
||||
trackingState.onStateChange(() => {
|
||||
stateCallbackCalled = true;
|
||||
});
|
||||
publishToMessageBus("/new", newTopicPayload);
|
||||
await publishToMessageBus("/new", newTopicPayload);
|
||||
|
||||
assert.deepEqual(
|
||||
trackingState.findState(222),
|
||||
{
|
||||
|
@ -800,9 +808,10 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {
|
|||
);
|
||||
});
|
||||
|
||||
test("adds incoming so it is counted in topic lists", function (assert) {
|
||||
test("adds incoming so it is counted in topic lists", async function (assert) {
|
||||
trackingState.trackIncoming("all");
|
||||
publishToMessageBus("/new", newTopicPayload);
|
||||
await publishToMessageBus("/new", newTopicPayload);
|
||||
|
||||
assert.deepEqual(
|
||||
trackingState.newIncoming,
|
||||
[222],
|
||||
|
@ -817,7 +826,7 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {
|
|||
}
|
||||
);
|
||||
|
||||
test("establishChannels - /delete MessageBus channel payloads processed", function (assert) {
|
||||
test("establishChannels - /delete MessageBus channel payloads processed", async function (assert) {
|
||||
const trackingState = TopicTrackingState.create({ messageBus: MessageBus });
|
||||
trackingState.establishChannels();
|
||||
|
||||
|
@ -828,7 +837,7 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {
|
|||
},
|
||||
]);
|
||||
|
||||
publishToMessageBus("/delete", { topic_id: 111 });
|
||||
await publishToMessageBus("/delete", { topic_id: 111 });
|
||||
|
||||
assert.strictEqual(
|
||||
trackingState.findState(111).deleted,
|
||||
|
@ -842,7 +851,7 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {
|
|||
);
|
||||
});
|
||||
|
||||
test("establishChannels - /recover MessageBus channel payloads processed", function (assert) {
|
||||
test("establishChannels - /recover MessageBus channel payloads processed", async function (assert) {
|
||||
const trackingState = TopicTrackingState.create({ messageBus: MessageBus });
|
||||
trackingState.establishChannels();
|
||||
|
||||
|
@ -853,7 +862,7 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {
|
|||
},
|
||||
]);
|
||||
|
||||
publishToMessageBus("/recover", { topic_id: 111 });
|
||||
await publishToMessageBus("/recover", { topic_id: 111 });
|
||||
|
||||
assert.strictEqual(
|
||||
trackingState.findState(111).deleted,
|
||||
|
@ -867,7 +876,7 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {
|
|||
);
|
||||
});
|
||||
|
||||
test("establishChannels - /destroy MessageBus channel payloads processed", function (assert) {
|
||||
test("establishChannels - /destroy MessageBus channel payloads processed", async function (assert) {
|
||||
sinon.stub(DiscourseURL, "router").value({
|
||||
currentRoute: { parent: { name: "topic", params: { id: 111 } } },
|
||||
});
|
||||
|
@ -882,7 +891,7 @@ discourseModule("Unit | Model | topic-tracking-state", function (hooks) {
|
|||
},
|
||||
]);
|
||||
|
||||
publishToMessageBus("/destroy", { topic_id: 111 });
|
||||
await publishToMessageBus("/destroy", { topic_id: 111 });
|
||||
|
||||
assert.strictEqual(
|
||||
trackingState.messageCount,
|
||||
|
|
|
@ -43,7 +43,7 @@ acceptance("Presence - Subscribing", function (needs) {
|
|||
last_message_id: 1,
|
||||
users: usersFixture(),
|
||||
};
|
||||
} else if (c.startsWith("/countonly/")) {
|
||||
} else if (c.startsWith("/count-only/")) {
|
||||
response[c] = {
|
||||
count: 3,
|
||||
last_message_id: 1,
|
||||
|
@ -74,7 +74,7 @@ acceptance("Presence - Subscribing", function (needs) {
|
|||
|
||||
assert.strictEqual(channel.users.length, 3, "it starts with three users");
|
||||
|
||||
publishToMessageBus(
|
||||
await publishToMessageBus(
|
||||
"/presence/test/ch1",
|
||||
{
|
||||
leaving_user_ids: [1],
|
||||
|
@ -86,7 +86,7 @@ acceptance("Presence - Subscribing", function (needs) {
|
|||
assert.strictEqual(channel.users.length, 2, "one user is removed");
|
||||
assert.strictEqual(changes, 2);
|
||||
|
||||
publishToMessageBus(
|
||||
await publishToMessageBus(
|
||||
"/presence/test/ch1",
|
||||
{
|
||||
entering_users: [usersFixture()[0]],
|
||||
|
@ -108,7 +108,7 @@ acceptance("Presence - Subscribing", function (needs) {
|
|||
|
||||
assert.strictEqual(channel.users.length, 3, "loads initial state");
|
||||
|
||||
publishToMessageBus(
|
||||
await publishToMessageBus(
|
||||
"/presence/test/ch1",
|
||||
{
|
||||
leaving_user_ids: [1],
|
||||
|
@ -129,7 +129,7 @@ acceptance("Presence - Subscribing", function (needs) {
|
|||
"PresenceChannel '/test/ch1' dropped message (received 99, expecting 3), resyncing..."
|
||||
);
|
||||
|
||||
publishToMessageBus(
|
||||
await publishToMessageBus(
|
||||
"/presence/test/ch1",
|
||||
{
|
||||
leaving_user_ids: [2],
|
||||
|
@ -161,7 +161,7 @@ acceptance("Presence - Subscribing", function (needs) {
|
|||
|
||||
test("can subscribe to count_only channel", async function (assert) {
|
||||
let presenceService = this.container.lookup("service:presence");
|
||||
let channel = presenceService.getChannel("/countonly/ch1");
|
||||
let channel = presenceService.getChannel("/count-only/ch1");
|
||||
|
||||
await channel.subscribe();
|
||||
|
||||
|
@ -169,8 +169,8 @@ acceptance("Presence - Subscribing", function (needs) {
|
|||
assert.strictEqual(channel.countOnly, true, "identifies as countOnly");
|
||||
assert.strictEqual(channel.users, null, "has null users list");
|
||||
|
||||
publishToMessageBus(
|
||||
"/presence/countonly/ch1",
|
||||
await publishToMessageBus(
|
||||
"/presence/count-only/ch1",
|
||||
{
|
||||
count_delta: 1,
|
||||
},
|
||||
|
@ -180,8 +180,8 @@ acceptance("Presence - Subscribing", function (needs) {
|
|||
|
||||
assert.strictEqual(channel.count, 4, "updates the count via messagebus");
|
||||
|
||||
publishToMessageBus(
|
||||
"/presence/countonly/ch1",
|
||||
await publishToMessageBus(
|
||||
"/presence/count-only/ch1",
|
||||
{
|
||||
leaving_user_ids: [2],
|
||||
},
|
||||
|
@ -296,9 +296,9 @@ acceptance("Presence - Entering and Leaving", function (needs) {
|
|||
);
|
||||
});
|
||||
|
||||
test("raises an error when entering a non-existant channel", async function (assert) {
|
||||
test("raises an error when entering a non-existent channel", async function (assert) {
|
||||
const presenceService = this.container.lookup("service:presence");
|
||||
const channel = presenceService.getChannel("/blah/doesnotexist");
|
||||
const channel = presenceService.getChannel("/blah/does-not-exist");
|
||||
await assert.rejects(
|
||||
channel.enter(),
|
||||
PresenceChannelNotFound,
|
||||
|
|
|
@ -571,7 +571,7 @@ acceptance("Poll results", function (needs) {
|
|||
0
|
||||
);
|
||||
|
||||
publishToMessageBus("/polls/134", {
|
||||
await publishToMessageBus("/polls/134", {
|
||||
post_id: "156",
|
||||
polls: [
|
||||
{
|
||||
|
@ -619,7 +619,6 @@ acceptance("Poll results", function (needs) {
|
|||
},
|
||||
],
|
||||
});
|
||||
await visit("/t/-/load-more-poll-voters");
|
||||
|
||||
assert.strictEqual(
|
||||
count(".poll-container .results li:nth-child(1) .poll-voters li"),
|
||||
|
|
|
@ -778,7 +778,7 @@ describe PrettyText do
|
|||
expect(PrettyText.excerpt("<details><summary>expand</summary><p>hello</p></details>", 60)).to match_html "<details><summary>expand</summary>hello</details>"
|
||||
end
|
||||
|
||||
it "should remove meta informations" do
|
||||
it "should remove meta information" do
|
||||
expect(PrettyText.excerpt(wrapped_image, 100)).to match_html "<a href='//localhost:3000/uploads/default/4399/33691397e78b4d75.png' class='lightbox' title='Screen Shot 2014-04-14 at 9.47.10 PM.png'>[image]</a>"
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue