2024-07-25 21:09:06 +08:00
|
|
|
import { getOwner } from "@ember/owner";
|
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";
|
2024-04-09 03:00:09 +08:00
|
|
|
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
|
2023-10-11 02:38:59 +08:00
|
|
|
import ChatMessage from "discourse/plugins/chat/discourse/models/chat-message";
|
2022-11-02 21:41:30 +08:00
|
|
|
|
|
|
|
module("Discourse Chat | Component | chat-message-avatar", function (hooks) {
|
|
|
|
setupRenderingTest(hooks);
|
|
|
|
|
2022-12-22 21:35:18 +08:00
|
|
|
test("chat_webhook_event", async function (assert) {
|
2024-04-09 03:00:09 +08:00
|
|
|
this.message = ChatMessage.create(
|
|
|
|
new ChatFabricators(getOwner(this)).channel(),
|
|
|
|
{
|
|
|
|
chat_webhook_event: { emoji: ":heart:" },
|
|
|
|
}
|
|
|
|
);
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2023-06-19 15:50:54 +08:00
|
|
|
await render(hbs`<Chat::Message::Avatar @message={{this.message}} />`);
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2024-10-15 23:11:20 +08:00
|
|
|
assert.dom(".chat-emoji-avatar .emoji").hasAttribute("title", "heart");
|
2022-11-02 21:41:30 +08:00
|
|
|
});
|
|
|
|
|
2022-12-22 21:35:18 +08:00
|
|
|
test("user", async function (assert) {
|
2024-04-09 03:00:09 +08:00
|
|
|
this.message = ChatMessage.create(
|
|
|
|
new ChatFabricators(getOwner(this)).channel(),
|
|
|
|
{
|
|
|
|
user: { username: "discobot" },
|
|
|
|
}
|
|
|
|
);
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2023-06-19 15:50:54 +08:00
|
|
|
await render(hbs`<Chat::Message::Avatar @message={{this.message}} />`);
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2024-11-09 03:27:32 +08:00
|
|
|
assert.dom('.chat-user-avatar [data-user-card="discobot"]').exists();
|
2022-11-02 21:41:30 +08:00
|
|
|
});
|
|
|
|
});
|