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