Skip to content

Commit f92c1a2

Browse files
NogaNHSsteph-torres-nhsadamwhitingnhs
authored
[PRMP-991] Remove ODS Report from main menu (#980)
Co-authored-by: steph-torres-nhs <[email protected]> Co-authored-by: Adam Whiting <[email protected]>
1 parent 8b42e94 commit f92c1a2

File tree

6 files changed

+141
-36
lines changed

6 files changed

+141
-36
lines changed

app/src/components/blocks/_downloadReport/downloadReportSelectStage/DownloadReportSelectStage.test.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import downloadReport from '../../../../helpers/requests/downloadReport';
1010
import { beforeEach, describe, expect, it, vi, MockedFunction, Mock } from 'vitest';
1111

1212
const mockDownloadReport = downloadReport as MockedFunction<typeof downloadReport>;
13+
const mockUseConfig = vi.fn();
14+
1315

1416
const mockedUseNavigate = vi.fn();
1517
vi.mock('react-router-dom', async () => {
@@ -27,9 +29,16 @@ vi.mock('../../../../helpers/utils/isLocal', () => ({
2729
isMock: (): boolean => false,
2830
}));
2931

32+
vi.mock('../../../../helpers/hooks/useConfig', () => ({
33+
default: (): unknown => mockUseConfig(),
34+
}));
35+
3036
describe('DownloadReportSelectStage', () => {
3137
beforeEach(() => {
3238
import.meta.env.VITE_ENVIRONMENT = 'vitest';
39+
mockUseConfig.mockReturnValue({
40+
featureFlags: {},
41+
});
3342
});
3443

3544
describe('Rendering', () => {
@@ -107,4 +116,24 @@ describe('DownloadReportSelectStage', () => {
107116
expect(mockedUseNavigate).toHaveBeenCalledWith(routes.HOME);
108117
});
109118
});
119+
120+
it ('should navigate to admin hub, upload version 3 enabled', async () => {
121+
mockUseConfig.mockReturnValue({
122+
featureFlags: { uploadDocumentIteration3Enabled: true },
123+
});
124+
125+
const report = getReportByType(REPORT_TYPE.ODS_PATIENT_SUMMARY);
126+
render(<DownloadReportSelectStage report={report!} />);
127+
128+
let backLink: Element;
129+
backLink = screen.getByTestId('return-to-home-button');
130+
131+
expect(backLink).toHaveTextContent('Go back');
132+
133+
await userEvent.click(backLink);
134+
135+
await waitFor(() => {
136+
expect(mockedUseNavigate).toHaveBeenCalledWith(routes.ADMIN_ROUTE);
137+
})
138+
});
110139
});

app/src/components/blocks/_downloadReport/downloadReportSelectStage/DownloadReportSelectStage.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { BackLink, Button } from 'nhsuk-react-components';
55
import downloadReport from '../../../../helpers/requests/downloadReport';
66
import useBaseAPIUrl from '../../../../helpers/hooks/useBaseAPIUrl';
77
import useBaseAPIHeaders from '../../../../helpers/hooks/useBaseAPIHeaders';
8+
import useConfig from '../../../../helpers/hooks/useConfig';
89
import { AxiosError } from 'axios';
910
import { isMock } from '../../../../helpers/utils/isLocal';
1011
import { JSX, ReactNode, useRef } from 'react';
@@ -19,6 +20,7 @@ type Props = {
1920
const DownloadReportSelectStage = (props: Props): JSX.Element => {
2021
const baseUrl = useBaseAPIUrl();
2122
const baseHeaders = useBaseAPIHeaders();
23+
const config = useConfig();
2224
const navigate = useNavigate();
2325
const [downloading, setDownloading] = React.useState(false);
2426
const [downloadError, setDownloadError] = React.useState<ReactNode>(null);
@@ -28,6 +30,7 @@ const DownloadReportSelectStage = (props: Props): JSX.Element => {
2830
navigate(`${routeChildren.REPORT_DOWNLOAD_COMPLETE}?reportType=${props.report.reportType}`);
2931
};
3032

33+
const uploadV3Enabled: boolean = !!config.featureFlags.uploadDocumentIteration3Enabled;
3134
const noDataContent = (): JSX.Element => {
3235
return (
3336
<>
@@ -131,11 +134,11 @@ const DownloadReportSelectStage = (props: Props): JSX.Element => {
131134
asElement="a"
132135
href='#'
133136
onClick={(): void => {
134-
navigate(routes.HOME)
137+
uploadV3Enabled ? navigate(routes.ADMIN_ROUTE) : navigate(routes.HOME);
135138
}}
136139
className="mb-5"
137140
>
138-
Go to home
141+
{uploadV3Enabled ? 'Go back' : 'Go to home'}
139142
</BackLink>
140143
{downloadError && (
141144
<NotificationBanner

app/src/pages/adminPage/AdminPage.test.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,28 @@ describe('AdminPage', (): void => {
4444
),
4545
).toBeInTheDocument();
4646
});
47+
48+
it('renders the Download a report card', (): void => {
49+
render(<AdminPage />);
50+
const reportLink = screen.getByTestId('download-report-btn');
51+
expect(reportLink).toBeInTheDocument();
52+
expect(reportLink).toHaveTextContent('Download a report');
53+
});
54+
55+
it('renders the Download a report card with correct href', (): void => {
56+
render(<AdminPage />);
57+
const reportLink = screen.getByTestId('download-report-btn');
58+
expect(reportLink).toHaveAttribute('href', '/create-report?reportType=0');
59+
});
60+
61+
it('renders the Download a report card description', (): void => {
62+
render(<AdminPage />);
63+
expect(
64+
screen.getByText(
65+
'This report shows the list of Lloyd George records stored for your organisation.',
66+
),
67+
).toBeInTheDocument();
68+
});
4769
});
4870

4971
describe('Accessibility', (): void => {

app/src/pages/adminPage/AdminPage.tsx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { Card } from 'nhsuk-react-components';
22
import { JSX } from 'react';
33
import useTitle from '../../helpers/hooks/useTitle';
44
import { ReactComponent as RightCircleIcon } from '../../styles/right-chevron-circle.svg';
5-
import { routeChildren } from '../../types/generic/routes';
5+
import { routeChildren, routes } from '../../types/generic/routes';
6+
import { REPORT_TYPE } from '../../types/generic/reports';
67
import { useNavigate } from 'react-router-dom';
78

89
export const AdminPage = (): JSX.Element => {
@@ -19,9 +20,9 @@ export const AdminPage = (): JSX.Element => {
1920
<Card.Heading className="nhsuk-heading-m">
2021
<Card.Link
2122
data-testid="admin-reviews-btn"
22-
href='#'
23+
href="#"
2324
onClick={(): void => {
24-
navigate(routeChildren.ADMIN_REVIEW)
25+
navigate(routeChildren.ADMIN_REVIEW);
2526
}}
2627
>
2728
Review documents
@@ -35,6 +36,25 @@ export const AdminPage = (): JSX.Element => {
3536
</Card.Content>
3637
</Card>
3738
</Card.GroupItem>
39+
<Card.GroupItem width="one-half">
40+
<Card clickable cardType="primary">
41+
<Card.Content>
42+
<Card.Heading className="nhsuk-heading-m">
43+
<Card.Link
44+
data-testid="download-report-btn"
45+
href={`${routes.REPORT_DOWNLOAD}?reportType=${REPORT_TYPE.ODS_PATIENT_SUMMARY}`}
46+
>
47+
Download a report
48+
</Card.Link>
49+
</Card.Heading>
50+
<Card.Description>
51+
This report shows the list of Lloyd George records stored for your
52+
organisation.
53+
</Card.Description>
54+
<RightCircleIcon />
55+
</Card.Content>
56+
</Card>
57+
</Card.GroupItem>
3858
</Card.Group>
3959
</>
4060
);

app/src/pages/homePage/HomePage.test.tsx

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@ describe('HomePage', () => {
3131
});
3232

3333
describe('Rendering', () => {
34-
it('should render home page with patient search and download report', async () => {
34+
it('should render home page with patient search and download report when uploadDocumentIteration3Enabled is false', async () => {
35+
mockUseConfig.mockReturnValue(
36+
buildConfig(undefined, { uploadDocumentIteration3Enabled: false }),
37+
);
3538
render(<HomePage />);
36-
3739
const searchPatientButton = screen.getByTestId(
3840
'search-patient-btn',
3941
) as HTMLAnchorElement;
@@ -67,6 +69,32 @@ describe('HomePage', () => {
6769

6870
expect(screen.queryByTestId('admin-console-btn')).not.toBeInTheDocument();
6971
});
72+
73+
it('should render home page with patient search and admin console when uploadDocumentIteration3Enabled is true', async () => {
74+
mockUseConfig.mockReturnValue(
75+
buildConfig(undefined, { uploadDocumentIteration3Enabled: true }),
76+
);
77+
render(<HomePage />);
78+
const searchPatientButton = screen.getByTestId(
79+
'search-patient-btn',
80+
) as HTMLAnchorElement;
81+
const adminConsoleButton = screen.getByTestId('admin-console-btn') as HTMLAnchorElement;
82+
expect(searchPatientButton).toBeInTheDocument();
83+
expect(adminConsoleButton).toBeInTheDocument();
84+
expect(adminConsoleButton).toHaveTextContent('Admin console');
85+
expect(adminConsoleButton).toHaveAttribute('href', '#');
86+
expect(screen.queryByTestId('download-report-btn')).not.toBeInTheDocument();
87+
});
88+
89+
it('does not render admin console button when feature flag is disabled', () => {
90+
mockUseConfig.mockReturnValue(
91+
buildConfig(undefined, { uploadDocumentIteration3Enabled: false }),
92+
);
93+
94+
render(<HomePage />);
95+
96+
expect(screen.queryByTestId('admin-console-btn')).not.toBeInTheDocument();
97+
});
7098
});
7199

72100
describe('Navigation', () => {

app/src/pages/homePage/HomePage.tsx

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ const HomePage = (): React.JSX.Element => {
2727
<Card.Heading className="nhsuk-heading-m">
2828
<Card.Link
2929
data-testid="search-patient-btn"
30-
href='#'
30+
href="#"
3131
onClick={(): void => {
32-
navigate(routes.SEARCH_PATIENT)
32+
navigate(routes.SEARCH_PATIENT);
3333
}}
3434
>
3535
View or upload a patient record
@@ -45,9 +45,9 @@ const HomePage = (): React.JSX.Element => {
4545
<Card.Heading className="nhsuk-heading-m">
4646
<Card.Link
4747
data-testid="search-patient-btn"
48-
href='#'
48+
href="#"
4949
onClick={(): void => {
50-
navigate(routes.SEARCH_PATIENT)
50+
navigate(routes.SEARCH_PATIENT);
5151
}}
5252
>
5353
Search for a patient
@@ -63,16 +63,16 @@ const HomePage = (): React.JSX.Element => {
6363
</Card.Content>
6464
</Card>
6565
</Card.GroupItem>
66-
{config.featureFlags.uploadDocumentIteration3Enabled && (
66+
{config.featureFlags.uploadDocumentIteration3Enabled ? (
6767
<Card.GroupItem width="one-half">
6868
<Card clickable cardType="primary">
6969
<Card.Content>
7070
<Card.Heading className="nhsuk-heading-m">
7171
<Card.Link
7272
data-testid="admin-console-btn"
73-
href='#'
73+
href="#"
7474
onClick={(): void => {
75-
navigate(routes.ADMIN_ROUTE)
75+
navigate(routes.ADMIN_ROUTE);
7676
}}
7777
>
7878
Admin console
@@ -85,29 +85,32 @@ const HomePage = (): React.JSX.Element => {
8585
</Card.Content>
8686
</Card>
8787
</Card.GroupItem>
88+
) : (
89+
<Card.GroupItem width="one-half">
90+
<Card clickable cardType="primary">
91+
<Card.Content>
92+
<Card.Heading className="nhsuk-heading-m">
93+
<Card.Link
94+
data-testid="download-report-btn"
95+
href="#"
96+
onClick={(): void => {
97+
navigate(
98+
`${routes.REPORT_DOWNLOAD}?reportType=${REPORT_TYPE.ODS_PATIENT_SUMMARY}`,
99+
);
100+
}}
101+
>
102+
Download a report
103+
</Card.Link>
104+
</Card.Heading>
105+
<Card.Description>
106+
This report shows the list of Lloyd George records stored for
107+
your organisation.
108+
</Card.Description>
109+
<RightCircleIcon />
110+
</Card.Content>
111+
</Card>
112+
</Card.GroupItem>
88113
)}
89-
<Card.GroupItem width="one-half">
90-
<Card clickable cardType="primary">
91-
<Card.Content>
92-
<Card.Heading className="nhsuk-heading-m">
93-
<Card.Link
94-
data-testid="download-report-btn"
95-
href='#'
96-
onClick={(): void => {
97-
navigate(`${routes.REPORT_DOWNLOAD}?reportType=${REPORT_TYPE.ODS_PATIENT_SUMMARY}`)
98-
}}
99-
>
100-
Download a report
101-
</Card.Link>
102-
</Card.Heading>
103-
<Card.Description>
104-
This report shows the list of Lloyd George records stored for your
105-
organisation.
106-
</Card.Description>
107-
<RightCircleIcon />
108-
</Card.Content>
109-
</Card>
110-
</Card.GroupItem>
111114
</Card.Group>
112115
</>
113116
);

0 commit comments

Comments
 (0)