2022-12-22 21:35:18 +08:00
|
|
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
2022-11-02 21:41:30 +08:00
|
|
|
import hbs from "htmlbars-inline-precompile";
|
|
|
|
import { exists, query } from "discourse/tests/helpers/qunit-helpers";
|
2022-12-22 21:35:18 +08:00
|
|
|
import { module, test } from "qunit";
|
|
|
|
import { render } from "@ember/test-helpers";
|
2023-03-03 20:09:25 +08:00
|
|
|
import ChatMessage from "discourse/plugins/chat/discourse/models/chat-message";
|
2023-05-17 23:49:52 +08:00
|
|
|
import fabricators from "discourse/plugins/chat/discourse/lib/fabricators";
|
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) {
|
2023-05-17 23:49:52 +08:00
|
|
|
this.message = ChatMessage.create(fabricators.channel(), {
|
2023-03-03 20:09:25 +08:00
|
|
|
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
|
|
|
|
2022-12-22 21:35:18 +08:00
|
|
|
assert.strictEqual(query(".chat-emoji-avatar .emoji").title, "heart");
|
2022-11-02 21:41:30 +08:00
|
|
|
});
|
|
|
|
|
2022-12-22 21:35:18 +08:00
|
|
|
test("user", async function (assert) {
|
2023-05-17 23:49:52 +08:00
|
|
|
this.message = ChatMessage.create(fabricators.channel(), {
|
2023-03-03 20:09:25 +08:00
|
|
|
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
|
|
|
|
2022-12-22 21:35:18 +08:00
|
|
|
assert.true(exists('.chat-user-avatar [data-user-card="discobot"]'));
|
2022-11-02 21:41:30 +08:00
|
|
|
});
|
|
|
|
});
|