Skip to content

Commit 8796cfc

Browse files
committed
test: implement some E2E tests
1 parent 59ab423 commit 8796cfc

File tree

46 files changed

+163
-21
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+163
-21
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import test, { expect } from "@playwright/test";
2+
3+
test(`should change code, then highlight code and AST nodes matching ESQuery selector`, async ({
4+
page,
5+
}) => {
6+
await page.goto("/");
7+
8+
// focus code editor textbox
9+
await page
10+
.getByRole("region", { name: "Code Editor" })
11+
.getByRole("textbox")
12+
.nth(1)
13+
.click();
14+
15+
// delete the default code
16+
await page.keyboard.press("Control+KeyA");
17+
await page.keyboard.press("Backspace");
18+
19+
// add new code
20+
await page.keyboard.type("console.log('Hello, World!');");
21+
22+
// add an ESQuery selector
23+
await page.getByRole("textbox", { name: "ESQuery Selector" }).click();
24+
await page.keyboard.type("CallExpression");
25+
26+
// wait for the debounced update of the AST to happen
27+
await expect(
28+
page
29+
.getByRole("listitem")
30+
.filter({ hasText: "end" })
31+
.filter({ hasText: "29" }),
32+
).toBeVisible();
33+
34+
// expand AST nodes for ExpressionStatement and CallExpression
35+
await page
36+
.getByRole("region", { name: "Program" })
37+
.getByRole("listitem")
38+
.filter({ hasText: "Array" })
39+
.getByRole("button", { name: "Toggle Property" })
40+
.click();
41+
await page.getByRole("button", { name: "ExpressionStatement" }).click();
42+
await page
43+
.getByRole("region", { name: "ExpressionStatement" })
44+
.getByLabel("Toggle Property")
45+
.click();
46+
await page.getByRole("button", { name: "CallExpression" }).click();
47+
48+
// screenshot
49+
await expect(page).toHaveScreenshot();
50+
});

e2e-tests/light-dark-theme.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { test, expect } from "@playwright/test";
2+
3+
test("should show light theme by default and switch to dark theme", async ({
4+
page,
5+
}) => {
6+
await page.goto("/");
7+
8+
await expect(page).toHaveScreenshot("light-theme.png");
9+
10+
await page.getByRole("button", { name: "Toggle theme" }).click();
11+
await page.getByRole("menuitem", { name: "Dark" }).click();
12+
13+
await expect(page).toHaveScreenshot("dark-theme.png");
14+
});
82.4 KB
120 KB
100 KB
85.2 KB
121 KB

0 commit comments

Comments
 (0)