mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
DEV: Modernize chat's component tests (#19577)
1. `test()` and `render()` instead of `componentTest()` 2. Angle brackets 3. `strictEqual()`/`true()`/`false()` assertions This removes all remaining uses of `componentTest` from core
This commit is contained in:
@ -60,26 +60,28 @@ module("Discourse Chat | Component | chat-message", function (hooks) {
|
||||
};
|
||||
}
|
||||
|
||||
const template = hbs`{{chat-message
|
||||
message=message
|
||||
canInteractWithChat=canInteractWithChat
|
||||
details=this.details
|
||||
chatChannel=chatChannel
|
||||
setReplyTo=setReplyTo
|
||||
replyMessageClicked=replyMessageClicked
|
||||
editButtonClicked=editButtonClicked
|
||||
selectingMessages=selectingMessages
|
||||
onStartSelectingMessages=onStartSelectingMessages
|
||||
onSelectMessage=onSelectMessage
|
||||
bulkSelectMessages=bulkSelectMessages
|
||||
onHoverMessage=onHoverMessage
|
||||
afterReactionAdded=reStickScrollIfNeeded
|
||||
}}`;
|
||||
const template = hbs`
|
||||
<ChatMessage
|
||||
@message={{this.message}}
|
||||
@canInteractWithChat={{this.canInteractWithChat}}
|
||||
@details={{this.details}}
|
||||
@chatChannel={{this.chatChannel}}
|
||||
@setReplyTo={{this.setReplyTo}}
|
||||
@replyMessageClicked={{this.replyMessageClicked}}
|
||||
@editButtonClicked={{this.editButtonClicked}}
|
||||
@selectingMessages={{this.selectingMessages}}
|
||||
@onStartSelectingMessages={{this.onStartSelectingMessages}}
|
||||
@onSelectMessage={{this.onSelectMessage}}
|
||||
@bulkSelectMessages={{this.bulkSelectMessages}}
|
||||
@onHoverMessage={{this.onHoverMessage}}
|
||||
@afterReactionAdded={{this.reStickScrollIfNeeded}}
|
||||
/>
|
||||
`;
|
||||
|
||||
test("Message with edits", async function (assert) {
|
||||
this.setProperties(generateMessageProps({ edited: true }));
|
||||
await render(template);
|
||||
assert.ok(
|
||||
assert.true(
|
||||
exists(".chat-message-edited"),
|
||||
"has the correct edited css class"
|
||||
);
|
||||
@ -88,7 +90,7 @@ module("Discourse Chat | Component | chat-message", function (hooks) {
|
||||
test("Deleted message", async function (assert) {
|
||||
this.setProperties(generateMessageProps({ deleted_at: moment() }));
|
||||
await render(template);
|
||||
assert.ok(
|
||||
assert.true(
|
||||
exists(".chat-message-deleted .chat-message-expand"),
|
||||
"has the correct deleted css class and expand button within"
|
||||
);
|
||||
@ -97,7 +99,7 @@ module("Discourse Chat | Component | chat-message", function (hooks) {
|
||||
test("Hidden message", async function (assert) {
|
||||
this.setProperties(generateMessageProps({ hidden: true }));
|
||||
await render(template);
|
||||
assert.ok(
|
||||
assert.true(
|
||||
exists(".chat-message-hidden .chat-message-expand"),
|
||||
"has the correct hidden css class and expand button within"
|
||||
);
|
||||
@ -109,7 +111,7 @@ module("Discourse Chat | Component | chat-message", function (hooks) {
|
||||
await render(template);
|
||||
await waitFor("div[data-visible=true]");
|
||||
|
||||
assert.ok(
|
||||
assert.true(
|
||||
exists(".chat-message-container[data-visible=true]"),
|
||||
"message is marked as visible"
|
||||
);
|
||||
|
Reference in New Issue
Block a user