forked from eslint/code-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode-editing-and-ast-interaction.test.ts
More file actions
58 lines (51 loc) · 1.64 KB
/
code-editing-and-ast-interaction.test.ts
File metadata and controls
58 lines (51 loc) · 1.64 KB
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
/**
* Tests for code editing functionality and AST tool interaction.
*/
import test, { expect } from "@playwright/test";
/**
* This test verifies that:
* - Users can edit code in the editor
* - The AST updates in response to code changes
* - ESQuery selectors correctly highlight matching code and AST nodes
* - AST node expansion functionality works properly
*/
test(`should change code, then highlight code and AST nodes matching ESQuery selector`, async ({
page,
}) => {
await page.goto("/");
// focus code editor textbox
await page
.getByRole("region", { name: "Code Editor Panel" })
.getByRole("textbox")
.nth(1)
.click();
// delete the default code
await page.keyboard.press("ControlOrMeta+KeyA");
await page.keyboard.press("Backspace");
// add new code
await page.keyboard.type("console.log('Hello, World!');");
// add an ESQuery selector
await page.getByRole("textbox", { name: "ESQuery Selector" }).click();
await page.keyboard.type("CallExpression");
// wait for the debounced update of the AST to happen
await expect(
page
.getByRole("listitem")
.filter({ hasText: "end" })
.filter({ hasText: "29" }),
).toBeVisible();
// expand AST nodes for ExpressionStatement and CallExpression
await page
.getByRole("region", { name: "Program" })
.getByRole("listitem")
.filter({ hasText: "bodyArray[1 element]" })
.getByLabel("Toggle Property")
.click();
await page.getByRole("button", { name: "ExpressionStatement" }).click();
await page
.getByRole("region", { name: "Program" })
.getByRole("listitem")
.filter({ hasText: "expressionCallExpression{type" })
.getByLabel("Toggle Property")
.click();
});