diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index 0dec63b4..5e70a476 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -58,6 +58,8 @@ jobs: typescript: name: TypeScript runs-on: ubuntu-latest + env: + PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: false steps: - uses: actions/checkout@v4 - uses: Swatinem/rust-cache@v2 @@ -74,6 +76,7 @@ jobs: - run: pnpm install --frozen-lockfile - uses: dtolnay/rust-toolchain@nightly - run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + - run: cd playground && pnpm playwright install - run: pnpm run ci test: name: Test diff --git a/editors/code/.gitignore b/editors/code/.gitignore new file mode 100644 index 00000000..c585e193 --- /dev/null +++ b/editors/code/.gitignore @@ -0,0 +1 @@ +out \ No newline at end of file diff --git a/package.json b/package.json index d5ad0478..a82d63be 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,9 @@ "prettier": "^3.4.2" }, "scripts": { - "ci": "pnpm run fmt:check && pnpm run lint && pnpm run build", + "ci": "pnpm run fmt:check && pnpm run lint && pnpm run build && pnpm run test", "lint": "pnpm run -r lint", + "test": "pnpm run -r --filter playground test", "build": "pnpm run -r --filter=playground build && pnpm run -r --filter=editors build", "fmt": "prettier --cache -w editors playground README.md .github/**/*.{yaml,yml}", "fmt:check": "prettier --cache --check editors playground README.md .github/**/*.{yaml,yml}" diff --git a/playground/.gitignore b/playground/.gitignore new file mode 100644 index 00000000..5b8b3b6f --- /dev/null +++ b/playground/.gitignore @@ -0,0 +1 @@ +test-results \ No newline at end of file diff --git a/playground/package.json b/playground/package.json index e4f1ce7e..e19d5b7b 100644 --- a/playground/package.json +++ b/playground/package.json @@ -6,10 +6,12 @@ "build": "pnpm run build:wasm && vite build", "dev": "vite", "dev:wasm": "wasm-pack build ../crates/lib-wasm --dev --target web --out-dir ../../playground/src/pkg", - "lint": "eslint src --max-warnings 0" + "lint": "eslint src --max-warnings 0", + "test": "playwright test" }, "dependencies": { "@monaco-editor/react": "^4.6.0", + "@playwright/test": "^1.49.1", "@typescript-eslint/eslint-plugin": "^8.17.0", "@typescript-eslint/parser": "^8.17.0", "classnames": "^2.5.1", @@ -21,7 +23,7 @@ "eslint-plugin-react-hooks": "^5.1.0", "monaco-editor": "^0.52.0", "react": "^18.3.1", - "react-dom": "^19.0.0", + "react-dom": "^18.3.1", "react-resizable-panels": "^2.1.7" }, "devDependencies": { diff --git a/playground/playwright.config.ts b/playground/playwright.config.ts new file mode 100644 index 00000000..9f8b3854 --- /dev/null +++ b/playground/playwright.config.ts @@ -0,0 +1,26 @@ +import { defineConfig, devices } from "@playwright/test"; + +export default defineConfig({ + testDir: "./tests", // directory where your tests will be located + timeout: 30_000, + expect: { + timeout: 5_000, + }, + // Run tests in headless browsers by default + use: { + headless: true, + }, + // Configure projects for different browsers if desired + projects: [ + { + name: "chromium", + use: { ...devices["Desktop Chrome"] }, + }, + ], + // Automatically start Vite dev server + webServer: { + command: "pnpm run dev", + url: "http://localhost:5173", // Vite default port + reuseExistingServer: !process.env.CI, + }, +}); diff --git a/playground/tests/main.spec.ts b/playground/tests/main.spec.ts new file mode 100644 index 00000000..a2acec57 --- /dev/null +++ b/playground/tests/main.spec.ts @@ -0,0 +1,10 @@ +import { test, expect } from "@playwright/test"; + +test("home page opens", async ({ page }) => { + // Navigate to the home page + await page.goto("http://localhost:5173"); + + // Check if the main heading or any expected element is visible + // For a React app created by Vite + React template, the initial content often includes

Vite + React

+ await page.getByRole("link", { name: "quary Quary" }).isVisible(); +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 3360cbf3..0f4cc83b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -77,7 +77,10 @@ importers: dependencies: '@monaco-editor/react': specifier: ^4.6.0 - version: 4.6.0(monaco-editor@0.52.0)(react-dom@19.0.0(react@18.3.1))(react@18.3.1) + version: 4.6.0(monaco-editor@0.52.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + '@playwright/test': + specifier: ^1.49.1 + version: 1.49.1 '@typescript-eslint/eslint-plugin': specifier: ^8.17.0 version: 8.17.0(@typescript-eslint/parser@8.17.0(eslint@9.16.0(jiti@2.0.0))(typescript@5.7.2))(eslint@9.16.0(jiti@2.0.0))(typescript@5.7.2) @@ -112,11 +115,11 @@ importers: specifier: ^18.3.1 version: 18.3.1 react-dom: - specifier: ^19.0.0 - version: 19.0.0(react@18.3.1) + specifier: ^18.3.1 + version: 18.3.1(react@18.3.1) react-resizable-panels: specifier: ^2.1.7 - version: 2.1.7(react-dom@19.0.0(react@18.3.1))(react@18.3.1) + version: 2.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1) devDependencies: '@types/react': specifier: ^18.3.12 @@ -457,6 +460,11 @@ packages: resolution: {integrity: sha512-SnDBEmw0h4XpbHcWR8T0LgLj1Cqn8Cvql+Nahot2zBud945z+MYXH3WVPvMI5U37WsWAgw9Cj7pZ6oL7haKrhg==} engines: {node: '>=18'} + '@playwright/test@1.49.1': + resolution: {integrity: sha512-Ky+BVzPz8pL6PQxHqNRW1k3mIyv933LML7HktS8uik0bUXNCdPhoS/kLihiO1tMf/egaJb4IutXd7UywvXEW+g==} + engines: {node: '>=18'} + hasBin: true + '@rauschma/env-var@1.0.1': resolution: {integrity: sha512-pMSdCEdo9nM4B4HrjTVAbujzSRKB6OsLh4c/3mlYmGBM3HWy8SiU2D8YZJGG+LjO1KsHvogWxos0kHJacF2SYg==} hasBin: true @@ -2445,11 +2453,21 @@ packages: engines: {node: '>=18'} hasBin: true + playwright-core@1.49.1: + resolution: {integrity: sha512-BzmpVcs4kE2CH15rWfzpjzVGhWERJfmnXmniSyKeRZUs9Ws65m+RGIi7mjJK/euCegfn3i7jvqWeWyHe9y3Vgg==} + engines: {node: '>=18'} + hasBin: true + playwright@1.49.0: resolution: {integrity: sha512-eKpmys0UFDnfNb3vfsf8Vx2LEOtflgRebl0Im2eQQnYMA4Aqd+Zw8bEOB+7ZKvN76901mRnqdsiOGKxzVTbi7A==} engines: {node: '>=18'} hasBin: true + playwright@1.49.1: + resolution: {integrity: sha512-VYL8zLoNTBxVOrJBbDuRgDWa3i+mfQgDTrL8Ah9QXZ7ax4Dsj0MSq5bYgytRnDVVe+njoKnfsYkH3HzqVj5UZA==} + engines: {node: '>=18'} + hasBin: true + possible-typed-array-names@1.0.0: resolution: {integrity: sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q==} engines: {node: '>= 0.4'} @@ -2549,10 +2567,10 @@ packages: resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==} hasBin: true - react-dom@19.0.0: - resolution: {integrity: sha512-4GV5sHFG0e/0AD4X+ySy6UJd3jVl1iNsNHdpad0qhABJ11twS3TTBnseqsKurKcsNqCEFeGL3uLpVChpIO3QfQ==} + react-dom@18.3.1: + resolution: {integrity: sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==} peerDependencies: - react: ^19.0.0 + react: ^18.3.1 react-is@16.13.1: resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==} @@ -2653,8 +2671,8 @@ packages: sax@1.4.1: resolution: {integrity: sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg==} - scheduler@0.25.0: - resolution: {integrity: sha512-xFVuu11jh+xcO7JOAGJNOXld8/TcEHK/4CituBUeUb5hqxJLj9YuemAEuvm9gQ/+pgXYfbQuqAkiYu+u7YEsNA==} + scheduler@0.23.2: + resolution: {integrity: sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==} semver@5.7.2: resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==} @@ -3438,12 +3456,12 @@ snapshots: monaco-editor: 0.52.0 state-local: 1.0.7 - '@monaco-editor/react@4.6.0(monaco-editor@0.52.0)(react-dom@19.0.0(react@18.3.1))(react@18.3.1)': + '@monaco-editor/react@4.6.0(monaco-editor@0.52.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': dependencies: '@monaco-editor/loader': 1.4.0(monaco-editor@0.52.0) monaco-editor: 0.52.0 react: 18.3.1 - react-dom: 19.0.0(react@18.3.1) + react-dom: 18.3.1(react@18.3.1) '@nodelib/fs.scandir@2.1.5': dependencies: @@ -3464,6 +3482,10 @@ snapshots: dependencies: playwright-core: 1.49.0 + '@playwright/test@1.49.1': + dependencies: + playwright: 1.49.1 + '@rauschma/env-var@1.0.1': {} '@rollup/rollup-android-arm-eabi@4.27.4': @@ -5723,12 +5745,20 @@ snapshots: playwright-core@1.49.0: {} + playwright-core@1.49.1: {} + playwright@1.49.0: dependencies: playwright-core: 1.49.0 optionalDependencies: fsevents: 2.3.2 + playwright@1.49.1: + dependencies: + playwright-core: 1.49.1 + optionalDependencies: + fsevents: 2.3.2 + possible-typed-array-names@1.0.0: {} postcss-import@15.1.0(postcss@8.4.49): @@ -5836,17 +5866,18 @@ snapshots: strip-json-comments: 2.0.1 optional: true - react-dom@19.0.0(react@18.3.1): + react-dom@18.3.1(react@18.3.1): dependencies: + loose-envify: 1.4.0 react: 18.3.1 - scheduler: 0.25.0 + scheduler: 0.23.2 react-is@16.13.1: {} - react-resizable-panels@2.1.7(react-dom@19.0.0(react@18.3.1))(react@18.3.1): + react-resizable-panels@2.1.7(react-dom@18.3.1(react@18.3.1))(react@18.3.1): dependencies: react: 18.3.1 - react-dom: 19.0.0(react@18.3.1) + react-dom: 18.3.1(react@18.3.1) react@18.3.1: dependencies: @@ -5980,7 +6011,9 @@ snapshots: sax@1.4.1: {} - scheduler@0.25.0: {} + scheduler@0.23.2: + dependencies: + loose-envify: 1.4.0 semver@5.7.2: {}