2024-07-25 21:09:06 +08:00
|
|
|
import { getOwner } from "@ember/owner";
|
2023-06-19 15:50:54 +08:00
|
|
|
import { render } from "@ember/test-helpers";
|
|
|
|
import hbs from "htmlbars-inline-precompile";
|
|
|
|
import { module, test } from "qunit";
|
2024-04-09 03:00:09 +08:00
|
|
|
import CoreFabricators from "discourse/lib/fabricators";
|
2023-10-11 02:38:59 +08:00
|
|
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
2024-11-20 04:45:18 +08:00
|
|
|
import { i18n } from 'discourse-i18n';
|
2024-04-09 03:00:09 +08:00
|
|
|
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
|
2023-06-19 15:50:54 +08:00
|
|
|
|
|
|
|
module(
|
|
|
|
"Discourse Chat | Component | Chat::Message::LeftGutter",
|
|
|
|
function (hooks) {
|
|
|
|
setupRenderingTest(hooks);
|
|
|
|
|
|
|
|
const template = hbs`
|
|
|
|
<Chat::Message::LeftGutter @message={{this.message}} />
|
|
|
|
`;
|
|
|
|
|
|
|
|
test("default", async function (assert) {
|
2024-04-09 03:00:09 +08:00
|
|
|
this.message = new ChatFabricators(getOwner(this)).message();
|
2023-06-19 15:50:54 +08:00
|
|
|
|
|
|
|
await render(template);
|
|
|
|
|
|
|
|
assert.dom(".chat-message-left-gutter__date").exists();
|
|
|
|
});
|
|
|
|
|
|
|
|
test("with reviewable", async function (assert) {
|
2024-04-09 03:00:09 +08:00
|
|
|
this.message = new ChatFabricators(getOwner(this)).message({
|
|
|
|
reviewable_id: 1,
|
|
|
|
});
|
2023-06-19 15:50:54 +08:00
|
|
|
|
|
|
|
await render(template);
|
|
|
|
|
|
|
|
assert
|
|
|
|
.dom(".chat-message-left-gutter__flag .svg-icon-title")
|
2024-11-20 04:45:18 +08:00
|
|
|
.hasAttribute("title", i18n("chat.flagged"));
|
2023-06-19 15:50:54 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
test("with flag status", async function (assert) {
|
2024-04-09 03:00:09 +08:00
|
|
|
this.message = new ChatFabricators(getOwner(this)).message({
|
|
|
|
user_flag_status: 0,
|
|
|
|
});
|
2023-06-19 15:50:54 +08:00
|
|
|
|
|
|
|
await render(template);
|
|
|
|
|
|
|
|
assert
|
|
|
|
.dom(".chat-message-left-gutter__flag .svg-icon-title")
|
2024-11-20 04:45:18 +08:00
|
|
|
.hasAttribute("title", i18n("chat.you_flagged"));
|
2023-06-19 15:50:54 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
test("bookmark", async function (assert) {
|
2024-04-09 03:00:09 +08:00
|
|
|
this.message = new ChatFabricators(getOwner(this)).message({
|
|
|
|
bookmark: new CoreFabricators(getOwner(this)).bookmark(),
|
|
|
|
});
|
2023-06-19 15:50:54 +08:00
|
|
|
|
|
|
|
await render(template);
|
|
|
|
|
|
|
|
assert.dom(".chat-message-left-gutter__date").exists();
|
|
|
|
assert.dom(".chat-message-left-gutter__bookmark").exists();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|