From 934e73e44180428bf77cface43f51cc90d94eee4 Mon Sep 17 00:00:00 2001 From: Pixel998 Date: Wed, 8 Apr 2026 05:38:22 +0300 Subject: [PATCH] fix: update @playwright/test to 1.59.1 and fix e2e tests --- .../code-editing-and-ast-interaction.test.ts | 31 +++++-------------- e2e-tests/helpers/code-editor.ts | 14 +++++++++ e2e-tests/persistence.test.ts | 25 +++++---------- package-lock.json | 24 +++++++------- package.json | 2 +- 5 files changed, 41 insertions(+), 55 deletions(-) create mode 100644 e2e-tests/helpers/code-editor.ts diff --git a/e2e-tests/code-editing-and-ast-interaction.test.ts b/e2e-tests/code-editing-and-ast-interaction.test.ts index ef03cde..0e5538f 100644 --- a/e2e-tests/code-editing-and-ast-interaction.test.ts +++ b/e2e-tests/code-editing-and-ast-interaction.test.ts @@ -2,6 +2,7 @@ * Tests for code editing functionality and AST tool interaction. */ import { expect, test } from "@playwright/test"; +import { getCodeEditor, replaceCodeEditorValue } from "./helpers/code-editor"; type HighlightSamplesState = { intervalId: number; @@ -26,19 +27,7 @@ test(`should change code, then highlight code and AST nodes matching ESQuery sel }) => { 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!');"); + await replaceCodeEditorValue(page, "console.log('Hello, World!');"); // add an ESQuery selector await page.getByRole("textbox", { name: "ESQuery Selector" }).click(); @@ -73,22 +62,16 @@ test(`should keep ESQuery highlights aligned while typing before a matching lite }) => { await page.goto("/"); - const codeEditor = page - .getByRole("region", { name: "Code Editor Panel" }) - .getByRole("textbox") - .nth(1); - const highlight = page.locator(".bg-editorHighlightedRangeColor"); + const codeEditor = getCodeEditor(page); + const highlight = codeEditor.locator(".bg-editorHighlightedRangeColor"); - await codeEditor.click(); - await codeEditor.press("ControlOrMeta+KeyA"); - await codeEditor.press("Backspace"); - await codeEditor.pressSequentially("42;"); + await replaceCodeEditorValue(page, "42;"); await page .getByRole("textbox", { name: "ESQuery Selector" }) .fill("Literal"); - await expect(highlight).toHaveText("42"); + await expect(highlight).toHaveText(["42"]); await codeEditor.click(); await codeEditor.press("Home"); @@ -125,5 +108,5 @@ test(`should keep ESQuery highlights aligned while typing before a matching lite expect( highlightSamples.every(highlightText => highlightText === "42"), ).toBe(true); - await expect(highlight).toHaveText("42"); + await expect(highlight).toHaveText(["42"]); }); diff --git a/e2e-tests/helpers/code-editor.ts b/e2e-tests/helpers/code-editor.ts new file mode 100644 index 0000000..50884d5 --- /dev/null +++ b/e2e-tests/helpers/code-editor.ts @@ -0,0 +1,14 @@ +import type { Page } from "@playwright/test"; + +export function getCodeEditor(page: Page) { + return page + .getByRole("region", { name: "Code Editor Panel" }) + .getByRole("textbox") + .last(); +} + +export async function replaceCodeEditorValue(page: Page, value: string) { + const codeEditor = getCodeEditor(page); + + await codeEditor.fill(value); +} diff --git a/e2e-tests/persistence.test.ts b/e2e-tests/persistence.test.ts index 32e3d6d..7351037 100644 --- a/e2e-tests/persistence.test.ts +++ b/e2e-tests/persistence.test.ts @@ -1,4 +1,5 @@ import { expect, test, type Page } from "@playwright/test"; +import { getCodeEditor, replaceCodeEditorValue } from "./helpers/code-editor"; const storageKey = "eslint-explorer"; @@ -35,18 +36,6 @@ async function getStoredHashValue(page: Page): Promise { }, storageKey); } -async function replaceEditorValue(page: Page, value: string) { - const codeEditor = page - .getByRole("region", { name: "Code Editor Panel" }) - .getByRole("textbox") - .nth(1); - - await codeEditor.click(); - await codeEditor.press("ControlOrMeta+KeyA"); - await codeEditor.press("Backspace"); - await codeEditor.pressSequentially(value); -} - test("should persist unicode code safely in the URL hash", async ({ page }) => { await page.addInitScript(key => { window.localStorage.removeItem(key); @@ -55,7 +44,7 @@ test("should persist unicode code safely in the URL hash", async ({ page }) => { const unicodeCode = 'const \u03C0 = "\u{1F600}";'; - await replaceEditorValue(page, unicodeCode); + await replaceCodeEditorValue(page, unicodeCode); await expect.poll(() => getPersistedJavaScriptCode(page)).toBe(unicodeCode); await expect.poll(() => getStoredHashValue(page)).toContain("v2."); @@ -67,7 +56,7 @@ test("should persist unicode code safely in the URL hash", async ({ page }) => { }, storageKey); await page.goto(`/${persistedHash}`); - await expect(page.locator(".cm-content")).toContainText(unicodeCode); + await expect(getCodeEditor(page)).toContainText(unicodeCode); }); test("should still load state from legacy hash links", async ({ page }) => { @@ -78,7 +67,7 @@ test("should still load state from legacy hash links", async ({ page }) => { const legacyCode = "console.log('legacy hash');"; - await replaceEditorValue(page, legacyCode); + await replaceCodeEditorValue(page, legacyCode); await expect.poll(() => getPersistedJavaScriptCode(page)).toBe(legacyCode); @@ -98,7 +87,7 @@ test("should still load state from legacy hash links", async ({ page }) => { }, storageKey); await page.goto(`/#${legacyHash}`); - await expect(page.locator(".cm-content")).toContainText(legacyCode); + await expect(getCodeEditor(page)).toContainText(legacyCode); }); test("should fall back to localStorage when a v2 hash is malformed", async ({ @@ -111,7 +100,7 @@ test("should fall back to localStorage when a v2 hash is malformed", async ({ const fallbackCode = "console.log('localStorage fallback');"; - await replaceEditorValue(page, fallbackCode); + await replaceCodeEditorValue(page, fallbackCode); await expect .poll(() => getPersistedJavaScriptCode(page)) @@ -145,5 +134,5 @@ test("should fall back to localStorage when a v2 hash is malformed", async ({ ); await page.goto(`/#${malformedHash}`); - await expect(page.locator(".cm-content")).toContainText(fallbackCode); + await expect(getCodeEditor(page)).toContainText(fallbackCode); }); diff --git a/package-lock.json b/package-lock.json index 451da5a..c829d6c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -50,7 +50,7 @@ "devDependencies": { "@babel/core": "^7.29.0", "@eslint/core": "^0.17.0", - "@playwright/test": "^1.58.2", + "@playwright/test": "^1.59.1", "@rolldown/plugin-babel": "^0.2.2", "@types/eslint-scope": "^8.4.0", "@types/espree": "^10.1.0", @@ -1678,13 +1678,13 @@ } }, "node_modules/@playwright/test": { - "version": "1.58.2", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.58.2.tgz", - "integrity": "sha512-akea+6bHYBBfA9uQqSYmlJXn61cTa+jbO87xVLCWbTqbWadRVmhxlXATaOjOgcBaWU4ePo0wB41KMFv3o35IXA==", + "version": "1.59.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.59.1.tgz", + "integrity": "sha512-PG6q63nQg5c9rIi4/Z5lR5IVF7yU5MqmKaPOe0HSc0O2cX1fPi96sUQu5j7eo4gKCkB2AnNGoWt7y4/Xx3Kcqg==", "dev": true, "license": "Apache-2.0", "dependencies": { - "playwright": "1.58.2" + "playwright": "1.59.1" }, "bin": { "playwright": "cli.js" @@ -8448,13 +8448,13 @@ } }, "node_modules/playwright": { - "version": "1.58.2", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.58.2.tgz", - "integrity": "sha512-vA30H8Nvkq/cPBnNw4Q8TWz1EJyqgpuinBcHET0YVJVFldr8JDNiU9LaWAE1KqSkRYazuaBhTpB5ZzShOezQ6A==", + "version": "1.59.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.59.1.tgz", + "integrity": "sha512-C8oWjPR3F81yljW9o5OxcWzfh6avkVwDD2VYdwIGqTkl+OGFISgypqzfu7dOe4QNLL2aqcWBmI3PMtLIK233lw==", "dev": true, "license": "Apache-2.0", "dependencies": { - "playwright-core": "1.58.2" + "playwright-core": "1.59.1" }, "bin": { "playwright": "cli.js" @@ -8467,9 +8467,9 @@ } }, "node_modules/playwright-core": { - "version": "1.58.2", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.58.2.tgz", - "integrity": "sha512-yZkEtftgwS8CsfYo7nm0KE8jsvm6i/PTgVtB8DL726wNf6H2IMsDuxCpJj59KDaxCtSnrWan2AeDqM7JBaultg==", + "version": "1.59.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.59.1.tgz", + "integrity": "sha512-HBV/RJg81z5BiiZ9yPzIiClYV/QMsDCKUyogwH9p3MCP6IYjUFu/MActgYAvK0oWyV9NlwM3GLBjADyWgydVyg==", "dev": true, "license": "Apache-2.0", "bin": { diff --git a/package.json b/package.json index 3b79d39..8a30f26 100644 --- a/package.json +++ b/package.json @@ -74,7 +74,7 @@ "devDependencies": { "@babel/core": "^7.29.0", "@eslint/core": "^0.17.0", - "@playwright/test": "^1.58.2", + "@playwright/test": "^1.59.1", "@rolldown/plugin-babel": "^0.2.2", "@types/eslint-scope": "^8.4.0", "@types/espree": "^10.1.0",