|
1 | | -import { test } from "@playwright/test" |
2 | | -import { assert } from "chai" |
3 | | -import { nextBody, pathname, visitAction } from "../helpers/page" |
| 1 | +import { expect, test } from "@playwright/test" |
| 2 | +import { visitAction, withPathname } from "../helpers/page" |
4 | 3 |
|
5 | 4 | test("visiting a location inside the root", async ({ page }) => { |
6 | | - page.goto("/src/tests/fixtures/root/index.html") |
7 | | - page.click("#link-page-inside") |
8 | | - await nextBody(page) |
9 | | - assert.equal(pathname(page.url()), "/src/tests/fixtures/root/page.html") |
10 | | - assert.notEqual(await visitAction(page), "load") |
| 5 | + await page.goto("/src/tests/fixtures/root/index.html") |
| 6 | + await page.click("#link-page-inside") |
| 7 | + |
| 8 | + await expect(page).toHaveURL(withPathname("/src/tests/fixtures/root/page.html")) |
| 9 | + expect(await visitAction(page)).not.toEqual("load") |
11 | 10 | }) |
12 | 11 |
|
13 | 12 | test("visiting the root itself", async ({ page }) => { |
14 | | - page.goto("/src/tests/fixtures/root/page.html") |
15 | | - page.click("#link-root") |
16 | | - await nextBody(page) |
17 | | - assert.equal(pathname(page.url()), "/src/tests/fixtures/root/") |
18 | | - assert.notEqual(await visitAction(page), "load") |
| 13 | + await page.goto("/src/tests/fixtures/root/page.html") |
| 14 | + await page.click("#link-root") |
| 15 | + |
| 16 | + await expect(page).toHaveURL(withPathname("/src/tests/fixtures/root/")) |
| 17 | + expect(await visitAction(page)).not.toEqual("load") |
19 | 18 | }) |
20 | 19 |
|
21 | 20 | test("visiting a location outside the root", async ({ page }) => { |
22 | | - page.goto("/src/tests/fixtures/root/index.html") |
23 | | - page.click("#link-page-outside") |
24 | | - await nextBody(page) |
25 | | - assert.equal(pathname(page.url()), "/src/tests/fixtures/one.html") |
26 | | - assert.equal(await visitAction(page), "load") |
| 21 | + await page.goto("/src/tests/fixtures/root/index.html") |
| 22 | + await page.click("#link-page-outside") |
| 23 | + |
| 24 | + await expect(page).toHaveURL(withPathname("/src/tests/fixtures/one.html")) |
| 25 | + expect(await visitAction(page)).toEqual("load") |
27 | 26 | }) |
28 | 27 |
|
29 | 28 | test("visiting a location outside the root having the root as a prefix", async ({ page }) => { |
30 | | - page.goto("/src/tests/fixtures/root/index.html") |
31 | | - page.click("#link-page-outside-prefix") |
32 | | - await nextBody(page) |
33 | | - assert.equal(pathname(page.url()), "/src/tests/fixtures/rootlet.html") |
34 | | - assert.equal(await visitAction(page), "load") |
| 29 | + await page.goto("/src/tests/fixtures/root/index.html") |
| 30 | + await page.click("#link-page-outside-prefix") |
| 31 | + |
| 32 | + await expect(page).toHaveURL(withPathname("/src/tests/fixtures/rootlet.html")) |
| 33 | + expect(await visitAction(page)).toEqual("load") |
35 | 34 | }) |
0 commit comments