0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-14 13:58:53 +08:00
discourse/plugins/chat/test/javascripts/components/chat-message-text-test.gjs
Martin Brennan 79d1c792eb
DEV: Update test module name conventions (#40389)
Currently, most of the JS test modules follow this
convention:

```
module("Integration | Component | topic-dismiss-buttons"
```

Which is a legacy from when ember components etc were
rendered in templates like this:

```
{{d-button title="foo"}}
```

Instead, this commit updates all of them to follow this
PascalCase convention:

```
module("Integration | Component | TopicDismissButtons", function (hooks) {
```

No linting is added to enforce this, we suspect that it's
mostly a result of cargo culting, and people will add new
tests following PascalCase convention.

Also adds an initial AI skill for writing JS tests.
2026-05-29 15:19:55 +10:00

74 lines
2 KiB
Text
Vendored

import { render } from "@ember/test-helpers";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import ChatMessageText from "discourse/plugins/chat/discourse/components/chat-message-text";
module("Component | ChatMessageText", function (hooks) {
setupRenderingTest(hooks);
test("yields", async function (assert) {
this.set("cooked", "<p></p>");
await render(
<template>
<ChatMessageText @cooked={{this.cooked}} @uploads={{this.uploads}}>
<div class="yield-me"></div>
</ChatMessageText>
</template>
);
assert.dom(".yield-me").exists();
});
test("shows collapsed", async function (assert) {
this.set(
"cooked",
'<div class="youtube-onebox lazy-video-container" data-video-id="WaT_rLGuUr8" data-video-title="Japanese Katsu Curry (Pork Cutlet)" data-provider-name="youtube"/>'
);
await render(
<template>
<ChatMessageText @cooked={{this.cooked}} @uploads={{this.uploads}} />
</template>
);
assert.dom(".chat-message-collapser").exists();
});
test("does not collapse a non-image onebox", async function (assert) {
this.set("cooked", '<p><a href="http://cat1.com" class="onebox"></a></p>');
await render(
<template><ChatMessageText @cooked={{this.cooked}} /></template>
);
assert.dom(".chat-message-collapser").doesNotExist();
});
test("shows edits - regular message", async function (assert) {
this.set("cooked", "<p></p>");
await render(
<template>
<ChatMessageText @cooked={{this.cooked}} @edited={{true}} />
</template>
);
assert.dom(".chat-message-edited").exists();
});
test("shows edits - collapsible message", async function (assert) {
this.set(
"cooked",
'<div class="youtube-onebox lazy-video-container"></div>'
);
await render(
<template>
<ChatMessageText @cooked={{this.cooked}} @edited={{true}} />
</template>
);
assert.dom(".chat-message-edited").exists();
});
});