From 469f68b25df25ccd7f20fa33da6eb75e70981a79 Mon Sep 17 00:00:00 2001 From: yiling Date: Fri, 3 Jul 2026 14:37:04 +0800 Subject: [PATCH 1/4] test(webui): add playwright e2e framework with video player play/pause test Add a Playwright UI integration test framework for the frame-accurate video player. Tests run against a backend-free harness served by Bun's native HTML bundler (matching the project's Bun-based dev/prod serving), so no database, auth or transcode pipeline is required. - Add @playwright/test with chromium/firefox/webkit projects; the browser is selectable via the Playwright --project flag (webkit = Safari engine). - Serve the harness with Bun.serve + bun-plugin-tailwind (no separate Vite toolchain); commit a deterministic 16x16/5s/30fps fixture video and matching AssetInfo. - Add a play/pause spec covering both the play control and clicking the video area, asserting the native video clock, seekbar fill and frame readout stay frame-locked after pause (settle-aware, tolerance-based assertions). - Mock all backend API calls (anchored /api/ and /files/ routes) for isolation. - Exclude e2e specs from Vitest; add a separate CI job (webkit on macOS). --- .github/workflows/ci.yaml | 41 +++++ .gitignore | 6 + bun.lock | 35 +++-- package.json | 6 + .../webui/components/viewers/progress-bar.tsx | 2 + .../webui/components/viewers/video-player.tsx | 13 +- packages/webui/e2e/fixtures/sample.mp4 | Bin 0 -> 6170 bytes packages/webui/e2e/harness/fixture.ts | 50 +++++++ packages/webui/e2e/harness/index.html | 13 ++ packages/webui/e2e/harness/main.tsx | 37 +++++ packages/webui/e2e/harness/serve.ts | 34 +++++ packages/webui/e2e/pages/video-player.page.ts | 139 +++++++++++++++++ packages/webui/e2e/tests/play-pause.spec.ts | 141 ++++++++++++++++++ playwright.config.ts | 57 +++++++ vitest.config.ts | 5 +- 15 files changed, 563 insertions(+), 16 deletions(-) create mode 100644 packages/webui/e2e/fixtures/sample.mp4 create mode 100644 packages/webui/e2e/harness/fixture.ts create mode 100644 packages/webui/e2e/harness/index.html create mode 100644 packages/webui/e2e/harness/main.tsx create mode 100644 packages/webui/e2e/harness/serve.ts create mode 100644 packages/webui/e2e/pages/video-player.page.ts create mode 100644 packages/webui/e2e/tests/play-pause.spec.ts create mode 100644 playwright.config.ts diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4f3aff9b..24111478 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -55,3 +55,44 @@ jobs: echo "Smoke testing shumai-transcode..." bun run /tmp/shumai-local-release/node/node_modules/@shumai-one/shumai-transcode/bin/shumai-transcode-app.js --check + + e2e_video_player: + name: E2E (${{ matrix.project }}) + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + project: chromium + - os: ubuntu-latest + project: firefox + # WebKit is the Safari engine; run it on a macOS runner to validate + # Safari compatibility. + - os: macos-latest + project: webkit + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Bun + uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + + - name: Install dependencies + run: bun install + + - name: Install Playwright browser (${{ matrix.project }}) + run: bunx playwright install --with-deps ${{ matrix.project }} + + - name: Run video player e2e tests + run: bun run test:e2e --project=${{ matrix.project }} + + - name: Upload Playwright report + if: ${{ !cancelled() }} + uses: actions/upload-artifact@v4 + with: + name: playwright-report-${{ matrix.project }} + path: playwright-report/ + retention-days: 7 diff --git a/.gitignore b/.gitignore index 99777272..ea9b3b70 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,9 @@ data/ *.db *.diff *.orig + +# Playwright +/playwright-report/ +/test-results/ +/blob-report/ +/playwright/.cache/ diff --git a/bun.lock b/bun.lock index 12bef044..82b19a33 100644 --- a/bun.lock +++ b/bun.lock @@ -11,6 +11,7 @@ "devDependencies": { "@eslint/js": "10.0.1", "@inlang/paraglide-js": "2.20.0", + "@playwright/test": "1.61.1", "@testcontainers/postgresql": "12.0.1", "@types/bun": "1.3.14", "@types/node": "25.9.1", @@ -33,7 +34,7 @@ }, "apps/agent": { "name": "@shumai/agent-app", - "version": "0.1.2", + "version": "0.1.5", "bin": { "shumai-agent": "./src/index.ts", }, @@ -45,7 +46,7 @@ }, "apps/cli": { "name": "@shumai/cli", - "version": "0.1.2", + "version": "0.1.5", "bin": { "shumai-cli": "./src/index.ts", }, @@ -60,7 +61,7 @@ }, "apps/transcode": { "name": "@shumai/transcode-app", - "version": "0.1.2", + "version": "0.1.5", "bin": { "shumai-transcode": "./src/index.ts", }, @@ -72,7 +73,7 @@ }, "apps/web": { "name": "@shumai/web-app", - "version": "0.1.2", + "version": "0.1.5", "dependencies": { "@shumai/agent": "workspace:*", "@shumai/api": "workspace:*", @@ -87,7 +88,7 @@ }, "packages/agent": { "name": "@shumai/agent", - "version": "0.1.2", + "version": "0.1.5", "dependencies": { "@anthropic-ai/sandbox-runtime": "0.0.52", "@earendil-works/pi-agent-core": "0.78.0", @@ -111,7 +112,7 @@ }, "packages/api": { "name": "@shumai/api", - "version": "0.1.2", + "version": "0.1.5", "dependencies": { "@hono/zod-validator": "0.7.6", "@shumai/core": "workspace:*", @@ -125,7 +126,7 @@ }, "packages/core": { "name": "@shumai/core", - "version": "0.1.2", + "version": "0.1.5", "dependencies": { "@shumai/db": "workspace:*", "@shumai/dtos": "workspace:*", @@ -152,7 +153,7 @@ }, "packages/db": { "name": "@shumai/db", - "version": "0.1.2", + "version": "0.1.5", "dependencies": { "@earendil-works/pi-agent-core": "0.78.0", "@prisma/adapter-pg": "7.8.0", @@ -168,18 +169,18 @@ }, "packages/dtos": { "name": "@shumai/dtos", - "version": "0.1.2", + "version": "0.1.5", "dependencies": { "zod": "4.4.3", }, }, "packages/tableprinter": { "name": "@shumai/tableprinter", - "version": "0.1.2", + "version": "0.1.5", }, "packages/transcode": { "name": "@shumai/transcode", - "version": "0.1.2", + "version": "0.1.5", "dependencies": { "@shumai/core": "workspace:*", "@shumai/db": "workspace:*", @@ -193,7 +194,7 @@ }, "packages/webui": { "name": "@shumai/webui", - "version": "0.1.2", + "version": "0.1.5", "dependencies": { "@base-ui/react": "1.5.0", "@dnd-kit/abstract": "0.4.0", @@ -294,7 +295,7 @@ }, "packages/workflow-core": { "name": "@shumai/workflow-core", - "version": "0.1.2", + "version": "0.1.5", "dependencies": { "@shumai/core": "workspace:*", "@shumai/db": "workspace:*", @@ -761,6 +762,8 @@ "@pkgr/core": ["@pkgr/core@0.3.6", "", {}, "sha512-SEeaJLb3qBNF/OaXnaR1NmmBbFYk1zC0ZH/52fATcRPLFg/p791YrcyFFy44Bo9sLaGuSuLp5Q6axbb/O+v/RA=="], + "@playwright/test": ["@playwright/test@1.61.1", "", { "dependencies": { "playwright": "1.61.1" }, "bin": { "playwright": "cli.js" } }, "sha512-8nKv6+0RJSL9FE4jYOEGXnPeM/Hg12qZpmqzZjRh3qM0Y7c3z1mrOTfFLids72RDQYVh9WpLEfR5WdpNX4fkig=="], + "@pondwader/socks5-server": ["@pondwader/socks5-server@1.0.10", "", {}, "sha512-bQY06wzzR8D2+vVCUoBsr5QS2U6UgPUQRmErNwtsuI6vLcyRKkafjkr3KxbtGFf9aBBIV2mcvlsKD1UYaIV+sg=="], "@preact/signals-core": ["@preact/signals-core@1.14.2", "", {}, "sha512-RZHdBj9ZF4n40Rp4jS052EHHjBWf96P9oNdXPfhQTovCuWY9iQn3Gq+gOTJSgBO9A/JBuPfMOWsSX/lIU9Pc/A=="], @@ -2249,6 +2252,10 @@ "pkg-types": ["pkg-types@2.3.1", "", { "dependencies": { "confbox": "^0.2.4", "exsolve": "^1.0.8", "pathe": "^2.0.3" } }, "sha512-y+ichcgc2LrADuhLNAx8DFjVfgz91pRxfZdI3UDhxHvcVEZsenLO+7XaU5vOp0u/7V/wZ+plyuQxtrDlZJ+yeg=="], + "playwright": ["playwright@1.61.1", "", { "dependencies": { "playwright-core": "1.61.1" }, "optionalDependencies": { "fsevents": "2.3.2" }, "bin": { "playwright": "cli.js" } }, "sha512-DWnY5o3YbLWK4GovuAVwpqL+1VwGNdUGrRr++8j8PtQQzvAVZUIMjKQ90fY689sEJZJBbZVw1rXaOKSTitkzPQ=="], + + "playwright-core": ["playwright-core@1.61.1", "", { "bin": { "playwright-core": "cli.js" } }, "sha512-h7Qlt6m4REp25qvIdvbDtVmD4LqVXfpRxhORv9L0jzETM05p4fuPJ3dKyuSXQxDSbXnmS79HAgi9589lGSpLkg=="], + "possible-typed-array-names": ["possible-typed-array-names@1.1.0", "", {}, "sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg=="], "postcss": ["postcss@8.5.15", "", { "dependencies": { "nanoid": "^3.3.12", "picocolors": "^1.1.1", "source-map-js": "^1.2.1" } }, "sha512-FfR8sjd4em2T6fb3I2MwAJU7HWVMr9zba+enmQeeWFfCbm+UOC/0X4DS8XtpUTMwWMGbjKYP7xjfNekzyGmB3A=="], @@ -3027,6 +3034,8 @@ "pg-types/postgres-array": ["postgres-array@2.0.0", "", {}, "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA=="], + "playwright/fsevents": ["fsevents@2.3.2", "", { "os": "darwin" }, "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA=="], + "prisma-json-types-generator/semver": ["semver@7.8.1", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-rkVq3IXh+4FDGch+KwzX3aV9W3kO54GyEgpvBzSyctDA6Xtd7RJQV1xmXbeQp5v7+VzLOfVqiutSE6GICgPFvg=="], "protobufjs/@types/node": ["@types/node@22.19.19", "", { "dependencies": { "undici-types": "~6.21.0" } }, "sha512-dyh/xO2Fh5bYrfWaaqGrRQQGkNdmYw6AmaAUvYeUMNTWQtvb796ikLdmTchRmOlOiIJ1TDXfWgVx1QkUlQ6Hew=="], diff --git a/package.json b/package.json index f8abccde..6e115c61 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,11 @@ "typecheck": "tsc --noEmit", "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "test": "bun --bun vitest run", + "test:e2e": "playwright test", + "test:e2e:ui": "playwright test --ui", + "test:e2e:report": "playwright show-report", + "test:e2e:install": "playwright install --with-deps", + "harness:dev": "bun run packages/webui/e2e/harness/serve.ts", "format": "prettier --write .", "db:migrate": "bun run prisma migrate dev", "db:deploy": "bun run prisma migrate deploy", @@ -38,6 +43,7 @@ "devDependencies": { "@eslint/js": "10.0.1", "@inlang/paraglide-js": "2.20.0", + "@playwright/test": "1.61.1", "@testcontainers/postgresql": "12.0.1", "@types/bun": "1.3.14", "@types/node": "25.9.1", diff --git a/packages/webui/components/viewers/progress-bar.tsx b/packages/webui/components/viewers/progress-bar.tsx index 3af8a42b..fc109a7a 100644 --- a/packages/webui/components/viewers/progress-bar.tsx +++ b/packages/webui/components/viewers/progress-bar.tsx @@ -262,6 +262,7 @@ const ProgressBar: React.FC = ({ onMouseLeave={handleMouseLeave} onMouseDown={handleMouseDown} onTouchStart={handleTouchStart} + data-testid="seekbar" > {/* Hidden Preview Video Element */}