2024-04-09 03:00:09 +08:00
|
|
|
import { getOwner } from "@ember/application";
|
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";
|
|
|
|
import { exists, query } from "discourse/tests/helpers/qunit-helpers";
|
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
|
|
|
|
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) {
|
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
|
|
|
|
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
|
|
|
});
|
|
|
|
});
|