discourse/plugins/chat/test/javascripts/components/chat-channel-metadata-test.js
David Battersby e991574389
UX: chat drawer increase unread channel visibility (#28731)
This change increases the visibility of unread channels to make them stand out more in drawer mode (desktop).

When a channel is unread:

- it floats to the top;
- when multiple channels are unread, they are sorted alphabetically (equal to how it’s done on mobile)
- the unread indicator blue dot moves to directly right of the channel name
2024-09-05 13:36:50 +04:00

32 lines
1.2 KiB
JavaScript

import { getOwner } from "@ember/owner";
import { render } from "@ember/test-helpers";
import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
module("Discourse Chat | Component | chat-channel-metadata", function (hooks) {
setupRenderingTest(hooks);
test("displays last message created at", async function (assert) {
let lastMessageSentAt = moment().subtract(1, "day").format();
this.channel = new ChatFabricators(getOwner(this)).directMessageChannel();
this.channel.lastMessage = new ChatFabricators(getOwner(this)).message({
channel: this.channel,
created_at: lastMessageSentAt,
});
await render(hbs`<ChatChannelMetadata @channel={{this.channel}} />`);
assert.dom(".chat-channel__metadata-date").hasText("Yesterday");
lastMessageSentAt = moment();
this.channel.lastMessage.createdAt = lastMessageSentAt;
await render(hbs`<ChatChannelMetadata @channel={{this.channel}} />`);
assert
.dom(".chat-channel__metadata-date")
.hasText(lastMessageSentAt.format("LT"));
});
});