diff --git a/application/CohortManager/src/Web/tests/features/home.feature b/application/CohortManager/src/Web/tests/features/home.feature index d9252ae496..c41e9ab6f6 100644 --- a/application/CohortManager/src/Web/tests/features/home.feature +++ b/application/CohortManager/src/Web/tests/features/home.feature @@ -46,3 +46,22 @@ Feature: testing Breast screening - Cohort Manager home page Scenario: verify navigation to cookies screen And the user clicks on cookies link Then they should navigate to 'Cookies on Cohort Manager - Cohort Manager - NHS' + + @epic_4a @req_6330 + Scenario: verify error message for invalid URL + When the user navigates to an invalid URL + Then the page should display 'Page not found' on screen + And the page not found error screen should include a 'Return to the homepage' link + And the page not found error screen should include a 'Contact us' link + + @epic_4a @req_6330 + Scenario: verify navigation to home from error page + When the user navigates to an invalid URL + And the user clicks on the 'Return to the homepage' link + Then they should navigate to 'Breast screening - Cohort Manager - NHS' + + @epic_4a @req_6330 + Scenario: verify navigation to contact us from error page + When the user navigates to an invalid URL + And the user clicks on the 'Contact us' link + Then they should navigate to 'Get help with Cohort Manager - Cohort Manager - NHS' diff --git a/application/CohortManager/src/Web/tests/features/steps/homeSteps.ts b/application/CohortManager/src/Web/tests/features/steps/homeSteps.ts index 3ac985e800..f12ed5380c 100644 --- a/application/CohortManager/src/Web/tests/features/steps/homeSteps.ts +++ b/application/CohortManager/src/Web/tests/features/steps/homeSteps.ts @@ -94,3 +94,20 @@ When('the user clicks on cookies link', async ({ page }) => { homePage = new HomePage(page); await homePage.clickOnCookiesLink() }); +When('the user navigates to an invalid URL', async ({ page }) => { + // Navigate to a non-existent page to trigger 404 + await page.goto('https://localhost:3000/exception'); +}); +Then("the page should display {string} on screen", async ({ page }, errorType) => { + // Check for a heading or text that indicates 404 + await expect(page.getByRole('heading', { name: new RegExp(errorType, 'i') })).toBeVisible(); +}); +Then("the page not found error screen should include a {string} link", async ({ page }, link) => { + // Check for the presence of the return link + const linkLocator = page.getByRole('link', { name: new RegExp(link, 'i') }).first(); + await expect(linkLocator).toBeVisible(); +}); +When('the user clicks on the {string} link', async ({ page }, linkText) => { + const linkLocator = page.getByRole('link', { name: new RegExp(linkText, 'i') }).first(); + await linkLocator.click(); +});