2020-05-14 10:04:08 -04:00
|
|
|
import I18n from "I18n";
|
2019-06-06 10:47:10 +02:00
|
|
|
import selectKit from "helpers/select-kit-helper";
|
2017-09-12 01:36:58 +02:00
|
|
|
import componentTest from "helpers/component-test";
|
|
|
|
import Topic from "discourse/models/topic";
|
|
|
|
|
2020-09-04 13:42:47 +02:00
|
|
|
const buildTopic = function (level, archetype = "regular") {
|
2017-09-12 01:36:58 +02:00
|
|
|
return Topic.create({
|
2020-09-04 13:42:47 +02:00
|
|
|
id: 4563,
|
2020-07-15 13:10:05 -04:00
|
|
|
}).updateFromJson({
|
2017-09-12 01:36:58 +02:00
|
|
|
title: "Qunit Test Topic",
|
|
|
|
details: {
|
2020-09-04 13:42:47 +02:00
|
|
|
notification_level: level,
|
2018-06-26 15:01:52 +03:00
|
|
|
},
|
2020-09-04 13:42:47 +02:00
|
|
|
archetype,
|
2017-09-12 01:36:58 +02:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2018-06-26 15:31:43 +03:00
|
|
|
const originalTranslation =
|
|
|
|
I18n.translations.en.js.topic.notifications.tracking_pm.title;
|
2018-06-26 15:01:52 +03:00
|
|
|
|
2020-02-03 14:22:14 +01:00
|
|
|
moduleForComponent("select-kit/topic-notifications-button", {
|
2018-06-26 15:01:52 +03:00
|
|
|
integration: true,
|
|
|
|
|
|
|
|
afterEach() {
|
|
|
|
I18n.translations.en.js.topic.notifications.tracking_pm.title = originalTranslation;
|
2020-09-04 13:42:47 +02:00
|
|
|
},
|
2018-06-26 15:01:52 +03:00
|
|
|
});
|
2017-09-12 01:36:58 +02:00
|
|
|
|
|
|
|
componentTest("the header has a localized title", {
|
2017-11-21 11:53:09 +01:00
|
|
|
template:
|
|
|
|
"{{topic-notifications-button notificationLevel=topic.details.notification_level topic=topic}}",
|
2017-09-12 01:36:58 +02:00
|
|
|
|
|
|
|
beforeEach() {
|
2017-11-21 11:53:09 +01:00
|
|
|
this.set("topic", buildTopic(1));
|
2017-09-12 01:36:58 +02:00
|
|
|
},
|
|
|
|
|
2018-07-24 20:12:09 +02:00
|
|
|
async test(assert) {
|
|
|
|
assert.equal(
|
2020-09-04 13:42:47 +02:00
|
|
|
selectKit().header().label(),
|
2018-07-24 20:12:09 +02:00
|
|
|
"Normal",
|
2020-02-03 14:22:14 +01:00
|
|
|
"it has the correct label"
|
2018-07-24 20:12:09 +02:00
|
|
|
);
|
2017-09-12 01:36:58 +02:00
|
|
|
|
2018-07-24 20:12:09 +02:00
|
|
|
await this.set("topic", buildTopic(2));
|
2017-11-21 11:53:09 +01:00
|
|
|
|
2018-07-24 20:12:09 +02:00
|
|
|
assert.equal(
|
2020-09-04 13:42:47 +02:00
|
|
|
selectKit().header().label(),
|
2018-07-24 20:12:09 +02:00
|
|
|
"Tracking",
|
2020-02-03 14:22:14 +01:00
|
|
|
"it correctly changes the label"
|
2018-07-24 20:12:09 +02:00
|
|
|
);
|
2020-09-04 13:42:47 +02:00
|
|
|
},
|
2017-09-12 01:36:58 +02:00
|
|
|
});
|
2018-06-26 15:01:52 +03:00
|
|
|
|
|
|
|
componentTest("the header has a localized title", {
|
|
|
|
template:
|
|
|
|
"{{topic-notifications-button notificationLevel=topic.details.notification_level topic=topic}}",
|
|
|
|
|
|
|
|
beforeEach() {
|
|
|
|
I18n.translations.en.js.topic.notifications.tracking_pm.title = `${originalTranslation} PM`;
|
|
|
|
this.set("topic", buildTopic(2, "private_message"));
|
|
|
|
},
|
|
|
|
|
|
|
|
test(assert) {
|
2018-07-24 20:12:09 +02:00
|
|
|
assert.equal(
|
2020-09-04 13:42:47 +02:00
|
|
|
selectKit().header().label(),
|
2018-07-24 20:12:09 +02:00
|
|
|
`${originalTranslation} PM`,
|
2020-02-03 14:22:14 +01:00
|
|
|
"it has the correct label for PMs"
|
2018-07-24 20:12:09 +02:00
|
|
|
);
|
2020-09-04 13:42:47 +02:00
|
|
|
},
|
2018-06-26 15:01:52 +03:00
|
|
|
});
|