mirror of
https://github.com/discourse/discourse.git
synced 2024-12-05 07:53:42 +08:00
cbb9396353
- Moves `<ChatMessageInfo />` to `<Chat::Message::Info />` - Moves `<ChatMessageAvatar />` to `<Chat::Message::Avatar />` - Moves `<ChatMessageLeftGutter />` to `<Chat::Message::LeftGutter />`, adds tests - Creates `<Chat::Message::Error />` - Creates `<Chat::Message::MentionWarning />`, adds tests and a styleguide - Creates a model for ChatMessageMentionWarning, adds fabricator for it - Keeps the enter/leave viewport logic inside the `<ChatMessage />` component instead of bubbling it to the channel and thread components - Adds a scale animation when clicking a reaction - Creates `chat/later-fn` modifier which accepts a function and a delay. It allows to call a function Xms after a component has been inserted, it's useful for animations. - Moves css code out of chat-message into relevant files - Deletes unused code <!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
103 lines
2.8 KiB
JavaScript
103 lines
2.8 KiB
JavaScript
import { render } from "@ember/test-helpers";
|
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
|
import hbs from "htmlbars-inline-precompile";
|
|
import { module, test } from "qunit";
|
|
import fabricators from "discourse/plugins/chat/discourse/lib/fabricators";
|
|
|
|
module(
|
|
"Discourse Chat | Component | Chat::Message::MentionWarning",
|
|
function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
const template = hbs`
|
|
<Chat::Message::MentionWarning @message={{this.message}} />
|
|
`;
|
|
|
|
test("without memberships", async function (assert) {
|
|
this.message = fabricators.message();
|
|
this.message.mentionWarning = fabricators.messageMentionWarning(
|
|
this.message,
|
|
{
|
|
without_membership: [fabricators.user()].map((u) => {
|
|
return { username: u.username, id: u.id };
|
|
}),
|
|
}
|
|
);
|
|
|
|
await render(template);
|
|
|
|
assert
|
|
.dom(".chat-message-mention-warning__text.-without-membership")
|
|
.exists();
|
|
});
|
|
|
|
test("cannot see channel", async function (assert) {
|
|
this.message = fabricators.message();
|
|
this.message.mentionWarning = fabricators.messageMentionWarning(
|
|
this.message,
|
|
{
|
|
cannot_see: [fabricators.user()].map((u) => {
|
|
return { username: u.username, id: u.id };
|
|
}),
|
|
}
|
|
);
|
|
|
|
await render(template);
|
|
|
|
assert.dom(".chat-message-mention-warning__text.-cannot-see").exists();
|
|
});
|
|
|
|
test("cannot see channel", async function (assert) {
|
|
this.message = fabricators.message();
|
|
this.message.mentionWarning = fabricators.messageMentionWarning(
|
|
this.message,
|
|
{
|
|
cannot_see: [fabricators.user()].map((u) => {
|
|
return { username: u.username, id: u.id };
|
|
}),
|
|
}
|
|
);
|
|
|
|
await render(template);
|
|
|
|
assert.dom(".chat-message-mention-warning__text.-cannot-see").exists();
|
|
});
|
|
|
|
test("too many groups", async function (assert) {
|
|
this.message = fabricators.message();
|
|
this.message.mentionWarning = fabricators.messageMentionWarning(
|
|
this.message,
|
|
{
|
|
groups_with_too_many_members: [fabricators.group()].mapBy("name"),
|
|
}
|
|
);
|
|
|
|
await render(template);
|
|
|
|
assert
|
|
.dom(
|
|
".chat-message-mention-warning__text.-groups-with-too-many-members"
|
|
)
|
|
.exists();
|
|
});
|
|
|
|
test("groups with mentions disabled", async function (assert) {
|
|
this.message = fabricators.message();
|
|
this.message.mentionWarning = fabricators.messageMentionWarning(
|
|
this.message,
|
|
{
|
|
group_mentions_disabled: [fabricators.group()].mapBy("name"),
|
|
}
|
|
);
|
|
|
|
await render(template);
|
|
|
|
assert
|
|
.dom(
|
|
".chat-message-mention-warning__text.-groups-with-mentions-disabled"
|
|
)
|
|
.exists();
|
|
});
|
|
}
|
|
);
|