Skip to content

Commit c2a5023

Browse files
adamwhitingnhslillie-dae
authored andcommitted
remove role permissions around admin button
1 parent f452b00 commit c2a5023

File tree

2 files changed

+26
-76
lines changed

2 files changed

+26
-76
lines changed
Lines changed: 7 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { render, screen } from '@testing-library/react';
22
import HomePage from './HomePage';
3-
import useRole from '../../helpers/hooks/useRole';
4-
import { REPOSITORY_ROLE } from '../../types/generic/authRole';
53
import { buildConfig } from '../../helpers/test/testBuilders';
64
import useConfig from '../../helpers/hooks/useConfig';
75
import { routes } from '../../types/generic/routes';
@@ -16,9 +14,7 @@ vi.mock('react-router-dom', async () => {
1614
};
1715
});
1816

19-
vi.mock('../../helpers/hooks/useRole');
2017
vi.mock('../../helpers/hooks/useConfig');
21-
const mockUseRole = useRole as Mock;
2218
const mockUseConfig = useConfig as Mock;
2319

2420
describe('HomePage', () => {
@@ -28,39 +24,20 @@ describe('HomePage', () => {
2824
afterEach(() => {
2925
vi.clearAllMocks();
3026
});
31-
const gpRoles = [REPOSITORY_ROLE.GP_ADMIN, REPOSITORY_ROLE.GP_CLINICAL];
3227

33-
const validateHomePageRendered = () => {
34-
render(<HomePage />);
35-
36-
const searchPatientButton = screen.getByTestId('search-patient-btn') as HTMLAnchorElement;
37-
const downloadReportButton = screen.getByTestId('download-report-btn') as HTMLAnchorElement;
38-
expect(searchPatientButton).toBeInTheDocument();
39-
expect(downloadReportButton).toBeInTheDocument();
40-
};
41-
42-
describe('Rendering for GP roles', () => {
43-
it.each(gpRoles)(
44-
'[%s] render home page with patient search and download report',
45-
async (role) => {
46-
mockUseRole.mockReturnValue(role);
47-
48-
validateHomePageRendered();
49-
},
50-
);
51-
});
52-
53-
describe('PCSE Rendering', () => {
28+
describe('Rendering', () => {
5429
it('should render home page with patient search and download report', async () => {
55-
mockUseRole.mockReturnValue(REPOSITORY_ROLE.PCSE);
30+
render(<HomePage />);
5631

57-
validateHomePageRendered();
32+
const searchPatientButton = screen.getByTestId('search-patient-btn') as HTMLAnchorElement;
33+
const downloadReportButton = screen.getByTestId('download-report-btn') as HTMLAnchorElement;
34+
expect(searchPatientButton).toBeInTheDocument();
35+
expect(downloadReportButton).toBeInTheDocument();
5836
});
5937
});
6038

6139
describe('Admin Console button', () => {
62-
it('renders admin console button when feature flag is enabled and user is GP_ADMIN', () => {
63-
mockUseRole.mockReturnValue(REPOSITORY_ROLE.GP_ADMIN);
40+
it('renders admin console button when feature flag is enabled', () => {
6441
mockUseConfig.mockReturnValue(
6542
buildConfig(undefined, { uploadDocumentIteration3Enabled: true }),
6643
);
@@ -74,7 +51,6 @@ describe('HomePage', () => {
7451
});
7552

7653
it('does not render admin console button when feature flag is disabled', () => {
77-
mockUseRole.mockReturnValue(REPOSITORY_ROLE.GP_ADMIN);
7854
mockUseConfig.mockReturnValue(
7955
buildConfig(undefined, { uploadDocumentIteration3Enabled: false }),
8056
);
@@ -83,27 +59,5 @@ describe('HomePage', () => {
8359

8460
expect(screen.queryByTestId('admin-console-btn')).not.toBeInTheDocument();
8561
});
86-
87-
it('does not render admin console button when user is GP_CLINICAL', () => {
88-
mockUseRole.mockReturnValue(REPOSITORY_ROLE.GP_CLINICAL);
89-
mockUseConfig.mockReturnValue(
90-
buildConfig(undefined, { uploadDocumentIteration3Enabled: true }),
91-
);
92-
93-
render(<HomePage />);
94-
95-
expect(screen.queryByTestId('admin-console-btn')).not.toBeInTheDocument();
96-
});
97-
98-
it('does not render admin console button when user is PCSE', () => {
99-
mockUseRole.mockReturnValue(REPOSITORY_ROLE.PCSE);
100-
mockUseConfig.mockReturnValue(
101-
buildConfig(undefined, { uploadDocumentIteration3Enabled: true }),
102-
);
103-
104-
render(<HomePage />);
105-
106-
expect(screen.queryByTestId('admin-console-btn')).not.toBeInTheDocument();
107-
});
10862
});
10963
});

app/src/pages/homePage/HomePage.tsx

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@ import useTitle from '../../helpers/hooks/useTitle';
44
import { REPORT_TYPE } from '../../types/generic/reports';
55
import { ReactComponent as RightCircleIcon } from '../../styles/right-chevron-circle.svg';
66
import useConfig from '../../helpers/hooks/useConfig';
7-
import useRole from '../../helpers/hooks/useRole';
8-
import { REPOSITORY_ROLE } from '../../types/generic/authRole';
97

108
const HomePage = (): React.JSX.Element => {
119
useTitle({ pageTitle: 'Access and store digital patient documents' });
1210
const config = useConfig();
13-
const role = useRole();
1411
const uploadEnabled =
1512
config.featureFlags.uploadLambdaEnabled &&
1613
config.featureFlags.uploadLloydGeorgeWorkflowEnabled;
@@ -78,26 +75,25 @@ const HomePage = (): React.JSX.Element => {
7875
</Card>
7976
</Card.GroupItem>
8077
{config.featureFlags.uploadDocumentIteration3Enabled &&
81-
role === REPOSITORY_ROLE.GP_ADMIN && (
82-
<Card.GroupItem width="one-half">
83-
<Card clickable cardType="primary">
84-
<Card.Content>
85-
<Card.Heading className="nhsuk-heading-m">
86-
<Card.Link
87-
data-testid="admin-console-btn"
88-
href={routes.ADMIN_ROUTE}
89-
>
90-
Admin console
91-
</Card.Link>
92-
</Card.Heading>
93-
<Card.Description>
94-
Review records and actions for incoming patients
95-
</Card.Description>
96-
<RightCircleIcon />
97-
</Card.Content>
98-
</Card>
99-
</Card.GroupItem>
100-
)}
78+
<Card.GroupItem width="one-half">
79+
<Card clickable cardType="primary">
80+
<Card.Content>
81+
<Card.Heading className="nhsuk-heading-m">
82+
<Card.Link
83+
data-testid="admin-console-btn"
84+
href={routes.ADMIN_ROUTE}
85+
>
86+
Admin console
87+
</Card.Link>
88+
</Card.Heading>
89+
<Card.Description>
90+
Review records and actions for incoming patients
91+
</Card.Description>
92+
<RightCircleIcon />
93+
</Card.Content>
94+
</Card>
95+
</Card.GroupItem>
96+
}
10197
</Card.Group>
10298
</>
10399
);

0 commit comments

Comments
 (0)