@@ -13,9 +13,12 @@ const locators = {
1313 navLinksLocator : `[aria-label="${ englishLocale . components . containers . navBar . controls . toggle } "] + div` ,
1414 // Global UI controls
1515 languageDropdownName : englishLocale . components . common . languageDropdown . label ,
16- // default light theme
16+ // Initially, the themeToggle's name will be the light mode i18n.
1717 themeToggleName : englishLocale . components . common . themeToggle . light ,
18-
18+ themeToggleAriaLabels : {
19+ light : englishLocale . components . common . themeToggle . light ,
20+ dark : englishLocale . components . common . themeToggle . dark ,
21+ } ,
1922 // Search components (from Orama library)
2023 searchButtonTag : 'orama-button' ,
2124 searchInputTag : 'orama-input' ,
@@ -75,7 +78,7 @@ test.describe('Node.js Website', () => {
7578 const initialTheme = await getTheme ( page ) ;
7679 const initialAriaLabel = await themeToggle . getAttribute ( 'aria-label' ) ;
7780 expect ( initialAriaLabel ) . toBe (
78- englishLocale . components . common . themeToggle [ initialTheme ]
81+ locators . themeToggleAriaLabels [ initialTheme ]
7982 ) ;
8083
8184 await themeToggle . click ( ) ;
@@ -86,9 +89,7 @@ test.describe('Node.js Website', () => {
8689 expect ( newTheme ) . not . toBe ( initialTheme ) ;
8790 expect ( [ 'light' , 'dark' ] ) . toContain ( newTheme ) ;
8891
89- expect ( newAriaLabel ) . toBe (
90- englishLocale . components . common . themeToggle [ newTheme ]
91- ) ;
92+ expect ( newAriaLabel ) . toBe ( locators . themeToggleAriaLabels [ newTheme ] ) ;
9293 } ) ;
9394
9495 test ( 'should persist theme across page navigation' , async ( { page } ) => {
0 commit comments