discourse/plugins/chat/test/javascripts/components/chat-retention-reminder-test.js
Joffrey JAFFEUX c1abf8b35c
UX: improves reminder setting text (#23918)
The setting will change from "%{count} days" to "Chat settings have been set to retain channel messages for %{count} day."

This commit also:
- migrates `chat-retention-reminder` to gjs
- adds a "type" property to `chat-retention-reminder-text` to allow use a long or short text depending on where it's used.
2023-10-13 07:55:47 +02:00

42 lines
1.4 KiB
JavaScript

import { render } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import I18n from "I18n";
import ChatChannel from "discourse/plugins/chat/discourse/models/chat-channel";
module(
"Discourse Chat | Component | chat-retention-reminder",
function (hooks) {
setupRenderingTest(hooks);
test("display retention info", 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}} />`);
assert.dom(".chat-retention-reminder").includesText(
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", {
count: this.siteSettings.chat_channel_retention_days,
})
);
});
}
);