Skip to content

Commit 5936dc4

Browse files
authored
test: added tests for error pages (#1454)
1 parent 482cab6 commit 5936dc4

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

application/CohortManager/src/Web/tests/features/home.feature

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,22 @@ Feature: testing Breast screening - Cohort Manager home page
4646
Scenario: verify navigation to cookies screen
4747
And the user clicks on cookies link
4848
Then they should navigate to 'Cookies on Cohort Manager - Cohort Manager - NHS'
49+
50+
@epic_4a @req_6330
51+
Scenario: verify error message for invalid URL
52+
When the user navigates to an invalid URL
53+
Then the page should display 'Page not found' on screen
54+
And the page not found error screen should include a 'Return to the homepage' link
55+
And the page not found error screen should include a 'Contact us' link
56+
57+
@epic_4a @req_6330
58+
Scenario: verify navigation to home from error page
59+
When the user navigates to an invalid URL
60+
And the user clicks on the 'Return to the homepage' link
61+
Then they should navigate to 'Breast screening - Cohort Manager - NHS'
62+
63+
@epic_4a @req_6330
64+
Scenario: verify navigation to contact us from error page
65+
When the user navigates to an invalid URL
66+
And the user clicks on the 'Contact us' link
67+
Then they should navigate to 'Get help with Cohort Manager - Cohort Manager - NHS'

application/CohortManager/src/Web/tests/features/steps/homeSteps.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,20 @@ When('the user clicks on cookies link', async ({ page }) => {
9494
homePage = new HomePage(page);
9595
await homePage.clickOnCookiesLink()
9696
});
97+
When('the user navigates to an invalid URL', async ({ page }) => {
98+
// Navigate to a non-existent page to trigger 404
99+
await page.goto('https://localhost:3000/exception');
100+
});
101+
Then("the page should display {string} on screen", async ({ page }, errorType) => {
102+
// Check for a heading or text that indicates 404
103+
await expect(page.getByRole('heading', { name: new RegExp(errorType, 'i') })).toBeVisible();
104+
});
105+
Then("the page not found error screen should include a {string} link", async ({ page }, link) => {
106+
// Check for the presence of the return link
107+
const linkLocator = page.getByRole('link', { name: new RegExp(link, 'i') }).first();
108+
await expect(linkLocator).toBeVisible();
109+
});
110+
When('the user clicks on the {string} link', async ({ page }, linkText) => {
111+
const linkLocator = page.getByRole('link', { name: new RegExp(linkText, 'i') }).first();
112+
await linkLocator.click();
113+
});

0 commit comments

Comments
 (0)