mirror of
https://github.com/discourse/discourse.git
synced 2026-08-06 19:25:37 -05:00
DEV: Add last_message_id to channel and thread (#22488)
Initial migration and changes to models as well as changing the following services to update last_message_id: * Chat::MessageCreator * Chat::RestoreMessage * Chat::TrashMessage The data migration will set the `last_message_id` for all existing threads and channels in the database. When we query the thread list as well as the channel, we look at the last message ID for the following: * Channel - Sorting DM channels, and channel metadata for the list of channels * Thread - Last reply details for thread indicators and thread list
This commit is contained in:
@@ -8,10 +8,12 @@ import { render } from "@ember/test-helpers";
|
||||
module("Discourse Chat | Component | chat-channel-metadata", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test("displays last message sent at", async function (assert) {
|
||||
test("displays last message created at", async function (assert) {
|
||||
let lastMessageSentAt = moment().subtract(1, "day").format();
|
||||
this.channel = fabricators.directMessageChannel({
|
||||
last_message_sent_at: lastMessageSentAt,
|
||||
this.channel = fabricators.directMessageChannel();
|
||||
this.channel.lastMessage = fabricators.message({
|
||||
channel: this.channel,
|
||||
created_at: lastMessageSentAt,
|
||||
});
|
||||
|
||||
await render(hbs`<ChatChannelMetadata @channel={{this.channel}} />`);
|
||||
@@ -19,7 +21,7 @@ module("Discourse Chat | Component | chat-channel-metadata", function (hooks) {
|
||||
assert.dom(".chat-channel-metadata__date").hasText("Yesterday");
|
||||
|
||||
lastMessageSentAt = moment();
|
||||
this.channel.lastMessageSentAt = lastMessageSentAt;
|
||||
this.channel.lastMessage.createdAt = lastMessageSentAt;
|
||||
await render(hbs`<ChatChannelMetadata @channel={{this.channel}} />`);
|
||||
|
||||
assert
|
||||
|
||||
@@ -47,13 +47,15 @@ module("Discourse Chat | Component | chat-channel-row", function (hooks) {
|
||||
});
|
||||
|
||||
test("renders correct channel metadata", async function (assert) {
|
||||
this.categoryChatChannel.lastMessageSentAt = moment().toISOString();
|
||||
this.categoryChatChannel.lastMessage = fabricators.message({
|
||||
created_at: moment().toISOString(),
|
||||
});
|
||||
await render(hbs`<ChatChannelRow @channel={{this.categoryChatChannel}} />`);
|
||||
|
||||
assert
|
||||
.dom(".chat-channel-metadata")
|
||||
.hasText(
|
||||
moment(this.categoryChatChannel.lastMessageSentAt).format("h:mm A")
|
||||
moment(this.categoryChatChannel.lastMessage.createdAt).format("h:mm A")
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user