mirror of
https://github.com/discourse/discourse.git
synced 2025-03-13 01:05:48 +08:00

- FIX: improves reactions and thread indicator touch event on mobile These "buttons" are located inside a scroll list which makes them very specific. The general idea is to ensure these events are passive and are not bubbling to the parent. - DEV: moves state on top level message node - FIX: ensures popover arrow has the correct border - FIX: makes a message expanded by default - FIX applies the same ios scroll fix on thread and channel - UI: better active/hover state for thread indicator - UI: attempts to follow more closely our BEM naming scheme - FIX: reduces bottom padding on message with thread indicator and user info hidden - UI: add padding for first message in thread - FIX: prevents actions backdrop to open thread - UI: makes thread indicator resizable
91 lines
2.7 KiB
JavaScript
91 lines
2.7 KiB
JavaScript
import User from "discourse/models/user";
|
|
import { render } from "@ember/test-helpers";
|
|
import ChatMessage from "discourse/plugins/chat/discourse/models/chat-message";
|
|
import { exists } from "discourse/tests/helpers/qunit-helpers";
|
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
|
import hbs from "htmlbars-inline-precompile";
|
|
import ChatChannel from "discourse/plugins/chat/discourse/models/chat-channel";
|
|
import { module, test } from "qunit";
|
|
|
|
module("Discourse Chat | Component | chat-message", function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
function generateMessageProps(messageData = {}) {
|
|
const channel = ChatChannel.create({
|
|
chatable_id: 1,
|
|
chatable_type: "Category",
|
|
id: 9,
|
|
title: "Site",
|
|
last_message_sent_at: "2021-11-08T21:26:05.710Z",
|
|
current_user_membership: {
|
|
unread_count: 0,
|
|
muted: false,
|
|
},
|
|
can_delete_self: true,
|
|
can_delete_others: true,
|
|
can_flag: true,
|
|
user_silenced: false,
|
|
can_moderate: true,
|
|
});
|
|
return {
|
|
message: ChatMessage.create(
|
|
channel,
|
|
Object.assign(
|
|
{
|
|
id: 178,
|
|
message: "from deleted user",
|
|
cooked: "<p>from deleted user</p>",
|
|
excerpt: "<p>from deleted user</p>",
|
|
created_at: "2021-07-22T08:14:16.950Z",
|
|
flag_count: 0,
|
|
user: User.create({ username: "someguy", id: 1424 }),
|
|
edited: false,
|
|
},
|
|
messageData
|
|
)
|
|
),
|
|
channel,
|
|
messageDidEnterViewport: () => {},
|
|
messageDidLeaveViewport: () => {},
|
|
};
|
|
}
|
|
|
|
const template = hbs`
|
|
<ChatMessage
|
|
@message={{this.message}}
|
|
@messageDidEnterViewport={{this.messageDidEnterViewport}}
|
|
@messageDidLeaveViewport={{this.messageDidLeaveViewport}}
|
|
/>
|
|
`;
|
|
|
|
test("Message with edits", async function (assert) {
|
|
this.setProperties(generateMessageProps({ edited: true }));
|
|
await render(template);
|
|
|
|
assert.true(
|
|
exists(".chat-message-edited"),
|
|
"has the correct edited css class"
|
|
);
|
|
});
|
|
|
|
test("Deleted message", async function (assert) {
|
|
this.setProperties(generateMessageProps({ deleted_at: moment() }));
|
|
await render(template);
|
|
|
|
assert.true(
|
|
exists(".chat-message-deleted .chat-message-expand"),
|
|
"has the correct deleted css class and expand button within"
|
|
);
|
|
});
|
|
|
|
test("Hidden message", async function (assert) {
|
|
this.setProperties(generateMessageProps({ hidden: true }));
|
|
await render(template);
|
|
|
|
assert.true(
|
|
exists(".chat-message-hidden .chat-message-expand"),
|
|
"has the correct hidden css class and expand button within"
|
|
);
|
|
});
|
|
});
|