discourse/plugins/chat/test/javascripts/components/chat-message-separator-date-test.js
Jan Cernik e51bbfa4e8
FEATURE: Scroll to first message when clicking date in chat (#21926)
This PR adds a new parameter to fetch chat messages: `target_date`.

It can be used to fetch messages by a specific date string. Note that it does not need to be the `created_at` date of an existing message, it can be any date. Similar to `target_message_id`, it retrieves an array of past and future messages following the query limits.
2023-06-20 15:58:38 +02:00

28 lines
904 B
JavaScript

import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { query } from "discourse/tests/helpers/qunit-helpers";
import hbs from "htmlbars-inline-precompile";
import { module, test } from "qunit";
import { render } from "@ember/test-helpers";
module(
"Discourse Chat | Component | chat-message-separator-date",
function (hooks) {
setupRenderingTest(hooks);
test("first message of the day", async function (assert) {
this.set("date", moment().format("LLL"));
this.set("message", { formattedFirstMessageDate: this.date });
this.set("fetchMessagesByDate", () => {});
await render(
hbs`<ChatMessageSeparatorDate @message={{this.message}} @fetchMessagesByDate={{this.fetchMessagesByDate}} />`
);
assert.strictEqual(
query(".chat-message-separator-date").innerText.trim(),
this.date
);
});
}
);