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";
|
2022-11-02 21:41:30 +08:00
|
|
|
|
|
|
|
module(
|
|
|
|
"Discourse Chat | Component | chat-user-display-name | prioritize username in UX",
|
|
|
|
function (hooks) {
|
|
|
|
setupRenderingTest(hooks);
|
|
|
|
|
2022-12-22 21:35:18 +08:00
|
|
|
test("username and no name", async function (assert) {
|
|
|
|
this.siteSettings.prioritize_username_in_ux = true;
|
|
|
|
this.set("user", { username: "bob", name: null });
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2022-12-22 21:35:18 +08:00
|
|
|
await render(hbs`<ChatUserDisplayName @user={{this.user}} />`);
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2024-11-30 23:44:51 +08:00
|
|
|
assert.dom(".chat-user-display-name").hasText("bob");
|
2022-11-02 21:41:30 +08:00
|
|
|
});
|
|
|
|
|
2022-12-22 21:35:18 +08:00
|
|
|
test("username and name", async function (assert) {
|
|
|
|
this.siteSettings.prioritize_username_in_ux = true;
|
|
|
|
this.set("user", { username: "bob", name: "Bobcat" });
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2022-12-22 21:35:18 +08:00
|
|
|
await render(hbs`<ChatUserDisplayName @user={{this.user}} />`);
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2024-11-30 23:44:51 +08:00
|
|
|
assert.dom(".chat-user-display-name").hasText("bob Bobcat");
|
2022-11-02 21:41:30 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
module(
|
|
|
|
"Discourse Chat | Component | chat-user-display-name | prioritize name in UX",
|
|
|
|
function (hooks) {
|
|
|
|
setupRenderingTest(hooks);
|
|
|
|
|
2022-12-22 21:35:18 +08:00
|
|
|
test("no name", async function (assert) {
|
|
|
|
this.siteSettings.prioritize_username_in_ux = false;
|
|
|
|
this.set("user", { username: "bob", name: null });
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2022-12-22 21:35:18 +08:00
|
|
|
await render(hbs`<ChatUserDisplayName @user={{this.user}} />`);
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2024-11-30 23:44:51 +08:00
|
|
|
assert.dom(".chat-user-display-name").hasText("bob");
|
2022-11-02 21:41:30 +08:00
|
|
|
});
|
|
|
|
|
2022-12-22 21:35:18 +08:00
|
|
|
test("name and username", async function (assert) {
|
|
|
|
this.siteSettings.prioritize_username_in_ux = false;
|
|
|
|
this.set("user", { username: "bob", name: "Bobcat" });
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2022-12-22 21:35:18 +08:00
|
|
|
await render(hbs`<ChatUserDisplayName @user={{this.user}} />`);
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2024-11-30 23:44:51 +08:00
|
|
|
assert.dom(".chat-user-display-name").hasText("Bobcat bob");
|
2022-11-02 21:41:30 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|