Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions app/src/pages/adminPage/AdminPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,28 @@ describe('AdminPage', (): void => {
),
).toBeInTheDocument();
});

it('renders the Download a report card', (): void => {
render(<AdminPage />);
const reportLink = screen.getByTestId('download-report-btn');
expect(reportLink).toBeInTheDocument();
expect(reportLink).toHaveTextContent('Download a report');
});

it('renders the Download a report card with correct href', (): void => {
render(<AdminPage />);
const reportLink = screen.getByTestId('download-report-btn');
expect(reportLink).toHaveAttribute('href', '/create-report?reportType=0');
});

it('renders the Download a report card description', (): void => {
render(<AdminPage />);
expect(
screen.getByText(
'This report shows the list of Lloyd George records stored for your organisation.',
),
).toBeInTheDocument();
});
});

describe('Accessibility', (): void => {
Expand Down
22 changes: 21 additions & 1 deletion app/src/pages/adminPage/AdminPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { Card } from 'nhsuk-react-components';
import { JSX } from 'react';
import useTitle from '../../helpers/hooks/useTitle';
import { ReactComponent as RightCircleIcon } from '../../styles/right-chevron-circle.svg';
import { routeChildren } from '../../types/generic/routes';
import { routeChildren, routes } from '../../types/generic/routes';
import {REPORT_TYPE} from "../../types/generic/reports";

export const AdminPage = (): JSX.Element => {
useTitle({ pageTitle: 'Admin hub' });
Expand Down Expand Up @@ -30,6 +31,25 @@ export const AdminPage = (): JSX.Element => {
</Card.Content>
</Card>
</Card.GroupItem>
<Card.GroupItem width="one-half">
<Card clickable cardType="primary">
<Card.Content>
<Card.Heading className="nhsuk-heading-m">
<Card.Link
data-testid="download-report-btn"
href={`${routes.REPORT_DOWNLOAD}?reportType=${REPORT_TYPE.ODS_PATIENT_SUMMARY}`}
>
Download a report
</Card.Link>
</Card.Heading>
<Card.Description>
This report shows the list of Lloyd George records stored for
your organisation.
</Card.Description>
<RightCircleIcon />
</Card.Content>
</Card>
</Card.GroupItem>
</Card.Group>
</>
);
Expand Down
41 changes: 10 additions & 31 deletions app/src/pages/homePage/HomePage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ describe('HomePage', () => {
});

describe('Rendering', () => {
it('should render home page with patient search and download report', async () => {
it('should render home page with patient search and download report when uploadDocumentIteration3Enabled is false', async () => {
mockUseConfig.mockReturnValue(
buildConfig(undefined, { uploadDocumentIteration3Enabled: false }),
);
render(<HomePage />);

const searchPatientButton = screen.getByTestId(
'search-patient-btn',
) as HTMLAnchorElement;
Expand All @@ -40,46 +42,23 @@ describe('HomePage', () => {
) as HTMLAnchorElement;
expect(searchPatientButton).toBeInTheDocument();
expect(downloadReportButton).toBeInTheDocument();
});
});

describe('Admin Console button', () => {
it('renders admin console button when feature flag is enabled', () => {
mockUseConfig.mockReturnValue(
buildConfig(undefined, { uploadDocumentIteration3Enabled: true }),
);

render(<HomePage />);

const adminConsoleButton = screen.getByTestId('admin-console-btn') as HTMLAnchorElement;
expect(adminConsoleButton).toBeInTheDocument();
expect(adminConsoleButton).toHaveTextContent('Admin console');
expect(adminConsoleButton).toHaveAttribute('href', routes.ADMIN_ROUTE);
});

it('does not render admin console button when feature flag is disabled', () => {
mockUseConfig.mockReturnValue(
buildConfig(undefined, { uploadDocumentIteration3Enabled: false }),
);

render(<HomePage />);

expect(screen.queryByTestId('admin-console-btn')).not.toBeInTheDocument();
});
});

describe('Admin Console button', () => {
it('renders admin console button when feature flag is enabled and user is GP_ADMIN', () => {
it('should render home page with patient search and admin console when uploadDocumentIteration3Enabled is true', async () => {
mockUseConfig.mockReturnValue(
buildConfig(undefined, { uploadDocumentIteration3Enabled: true }),
);

render(<HomePage />);

const searchPatientButton = screen.getByTestId(
'search-patient-btn',
) as HTMLAnchorElement;
const adminConsoleButton = screen.getByTestId('admin-console-btn') as HTMLAnchorElement;
expect(searchPatientButton).toBeInTheDocument();
expect(adminConsoleButton).toBeInTheDocument();
expect(adminConsoleButton).toHaveTextContent('Admin console');
expect(adminConsoleButton).toHaveAttribute('href', routes.ADMIN_ROUTE);
expect(screen.queryByTestId('download-report-btn')).not.toBeInTheDocument();
});

it('does not render admin console button when feature flag is disabled', () => {
Expand Down
41 changes: 21 additions & 20 deletions app/src/pages/homePage/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const HomePage = (): React.JSX.Element => {
</Card.Content>
</Card>
</Card.GroupItem>
{config.featureFlags.uploadDocumentIteration3Enabled && (
{config.featureFlags.uploadDocumentIteration3Enabled ? (
<Card.GroupItem width="one-half">
<Card clickable cardType="primary">
<Card.Content>
Expand All @@ -74,26 +74,27 @@ const HomePage = (): React.JSX.Element => {
</Card.Content>
</Card>
</Card.GroupItem>
) : (
<Card.GroupItem width="one-half">
<Card clickable cardType="primary">
<Card.Content>
<Card.Heading className="nhsuk-heading-m">
<Card.Link
data-testid="download-report-btn"
href={`${routes.REPORT_DOWNLOAD}?reportType=${REPORT_TYPE.ODS_PATIENT_SUMMARY}`}
>
Download a report
</Card.Link>
</Card.Heading>
<Card.Description>
This report shows the list of Lloyd George records stored for
your organisation.
</Card.Description>
<RightCircleIcon />
</Card.Content>
</Card>
</Card.GroupItem>
)}
<Card.GroupItem width="one-half">
<Card clickable cardType="primary">
<Card.Content>
<Card.Heading className="nhsuk-heading-m">
<Card.Link
data-testid="download-report-btn"
href={`${routes.REPORT_DOWNLOAD}?reportType=${REPORT_TYPE.ODS_PATIENT_SUMMARY}`}
>
Download a report
</Card.Link>
</Card.Heading>
<Card.Description>
This report shows the list of Lloyd George records stored for your
organisation.
</Card.Description>
<RightCircleIcon />
</Card.Content>
</Card>
</Card.GroupItem>
</Card.Group>
</>
);
Expand Down
Loading