From 9b951eb21361224bd670c66ab63e62877fe74f58 Mon Sep 17 00:00:00 2001 From: Prateek Chaplot Date: Tue, 24 Nov 2026 09:27:46 +0530 Subject: [PATCH] test(e2e): add Playwright suite covering AC1-AC15 --- docs/TASKS.md | 9 +- tests/e2e/fixtures/texts/one-char.txt | 1 + tests/e2e/fixtures/texts/sample-200.txt | 1 + tests/e2e/fixtures/texts/sample-5000.txt | 1 + tests/e2e/fixtures/unsupported.md | 3 + tests/e2e/playwright.config.ts | 98 +++++++ tests/e2e/scripts/ensure-data.mjs | 51 ++++ .../e2e/specs/ac01-offline-generation.spec.ts | 56 ++++ tests/e2e/specs/ac02-file-upload.spec.ts | 46 ++++ tests/e2e/specs/ac03-unsupported-type.spec.ts | 37 +++ tests/e2e/specs/ac04-empty-input.spec.ts | 33 +++ .../e2e/specs/ac05-voice-list-preview.spec.ts | 53 ++++ tests/e2e/specs/ac06-rate-range.spec.ts | 82 ++++++ tests/e2e/specs/ac07-spotcheck-timing.spec.ts | 84 ++++++ tests/e2e/specs/ac08-highlight-seek.spec.ts | 86 ++++++ tests/e2e/specs/ac09-audio-plays.spec.ts | 82 ++++++ tests/e2e/specs/ac10-subtitle-loads.spec.ts | 85 ++++++ tests/e2e/specs/ac11-forced-failure.spec.ts | 108 ++++++++ tests/e2e/specs/ac12-cancel.spec.ts | 81 ++++++ tests/e2e/specs/ac13-history.spec.ts | 80 ++++++ tests/e2e/specs/ac14-no-egress.spec.ts | 66 +++++ tests/e2e/specs/ac15-keyboard.spec.ts | 104 +++++++ tests/e2e/support/api.ts | 214 +++++++++++++++ tests/e2e/support/env.ts | 100 +++++++ tests/e2e/support/fixtures.ts | 20 ++ tests/e2e/support/node-shims.d.ts | 39 +++ tests/e2e/support/run.ts | 14 + tests/e2e/support/subtitles.ts | 81 ++++++ tests/e2e/support/ui.ts | 253 ++++++++++++++++++ tests/e2e/support/wav.ts | 93 +++++++ tests/e2e/tsconfig.json | 19 ++ 31 files changed, 2078 insertions(+), 2 deletions(-) create mode 100644 tests/e2e/fixtures/texts/one-char.txt create mode 100644 tests/e2e/fixtures/texts/sample-200.txt create mode 100644 tests/e2e/fixtures/texts/sample-5000.txt create mode 100644 tests/e2e/fixtures/unsupported.md create mode 100644 tests/e2e/playwright.config.ts create mode 100644 tests/e2e/scripts/ensure-data.mjs create mode 100644 tests/e2e/specs/ac01-offline-generation.spec.ts create mode 100644 tests/e2e/specs/ac02-file-upload.spec.ts create mode 100644 tests/e2e/specs/ac03-unsupported-type.spec.ts create mode 100644 tests/e2e/specs/ac04-empty-input.spec.ts create mode 100644 tests/e2e/specs/ac05-voice-list-preview.spec.ts create mode 100644 tests/e2e/specs/ac06-rate-range.spec.ts create mode 100644 tests/e2e/specs/ac07-spotcheck-timing.spec.ts create mode 100644 tests/e2e/specs/ac08-highlight-seek.spec.ts create mode 100644 tests/e2e/specs/ac09-audio-plays.spec.ts create mode 100644 tests/e2e/specs/ac10-subtitle-loads.spec.ts create mode 100644 tests/e2e/specs/ac11-forced-failure.spec.ts create mode 100644 tests/e2e/specs/ac12-cancel.spec.ts create mode 100644 tests/e2e/specs/ac13-history.spec.ts create mode 100644 tests/e2e/specs/ac14-no-egress.spec.ts create mode 100644 tests/e2e/specs/ac15-keyboard.spec.ts create mode 100644 tests/e2e/support/api.ts create mode 100644 tests/e2e/support/env.ts create mode 100644 tests/e2e/support/fixtures.ts create mode 100644 tests/e2e/support/node-shims.d.ts create mode 100644 tests/e2e/support/run.ts create mode 100644 tests/e2e/support/subtitles.ts create mode 100644 tests/e2e/support/ui.ts create mode 100644 tests/e2e/support/wav.ts create mode 100644 tests/e2e/tsconfig.json diff --git a/docs/TASKS.md b/docs/TASKS.md index daab34e..b7398d3 100644 --- a/docs/TASKS.md +++ b/docs/TASKS.md @@ -37,7 +37,7 @@ Statuses: done (PR merged) · doing (branch open, pending review) · remaining | ID | Task | Branch | Verification | Status | |---|---|---|---|---| -| _(empty)_ | | | | | +| T5.1 | E2E suite | `arch/tts/t5.1` | 15/15 Playwright specs (AC1–AC15) against the real `en_US-lessac-medium`, run three times including once from empty data dirs; `tsc -p tests/e2e --noEmit`; 201 pytest unit + 16 integration; 111 Vitest; Ruff; mypy; ESLint; frontend `tsc`; Prettier; PR CI pending | Pending review | ## Remaining @@ -65,7 +65,6 @@ _All P4 tasks done._ | ID | Task | Files | Deps | Acceptance criteria (summary) | |---|---|---|---|---| -| T5.1 | E2E suite | `tests/e2e/` | T4.1 | All 15 acceptance criteria tested or recorded as manual checks | | T5.2 | Docs | `README.md`, `docs/USER_GUIDE.md`, `docs/KNOWN_LIMITATIONS.md`, `docs/PRD.md` | T5.1 | Fresh-machine workflow completes using README alone | | T5.3 | Measurement | `tests/measure.py`, `docs/MEASUREMENTS.md` | T4.1 | Performance and timing measurements with hardware note | @@ -151,3 +150,9 @@ _All P4 tasks done._ - T4.3 decision (closes T1.6's `TTS_FAULT` note): `TTS_FAULT` is now read only by `config.py`, which adds a `fault` field to `Settings` (`none` by default, `engine` the test fault), normalizes case/whitespace, falls back to `none` with a warning on an unknown value, and logs "Fault injection enabled: engine" when armed. `jobs/manager.py` compares `self._settings.fault` and no longer touches `os.environ`, so §7.1 is true again; §7.1's field list was updated in this PR (§14.4). Dependent tests switched from env mutation to fault-enabled fixtures: `tests/unit/test_jobs_manager.py` gained a `fault_harness` fixture (built by the shared `_build_harness` helper) and `tests/integration/test_jobs_pipeline.py` gained a `fault_environment` fixture (built by `_build_environment(tmp_path, fault=...)`). - T4.3 logging: the two failure branches call the new `_log_preview(text)` helper (`text[:LOG_PREVIEW_CHARS]`, 80 chars) so the input preview can never exceed §11's limit; the existing WARNING line still carries the §9.1 code and the failure reason, and the exception keeps the traceback at ERROR. No production behavior other than `TTS_FAULT`'s source changed — the §11 log lines (start/success/failure/cancel, degraded timings, eviction, offline first run) already existed. - T4.3 enforcement test: new `tests/unit/test_observability.py` (unique basename, per the T1.2 note) proves a failed generation logs `ENGINE_ERROR` + the reason + the 80-char preview, and uses `difflib.SequenceMatcher` to assert the longest common run between the >80-char input and all captured log text is ≤ 80 characters (the marker after char 80 never appears, no timing JSON is logged). It also pins `Settings.load()` fault parsing (default/override/unknown) and proves a manager built with `fault="none"` succeeds even when `TTS_FAULT=engine` is set in the environment. +- T5.1 decisions: the suite is serial (`workers: 1`, `fullyParallel: false`, `retries: 0`, 180 s per test) because synthesis is single-worker and AC13 describes one shared library. Two real `tts` servers back the run: the main one on 8321 (CI starts it; locally Playwright starts it, or reuses a healthy one) using `.venv/e2e-data` locally and `$RUNNER_TEMP/tts-data` in CI, plus a `TTS_FAULT=engine` server on 8322 with its own data dir for AC11 (faults are read once at startup, so AC11 cannot share the main process). Both start offline: `scripts/ensure-data.mjs` copies `voices/` from `.venv/tts-data/voices` (local) or the main data dir (CI's restored cache) before `tts` runs, so neither server downloads a voice. +- T5.1 wiring: `@playwright/test` resolves through `tests/e2e/tsconfig.json`'s `paths` to `frontend/node_modules/@playwright/test` (no root `package.json` and no `@types/node` was added); `support/node-shims.d.ts` declares the few Node builtins the support layer uses. `PYTHON` in `support/env.ts` prefers `TTS_E2E_PYTHON`, then the repo `.venv`, then `python`/`python3` (CI has no repo virtualenv). Playwright failure artifacts go to the ignored `.venv/e2e-artifacts`. `npx tsc -p tests/e2e --noEmit` is clean. +- T5.1 AC7 tolerance: `WORD_START_TOLERANCE_MS = 100` in `support/env.ts` is assumption A-3's target for word-start accuracy, measured by seeking in the UI and comparing `audio.currentTime`; T5.3 owns the final listening measurement and the constant follows its result. The spec also checks timing structure, monotonicity, bounds within the file, and that the last word does not extend past the audio. That last check is one-sided: Piper pads the final sentence with up to ~0.5 s of silence, so the last word may end before the file does. +- T5.1 results: 15/15 specs pass against the real `en_US-lessac-medium`, three consecutive runs (one from empty data dirs to prove voice seeding) at ~24 s each. AC11 runs on the fault server and proves the failed row has no `.wav`/`.part` while the main server's history total and a prior ready entry stay intact and restorable; AC12 cancels a 5,000-char slow-rate job and proves no partial file, no audio, no downloads; AC9/AC10 parse the downloaded WAV/SRT/VTT bytes (not API bodies) and cross-check download names, RIFF sizes, and cue timing; AC15 drives the whole flow with Tab/Enter/Space only. +- T5.1 browser finding (recorded, no production change): a native `