Skip to content

Commit 2e1eeb9

Browse files
committed
test: setup E2E tests
1 parent da3e1e5 commit 2e1eeb9

File tree

52 files changed

+390
-19
lines changed

Some content is hidden

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

52 files changed

+390
-19
lines changed

.github/workflows/ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,33 @@ jobs:
4848
- name: Check formatting of everything (prettier)
4949
run: |
5050
npm run fmt
51+
52+
e2e-test:
53+
name: E2E Tests (Playwright)
54+
timeout-minutes: 60
55+
# run only if triggered by push on a branch or by a PR event for a PR which is not a draft
56+
if: ${{ !github.event.pull_request || github.event.pull_request.draft == false }}
57+
runs-on: ubuntu-24.04
58+
steps:
59+
- uses: actions/checkout@v4
60+
61+
- name: Install Node.js
62+
uses: actions/setup-node@v4
63+
with:
64+
node-version-file: ".nvmrc"
65+
cache: npm
66+
67+
- name: Install dependencies
68+
run: |
69+
npm ci
70+
71+
- name: Run Playwright tests
72+
run: |
73+
npm run test:e2e
74+
75+
- uses: actions/upload-artifact@v4
76+
if: ${{ !cancelled() }}
77+
with:
78+
name: playwright-report
79+
path: playwright-report/
80+
retention-days: 30

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,9 @@ next-env.d.ts
5858
npm-debug.log*
5959
yarn-debug.log*
6060
yarn-error.log*
61+
62+
# Playwright
63+
/test-results/
64+
/playwright-report/
65+
/blob-report/
66+
/playwright/.cache/

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ To install and set up the project, follow these steps:
1313
1. Ensure you have Node.js v20 installed. You can download it from the [official Node.js website](https://nodejs.org/).
1414
2. Clone the repository to your local machine.
1515
3. Install the project dependencies using npm - `npm install`.
16+
4. Setup Docker to run E2E tests via Playwright ([Docker Desktop](https://www.docker.com/products/docker-desktop/) or [Docker Engine](https://docs.docker.com/engine/install/)).
1617

1718
This will install all the necessary packages and dependencies required to run the project.
1819

@@ -28,6 +29,7 @@ Open [http://localhost:5173](http://localhost:5173) with your browser to see the
2829

2930
- `npm run start`: Starts the development server.
3031
- `npm run build`: Builds the app for production.
32+
- `npm run test:e2e:update`: Runs all End-to-End tests and updates the screenshots/snapshots.
3133

3234
## Configuration
3335

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

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Tests for theme switching functionality.
3+
*/
4+
5+
import { test, expect } from "@playwright/test";
6+
7+
/**
8+
* This test verifies that:
9+
* - The application shows light theme by default
10+
* - Users can toggle between light and dark themes
11+
* - Theme changes are visually reflected in the UI
12+
*/
13+
test("should show light theme by default and switch to dark theme", async ({
14+
page,
15+
}) => {
16+
await page.goto("/");
17+
18+
await expect(page).toHaveScreenshot("light-theme.png");
19+
20+
await page.getByRole("button", { name: "Toggle theme" }).click();
21+
await page.getByRole("menuitem", { name: "Dark" }).click();
22+
23+
await expect(page).toHaveScreenshot("dark-theme.png");
24+
});
82.4 KB
Loading
120 KB
Loading

0 commit comments

Comments
 (0)