Skip to content

test(player): transcript-ownership harness for canvas switches - #70

Merged
trevormunoz merged 2 commits into
mainfrom
test/transcript-ownership-harness
Sep 10, 2026
Merged

trevormunoz merged 2 commits into
mainfrom
test/transcript-ownership-harness

Conversation

@trevormunoz

Copy link
Copy Markdown
Member

Adds a regression lock for a currently-untested path: a late external-VTT response for a canvas the viewer has already left must not overwrite the current canvas's transcript.

Honest framing

The guard this exercises — transcriptGeneration re-checked after each await in resolveVTTTranscript — already exists and works. This is not a bug report; it's a named regression test for a path that had no direct coverage (the existing Root.transcript-generation test covers a different stale case: an annotations mode-flip vs. an in-flight HLS import).

What the test does

  • Distinguishable by construction: two video canvases with unmistakably different transcript text and timestamps — ALPHA @ 0:07, BRAVO @ 0:23 — delivered as external VTT supplementing tracks under annotations="auto", the only path that issues a deferrable fetch (embedded transcripts resolve synchronously with nothing to race).
  • Controlled fetch layer: reuses mockFetchRoutes + deferred to hold each VTT response until released, so the test forces resolution in reverse order: mount A → switch to B while A is pending → resolve B → resolve A late.
  • Proves it reaches the race: asserts both VTT requests were actually outstanding before resolving, then that BRAVO owns the panel both after B resolves and after the late A resolves. Expected text/timestamps come from the fixtures, never the library's own parser.
  • Calibrated ("test the test"): with the generation re-check temporarily disabled, the test fails at the late-A step (ALPHA overwrites BRAVO) — confirming it detects the fault rather than merely the current behavior.

Test-only; no production changes. Full suite green (734).

🤖 Generated with Claude Code

https://claude.ai/code/session_015KfYGrLi7iJoevyVQsn5ur

trevormunoz and others added 2 commits September 9, 2026 22:44
Locks in a previously-untested path: a late external-VTT response for a
canvas the viewer has already left must not overwrite the current canvas's
transcript. The guard (transcriptGeneration in Root's resolveVTTTranscript)
already exists — this is a regression lock, not a bug report.

The scenario is distinguishable by construction: two video canvases with
unmistakably different transcript text and timestamps (ALPHA @ 0:07,
BRAVO @ 0:23), delivered as external VTT supplementing tracks under
annotations="auto" — the only path that issues a deferrable fetch. A
controlled fetch layer (mockFetchRoutes + deferred) holds each VTT response
until the test releases it, so it can force resolution in reverse order:
mount A, switch to B while A is pending, resolve B, then resolve A late.
The test asserts both requests were actually outstanding (so it really
reproduces the race) and that BRAVO owns the panel throughout. Expected
text and timestamps come from the fixtures, never the library's parser.

Calibrated: with the generation re-check temporarily disabled, the test
fails at the late-A step (ALPHA overwrites BRAVO), confirming it detects
the fault rather than merely the current behavior.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015KfYGrLi7iJoevyVQsn5ur
Review follow-up on the ownership harness.

Steps 9-10 previously only checked the rendered segment's timestamp text and
inferred the seek — a broken click handler would have passed. Now the test
drives the media element to ready with a duration, actually clicks the
segment, and asserts the seek landed on BRAVO's 23s (not ALPHA's 7s).

The late-A wait was a fixed 50ms sleep. Replace it with an explicit signal:
wrap loadVTTTranscript via vi.mock (importOriginal, real implementation) to
capture the exact promise Root awaits for A, then await that whole chain
(fetch → text → parse → generation re-check) before asserting. Re-verified
calibration: with the guard disabled the test fails at the late-A step. (An
intermediate microtask-drain attempt gave a false green under calibration —
caught precisely because calibration was repeated.)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015KfYGrLi7iJoevyVQsn5ur
@trevormunoz
trevormunoz merged commit fc364fd into main Sep 10, 2026
1 check passed
@trevormunoz
trevormunoz deleted the test/transcript-ownership-harness branch September 10, 2026 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant