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