-
Notifications
You must be signed in to change notification settings - Fork 2
/
redirect.spec.js
46 lines (41 loc) · 1.48 KB
/
redirect.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
const { test, expect } = require("@playwright/test")
test.describe("Redirection", () => {
test("Should verify each redirection", async ({ page }) => {
await page.goto("apps/redirect/")
await expect(page.locator("text=Start Redirection chain")).toBeVisible()
// 1st redirection
const firstRedirectPromise = page.waitForResponse((response) =>
response.url().includes("second")
)
// 2nd redirection
const secondRedirectPromise = page.waitForResponse((response) =>
response.url().includes("third")
)
// 3rd redirection
const thirdRedirectPromise = page.waitForResponse((response) =>
response.url().includes("fourth")
)
// 4th redirection
const fourthRedirectPromise = page.waitForResponse((response) =>
response.url().includes("fifth")
)
// 5th redirection
const fifthRedirectPromise = page.waitForResponse((response) =>
response.url().includes("sixth")
)
// 6th redirection
const lastRedirectPromise = page.waitForResponse((response) =>
response.url().includes("last")
)
await page.locator("#redirect").click() // Start redirects
// Wait for the redirects to complete
await firstRedirectPromise
await secondRedirectPromise
await thirdRedirectPromise
await fourthRedirectPromise
await fifthRedirectPromise
await lastRedirectPromise
// Verifies that the landing page is open
await expect(page.locator("#info")).toHaveText("Welcome to the Last Page")
})
})