discourse/plugins/chat/test/javascripts/components/chat-user-avatar-test.js
Joffrey JAFFEUX d75d64bf16
FEATURE: new jump to channel menu (#22383)
This commit replaces two existing screens:
- draft
- channel selection modal

Main features compared to existing solutions
- features are now combined, meaning you can for example create multi users DM
- it will show users with chat disabled
- it shows unread state
- hopefully a better look/feel
- lots of small details and fixes...

Other noticeable fixes
- starting a DM with a user, even from the user card and clicking <kbd>Chat</kbd> will not show a green dot for the target user (or even the channel) until a message is actually sent
- it should almost never do a full page reload anymore

---------

Co-authored-by: Martin Brennan <mjrbrennan@gmail.com>
Co-authored-by: Jordan Vidrine <30537603+jordanvidrine@users.noreply.github.com>
Co-authored-by: chapoi <101828855+chapoi@users.noreply.github.com>
Co-authored-by: Mark VanLandingham <markvanlan@gmail.com>
2023-07-05 18:18:27 +02:00

51 lines
1.5 KiB
JavaScript

import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { exists } from "discourse/tests/helpers/qunit-helpers";
import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit";
import { render } from "@ember/test-helpers";
const user = {
id: 1,
username: "markvanlan",
name: null,
avatar_template: "/letter_avatar_proxy/v4/letter/m/48db29/{size}.png",
};
module("Discourse Chat | Component | chat-user-avatar", function (hooks) {
setupRenderingTest(hooks);
test("user is not online", async function (assert) {
this.set("user", user);
this.set("chat", { presenceChannel: { users: [] } });
await render(
hbs`<ChatUserAvatar @chat={{this.chat}} @user={{this.user}} />`
);
assert.true(
exists(
`.chat-user-avatar .chat-user-avatar-container[data-user-card=${user.username}] .avatar[title=${user.username}]`
)
);
assert.false(exists(".chat-user-avatar.is-online"));
});
test("user is online", async function (assert) {
this.set("user", user);
this.set("chat", {
presenceChannel: { users: [{ id: user.id }] },
});
await render(
hbs`<ChatUserAvatar @showPresence={{true}} @chat={{this.chat}} @user={{this.user}} />`
);
assert.true(
exists(
`.chat-user-avatar .chat-user-avatar-container[data-user-card=${user.username}] .avatar[title=${user.username}]`
)
);
assert.true(exists(".chat-user-avatar.is-online"));
});
});