@@ -12,17 +12,22 @@ jest.mock('../ToolbarToggle', () => () => '<ToolbarToggle />');
1212jest . mock ( '../SettingsToggle' , ( ) => {
1313 const MockSettingsToggle = ( props ) => {
1414 return (
15- < div id = { props . id } onClick = { ( ) => props . setIsOpen && props . setIsOpen ( true ) } data-testid = "settings-toggle" >
16- { props . dropdownItems . map ( ( group , groupIndex ) => (
17- < div key = { groupIndex } >
18- { group . items . map ( ( item , itemIndex ) => (
19- < a key = { itemIndex } href = { item . url } data-testid = { item . ouiaId } >
20- { item . title }
21- </ a >
22- ) ) }
23- </ div >
24- ) ) }
25- </ div >
15+ < >
16+ < button id = { props . id } aria-label = { props . ariaLabel } onClick = { ( ) => props . setIsOpen && props . setIsOpen ( true ) } data-testid = "settings-toggle" >
17+ Settings
18+ </ button >
19+ < div >
20+ { props . dropdownItems . map ( ( group , groupIndex ) => (
21+ < div key = { groupIndex } >
22+ { group . items . map ( ( item , itemIndex ) => (
23+ < a key = { itemIndex } href = { item . url } data-testid = { item . ouiaId } >
24+ { item . title }
25+ </ a >
26+ ) ) }
27+ </ div >
28+ ) ) }
29+ </ div >
30+ </ >
2631 ) ;
2732 } ;
2833 MockSettingsToggle . displayName = 'MockSettingsToggle' ;
@@ -153,15 +158,15 @@ describe('Tools', () => {
153158 await renderTools ( mockAuthContext ) ;
154159
155160 // Open the settings dropdown
156- const settingsButton = screen . getByTestId ( 'settings-toggle' ) ;
161+ const settingsButton = screen . getByRole ( 'button' , { name : 'Settings menu' } ) ;
157162 expect ( settingsButton ) . toBeInTheDocument ( ) ;
158163
159164 await act ( async ( ) => {
160165 settingsButton . click ( ) ;
161166 } ) ;
162167
163- // Check that the link with correct href exists
164- const iamLink = screen . getByTestId ( 'UserAccess' ) ;
168+ // Check that the link with correct href exists (note: "Acess" is a typo in the source code)
169+ const iamLink = screen . getByRole ( 'link' , { name : / A c e s s m a n a g e m e n t / i } ) ;
165170 expect ( iamLink ) . toBeInTheDocument ( ) ;
166171 expect ( iamLink ) . toHaveAttribute ( 'href' , '/iam/overview' ) ;
167172 } ) ;
@@ -176,15 +181,15 @@ describe('Tools', () => {
176181 await renderTools ( mockAuthContext ) ;
177182
178183 // Open the settings dropdown
179- const settingsButton = screen . getByTestId ( 'settings-toggle' ) ;
184+ const settingsButton = screen . getByRole ( 'button' , { name : 'Settings menu' } ) ;
180185 expect ( settingsButton ) . toBeInTheDocument ( ) ;
181186
182187 await act ( async ( ) => {
183188 settingsButton . click ( ) ;
184189 } ) ;
185190
186191 // Check that the link with correct href exists
187- const iamLink = screen . getByTestId ( 'UserAccess' ) ;
192+ const iamLink = screen . getByRole ( 'link' , { name : / U s e r A c c e s s / i } ) ;
188193 expect ( iamLink ) . toBeInTheDocument ( ) ;
189194 expect ( iamLink ) . toHaveAttribute ( 'href' , '/iam/user-access/overview' ) ;
190195 } ) ;
@@ -199,15 +204,15 @@ describe('Tools', () => {
199204 await renderTools ( mockAuthContext ) ;
200205
201206 // Open the settings dropdown
202- const settingsButton = screen . getByTestId ( 'settings-toggle' ) ;
207+ const settingsButton = screen . getByRole ( 'button' , { name : 'Settings menu' } ) ;
203208 expect ( settingsButton ) . toBeInTheDocument ( ) ;
204209
205210 await act ( async ( ) => {
206211 settingsButton . click ( ) ;
207212 } ) ;
208213
209214 // Check that the link with correct href exists
210- const iamLink = screen . getByTestId ( 'UserAccess' ) ;
215+ const iamLink = screen . getByRole ( 'link' , { name : / M y U s e r A c c e s s / i } ) ;
211216 expect ( iamLink ) . toBeInTheDocument ( ) ;
212217 expect ( iamLink ) . toHaveAttribute ( 'href' , '/iam/my-user-access' ) ;
213218 } ) ;
0 commit comments