Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export class ExceptionOverviewPage extends BasePage {
readonly exceptionIDLink: Locator;
readonly sortByDateExceptionCreated: Locator;
readonly applyButton: Locator;
readonly sortByexceptionstatus

constructor(page: Page) {
super(page)
Expand All @@ -19,6 +20,7 @@ export class ExceptionOverviewPage extends BasePage {
//this.exceptionIDLink = page.locator('[data-testid="exceptions-table"] tbody tr:nth-child(2) td:nth-child(1) a');
this.sortByDateExceptionCreated = page.locator('[data-testid="sort-not-raised-exceptions"]');
this.applyButton = page.locator('[data-testid="apply-button"]');
this.sortByexceptionstatus = page.locator('[data-testid="sort-raised-exceptions"]');
}
async getTableHeaders(): Promise<string[]> {
return this.page.$$eval('[data-testid="exceptions-table"] th', headers =>
Expand Down Expand Up @@ -46,15 +48,29 @@ export class ExceptionOverviewPage extends BasePage {
async clickOnexceptionID() {
await this.clickElement(this.exceptionIDLink)
}
async sortByDateExceptionCreatedDescending(optionText: string) {
async sortOptionSelect(optionText: string) {
// Adjust selector to match your sortable column header
await this.sortByDateExceptionCreated.selectOption({ label: optionText });
if (optionText.toLowerCase().includes('date exception created')) {
// Use the locator for "Date exception created"
await this.sortByDateExceptionCreated.selectOption({ label: optionText });
} else {
// Use the locator for another column (replace with your actual locator)
await this.sortByexceptionstatus.selectOption({ label: optionText });
}
await this.applyButton.click();
}
async getDateExceptionCreatedColumn(): Promise<Date[]> {
// Adjust selector to match the correct column index for "Date exception created"
const dateCells = await this.page.locator('[data-testid="exceptions-table"] tbody tr td:nth-child(3)').allTextContents();
return dateCells.map(text => new Date(text.trim()));
}
async getStatusUpdateDates(): Promise<Date[]> {
const texts = await this.page.locator('[data-testid="exceptions-table"] tbody tr td:nth-child(5)').allTextContents();
// Extract date from "Raised on 16 June 2025"
return texts.map(text => {
const match = text.match(/on (.+)$/); // match "on <date>"
return match ? new Date(match[1]) : new Date(0); // fallback to epoch if no match
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,18 @@ Feature: testing Breast screening - exception overview 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_6389 @test_9447
Scenario: verify sorting by with Status last updated (most recent first)
When the user sorts the exception summary table by 'Status last updated (most recent first)'
Then the exceptions should be sorted by exception status last updated in descending order

@epic_4a @req_6389 @test_9437
Scenario: verify sorting by with Status last updated (oldest first)
When the user sorts the exception summary table by 'Status last updated (oldest first)'
Then the exceptions should be sorted by exception status last updated in ascending order

@epic_4a @req_6389 @test_9449
Scenario: verify sorting by with unsupported sort option
When the user sorts with unsupported options by 'exception created (oldest first)'
Then the error message should thrown
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Given('the user navigate to not raised exception overview page', async ({ page }
});
When('the user sorts the exception summary table by {string}', async ({ page }, sortOption: string) => {
const exceptionOverviewPage = new ExceptionOverviewPage(page);
await exceptionOverviewPage.sortByDateExceptionCreatedDescending(sortOption);
await exceptionOverviewPage.sortOptionSelect(sortOption);
await page.waitForTimeout(3000);
});
Then('the exception summary table should be sorted by Date exception created in descending order', async ({ page }) => {
Expand All @@ -61,13 +61,25 @@ Then('the exception summary table should be sorted by Date exception created in
const sorted = [...dates].sort((a, b) => a.getTime() - b.getTime());
expect(dates).toEqual(sorted);
});
Then('the exceptions should be sorted by exception status last updated in descending order', async ({ page }) => {
const exceptionOverviewPage = new ExceptionOverviewPage(page);
const dates = await exceptionOverviewPage.getStatusUpdateDates();
const isDescending = dates.every((d, i, arr) => i === 0 || arr[i - 1].getTime() >= d.getTime());
expect(isDescending).toBe(true);
});
Then('the exceptions should be sorted by exception status last updated in ascending order', async ({ page }) => {
const exceptionOverviewPage = new ExceptionOverviewPage(page);
const dates = await exceptionOverviewPage.getStatusUpdateDates();
const isAscending = dates.every((d, i, arr) => i === 0 || arr[i - 1].getTime() <= d.getTime());
expect(isAscending).toBe(true);
});
// Use a WeakMap to store sort errors per context
const sortErrorMap = new WeakMap();
When('the user sorts with unsupported options by {string}', async ({ page }, sortOption: string) => {
const exceptionOverviewPage = new ExceptionOverviewPage(page);
try {
await Promise.race([
exceptionOverviewPage.sortByDateExceptionCreatedDescending(sortOption),
exceptionOverviewPage.sortOptionSelect(sortOption),
new Promise((_, reject) => setTimeout(() => reject(new Error('Custom timeout')), 3000))
]);
sortErrorMap.set(page.context(), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ export const { Given, When, Then } = createBdd(test);
const { AfterScenario } = createBdd(test);

AfterScenario(async ({ page }) => {
// Scroll to bottom
await page.evaluate(() => window.scrollTo(0, document.body.scrollHeight));
await page.waitForTimeout(1000); // Wait for video to capture the bottom
// runs after each scenario
await page.evaluate(() => window.scrollTo(0, 0));
await page.waitForTimeout(1000);
// Take a screenshot after each scenario
const timestamp = Date.now();
await page.screenshot({ path: `screenshots/afterScenario_${timestamp}.png`, fullPage: true });
});
Loading