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
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { render, screen } from '@testing-library/react';
import UserPatientRestrictionsAddStage from './UserPatientRestrictionsAddStage';

describe('UserPatientRestrictionsAddStage', () => {
it('renders correctly', () => {
render(<UserPatientRestrictionsAddStage />);

expect(screen.getByText('Add user patient restriction')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const UserPatientRestrictionsAddStage = (): React.JSX.Element => {
return <div>Add user patient restriction</div>;
};

export default UserPatientRestrictionsAddStage;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { render, screen } from '@testing-library/react';
import UserPatientRestrictionsIndex from './UserPatientRestrictionsIndex';
import { runAxeTest } from '../../../../helpers/test/axeTestHelper';
import { beforeEach, describe, expect, it, Mock, vi } from 'vitest';
import { routes } from '../../../../types/generic/routes';
import { routeChildren, routes } from '../../../../types/generic/routes';

vi.mock('../../../helpers/hooks/useTitle');
vi.mock('../../../../styles/right-chevron-circle.svg', () => ({
Expand Down Expand Up @@ -59,6 +59,16 @@ describe('UserRestrictionsPage', (): void => {
screen.getByTestId('user-restrictions-back-btn').click();
expect(mockNavigate).toHaveBeenCalledWith(routes.ADMIN_ROUTE);
});

it('navigates to add restriction page when add restriction button is clicked', (): void => {
screen.getByTestId('add-user-restriction-btn').click();
expect(mockNavigate).toHaveBeenCalledWith(routeChildren.USER_PATIENT_RESTRICTIONS_ADD);
});

it('navigates to view restrictions page when view restrictions button is clicked', (): void => {
screen.getByTestId('view-user-restrictions-btn').click();
expect(mockNavigate).toHaveBeenCalledWith(routeChildren.USER_PATIENT_RESTRICTIONS_LIST);
});
});

describe('Accessibility', (): void => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { JSX } from 'react';
import useTitle from '../../../../helpers/hooks/useTitle';
import { ReactComponent as RightCircleIcon } from '../../../../styles/right-chevron-circle.svg';
import BackButton from '../../../generic/backButton/BackButton';
import { routes } from '../../../../types/generic/routes';
import { routeChildren, routes } from '../../../../types/generic/routes';
import { useNavigate } from 'react-router-dom';

const UserPatientRestrictionsIndex = (): JSX.Element => {
const navigate = useNavigate();
useTitle({ pageTitle: 'Restrict staff from accessing patient records' });

return (
Expand All @@ -17,7 +19,14 @@ const UserPatientRestrictionsIndex = (): JSX.Element => {
<Card clickable cardType="primary">
<Card.Content>
<Card.Heading className="nhsuk-heading-m">
<Card.Link data-testid="add-user-restriction-btn" href="#">
<Card.Link
data-testid="add-user-restriction-btn"
href="#"
onClick={(e): void => {
e.preventDefault();
navigate(routeChildren.USER_PATIENT_RESTRICTIONS_ADD);
}}
>
Add a restriction
</Card.Link>
</Card.Heading>
Expand All @@ -32,7 +41,14 @@ const UserPatientRestrictionsIndex = (): JSX.Element => {
<Card clickable cardType="primary">
<Card.Content>
<Card.Heading className="nhsuk-heading-m">
<Card.Link data-testid="view-user-restrictions-btn" href="#">
<Card.Link
data-testid="view-user-restrictions-btn"
href="#"
onClick={(e): void => {
e.preventDefault();
navigate(routeChildren.USER_PATIENT_RESTRICTIONS_LIST);
}}
>
View and remove a restriction
</Card.Link>
</Card.Heading>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.user-patient-restrictions-list-stage {
#search-input {
width: 300px;
}
}
Loading
Loading