@@ -5,15 +5,13 @@ import { test } from "qunit";
55acceptance ( "Custom Top Navigation Links | Topic Counts" , function ( needs ) {
66 needs . user ( ) ;
77
8- let originalNavLinks ;
9- let originalShowCounts ;
8+ let originalSettings ;
109
1110 needs . hooks . beforeEach ( ( ) => {
12- if ( window . settings ) {
13- originalNavLinks = window . settings . nav_links ;
14- originalShowCounts = window . settings . Show_counts ;
11+ originalSettings = window . settings ;
1512
16- window . settings . nav_links = [
13+ const mockSettings = {
14+ nav_links : [
1715 {
1816 display_name : "New Topics" ,
1917 title : "new topics" ,
@@ -24,15 +22,29 @@ acceptance("Custom Top Navigation Links | Topic Counts", function (needs) {
2422 title : "unread topics" ,
2523 url : "/unread" ,
2624 } ,
27- ] ;
28- window . settings . Show_counts = true ;
29- }
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 ;
36+ } ,
37+ set ( ) {
38+ // Prevent framework from overwriting our mock settings during boot
39+ } ,
40+ } ) ;
3041 } ) ;
3142
3243 needs . hooks . afterEach ( ( ) => {
33- if ( window . settings ) {
34- window . settings . nav_links = originalNavLinks ;
35- window . settings . Show_counts = originalShowCounts ;
44+ // Restore original window.settings
45+ delete window . settings ;
46+ if ( originalSettings ) {
47+ window . settings = originalSettings ;
3648 }
3749 } ) ;
3850
@@ -45,6 +57,13 @@ acceptance("Custom Top Navigation Links | Topic Counts", function (needs) {
4557
4658 await visit ( "/latest" ) ;
4759
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+ ) ;
66+
4867 assert . ok (
4968 exists ( ".nav-item_custom_new-topics" ) ,
5069 "custom navigation item for new topics is rendered"
0 commit comments