From 37fb818e0ea2fc4add17a976b5ff9bdad405f646 Mon Sep 17 00:00:00 2001 From: Nicki Derrick Date: Mon, 3 Nov 2025 16:08:23 +0000 Subject: [PATCH 1/2] CCM-10814 WIP --- .../src/__tests__/app/signin/route.test.ts | 10 +-- .../__snapshots__/Header.test.tsx.snap | 2 +- .../__tests__/utils/get-templates-url.test.ts | 74 +++++++++++++++++++ frontend/src/app/signin/route.ts | 17 +++-- frontend/src/content/content.ts | 3 +- frontend/src/utils/get-templates-url.ts | 6 ++ .../terraform/components/app/amplify_app.tf | 1 + 7 files changed, 98 insertions(+), 15 deletions(-) create mode 100644 frontend/src/__tests__/utils/get-templates-url.test.ts create mode 100644 frontend/src/utils/get-templates-url.ts diff --git a/frontend/src/__tests__/app/signin/route.test.ts b/frontend/src/__tests__/app/signin/route.test.ts index 7e640189..cc9b6936 100644 --- a/frontend/src/__tests__/app/signin/route.test.ts +++ b/frontend/src/__tests__/app/signin/route.test.ts @@ -31,7 +31,7 @@ test('returns redirect', async () => { secure: true, }); expect(response.status).toEqual(307); - expect(response.headers.get('Location')).toEqual('/redirect-url'); + expect(response.headers.get('Location')).toEqual('http://localhost:3000/redirect-url'); }); test('returns redirect - sanitizes redirect path', async () => { @@ -43,7 +43,7 @@ test('returns redirect - sanitizes redirect path', async () => { const response = await GET(request); expect(response.status).toEqual(307); - expect(response.headers.get('Location')).toEqual('/redirect-url'); + expect(response.headers.get('Location')).toEqual('http://localhost:3000/redirect-url'); }); test('returns redirect to /templates/message-templates if no redirect given', async () => { @@ -56,7 +56,7 @@ test('returns redirect to /templates/message-templates if no redirect given', as expect(response.status).toEqual(307); expect(response.headers.get('Location')).toEqual( - '/templates/message-templates' + 'http://localhost:3000/templates/message-templates' ); }); @@ -71,7 +71,7 @@ test('returns redirect to /auth if no session detected', async () => { expect(cookiesMock.delete).toHaveBeenCalledWith('csrf_token'); expect(response.status).toEqual(307); - expect(response.headers.get('Location')).toEqual('/auth'); + expect(response.headers.get('Location')).toEqual('https://test/auth'); }); test('retains redirect search param on /auth redirect', async () => { @@ -86,6 +86,6 @@ test('retains redirect search param on /auth redirect', async () => { expect(response.status).toEqual(307); expect(response.headers.get('Location')).toEqual( - '/auth?redirect=%2Fredirect-path' + 'https://test/auth?redirect=%2Fredirect-path' ); }); diff --git a/frontend/src/__tests__/components/__snapshots__/Header.test.tsx.snap b/frontend/src/__tests__/components/__snapshots__/Header.test.tsx.snap index 314b995c..6690fdd8 100644 --- a/frontend/src/__tests__/components/__snapshots__/Header.test.tsx.snap +++ b/frontend/src/__tests__/components/__snapshots__/Header.test.tsx.snap @@ -18,7 +18,7 @@ exports[`Header component renders component correctly 1`] = ` aria-label="NHS Notify templates" class="nhsuk-header__service-logo" data-testid="header-logo-service-link" - href="/templates/create-and-submit-templates" + href="http://localhost:3000/templates/create-and-submit-templates" >