2023-10-11 02:38:59 +08:00
|
|
|
import { htmlSafe } from "@ember/template";
|
2022-12-22 21:35:18 +08:00
|
|
|
import { click, render } from "@ember/test-helpers";
|
2022-11-02 21:41:30 +08:00
|
|
|
import hbs from "htmlbars-inline-precompile";
|
2022-12-22 21:35:18 +08:00
|
|
|
import { module, test } from "qunit";
|
2023-10-11 02:38:59 +08:00
|
|
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
2022-11-02 21:41:30 +08:00
|
|
|
|
|
|
|
module("Discourse Chat | Component | collapser", function (hooks) {
|
|
|
|
setupRenderingTest(hooks);
|
|
|
|
|
2022-12-22 21:35:18 +08:00
|
|
|
test("renders header", async function (assert) {
|
|
|
|
this.set("header", htmlSafe(`<div class="cat">tomtom</div>`));
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2022-12-22 21:35:18 +08:00
|
|
|
await render(hbs`<Collapser @header={{this.header}} />`);
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2024-11-09 03:27:32 +08:00
|
|
|
assert.dom(".cat").exists();
|
2022-11-02 21:41:30 +08:00
|
|
|
});
|
|
|
|
|
2022-12-22 21:35:18 +08:00
|
|
|
test("collapses and expands yielded body", async function (assert) {
|
|
|
|
await render(hbs`
|
|
|
|
<Collapser>
|
|
|
|
<div class="cat">body text</div>
|
|
|
|
</Collapser>
|
|
|
|
`);
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2024-11-10 08:41:50 +08:00
|
|
|
assert.dom(".cat").isVisible();
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2024-11-10 08:41:50 +08:00
|
|
|
await click(".chat-message-collapser-opened");
|
|
|
|
assert.dom(".cat").isNotVisible();
|
2022-11-02 21:41:30 +08:00
|
|
|
|
2024-11-10 08:41:50 +08:00
|
|
|
await click(".chat-message-collapser-closed");
|
|
|
|
assert.dom(".cat").isVisible();
|
2022-11-02 21:41:30 +08:00
|
|
|
});
|
|
|
|
});
|