-
-
Notifications
You must be signed in to change notification settings - Fork 17
test: setup E2E testing via Playwright and implement some tests #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
69dca82
test: setup E2E tests
patricktree 0b349ae
ci: try to fix
patricktree 0240353
debug
patricktree 112e8a8
ci: try to fix
patricktree 0762f5b
check `process.env.CI` for value `"true"`
patricktree a4a3b79
Merge remote-tracking branch 'origin/main' into test/setup-e2e-test
patricktree c727b9b
chore: update CI.yml action versions
patricktree b9e5174
Update playwright.config.ts
patricktree 1a4b4df
refactor: remove Docker setup, remove screenshot assertions, update p…
patricktree f198d04
ci: fix
patricktree 0bf6453
Merge remote-tracking branch 'origin/main' into test/setup-e2e-test
patricktree df0b8fc
test: rename e2e specs to .test
patricktree 71379e2
test: cover HTML language option
patricktree a92bc90
test: simplify Playwright config
patricktree a79a850
chore: remove unused cross-env
patricktree ffab69f
ci: bump upload-artifact to v6
patricktree b1542cc
cleanup
patricktree d2729be
test: include HTML in language list
patricktree File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /** | ||
| * Tests for code editing functionality and AST tool interaction. | ||
| */ | ||
| import test, { expect } from "@playwright/test"; | ||
patricktree marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * 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(); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| /** | ||
| * Tests for theme switching functionality. | ||
| */ | ||
|
|
||
| import { test } from "@playwright/test"; | ||
|
|
||
| /** | ||
| * This test verifies that: | ||
| * - The application shows light theme by default | ||
| * - Users can toggle between light and dark themes | ||
| * - Theme changes are visually reflected in the UI | ||
| */ | ||
| test("should show light theme by default and switch to dark theme", async ({ | ||
| page, | ||
| }) => { | ||
| await page.goto("/"); | ||
|
|
||
| await page.getByRole("button", { name: "Toggle theme" }).click(); | ||
| await page.getByRole("menuitem", { name: "Dark" }).click(); | ||
| }); |
patricktree marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /** | ||
| * Tests for language selection and options panel functionality. | ||
| */ | ||
| import { test } from "@playwright/test"; | ||
|
|
||
| /** | ||
| * This test verifies that: | ||
| * - Users can open the language options popover | ||
| * - Users can switch between supported languages (JavaScript, JSON, Markdown, CSS, HTML) | ||
| * - For each language the entire page is correctly rendered | ||
| */ | ||
| test("should switch language and show options for each", async ({ page }) => { | ||
| await page.goto("/"); | ||
|
|
||
| await page.getByRole("button", { name: "Language Options" }).click(); | ||
|
|
||
| await page.getByRole("combobox", { name: "Language" }).click(); | ||
| await page.getByRole("option", { name: "JSON JSON" }).click(); | ||
|
|
||
| await page.getByRole("combobox", { name: "Language" }).click(); | ||
| await page.getByRole("option", { name: "Markdown Markdown" }).click(); | ||
|
|
||
| await page.getByRole("combobox", { name: "Language" }).click(); | ||
| await page.getByRole("option", { name: "CSS CSS" }).click(); | ||
|
|
||
| await page.getByRole("combobox", { name: "Language" }).click(); | ||
| await page.getByRole("option", { name: "HTML HTML" }).click(); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /** | ||
| * Tests for the Code Analysis Tools Panel. | ||
| */ | ||
| import { test } from "@playwright/test"; | ||
|
|
||
| /** | ||
| * This test verifies that: | ||
| * - Users can switch between different code analysis tools (AST, Scope, Code Path) | ||
| * - Each tool displays correctly | ||
| * - Tool-specific interactions work as expected (e.g. scope selection) | ||
| */ | ||
| test("should switch to each tool and show it", async ({ page }) => { | ||
| await page.goto("/"); | ||
|
|
||
| await page.getByRole("button", { name: "Scope" }).click(); | ||
| await page.getByRole("button", { name: "global" }).click(); | ||
| // move mouse away to avoid accordion hover state | ||
| await page.mouse.move(0, 0); | ||
|
|
||
| await page.getByRole("button", { name: "Code Path" }).click(); | ||
| }); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import os from "node:os"; | ||
|
|
||
| import { defineConfig, devices } from "@playwright/test"; | ||
|
|
||
| const countOfCpus = os.cpus().length; | ||
| const workers = countOfCpus | ||
| ? // utilize all logical processors up to a max of 4 to limit RAM usage | ||
| Math.min(countOfCpus, 4) | ||
| : undefined; | ||
|
|
||
| const isInCi = process.env.CI === "true"; | ||
|
|
||
| export default defineConfig({ | ||
| testDir: "./e2e-tests", | ||
| fullyParallel: true, | ||
| // fail a Playwright run in CI if some test.only is in the source code | ||
| forbidOnly: isInCi, | ||
| retries: isInCi ? 1 : 0, | ||
| workers, | ||
| reporter: isInCi ? [["html"], ["github"]] : "html", | ||
|
|
||
| use: { | ||
| baseURL: `http://localhost:5173`, | ||
|
|
||
| // ensure consistent timezone and locale | ||
| timezoneId: "America/Los_Angeles", | ||
| locale: "en-US", | ||
|
|
||
| // always capture trace and video (seems to not have significant performance impact) | ||
| trace: "on", | ||
| video: "on", | ||
| }, | ||
|
|
||
| projects: [ | ||
| { | ||
| name: "chromium", | ||
| use: { | ||
| ...devices["Desktop Chrome"], | ||
| // opt into "New Headless" chromium (https://playwright.dev/docs/browsers#chromium-new-headless-mode, https://developer.chrome.com/docs/chromium/headless) | ||
| channel: "chromium", | ||
| }, | ||
| }, | ||
| { | ||
| name: "firefox", | ||
| use: { ...devices["Desktop Firefox"] }, | ||
| }, | ||
| { | ||
| name: "webkit", | ||
| use: { ...devices["Desktop Safari"] }, | ||
| }, | ||
| ], | ||
|
|
||
| webServer: [ | ||
| { | ||
| command: "npm run start", | ||
| url: "http://localhost:5173", | ||
| reuseExistingServer: !isInCi, | ||
| }, | ||
| ], | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.