File tree Expand file tree Collapse file tree
test/javascripts/acceptance Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments