Skip to content

Commit fcb6868

Browse files
committed
Enhance Playwright tests for pizza and chocolate paths to verify absence of error messages and ensure correct redirection
1 parent 2a44413 commit fcb6868

1 file changed

Lines changed: 24 additions & 12 deletions

File tree

test/playwright/example-form.spec.ts

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ test("page redirects - pizza path", async ({ page }) => {
5151
]);
5252

5353
await page.goto("/example-form/pizza-or-chocolate/");
54+
await expect(page.locator("main")).not.toHaveText(/There is a problem/);
55+
await page.getByRole("button", { name: "Continue" }).click();
56+
await expect(page).toHaveURL("/example-form/pizza-or-chocolate/");
57+
await expect(page.locator("main")).toHaveText(/There is a problem/);
5458
await page.getByLabel("Pizza").check();
5559
await page.getByRole("button", { name: "Continue" }).click();
5660
await expect(page).toHaveURL("/example-form/pizza-topping/");
@@ -66,6 +70,10 @@ test("page redirects - pizza path", async ({ page }) => {
6670
]);
6771

6872
await page.goto("/example-form/pizza-topping/");
73+
await expect(page.locator("main")).not.toHaveText(/There is a problem/);
74+
await page.getByRole("button", { name: "Continue" }).click();
75+
await expect(page).toHaveURL("/example-form/pizza-topping/");
76+
await expect(page.locator("main")).toHaveText(/There is a problem/);
6977
await page.getByLabel("Plain cheese").check();
7078
await page.getByRole("button", { name: "Continue" }).click();
7179
await expect(page).toHaveURL("/example-form/pizza-brand/");
@@ -81,18 +89,10 @@ test("page redirects - pizza path", async ({ page }) => {
8189
]);
8290

8391
await page.goto("/example-form/address/");
84-
await checkPageRedirections(page, [
85-
["/example-form/", "/example-form/pizza-or-chocolate/"],
86-
["/example-form/pizza-or-chocolate/"],
87-
["/example-form/neither/"],
88-
["/example-form/pizza-topping/"],
89-
["/example-form/pizza-brand/"],
90-
["/example-form/address/"],
91-
["/example-form/type-of-chocolate/", "/example-form/pizza-or-chocolate/"],
92-
["/example-form/final-page/", "/example-form/address/"],
93-
]);
94-
95-
await page.goto("/example-form/address/");
92+
await expect(page.locator("main")).not.toHaveText(/There is a problem/);
93+
await page.getByRole("button", { name: "Continue" }).click();
94+
await expect(page).toHaveURL("/example-form/address/");
95+
await expect(page.locator("main")).toHaveText(/There is a problem/);
9696
await page.getByLabel("Address line 1").fill("123 Main St");
9797
await page.getByLabel("Town or city").fill("Testville");
9898
await page.getByLabel("Postcode").fill("SW1A 1AA");
@@ -112,6 +112,10 @@ test("page redirects - pizza path", async ({ page }) => {
112112

113113
test("page redirects - chocolate path", async ({ page }) => {
114114
await page.goto("/example-form/pizza-or-chocolate/");
115+
await expect(page.locator("main")).not.toHaveText(/There is a problem/);
116+
await page.getByRole("button", { name: "Continue" }).click();
117+
await expect(page).toHaveURL("/example-form/pizza-or-chocolate/");
118+
await expect(page.locator("main")).toHaveText(/There is a problem/);
115119
await page.getByLabel("Chocolate").check();
116120
await page.getByRole("button", { name: "Continue" }).click();
117121
await expect(page).toHaveURL("/example-form/type-of-chocolate/");
@@ -127,6 +131,10 @@ test("page redirects - chocolate path", async ({ page }) => {
127131
]);
128132

129133
await page.goto("/example-form/type-of-chocolate/");
134+
await expect(page.locator("main")).not.toHaveText(/There is a problem/);
135+
await page.getByRole("button", { name: "Continue" }).click();
136+
await expect(page).toHaveURL("/example-form/type-of-chocolate/");
137+
await expect(page.locator("main")).toHaveText(/There is a problem/);
130138
await page.getByLabel("White chocolate").check();
131139
await page.getByRole("button", { name: "Continue" }).click();
132140
await expect(page).toHaveURL("/example-form/address/");
@@ -142,6 +150,10 @@ test("page redirects - chocolate path", async ({ page }) => {
142150
]);
143151

144152
await page.goto("/example-form/address/");
153+
await expect(page.locator("main")).not.toHaveText(/There is a problem/);
154+
await page.getByRole("button", { name: "Continue" }).click();
155+
await expect(page).toHaveURL("/example-form/address/");
156+
await expect(page.locator("main")).toHaveText(/There is a problem/);
145157
await page.getByLabel("Address line 1").fill("123 Main St");
146158
await page.getByLabel("Town or city").fill("Testville");
147159
await page.getByLabel("Postcode").fill("SW1A 1AA");

0 commit comments

Comments
 (0)