Skip to content

Commit b9e6ac1

Browse files
committed
add in error checks and other stuff
1 parent 74757fe commit b9e6ac1

6 files changed

Lines changed: 86 additions & 1 deletion

File tree

tests/POM.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ test(`Page object model for Calculate Holiday Entitlement for a full leave year
5757
const workOutHolidayPage: WorkOutHolidayPage = new WorkOutHolidayPage();
5858
await workOutHolidayPage.checkPageLoads(page);
5959
await workOutHolidayPage.continueOn(page);
60+
const answersPage: AnswersPage = new AnswersPage();
61+
await answersPage.checkPageLoadsFirstScenario(page);
6062
});
6163

6264
test(`Calculate Holiday Entitlement for someone starting and leaving part way through a leave year with shifts and other options`, async ({ page }): Promise<void> => {
@@ -91,8 +93,36 @@ test(`Calculate Holiday Entitlement for someone starting and leaving part way th
9193
const daysInTheShiftPatternPage: daysInTheShiftPatternPage = new DaysInTheShiftPatternPage();
9294
await daysInTheShiftPatternPage.checkPageLoads(page);
9395
await daysInTheShiftPatternPage.continueOn(page);
96+
const answersPage: AnswersPage = new AnswersPage();
97+
await answersPage.checkPageLoadsSecondScenario(page);
98+
});
99+
100+
test(`Page object model unhappy path for scenario 2`, async ({ page }): Promise<void> => {
101+
const landingPage: LandingPage = new LandingPage();
102+
await landingPage.checkPageLoads(page);
103+
await landingPage.continueOn(page);
104+
const irregularHoursPage: IrregularHoursPage = new IrregularHoursPage();
105+
await irregularHoursPage.checkPageLoads(page);
106+
await irregularHoursPage.selectYes(page);
107+
await irregularHoursPage.continueOn(page);
108+
const leaveYearStartPage = new LeaveYearStartPage();
109+
await leaveYearStartPage.checkPageLoads(page);
110+
await leaveYearStartPage.continueOn(page);
111+
const entitlementBasedOnPage: HolidayEntitlementPage = new HolidayEntitlementPage();
112+
await entitlementBasedOnPage.checkPageLoads(page);
113+
await entitlementBasedOnPage.continueOnWithShifts(page);
114+
const calculateHolidayPage: calculateHolidayPage = new CalculateHolidayPage();
115+
await calculateHolidayPage.checkPageLoads(page);
116+
await calculateHolidayPage.continueOnWithLastOption(page);
117+
const employmentStartDatePage: employmentStartDatePage = new EmploymentStartDatePage();
118+
await employmentStartDatePage.checkPageLoads(page);
119+
await employmentStartDatePage.continueOn(page);
120+
const employmentEndDatePage: employmentEndDatePage = new EmploymentEndDate();
121+
await employmentEndDatePage.checkPageLoads(page);
122+
await employmentEndDatePage.triggerErrorMessages(page);
94123
});
95124

