Skip to content

Commit 06bf0fd

Browse files
committed
test : added tests for dtoss-3912 and dtoss-6972
1 parent 5bdf4dc commit 06bf0fd

5 files changed

Lines changed: 171 additions & 1 deletion

File tree

application/CohortManager/src/Web/app/components/exceptionsTable.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ export default function ExceptionsTable({
1212
caption,
1313
}: Readonly<ExceptionsTableProps>) {
1414
return (
15-
<table role="table" className="nhsuk-table-responsive">
15+
<table
16+
role="table"
17+
className="nhsuk-table-responsive"
18+
data-testid="exceptions-table"
19+
>
1620
<caption className="nhsuk-table__caption nhsuk-u-visually-hidden">
1721
{caption ? `${caption}` : "Total breast screening exceptions"}
1822
</caption>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
@notraisedExceptionOverview
2+
Feature: testing Breast screening - Not raisedexception overview page
3+
4+
Background:
5+
Given the user navigate to not raised exception overview page
6+
7+
Scenario: verify column headers on Raised exception overview page
8+
Then the exception summary table should have the following columns:
9+
| Local reference Exception ID |
10+
| NHS number |
11+
| Date exception created |
12+
| Short description |
13+
| Exception status |
14+
15+
Scenario: verify that the Sorting is out of scope on table Headers.
16+
Then the exception summary table headers should not be sortable
17+
18+
Scenario: navigation to exception information page
19+
When the user clicks on exception ID link
20+
Then they should navigate to 'Exception information - Cohort Manager - NHS'
21+
22+
Scenario: verify navigation to Home screen from Raised exception overview page
23+
When the user clicks on Home link
24+
Then they should navigate to 'Breast screening - Cohort Manager - NHS'
25+
26+
Scenario: verify navigation to Contact us screen
27+
And the user clicks on contact us link
28+
Then they should navigate to 'Get help with Cohort Manager - Cohort Manager - NHS'
29+
30+
Scenario: verify navigation to Terms and conditions screen
31+
And the user clicks on Terms and conditions link
32+
Then they should navigate to 'Terms and conditions - Cohort Manager - NHS'
33+
34+
Scenario: verify navigation to cookies screen
35+
And the user clicks on cookies link
36+
Then they should navigate to 'Cookies on Cohort Manager - Cohort Manager - NHS'
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { expect, Locator, Page } from "@playwright/test";
2+
import BasePage from "./basePage";
3+
4+
5+
export class ExceptionOverviewPage extends BasePage {
6+
readonly page!: Page;
7+
readonly exceptionTable: Locator;
8+
readonly exceptiontableHeaders: Locator;
9+
readonly homepageLink: Locator;
10+
readonly exceptionIDLink: Locator;
11+
12+
constructor(page: Page) {
13+
super(page)
14+
this.page = page;
15+
this.exceptionTable = page.locator('[data-testid="exceptions-table"]');
16+
this.exceptiontableHeaders = page.locator('[data-testid="exceptions-table"] th');
17+
this.homepageLink = page.getByRole('link', { name: 'Home', exact: true });
18+
this.exceptionIDLink = page.locator('[data-testid="exceptions-table"] tbody tr:first-child td:nth-child(1) a');
19+
}
20+
async getTableHeaders(): Promise<string[]> {
21+
return this.page.$$eval('[data-testid="exceptions-table"] th', headers =>
22+
headers.map(h => h.textContent?.trim() || '')
23+
);
24+
}
25+
async clickOnHome() {
26+
await this.clickElement(this.homepageLink)
27+
}
28+
async verifySortnotavailable() {
29+
const headers = this.exceptiontableHeaders
30+
const count = await headers.count();
31+
for (let i = 0; i < count; i++) {
32+
// Check for aria-sort attribute
33+
const ariaSort = await headers.nth(i).getAttribute('aria-sort');
34+
expect(ariaSort).toBeNull();
35+
// Check for sort icon (example: using a class or data-testid)
36+
const sortIcon = await headers.nth(i).locator('.sort-icon, [data-testid="sort-icon"]').count();
37+
expect(sortIcon).toBe(0);
38+
// Optionally, check for clickable/sortable role
39+
const role = await headers.nth(i).getAttribute('role');
40+
expect(role).not.toBe('button');
41+
42+
}
43+
}
44+
async clickOnexceptionID() {
45+
await this.clickElement(this.exceptionIDLink)
46+
}
47+
48+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
@raisedExceptionOverview
2+
Feature: testing Breast screening - exception overview page
3+
4+
Background:
5+
Given the user navigate to raised exception overview page
6+
7+
Scenario: verify column headers on Raised exception overview page
8+
Then the exception summary table should have the following columns:
9+
| Local reference Exception ID |
10+
| NHS number |
11+
| Date exception created |
12+
| Short description |
13+
| Exception status |
14+
15+
Scenario: verify that the Sorting is out of scope on table Headers.
16+
Then the exception summary table headers should not be sortable
17+
18+
Scenario: navigation to exception information page
19+
When the user clicks on exception ID link
20+
Then they should navigate to 'Exception information - Cohort Manager - NHS'
21+
22+
Scenario: verify navigation to Home screen from Raised exception overview page
23+
When the user clicks on Home link
24+
Then they should navigate to 'Breast screening - Cohort Manager - NHS'
25+
26+
Scenario: verify navigation to Contact us screen
27+
And the user clicks on contact us link
28+
Then they should navigate to 'Get help with Cohort Manager - Cohort Manager - NHS'
29+
30+
Scenario: verify navigation to Terms and conditions screen
31+
And the user clicks on Terms and conditions link
32+
Then they should navigate to 'Terms and conditions - Cohort Manager - NHS'
33+
34+
Scenario: verify navigation to cookies screen
35+
And the user clicks on cookies link
36+
Then they should navigate to 'Cookies on Cohort Manager - Cohort Manager - NHS'
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { expect } from '@playwright/test';
2+
import { Given, When, Then } from './fixtures';
3+
import { HomePage } from '../pages/homePage';
4+
import { ExceptionOverviewPage } from '../pages/exceptionOverviewPage';
5+
6+
let homePage: HomePage;
7+
let exceptionOverviewPage: ExceptionOverviewPage;
8+
Given('the user navigate to raised exception overview page', async ({ page }) => {
9+
homePage = new HomePage(page)
10+
await page.goto("/");
11+
await homePage.signInwithCredentials('test@test.com', 'test123')
12+
await homePage.clickOnRaised()
13+
await page.waitForTimeout(3000);
14+
15+
});
16+
17+
Then('the exception summary table should have the following columns:', async ({ page }, table: any) => {
18+
exceptionOverviewPage = new ExceptionOverviewPage(page);
19+
// Convert DataTable to array
20+
const rows: string[][] = typeof table.raw === 'function' ? table.raw() : table;
21+
const expectedHeaders = rows.map(row => row[0]);
22+
const actualHeaders = await exceptionOverviewPage.getTableHeaders();
23+
expect(actualHeaders).toEqual(expectedHeaders);
24+
});
25+
26+
When('the user clicks on Home link', async ({ page }) => {
27+
exceptionOverviewPage = new ExceptionOverviewPage(page);
28+
await exceptionOverviewPage.clickOnHome()
29+
});
30+
Then('the exception summary table headers should not be sortable', async ({ page }) => {
31+
exceptionOverviewPage = new ExceptionOverviewPage(page);
32+
await exceptionOverviewPage.verifySortnotavailable();
33+
34+
});
35+
When('the user clicks on exception ID link', async ({ page }) => {
36+
exceptionOverviewPage = new ExceptionOverviewPage(page);
37+
await exceptionOverviewPage.clickOnexceptionID()
38+
});
39+
Given('the user navigate to not raised exception overview page', async ({ page }) => {
40+
homePage = new HomePage(page)
41+
await page.goto("/");
42+
await homePage.signInwithCredentials('test@test.com', 'test123')
43+
await homePage.clickOnNotRaised()
44+
await page.waitForTimeout(3000);
45+
46+
});

0 commit comments

Comments
 (0)