Skip to content

Commit

Permalink
[PRMP-1074] Refreshing browser redirects to search patient page
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyFlintNHS committed Dec 2, 2024
1 parent b9a3138 commit 40014d0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/src/router/guards/patientGuard/PatientGuard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ describe('AuthGuard', () => {
afterEach(() => {
jest.clearAllMocks();
});
it('navigates user to unauthorised when no patient is searched', async () => {
it('navigates user to search patient page when no patient details are stored', async () => {
mockedUsePatient.mockReturnValue(null);

renderGuard();

await waitFor(async () => {
expect(mockedUseNavigate).toHaveBeenCalledWith(routes.UNAUTHORISED);
expect(mockedUseNavigate).toHaveBeenCalledWith(routes.SEARCH_PATIENT);
});
});

Expand Down
2 changes: 1 addition & 1 deletion app/src/router/guards/patientGuard/PatientGuard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function PatientGuard({ children }: Props) {
const navigate = useNavigate();
useEffect(() => {
if (!patient) {
navigate(routes.UNAUTHORISED);
navigate(routes.SEARCH_PATIENT);
}
}, [patient, navigate]);
return <>{children}</>;
Expand Down

0 comments on commit 40014d0

Please sign in to comment.