-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbasic.test.ts
49 lines (44 loc) · 1.64 KB
/
basic.test.ts
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
47
48
49
import { type Page, expect, test } from "@playwright/test";
import { testNoJs, waitForHydration } from "./helper";
test("basic @js", async ({ page }) => {
await page.goto("/");
await waitForHydration(page);
await page.getByRole("heading", { name: "Vue Server Component" }).click();
await page.getByText("typeof window = undefined").click();
await page.getByText("Count: 0").click();
await page.getByRole("button", { name: "+" }).click();
await page.getByText("Count: 1").click();
await page.getByRole("button", { name: "-" }).click();
await page.getByText("Count: 0").click();
});
testNoJs("basic @nojs", async ({ page }) => {
await page.goto("/");
await page.getByRole("heading", { name: "Vue Server Component" }).click();
await page.getByText("typeof window = undefined").click();
await page.getByText("Count: 0").click();
});
test("navigation @js", async ({ page }) => {
await page.goto("/");
await waitForHydration(page);
await testNavigation(page, { js: true });
});
testNoJs("navigation @nojs", async ({ page }) => {
await page.goto("/");
await testNavigation(page, { js: false });
});
async function testNavigation(page: Page, options: { js: boolean }) {
await page.getByPlaceholder("(test)").fill("hello");
await page.getByRole("link", { name: "SFC" }).click();
await page.waitForURL("/sfc");
await page.getByRole("heading", { name: "Server SFC" }).click();
await page.getByRole("button", { name: "client counter 0" }).first().click();
if (options.js) {
await page
.getByRole("button", { name: "client counter 1" })
.first()
.click();
}
await expect(page.getByPlaceholder("(test)")).toHaveValue(
options.js ? "hello" : "",
);
}