@@ -4,20 +4,48 @@ import { test } from "qunit";
44
55acceptance ( "Custom Top Navigation Links | Topic Counts" , function ( needs ) {
66 needs . user ( ) ;
7- needs . settings ( {
8- nav_links : [
9- {
10- display_name : "New Topics" ,
11- title : "new topics" ,
12- url : "/new" ,
7+
8+ let originalSettings ;
9+
10+ needs . hooks . beforeEach ( ( ) => {
11+ originalSettings = window . settings ;
12+
13+ const mockSettings = {
14+ nav_links : [
15+ {
16+ display_name : "New Topics" ,
17+ title : "new topics" ,
18+ url : "/new" ,
19+ } ,
20+ {
21+ display_name : "Unread Topics" ,
22+ title : "unread topics" ,
23+ url : "/unread" ,
24+ } ,
25+ ] ,
26+ Show_counts : true ,
27+ } ;
28+
29+ // Use defineProperty to ensure window.settings returns our mock settings
30+ // regardless of when or how the framework boots/initializes it.
31+ Object . defineProperty ( window , "settings" , {
32+ configurable : true ,
33+ enumerable : true ,
34+ get ( ) {
35+ return mockSettings ;
1336 } ,
14- {
15- display_name : "Unread Topics" ,
16- title : "unread topics" ,
17- url : "/unread" ,
37+ set ( ) {
38+ // Prevent framework from overwriting our mock settings during boot
1839 } ,
19- ] ,
20- Show_counts : true ,
40+ } ) ;
41+ } ) ;
42+
43+ needs . hooks . afterEach ( ( ) => {
44+ // Restore original window.settings
45+ delete window . settings ;
46+ if ( originalSettings ) {
47+ window . settings = originalSettings ;
48+ }
2149 } ) ;
2250
2351 test ( "shows new and unread counts in navigation items" , async function ( assert ) {
@@ -27,7 +55,14 @@ acceptance("Custom Top Navigation Links | Topic Counts", function (needs) {
2755 topicTrackingState . countNew = ( ) => 42 ;
2856 topicTrackingState . countUnread = ( ) => 17 ;
2957
30- await visit ( "/" ) ;
58+ await visit ( "/latest" ) ;
59+
60+ // Print navigation HTML to debug
61+ // eslint-disable-next-line no-console
62+ console . log (
63+ "NAVIGATION BAR HTML:" ,
64+ document . querySelector ( ".nav-pills" ) ?. innerHTML || "NOT FOUND"
65+ ) ;
3166
3267 assert . ok (
3368 exists ( ".nav-item_custom_new-topics" ) ,
0 commit comments