-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from cabinetoffice/TMI2-192/remove_condition_i…
…n_nav_bar_item TMI2-192:remove conditional rendering of the navBar Item
- Loading branch information
Showing
3 changed files
with
10 additions
and
38 deletions.
There are no files selected for viewing
22 changes: 2 additions & 20 deletions
22
packages/admin/src/pages/super-admin-dashboard/Navigation.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,15 @@ | ||
import '@testing-library/jest-dom'; | ||
import { render } from '@testing-library/react'; | ||
import Navigation from './Navigation'; | ||
import { Role } from './types'; | ||
|
||
const roles: Role[] = [ | ||
{ name: 'ADMIN', id: '1', description: 'adminRole', label: 'adminLabel' }, | ||
{ | ||
name: 'TECHNICAL_SUPPORT', | ||
id: '2', | ||
description: 'technicalSupportRole', | ||
label: 'technicalSupportLabel', | ||
}, | ||
]; | ||
|
||
describe('Navigation', () => { | ||
it('renders navigation items correctly when TECHNICAL_SUPPORT role is present in the roles', () => { | ||
const { getByRole } = render(<Navigation roles={roles} />); | ||
const { getByRole } = render(<Navigation />); | ||
|
||
expect(getByRole('link', { name: 'Home' })).toBeVisible(); | ||
expect(getByRole('link', { name: 'Manage users' })).toBeVisible(); | ||
expect(getByRole('link', { name: 'Admin dashboard' })).toBeVisible(); | ||
expect(getByRole('link', { name: 'Applicant dashboard' })).toBeVisible(); | ||
expect(getByRole('link', { name: 'Manage API Keys' })).toBeVisible(); | ||
}); | ||
|
||
it('does not render "Manage API Keys" link for non-TECHNICAL_SUPPORT roles', () => { | ||
const { queryByText } = render(<Navigation roles={roles.slice(0, 1)} />); | ||
|
||
const technicalSupportDashboardLink = queryByText('Manage API Keys'); | ||
expect(technicalSupportDashboardLink).toBeNull(); | ||
expect(getByRole('link', { name: 'Manage API keys' })).toBeVisible(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters