forked from QwikDev/qwik
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe2e.streaming.spec.ts
67 lines (57 loc) · 2 KB
/
e2e.streaming.spec.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { test, expect } from "@playwright/test";
test.describe("streaming", () => {
test.beforeEach(async ({ page }) => {
await page.goto("/e2e/streaming", {
waitUntil: "domcontentloaded",
});
page.on("console", (msg) => {
if (msg.type() === "error") {
expect(msg.text()).toEqual(undefined);
}
});
page.on("pageerror", (err) => expect(err).toEqual(undefined));
page.on("console", (msg) => {
if (msg.type() === "error") {
expect(msg.text()).toEqual(undefined);
}
});
});
test("should render correctly", async ({ page }) => {
const ul = page.locator("ul > li");
const ol = page.locator("ol > li");
const cmps = page.locator(".cmp");
await expect(ul).toHaveCount(5);
await expect(ol).toHaveCount(10);
await expect(cmps).toHaveCount(5);
});
test("should rerender correctly", async ({ page }) => {
const ul = page.locator("ul > li");
const ol = page.locator("ol > li");
const cmps = page.locator(".cmp");
const count = page.locator("button#count");
await count.click();
await expect(count).toHaveText("Rerender: 1");
await expect(ul).toHaveCount(5);
await expect(ol).toHaveCount(10);
await expect(cmps).toHaveCount(5);
});
test("should render in client correctly", async ({ page }) => {
const ul = page.locator("ul > li");
const ol = page.locator("ol > li");
const cmps = page.locator(".cmp");
const count = page.locator("button#count");
const rerender = page.locator("button#client-render");
await count.click();
await expect(count).toHaveText("Rerender: 1");
await rerender.click();
expect(rerender).toHaveText("Client rerender: 1");
await expect(count).toHaveText("Rerender: 0");
await count.click();
await expect(count).toHaveText("Rerender: 1");
await expect(ul).toHaveCount(0);
await expect(ol).toHaveCount(0);
await expect(cmps).toHaveCount(5);
await count.click();
await expect(count).toHaveText("Rerender: 2");
});
});