test(edl): pin the full-transcript contract with words outside the old window

The existing test's words all sat inside the removed ±45s window, so it
passed with or without the change. Add words starting 160s after the clip
ends: the old windowed code drops them, the new contract ships them. Also
assert the words arrive sorted by start time, which the editor's
follow-along binary search depends on.
This commit is contained in:
juancarlos.cavero 2026-08-20 13:31:20 +02:00
parent 05f13254e7
commit f8bc461c8e

View file

@ -121,6 +121,28 @@ class TestGetEdl:
# Self-host meters nothing.
assert data["rerender_minutes"] == 0
def test_ships_words_far_outside_the_clip(self, job):
"""The EDL carries the WHOLE source transcript. The old ±45s window
would drop these words (clip ends at 40s, they start at 200s), and a
cut can only be extended into material whose words were sent."""
meta = json.loads(job["meta_path"].read_text())
meta["transcript"]["segments"].append({
"start": 200.0, "end": 260.0, "text": "distant tail",
"words": [
{"word": "distant", "start": 200.0, "end": 200.4},
{"word": "tail", "start": 259.0, "end": 259.5},
],
})
job["meta_path"].write_text(json.dumps(meta))
data = _request("GET", f"/api/clip/{JOB_ID}/0/edl").json()
assert [w["w"] for w in data["words"]] == [
"hello", "world", "again", "distant", "tail"]
# Word order is the binary-search invariant the editor's follow-along
# highlight depends on.
starts = [w["s"] for w in data["words"]]
assert starts == sorted(starts)
def test_reports_missing_source(self, job):
os.remove(job["dir"] / "src.mp4")
data = _request("GET", f"/api/clip/{JOB_ID}/0/edl").json()