From 40014d07003228f103991a32e013ad6ba930463c Mon Sep 17 00:00:00 2001 From: AndyFlintNHS Date: Mon, 2 Dec 2024 16:09:59 +0000 Subject: [PATCH] [PRMP-1074] Refreshing browser redirects to search patient page --- app/src/router/guards/patientGuard/PatientGuard.test.tsx | 4 ++-- app/src/router/guards/patientGuard/PatientGuard.tsx | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/router/guards/patientGuard/PatientGuard.test.tsx b/app/src/router/guards/patientGuard/PatientGuard.test.tsx index 8e6154eba..07b8c4720 100644 --- a/app/src/router/guards/patientGuard/PatientGuard.test.tsx +++ b/app/src/router/guards/patientGuard/PatientGuard.test.tsx @@ -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); }); }); diff --git a/app/src/router/guards/patientGuard/PatientGuard.tsx b/app/src/router/guards/patientGuard/PatientGuard.tsx index 9cbd3d953..6a1009872 100644 --- a/app/src/router/guards/patientGuard/PatientGuard.tsx +++ b/app/src/router/guards/patientGuard/PatientGuard.tsx @@ -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};