@@ -246,17 +246,37 @@ describe('Header Navigator', () => {
246
246
expect ( contextSwitcher ) . toBeInTheDocument ( )
247
247
} )
248
248
249
- it ( 'should show Viewing as Visitor' , async ( ) => {
250
- setup ( { isMyOrg : false } )
251
- render ( < Navigator currentUser = { mockUser } hasRepoAccess = { false } /> , {
252
- wrapper : wrapper ( {
253
- initialEntries : '/gh/not-codecov/test-repo' ,
254
- path : '/:provider/:owner/:repo' ,
255
- } ) ,
249
+ describe ( 'the user is not a visitor' , ( ) => {
250
+ it ( 'should not show Viewing as Visitor' , async ( ) => {
251
+ setup ( { isMyOrg : true } )
252
+ render ( < Navigator currentUser = { mockUser } hasRepoAccess = { false } /> , {
253
+ wrapper : wrapper ( {
254
+ initialEntries : '/gh/not-codecov/test-repo' ,
255
+ path : '/:provider/:owner/:repo' ,
256
+ } ) ,
257
+ } )
258
+
259
+ await waitFor ( ( ) => queryClient . isFetching ( ) )
260
+ await waitFor ( ( ) => ! queryClient . isFetching ( ) )
261
+
262
+ const text = screen . queryByText ( 'Viewing as visitor' )
263
+ expect ( text ) . not . toBeInTheDocument ( )
256
264
} )
265
+ } )
257
266
258
- const text = await screen . findByText ( 'Viewing as visitor' )
259
- expect ( text ) . toBeInTheDocument ( )
267
+ describe ( 'the user is a visitor' , ( ) => {
268
+ it ( 'should show Viewing as Visitor' , async ( ) => {
269
+ setup ( { isMyOrg : false } )
270
+ render ( < Navigator currentUser = { mockUser } hasRepoAccess = { false } /> , {
271
+ wrapper : wrapper ( {
272
+ initialEntries : '/gh/not-codecov/test-repo' ,
273
+ path : '/:provider/:owner/:repo' ,
274
+ } ) ,
275
+ } )
276
+
277
+ const text = await screen . findByText ( 'Viewing as visitor' )
278
+ expect ( text ) . toBeInTheDocument ( )
279
+ } )
260
280
} )
261
281
} )
262
282
0 commit comments