discourse/plugins/chat/test/javascripts/components/chat-thread-participants-test.js
Joffrey JAFFEUX a39ff830e8
UX: makes avatar non interactive in thread participants list (#23847)
It was slightly surprising to have a user card show when click on a thread item list.

More over this commit does:
- moves chat/user-avatar to chat-user-avatar and converts it to gjs
- moves chat/thread/participants to chat-thread-participants
- rewrite the `toggleCheckIfPossible` modifier to only be applied when selecting messages, it prevents the click event to collide with the click of avatars in regular messages
2023-10-09 21:12:50 +02:00

59 lines
2.0 KiB
JavaScript

import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import hbs from "htmlbars-inline-precompile";
import fabricators from "discourse/plugins/chat/discourse/lib/fabricators";
import { render } from "@ember/test-helpers";
import { module, test } from "qunit";
module(
"Discourse Chat | Component | <ChatThreadParticipants />",
function (hooks) {
setupRenderingTest(hooks);
test("no participants", async function (assert) {
this.thread = fabricators.thread();
await render(hbs`<ChatThreadParticipants @thread={{this.thread}} />`);
assert.dom(".chat-thread-participants").doesNotExist();
});
test("@includeOriginalMessageUser=true", async function (assert) {
const orignalMessageUser = fabricators.user({ username: "bob" });
this.thread = fabricators.thread({
original_message: fabricators.message({ user: orignalMessageUser }),
preview: fabricators.threadPreview({
channel: this.channel,
participant_users: [
orignalMessageUser,
fabricators.user({ username: "alice" }),
],
}),
});
await render(hbs`<ChatThreadParticipants @thread={{this.thread}} />`);
assert.dom(".chat-user-avatar[data-username]").exists({ count: 2 });
});
test("@includeOriginalMessageUser=false", async function (assert) {
const orignalMessageUser = fabricators.user({ username: "bob" });
this.thread = fabricators.thread({
original_message: fabricators.message({ user: orignalMessageUser }),
preview: fabricators.threadPreview({
channel: this.channel,
participant_users: [
orignalMessageUser,
fabricators.user({ username: "alice" }),
],
}),
});
await render(
hbs`<ChatThreadParticipants @thread={{this.thread}} @includeOriginalMessageUser={{false}} />`
);
assert.dom('.chat-user-avatar[data-username="bob"]').doesNotExist();
assert.dom('.chat-user-avatar[data-username="alice"]').exists();
});
}
);