mirror of
https://github.com/discourse/discourse.git
synced 2024-12-22 02:26:17 +08:00
1060e4573a
The complexity of the situation is that we don't want to load faker into production by default but fabricators and styleguide are available on production. This is made possible through app/assets/javascripts/discourse/app/lib/load-faker.js which contains a function to ensure faker is loaded asynchronously (loadFaker) and another function to access the loaded faker (getLoadedFaker). Note 1: this commit also refactors fabricators to have access to context and use faker where possible Note 2: this commit moves automation to admin bundle --------- Co-authored-by: David Taylor <david@taylorhq.com>
83 lines
2.6 KiB
JavaScript
83 lines
2.6 KiB
JavaScript
import { getOwner } from "@ember/application";
|
||
import { render } from "@ember/test-helpers";
|
||
import hbs from "htmlbars-inline-precompile";
|
||
import { module, test } from "qunit";
|
||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
|
||
|
||
module(
|
||
"Discourse Chat | Component | chat-composer-message-details",
|
||
function (hooks) {
|
||
setupRenderingTest(hooks);
|
||
|
||
test("data-id attribute", async function (assert) {
|
||
this.message = new ChatFabricators(getOwner(this)).message();
|
||
|
||
await render(
|
||
hbs`<ChatComposerMessageDetails @message={{this.message}} />`
|
||
);
|
||
|
||
assert
|
||
.dom(".chat-composer-message-details")
|
||
.hasAttribute("data-id", this.message.id.toString());
|
||
});
|
||
|
||
test("editing a message has the pencil icon", async function (assert) {
|
||
this.message = new ChatFabricators(getOwner(this)).message({
|
||
editing: true,
|
||
});
|
||
|
||
await render(
|
||
hbs`<ChatComposerMessageDetails @message={{this.message}} />`
|
||
);
|
||
|
||
assert.dom(".chat-composer-message-details .d-icon-pencil-alt").exists();
|
||
});
|
||
|
||
test("replying to a message has the reply icon", async function (assert) {
|
||
const firstMessage = new ChatFabricators(getOwner(this)).message();
|
||
this.message = new ChatFabricators(getOwner(this)).message({
|
||
inReplyTo: firstMessage,
|
||
});
|
||
|
||
await render(
|
||
hbs`<ChatComposerMessageDetails @message={{this.message}} />`
|
||
);
|
||
|
||
assert.dom(".chat-composer-message-details .d-icon-reply").exists();
|
||
});
|
||
|
||
test("displays user avatar", async function (assert) {
|
||
this.message = new ChatFabricators(getOwner(this)).message();
|
||
|
||
await render(
|
||
hbs`<ChatComposerMessageDetails @message={{this.message}} />`
|
||
);
|
||
|
||
assert
|
||
.dom(".chat-composer-message-details .chat-user-avatar .avatar")
|
||
.hasAttribute("title", this.message.user.username);
|
||
});
|
||
|
||
test("displays message excerpt", async function (assert) {
|
||
this.message = new ChatFabricators(getOwner(this)).message();
|
||
|
||
await render(
|
||
hbs`<ChatComposerMessageDetails @message={{this.message}} />`
|
||
);
|
||
|
||
assert.dom(".chat-reply__excerpt").hasText(this.message.excerpt);
|
||
});
|
||
|
||
test("displays user’s username", async function (assert) {
|
||
this.message = new ChatFabricators(getOwner(this)).message();
|
||
|
||
await render(
|
||
hbs`<ChatComposerMessageDetails @message={{this.message}} />`
|
||
);
|
||
|
||
assert.dom(".chat-reply__username").hasText(this.message.user.username);
|
||
});
|
||
}
|
||
);
|