commit 7ac4cc1898708139ff4bcec98bf53aa9c35d33df
parent c6caeb87fef1d679d407c9ae435469c532b0e8d0
Author: I Mean I'm Just Saying <imeanimjustsaying@kiwifarms.st>
Date: Mon, 19 Oct 2026 14:19:52 -0400
e2e: find-clips.spec — Find clips on the video page over a stub umtool
Every step skipped (each named in the log), the clips route asked with the
worker token and the contract's body, the project linked and the two segments
listed, then "Find clips in this part" posting again with the segment.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Diffstat:
1 file changed, 139 insertions(+), 0 deletions(-)
diff --git a/editor/e2e/find-clips.spec.ts b/editor/e2e/find-clips.spec.ts
@@ -0,0 +1,139 @@
+import { test, expect } from "@playwright/test";
+import http from "node:http";
+import type { AddressInfo } from "node:net";
+import { mkdir, rm, writeFile } from "node:fs/promises";
+import { join } from "node:path";
+import { resetData, testPaths, writeSettings } from "./helpers";
+import { umtoolOriginFile } from "./servers";
+
+// FIND CLIPS (release 36, lane A) on the video page, end to end over a STUB
+// umtool started here and named to the test server through
+// E2E_UMTOOL_ORIGIN_FILE (e2e/servers.ts, common/lib/umtoolUrl.ts). The
+// fixture video already holds everything the chain makes — the source
+// container, the transcript, words.json, the chat replay, diarization.json —
+// so every editor step is skipped (each named in the log) and the job goes
+// straight to umtool's clips route: the worker token, the contract's body,
+// the job followed. Then the panel links the project and lists the segments,
+// and "Find clips in this part" posts again with that segment.
+
+const SLUG = "test-transcribe";
+const ID = "vidFC";
+
+type Call = { method: string; url: string; auth: string | undefined; body: Record<string, unknown> | null };
+
+let server: http.Server;
+let origin = "";
+const calls: Call[] = [];
+
+test.beforeAll(async () => {
+ server = http.createServer((req, res) => {
+ let raw = "";
+ req.on("data", (c) => (raw += c));
+ req.on("end", () => {
+ const body = raw ? (JSON.parse(raw) as Record<string, unknown>) : null;
+ calls.push({ method: req.method ?? "", url: req.url ?? "", auth: req.headers.authorization, body });
+ res.setHeader("content-type", "application/json");
+ if (req.method === "POST" && req.url === "/api/report/clips") {
+ const segment = typeof body?.segment === "string" ? body.segment : null;
+ res.end(
+ JSON.stringify({
+ ok: true,
+ jobId: segment ? "u2" : "u1",
+ job: { id: segment ? "u2" : "u1" },
+ project: segment ? `vidfc-clips-${segment}` : "vidfc-clips",
+ created: true,
+ segment: segment ?? "s1",
+ href: `/projects/${segment ? `vidfc-clips-${segment}` : "vidfc-clips"}/clips`,
+ notes: [],
+ segments: [
+ { id: "s1", from: 290, to: 6300, why: "subject 4 holds 81% of long-turn time" },
+ { id: "s2", from: 6500, to: 9278, why: "subject 16 holds 77% of long-turn time" },
+ ],
+ }),
+ );
+ return;
+ }
+ if (req.method === "GET" && req.url?.startsWith("/api/report/clips?job=")) {
+ res.end(JSON.stringify({ state: "done", log: ["propose: 9 clips, 598 s"], next: 1 }));
+ return;
+ }
+ res.statusCode = 404;
+ res.end(JSON.stringify({ error: "no such route" }));
+ });
+ });
+ await new Promise<void>((r) => server.listen(0, "127.0.0.1", r));
+ origin = `http://127.0.0.1:${(server.address() as AddressInfo).port}`;
+});
+
+test.afterAll(async () => {
+ await rm(umtoolOriginFile(testPaths().transcriptsDir), { force: true });
+ await new Promise<void>((r) => server.close(() => r()));
+});
+
+test("Find clips: every step skipped, umtool asked with the token, the project linked and its segments listed", async ({ page }) => {
+ test.setTimeout(120_000);
+ await resetData("one-transcribe-channel");
+ await writeSettings({ minFreeDiskGB: 0 });
+ const videoDir = join(testPaths().transcriptsDir, "channels", SLUG, "data", ID);
+ await mkdir(videoDir, { recursive: true });
+ await writeFile(
+ join(videoDir, "metadata.info.json"),
+ JSON.stringify({ id: ID, title: "Synthetic reaction stream", webpage_url: `https://www.youtube.com/watch?v=${ID}`, was_live: true, duration: 9278 }),
+ );
+ await writeFile(join(videoDir, "source-media.mp4"), "container");
+ await writeFile(join(videoDir, "transcript.json"), JSON.stringify({ transcription: [] }));
+ await writeFile(join(videoDir, "words.json"), JSON.stringify({ version: 1, words: [{ w: "hello", start: 1, end: 1.4 }] }));
+ await writeFile(join(videoDir, "transcript.live_chat.json"), "\n");
+ await writeFile(join(videoDir, "live_chat.cues.json"), JSON.stringify({ version: 1, source: "live_chat", cues: [] }));
+ await writeFile(join(videoDir, "diarization.json"), JSON.stringify({ speakers: [], turns: [] }));
+ await writeFile(umtoolOriginFile(testPaths().transcriptsDir), origin);
+
+ await page.goto(`/channels/${SLUG}/videos/${ID}`);
+ const panel = page.getByRole("region", { name: "find-clips panel" });
+ await expect(panel.getByLabel("find-clips status")).toHaveText("not run yet");
+ await panel.getByLabel("target length (minutes)").fill("10");
+ await panel.getByRole("button", { name: "Find clips", exact: true }).click();
+ const out = page.getByLabel(`Find clips in ${ID} output`);
+ await expect(out).toContainText("@@find-clips", { timeout: 60_000 });
+ for (const line of [
+ "skipped: saved video — saved video present",
+ "skipped: corpus transcript — transcript.json present",
+ "skipped: word timings — words.json present (1 words)",
+ "skipped: chat replay — live_chat.cues.json present",
+ "skipped: diarization — diarization.json present",
+ "running: umtool — finding the segments and the clips",
+ "umtool: propose: 9 clips, 598 s",
+ ]) {
+ await expect(out).toContainText(line);
+ }
+
+ // umtool was asked as the contract says.
+ const post = calls.find((c) => c.method === "POST");
+ expect(post?.auth).toBe("Bearer test-worker-token");
+ expect(post?.body).toEqual({
+ mode: "new",
+ slug: "vidfc-clips",
+ from: `${SLUG}/${ID}`,
+ target: 600,
+ scope: "auto",
+ wordsPath: join(videoDir, "words.json"),
+ });
+
+ await page.reload();
+ const result = panel.getByLabel("find-clips result");
+ await expect(result.getByRole("link", { name: "vidfc-clips", exact: true })).toHaveAttribute("href", `${origin}/projects/vidfc-clips/clips`);
+ const segments = panel.getByRole("list", { name: "segments found" });
+ await expect(segments.getByRole("listitem")).toHaveCount(2);
+ await expect(segments).toContainText("s1 4:50–1:45:00");
+ await expect(segments).toContainText("s2 1:48:20–2:34:38");
+ await expect(panel.getByLabel("find-clips status")).toContainText("2 segments");
+
+ // One part: posts again with that segment (the target typed again: a
+ // reload clears the field).
+ await panel.getByLabel("target length (minutes)").fill("10");
+ await segments.getByRole("listitem").nth(1).getByRole("button", { name: "Find clips in this part", exact: true }).click();
+ await expect(page.getByLabel("Find clips in segment s2 output")).toContainText("@@find-clips", { timeout: 60_000 });
+ const second = calls.filter((c) => c.method === "POST")[1];
+ expect(second?.body).toMatchObject({ mode: "new", slug: "vidfc-clips-s2", segment: "s2", target: 600 });
+ expect(second?.body).not.toHaveProperty("scope");
+});