DEV: Add acceptance tests for assignment notifications (#307)
Co-authored-by: Jarek Radosz <jradosz@gmail.com> Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
This commit is contained in:
parent
872430bd2c
commit
9f514a50ca
|
|
@ -7,8 +7,10 @@ import {
|
|||
} from "discourse/tests/helpers/qunit-helpers";
|
||||
import { visit } from "@ember/test-helpers";
|
||||
import { cloneJSON } from "discourse-common/lib/object";
|
||||
import I18n from "I18n";
|
||||
import topicFixtures from "discourse/tests/fixtures/topic";
|
||||
import selectKit from "discourse/tests/helpers/select-kit-helper";
|
||||
import NotificationFixture from "../fixtures/notifications-fixtures";
|
||||
|
||||
function assignCurrentUserToTopic(needs) {
|
||||
needs.pretender((server, helper) => {
|
||||
|
|
@ -40,6 +42,12 @@ function assignCurrentUserToTopic(needs) {
|
|||
};
|
||||
return helper.response(topic);
|
||||
});
|
||||
|
||||
server.get("/notifications", () => {
|
||||
return helper.response(
|
||||
NotificationFixture["/assign/notifications/eviltrout"]
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -146,6 +154,33 @@ acceptance("Discourse Assign | Assigned topic", function (needs) {
|
|||
"does not show reassign dropdown at the bottom of the topic"
|
||||
);
|
||||
});
|
||||
|
||||
test("Shows assignment notification", async function (assert) {
|
||||
updateCurrentUser({ can_assign: true });
|
||||
|
||||
await visit("/u/eviltrout/notifications");
|
||||
|
||||
const notification = query(
|
||||
"section.user-content ul.notifications li.item.notification"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
notification.children[0].classList,
|
||||
"assigned",
|
||||
"with correct assigned class"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
notification.querySelector("a").title,
|
||||
I18n.t("notifications.titles.assigned"),
|
||||
"with correct title"
|
||||
);
|
||||
assert.equal(
|
||||
notification.querySelector("svg use").href["baseVal"],
|
||||
"#user-plus",
|
||||
"with correct icon"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
acceptance("Discourse Assign | Re-assign topic", function (needs) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,87 @@
|
|||
export default {
|
||||
"/assign/notifications/eviltrout": {
|
||||
notifications: [
|
||||
{
|
||||
id: 193,
|
||||
user_id: 26,
|
||||
notification_type: 34,
|
||||
read: false,
|
||||
high_priority: true,
|
||||
created_at: "2022-03-18T17:51:11.920Z",
|
||||
post_number: 1,
|
||||
topic_id: 59,
|
||||
fancy_title:
|
||||
"A bear, however hard he tries, grows tubby without exercise",
|
||||
slug: "a-bear-however-hard-he-tries-grows-tubby-without-exercise",
|
||||
data: {
|
||||
message: "discourse_assign.assign_notification",
|
||||
display_username: "system",
|
||||
topic_title:
|
||||
"A bear, however hard he tries, grows tubby without exercise",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 192,
|
||||
user_id: 26,
|
||||
notification_type: 12,
|
||||
read: false,
|
||||
high_priority: false,
|
||||
created_at: "2022-03-18T16:47:09.668Z",
|
||||
post_number: null,
|
||||
topic_id: null,
|
||||
slug: null,
|
||||
data: {
|
||||
badge_id: 5,
|
||||
badge_name: "Welcome",
|
||||
badge_slug: "welcome",
|
||||
badge_title: false,
|
||||
username: "eviltrout",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 191,
|
||||
user_id: 26,
|
||||
notification_type: 5,
|
||||
read: false,
|
||||
high_priority: false,
|
||||
created_at: "2022-03-18T16:46:57.744Z",
|
||||
post_number: 5,
|
||||
topic_id: 59,
|
||||
fancy_title:
|
||||
"A bear, however hard he tries, grows tubby without exercise",
|
||||
slug: "a-bear-however-hard-he-tries-grows-tubby-without-exercise",
|
||||
data: {
|
||||
topic_title:
|
||||
"A bear, however hard he tries, grows tubby without exercise",
|
||||
original_post_id: 285,
|
||||
original_post_type: 1,
|
||||
original_username: "system",
|
||||
revision_number: null,
|
||||
display_username: "system",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 148,
|
||||
user_id: 26,
|
||||
notification_type: 12,
|
||||
read: false,
|
||||
high_priority: false,
|
||||
created_at: "2022-03-17T21:49:02.226Z",
|
||||
post_number: null,
|
||||
topic_id: null,
|
||||
slug: null,
|
||||
data: {
|
||||
badge_id: 1,
|
||||
badge_name: "Basic",
|
||||
badge_slug: "basic",
|
||||
badge_title: false,
|
||||
username: "eviltrout",
|
||||
},
|
||||
},
|
||||
],
|
||||
total_rows_notifications: 4,
|
||||
seen_notification_id: 193,
|
||||
load_more_notifications:
|
||||
"/notifications?filter=all&offset=60&username=eviltrout",
|
||||
},
|
||||
};
|
||||
Loading…
Reference in New Issue