0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-11 02:59:07 +08:00
discourse/plugins/discourse-calendar/test/javascripts/integration/components/embeddable-chat-channel-connector-test.gjs
Kris 2bfb79d6aa
UX: keep livestream chat position throughout whole topic (#42193)
This fixes an issue where scrolling in a livestream topic loses the chat
sidebar. The body class had to be based on the topic rather than the
event card so the class can persist. Added a test to make sure it
doesn't regress.
2026-07-31 10:02:53 +10:00

42 lines
1.4 KiB
Text
Vendored

import { getOwner } from "@ember/owner";
import { render } from "@ember/test-helpers";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import EmbeddableChatChannelConnector from "../../discourse/connectors/before-main-outlet/embeddable-chat-channel-connector";
module(
"Integration | Component | Livestream | embeddable chat channel connector",
function (hooks) {
setupRenderingTest(hooks);
function stubEmbeddableChat(context, useLivestreamLayout) {
const owner = getOwner(context);
owner.unregister("service:embeddable-chat");
owner.register(
"service:embeddable-chat",
{
useLivestreamLayout,
chatChannelId: 9,
canRenderChatChannel: () => false,
},
{ instantiate: false }
);
}
test("applies the livestream body class from outside the post stream", async function (assert) {
stubEmbeddableChat(this, true);
await render(<template><EmbeddableChatChannelConnector /></template>);
assert.dom(document.body).hasClass("livestream-topic");
});
test("omits the livestream body class when the layout does not apply", async function (assert) {
stubEmbeddableChat(this, false);
await render(<template><EmbeddableChatChannelConnector /></template>);
assert.dom(document.body).doesNotHaveClass("livestream-topic");
});
}
);