mirror of
https://github.com/discourse/discourse.git
synced 2026-08-14 13:58:53 +08:00
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.
108 lines
3.3 KiB
Text
Vendored
108 lines
3.3 KiB
Text
Vendored
import { render } from "@ember/test-helpers";
|
|
import { module, test } from "qunit";
|
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
|
import ChatSidebarIndicators from "discourse/plugins/chat/discourse/components/chat-sidebar-indicators";
|
|
|
|
module("Component | ChatSidebarIndicators", function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
test("shows indicator when unreadCount > 0", async function (assert) {
|
|
const status = { unreadCount: 1 };
|
|
|
|
await render(
|
|
<template><ChatSidebarIndicators @suffixArgs={{status}} /></template>
|
|
);
|
|
|
|
assert.dom(".sidebar-section-link-content-badge").exists();
|
|
});
|
|
|
|
test("shows indicator when unreadThreadsCount > 0", async function (assert) {
|
|
const status = { unreadThreadsCount: 1 };
|
|
|
|
await render(
|
|
<template><ChatSidebarIndicators @suffixArgs={{status}} /></template>
|
|
);
|
|
|
|
assert.dom(".sidebar-section-link-content-badge").exists();
|
|
});
|
|
|
|
test("shows indicator when mentionCount > 0", async function (assert) {
|
|
const status = { mentionCount: 1 };
|
|
|
|
await render(
|
|
<template><ChatSidebarIndicators @suffixArgs={{status}} /></template>
|
|
);
|
|
|
|
assert.dom(".sidebar-section-link-content-badge").exists();
|
|
assert.dom(".sidebar-section-link-content-badge").hasClass("urgent");
|
|
});
|
|
|
|
test("shows indicator when watchedThreadsUnreadCount > 0", async function (assert) {
|
|
const status = { watchedThreadsUnreadCount: 1 };
|
|
|
|
await render(
|
|
<template><ChatSidebarIndicators @suffixArgs={{status}} /></template>
|
|
);
|
|
|
|
assert.dom(".sidebar-section-link-content-badge").exists();
|
|
assert.dom(".sidebar-section-link-content-badge").hasClass("urgent");
|
|
});
|
|
|
|
test("does not show indicator when all counts are 0", async function (assert) {
|
|
const status = {
|
|
unreadCount: 0,
|
|
unreadThreadsCount: 0,
|
|
mentionCount: 0,
|
|
watchedThreadsUnreadCount: 0,
|
|
};
|
|
|
|
await render(
|
|
<template><ChatSidebarIndicators @suffixArgs={{status}} /></template>
|
|
);
|
|
|
|
assert.dom(".sidebar-section-link-content-badge").doesNotExist();
|
|
});
|
|
|
|
test("shows urgent class for DM with unread messages", async function (assert) {
|
|
const status = {
|
|
unreadCount: 1,
|
|
isDirectMessageChannel: true,
|
|
};
|
|
|
|
await render(
|
|
<template><ChatSidebarIndicators @suffixArgs={{status}} /></template>
|
|
);
|
|
|
|
assert.dom(".sidebar-section-link-content-badge").hasClass("urgent");
|
|
});
|
|
|
|
test("shows unread class for public channel with unread messages", async function (assert) {
|
|
const status = {
|
|
unreadCount: 1,
|
|
isDirectMessageChannel: false,
|
|
};
|
|
|
|
await render(
|
|
<template><ChatSidebarIndicators @suffixArgs={{status}} /></template>
|
|
);
|
|
|
|
assert.dom(".sidebar-section-link-content-badge").hasClass("unread");
|
|
});
|
|
|
|
test("shows urgent class when watchedThreadsUnreadCount > 0 even without other unreads", async function (assert) {
|
|
const status = {
|
|
unreadCount: 0,
|
|
unreadThreadsCount: 0,
|
|
mentionCount: 0,
|
|
watchedThreadsUnreadCount: 1,
|
|
isDirectMessageChannel: false,
|
|
};
|
|
|
|
await render(
|
|
<template><ChatSidebarIndicators @suffixArgs={{status}} /></template>
|
|
);
|
|
|
|
assert.dom(".sidebar-section-link-content-badge").exists();
|
|
assert.dom(".sidebar-section-link-content-badge").hasClass("urgent");
|
|
});
|
|
});
|