2023-10-11 02:38:59 +08:00
|
|
|
import { render } from "@ember/test-helpers";
|
2022-11-02 21:41:30 +08:00
|
|
|
import hbs from "htmlbars-inline-precompile";
|
2022-12-22 21:35:18 +08:00
|
|
|
import { module, test } from "qunit";
|
2023-10-11 02:38:59 +08:00
|
|
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
2023-10-18 18:07:09 +08:00
|
|
|
import I18n from "discourse-i18n";
|
2023-10-11 02:38:59 +08:00
|
|
|
import ChatChannel from "discourse/plugins/chat/discourse/models/chat-channel";
|
2022-11-02 21:41:30 +08:00
|
|
|
|
|
|
|
module(
|
|
|
|
"Discourse Chat | Component | chat-retention-reminder",
|
|
|
|
function (hooks) {
|
|
|
|
setupRenderingTest(hooks);
|
|
|
|
|
2023-02-15 21:50:01 +08:00
|
|
|
test("display retention info", async function (assert) {
|
|
|
|
this.channel = ChatChannel.create({ chatable_type: "Category" });
|
2022-12-22 21:35:18 +08:00
|
|
|
this.currentUser.set("needs_channel_retention_reminder", true);
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2023-03-03 20:09:25 +08:00
|
|
|
await render(hbs`<ChatRetentionReminder @channel={{this.channel}} />`);
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2023-02-15 21:50:01 +08:00
|
|
|
assert.dom(".chat-retention-reminder").includesText(
|
2023-10-13 13:55:47 +08:00
|
|
|
I18n.t("chat.retention_reminders.long", {
|
|
|
|
count: this.siteSettings.chat_channel_retention_days,
|
|
|
|
})
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("@type=short", async function (assert) {
|
|
|
|
this.channel = ChatChannel.create({ chatable_type: "Category" });
|
|
|
|
this.currentUser.set("needs_channel_retention_reminder", true);
|
|
|
|
|
|
|
|
await render(
|
|
|
|
hbs`<ChatRetentionReminder @channel={{this.channel}} @type="short" />`
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.dom(".chat-retention-reminder").includesText(
|
|
|
|
I18n.t("chat.retention_reminders.short", {
|
2023-02-15 21:50:01 +08:00
|
|
|
count: this.siteSettings.chat_channel_retention_days,
|
|
|
|
})
|
2022-12-22 21:35:18 +08:00
|
|
|
);
|
2022-11-02 21:41:30 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|