Skip to content

Commit 0d38341

Browse files
committed
add tests where use belongs to org but doesn't have access to a repo
1 parent e6f3a0c commit 0d38341

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

src/layouts/Header/components/Navigator/Navigator.test.tsx

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -246,17 +246,37 @@ describe('Header Navigator', () => {
246246
expect(contextSwitcher).toBeInTheDocument()
247247
})
248248

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()
256264
})
265+
})
257266

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+
})
260280
})
261281
})
262282

0 commit comments

Comments
 (0)