forked from QwikDev/qwik
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe2e.sync-qrl.spec.ts
31 lines (26 loc) · 987 Bytes
/
e2e.sync-qrl.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
import { test, expect } from "@playwright/test";
test.describe("resuming", () => {
test.beforeEach(async ({ page }) => {
await page.goto("/e2e/sync-qrl");
page.on("pageerror", (err) => expect(err).toEqual(undefined));
page.on("console", (msg) => {
if (msg.type() === "error") {
expect(msg.text()).toEqual(undefined);
}
});
});
test("should synchronously prevent default", async ({ page }) => {
const input = page.locator("#preventDefaultInput");
await expect(input).not.toBeChecked();
// clicking checkbox toggles the checked state.
await input.click();
await expect(input).toBeChecked();
await input.evaluate((el) =>
el.setAttribute("shouldPreventDefault", "true"),
);
// clicking checkbox does not toggles the checked state, because default is prevented.
await input.click();
await expect(input).toBeChecked();
await expect(await input.getAttribute("prevented")).toBeDefined();
});
});