mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 12:43:45 +08:00
abcaa1a961
This is a followup of the previous refactor where we created two new models to handle all the dedicated logic that was present in the `ChatChannel` model. For the sake of consistency, `DMChannel` has been renamed to `DirectMessageChannel` and the previous `DirectMessageChannel` model is now named `DirectMessage`. This should help reasoning about direct messages.
88 lines
2.2 KiB
JavaScript
88 lines
2.2 KiB
JavaScript
import { set } from "@ember/object";
|
|
import componentTest, {
|
|
setupRenderingTest,
|
|
} from "discourse/tests/helpers/component-test";
|
|
import { query } from "discourse/tests/helpers/qunit-helpers";
|
|
import hbs from "htmlbars-inline-precompile";
|
|
import ChatChannel from "discourse/plugins/chat/discourse/models/chat-channel";
|
|
import { module } from "qunit";
|
|
|
|
module(
|
|
"Discourse Chat | Component | chat-composer placeholder",
|
|
function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
componentTest("direct message to self shows Jot something down", {
|
|
template: hbs`{{chat-composer chatChannel=chatChannel}}`,
|
|
|
|
beforeEach() {
|
|
set(this.currentUser, "id", 1);
|
|
this.set(
|
|
"chatChannel",
|
|
ChatChannel.create({
|
|
chatable_type: "DirectMessage",
|
|
chatable: {
|
|
users: [{ id: 1 }],
|
|
},
|
|
})
|
|
);
|
|
},
|
|
|
|
async test(assert) {
|
|
assert.equal(
|
|
query(".chat-composer-input").placeholder,
|
|
"Jot something down"
|
|
);
|
|
},
|
|
});
|
|
|
|
componentTest("direct message to multiple folks shows their names", {
|
|
template: hbs`{{chat-composer chatChannel=chatChannel}}`,
|
|
|
|
beforeEach() {
|
|
this.set(
|
|
"chatChannel",
|
|
ChatChannel.create({
|
|
chatable_type: "DirectMessage",
|
|
chatable: {
|
|
users: [
|
|
{ name: "Tomtom" },
|
|
{ name: "Steaky" },
|
|
{ username: "zorro" },
|
|
],
|
|
},
|
|
})
|
|
);
|
|
},
|
|
|
|
async test(assert) {
|
|
assert.equal(
|
|
query(".chat-composer-input").placeholder,
|
|
"Chat with Tomtom, Steaky, @zorro"
|
|
);
|
|
},
|
|
});
|
|
|
|
componentTest("message to channel shows send message to channel name", {
|
|
template: hbs`{{chat-composer chatChannel=chatChannel}}`,
|
|
|
|
beforeEach() {
|
|
this.set(
|
|
"chatChannel",
|
|
ChatChannel.create({
|
|
chatable_type: "Category",
|
|
title: "just-cats",
|
|
})
|
|
);
|
|
},
|
|
|
|
async test(assert) {
|
|
assert.equal(
|
|
query(".chat-composer-input").placeholder,
|
|
"Chat with #just-cats"
|
|
);
|
|
},
|
|
});
|
|
}
|
|
);
|