125+
96126
test(`Page object model unhappy path`, async ({ page }): Promise<void> => {
97127
const landingPage: LandingPage = new LandingPage();
98128
await landingPage.checkPageLoads(page);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const answersFirstScenario_content = {
2+
pageTitle: "Information based on your answers",
3+
divText: "The statutory holiday entitlement is 5.6 weeks holiday.",
4+
} as const;
5+
6+
export default answersFirstScenario_content
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
const answersSecondScenario_content = {
2+
pageTitle: "Information based on your answers",
3+
divText: "The statutory holiday entitlement is 27.47 shifts for the year. Each shift being 10.0 hours.",
4+
} as const;
5+
6+
export default answersSecondScenario_content
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
const employmentEndDate_content = {
2-
pageTitle: "What was the employment end date?"
2+
pageTitle: "What was the employment end date?",
3+
errorBanner: "There is a problem",
4+
errorMessage: "Your end date can not be before your start date of 01 January 2024.",
35
} as const;
46

57
export default employmentEndDate_content;

tests/pages/answersPage.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
import { Page } from 'playwright';
22
import {expect} from "@playwright/test";
33
import answers_content from "../content/answers_content";
4+
import answersFirstScenario_content from "../content/answersFirstScenario_content";
45
import axeTest from "../accessibilityTestHelper";
6+
import answersSecondScenario_content from "../content/answersSecondScenario_content";
57

68
class AnswersPage {
79
private readonly title: string;
810
private readonly text: string;
11+
private readonly textFirstScenario: string;
12+
private readonly testSecondScenario: string;
913

1014
constructor() {
1115
this.title = `.govuk-heading-xl`
1216
this.text = `.summary`
17+
this.textFirstScenario = `.gem-c-govspeak`
18+
this.testSecondScenario = `.summary`
1319
}
1420

1521
async checkPageLoads(page: Page): Promise<void> {
@@ -20,5 +26,23 @@ class AnswersPage {
2026
]);
2127
await axeTest(page);
2228
}
29+
30+
async checkPageLoadsFirstScenario(page: Page): Promise<void> {
31+
// Check elements of the page
32+
await Promise.all([
33+
expect(page.locator(this.title)).toContainText(answersFirstScenario_content.pageTitle),
34+
expect(page.locator(this.textFirstScenario)).toContainText(answersFirstScenario_content.divText),
35+
]);
36+
await axeTest(page);
37+
}
38+
39+
async checkPageLoadsSecondScenario(page: Page): Promise<void> {
40+
// Check elements of the page
41+
await Promise.all([
42+
expect(page.locator(this.title)).toContainText(answersSecondScenario_content.pageTitle),
43+
expect(page.locator(this.testSecondScenario)).toContainText(answersSecondScenario_content.divText),
44+
]);
45+
await axeTest(page);
46+
}
2347
}
2448
export default AnswersPage;

tests/pages/employmentEndDatePage.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,25 @@ import { Page } from "playwright";
22
import { expect } from "@playwright/test";
33
import employmentEndDate_content from "../content/employmentEndDate_content";
44
import axeTest from "../accessibilityTestHelper";
5+
import irregularHours_content from "../content/irregularHours_content";
56

67
class EmploymentEndDate {
78
private readonly title: string;
89
private readonly dayDate: string;
910
private readonly monthDate: string;
1011
private readonly yearDate: string;
12+
private readonly errorBanner: string;
13+
private readonly errorMessage: string;
1114

1215

1316
constructor() {
1417
this.title = `.govuk-fieldset__heading`;
1518
this.dayDate = `#response-0`; // The date input field
1619
this.monthDate = `#response-1`;
1720
this.yearDate = `#response-2`;
21+
this.errorBanner = `.govuk-error-summary__title`;
22+
this.errorMessage = `.govuk-error-summary__body`;
23+
1824
}
1925

2026
async checkPageLoads(page: Page): Promise<void> {
@@ -30,6 +36,17 @@ class EmploymentEndDate {
3036
await page.locator(this.yearDate).fill("2024");
3137
await page.getByRole("button", { name: "Continue" }).click();
3238
}
39+
40+
async triggerErrorMessages(page: Page): Promise<void> {
41+
await page.locator(this.dayDate).fill("01");
42+
await page.locator(this.monthDate).fill("01");
43+
await page.locator(this.yearDate).fill("2024");
44+
await page.getByRole("button", { name: "Continue" }).click();
45+
await Promise.all([
46+
expect(page.locator(this.errorBanner)).toHaveText(employmentEndDate_content.errorBanner),
47+
expect(page.locator(this.errorMessage)).toContainText(employmentEndDate_content.errorMessage),
48+
]);
49+
}
3350
}
3451

3552
export default EmploymentEndDate;

0 commit comments

Comments
 (0)