Skip to content

Commit

Permalink
fix: fix playground and add playwright test
Browse files Browse the repository at this point in the history
  • Loading branch information
benfdking committed Dec 15, 2024
1 parent a0ffd3a commit 98e38af
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 19 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions editors/code/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
out
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
1 change: 1 addition & 0 deletions playground/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test-results
6 changes: 4 additions & 2 deletions playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {
Expand Down
26 changes: 26 additions & 0 deletions playground/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -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,
},
});
10 changes: 10 additions & 0 deletions playground/tests/main.spec.ts
Original file line number Diff line number Diff line change
@@ -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 <h1>Vite + React</h1>
await page.getByRole("link", { name: "quary Quary" }).isVisible();
});
65 changes: 49 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 98e38af

Please sign in to comment.