Skip to content

Commit b0c0e5d

Browse files
committed
test: add qunit acceptance test for topic count tracking in custom nav links
1 parent 3c68250 commit b0c0e5d

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { acceptance, exists } from "discourse/tests/helpers/qunit-helpers";
2+
import { visit } from "@ember/test-helpers";
3+
import { test } from "qunit";
4+
5+
acceptance("Custom Top Navigation Links | Topic Counts", function (needs) {
6+
needs.user();
7+
needs.settings({
8+
nav_links: [
9+
{
10+
display_name: "New Topics",
11+
title: "new topics",
12+
url: "/new",
13+
},
14+
{
15+
display_name: "Unread Topics",
16+
title: "unread topics",
17+
url: "/unread",
18+
},
19+
],
20+
Show_counts: true,
21+
});
22+
23+
test("shows new and unread counts in navigation items", async function (assert) {
24+
const topicTrackingState = this.owner.lookup(
25+
"service:topic-tracking-state"
26+
);
27+
topicTrackingState.countNew = () => 42;
28+
topicTrackingState.countUnread = () => 17;
29+
30+
await visit("/");
31+
32+
assert.ok(
33+
exists(".nav-item_custom_new-topics"),
34+
"custom navigation item for new topics is rendered"
35+
);
36+
assert
37+
.dom(".nav-item_custom_new-topics a")
38+
.hasText("New Topics (42)", "it shows the custom new topics count");
39+
40+
assert.ok(
41+
exists(".nav-item_custom_unread-topics"),
42+
"custom navigation item for unread topics is rendered"
43+
);
44+
assert
45+
.dom(".nav-item_custom_unread-topics a")
46+
.hasText("Unread Topics (17)", "it shows the custom unread topics count");
47+
});
48+
});

0 commit comments

Comments
 (0)