Files
shumai/packages/webui/e2e/harness/serve.ts
T
yiling 469f68b25d 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).
2026-07-03 14:50:38 +08:00

35 lines
1.1 KiB
TypeScript

import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
import index from './index.html'
/**
* Backend-free harness server for the Playwright e2e suite.
*
* Uses Bun's native HTML bundler (the same path the real app uses via
* `Bun.serve({ routes })` in apps/web) so the test toolchain matches the
* project's Bun-based dev/prod serving. Tailwind is applied through the
* `bun-plugin-tailwind` entry configured in the repo's bunfig.toml
* ([serve.static]). It serves:
* - the harness page (index.html -> main.tsx, bundled on the fly), and
* - the committed fixture video from ../fixtures at the site root.
*/
const here = dirname(fileURLToPath(import.meta.url))
const fixturesDir = join(here, '..', 'fixtures')
const port = process.env.HARNESS_PORT ? Number(process.env.HARNESS_PORT) : 5199
const server = Bun.serve({
port,
development: true,
routes: {
'/sample.mp4': () =>
new Response(Bun.file(join(fixturesDir, 'sample.mp4')), {
headers: { 'Content-Type': 'video/mp4' },
}),
'/': index,
'/*': index,
},
})
console.log(`🎬 Video player harness running at ${server.url}`)