feat(stats): real-time E2E run dashboard via live Playwright reporter

Merged
LA
8d ago
+519-99

Summary

Streams E2E test results to stats.sonicjs.com as tests finish — one file-batch at a time — so the dashboard updates live during a run rather than waiting for completion.

How it works

A custom Playwright Reporter class (tests/e2e/stats-live-reporter.ts) hooks into the test lifecycle:

HookAction
onBeginPOST /v1/playwright-runs/start — opens a running run record
onTestEndBuffer results by file; flush the file's batch when all its tests finish
onEndPOST /:run_id/complete — recomputes final counts, seals the run

New API endpoints

  • POST /v1/playwright-runs/start — create a pending run
  • POST /v1/playwright-runs/:id/tests — append a batch of test results
  • POST /v1/playwright-runs/:id/complete — finalise with counts + status

The original POST /v1/playwright-runs batch endpoint is unchanged (still works for manual npm run e2e:report).

Dashboard changes

  • ● live animated badge on in-progress rows in Recent Runs
  • Running rows sorted to the top
  • Main dashboard auto-reloads every 8 s while any run is live
  • Run detail page: green "in progress" banner + 5 s auto-refresh

Zero-config opt-out

Reporter self-disables when PLAYWRIGHT_STATS_API_KEY is not set — both locally (reads .dev.vars fallback) and in CI (empty on fork PRs that can't access secrets).

Replaces

  • Teardown batch reporting (global-teardown.ts stats block removed)
  • CI workflow upload step (superseded by live reporter running inline)

RetriggerView in GreptileConfidence Score: 1/5

This PR is not ready to merge because live totals remain zero, uploads can duplicate or lose results, and earlier test history is disconnected.

Findings

  1. P1 Live counts stay zero ▶
  2. P1 Last file saved twice ▶
  3. P1 Retry results disappear ▶
  4. P1 Earlier test history disappears ▶
  5. P1 Live totals stay at zero ▶
  6. P1 Final results can upload twice ▶
  7. P2 Required database tests are missing ▶
  8. P2 New API docs are missing ▶
  9. P2 Document access rules bypassed ▶
  10. P2 Invalid run fields saved ▶
  11. P2 Required Playwright coverage missing ▶
  12. P2 Document access rules are bypassed ▶
  13. P2 Request fields are not checked ▶
  14. P2 Required live reporting tests missing ▶

Summary

Adds live Playwright reporting and dashboard refreshes.

  • Playwright sends run results to stats as test files finish.
  • The stats API accepts run results before a Playwright run is finished.
  • Dashboard pages keep active Playwright runs up to date.

Diagram

sequenceDiagram
  participant P as Playwright reporter
  participant A as Stats API
  participant D as Database
  participant U as Dashboard
  P->>A: Start run
  A->>D: Save running record
  loop Each finished file
    P->>A: Append test results
    A->>D: Insert test rows
  end
  U->>A: Reload dashboard
  A->>D: Read run and test rows
  P->>A: Complete run
  A->>D: Count final attempts and save completion

Reviews (3) · Last reviewed commit: "fix(stats): address remaining PR review ..." · Reviewed by Greptile