Skip to content

End-to-end tests

Restura ships from one renderer to three targets, but only two of them have a browser to automate — the web app and the desktop app. End-to-end coverage is split into two Playwright harnesses, each scoped to the harness it can actually reach.

Playwright drives the real web app in a browser. The webServer config boots npm run dev — a single command that starts both the Vite SPA and the Cloudflare Worker via Miniflare — and waits for it to come up before running specs.

Two test styles live side by side:

  • Route-mocked specs (http.spec.ts, protocols.spec.ts, data-management.spec.ts) intercept network calls at Playwright’s request layer. Fast and hermetic — good for UI behavior assertions.
  • real-*.spec.ts specs (real-http.spec.ts, real-https.spec.ts, real-proxy.spec.ts, real-grpc.spec.ts) hit live upstreams — mock HTTP/HTTPS/proxy/gRPC servers spun up as worker-scoped fixtures, exercised through real sockets, real TLS, and real Worker → upstream traversal. These catch issues route mocking can’t.
Terminal window
npm run test:e2e # headless
npm run test:e2e:headed # with the browser visible
npm run test:e2e:ui # Playwright UI mode

The web harness can’t cover the desktop app — there’s no Vite dev server, no Worker, and IPC replaces HTTP as the transport. e2e-electron/ launches the compiled, unpacked app via Playwright’s _electron API instead, with its own playwright.config.ts kept separate from the web one on purpose.

Two protocols need more than an in-process mock:

  • gRPC needs a real @grpc/grpc-js dev server (npm run grpc:server, port 50051) — the echo Worker’s Connect endpoint is web-only, so desktop gRPC has no other way to get real HTTP/2 framing and trailers.
  • Kafka and MQTT specs use a brokers fixture that auto-brings-up the Dockerised Redpanda + EMQX stack from echo-local/docker-compose.yml and polls until both containers report healthy. If Docker isn’t reachable, those specs skip instead of failing.
Terminal window
npm run test:e2e:electron:build # electron:build:web + electron:compile
npm run test:e2e:electron