import { test, expect } from "@playwright/test"; import { mkdir, writeFile } from "node:fs/promises"; import { join } from "node:path"; // By relative path, as frame-scan.spec.ts imports the kit: plain .mjs. import { syntheticPokerHighlights } from "../../common/testing/frames/pokerReadings.mjs"; import { channelStage, resetData, testPaths } from "./helpers"; // Release 32, lane R3: operations that were CLI- or ops-only, as buttons — // find-copy's scope mode previewed from the channel's Download stage (a gone // recording that is not YouTube's: listed, nothing asked of any network), the // audio audit started from the same stage (the fake ffmpeg's tolerant decode // reads a marked file as damaged), and a frame scan re-derived and corrected // on the video page with no model. And the Configure form's audio check on an // Odysee channel: ticked by default. Synthetic records only. const SLUG = "test-transcribe"; // an Odysee channel (one-transcribe-channel) const GONE = "v7gone01"; const AUDIO = "v7audio01"; const FRAMES = "v7frames01"; const rumble = (id: string) => `https://rumble.com/${id}-synthetic-recording.html`; async function video(id: string, files: Record) { const dir = join(testPaths().transcriptsDir, "channels", SLUG, "data", id); await mkdir(dir, { recursive: true }); await writeFile(join(dir, "metadata.info.json"), JSON.stringify({ id, title: `Synthetic ${id}`, webpage_url: rumble(id), duration: 600 })); for (const [name, body] of Object.entries(files)) await writeFile(join(dir, name), body); } test.beforeEach(async () => { await resetData("one-transcribe-channel"); }); test("find copies of gone videos: the preview lists the candidate and arms the run", async ({ page }) => { await video(GONE, { "availability.json": JSON.stringify({ checkedAt: "2026-10-01T00:00:00.000Z", availability: "deleted", webpageUrl: rumble(GONE), history: [] }), }); await page.goto(channelStage(SLUG, "download")); const box = page.getByRole("region", { name: "find copies of gone videos" }); await expect(box.getByRole("button", { name: "Find and fetch copies" })).toBeDisabled(); await box.getByLabel("gone videos to look for").selectOption("all"); await box.getByRole("button", { name: "Preview", exact: true }).click(); const preview = box.getByLabel("find copies preview", { exact: true }); await expect(preview).toBeVisible({ timeout: 30_000 }); await expect(box.getByLabel("find copies preview counts")).toContainText("1 gone video with no media in 1 channel; 1 looked up"); const row = box.getByTestId("find-copy-candidate"); await expect(row).toHaveCount(1); await expect(row).toContainText(`${SLUG}/${GONE}`); await expect(row).toContainText("not looked for (not YouTube)"); await expect(box.getByRole("button", { name: "Find and fetch copies" })).toBeEnabled(); // Other settings than the preview's disarm it. await box.getByLabel("gone videos to look for").selectOption("no-transcript"); await expect(box.getByRole("button", { name: "Find and fetch copies" })).toBeDisabled(); }); test("audit audio: the job decodes the held file, the verdict is beside it and on the video page", async ({ page }) => { test.setTimeout(90_000); await video(AUDIO, { "audio.m4a": "__CORRUPT__ __DUR=600__ held audio\n" }); await page.goto(channelStage(SLUG, "download")); const box = page.getByLabel("audit audio", { exact: true }); await expect(box.getByLabel("audio audit tally")).toHaveText("Not audited."); await box.getByRole("button", { name: "Audit audio" }).click(); const log = page.getByLabel(`Audit audio of ${SLUG} output`); await expect(log).toContainText("@@audio-audit", { timeout: 30_000 }); await expect(log).toContainText('"damaged":1'); // The report's tally once the job's regen lands. await expect .poll( async () => { await page.reload(); return (await page.getByLabel("audio audit tally").textContent()) ?? ""; }, { timeout: 45_000, message: "the tally on the Download stage" }, ) .toContain("0 clean, 1 damaged, 0 undecodable"); await page.goto(`/channels/${SLUG}/videos/${AUDIO}`); await expect(page.getByLabel("audio integrity")).toContainText("damaged: 5:00 of 10:00 decodes (50%)"); }); test("frame scan: Re-derive (no model), then a reading set aside as a misread from its event", async ({ page }) => { const fx = syntheticPokerHighlights(); await video(FRAMES, { "frame-scan.poker.json": JSON.stringify({ format: "archilyzer-frame-scan", version: 1, profile: "poker", source: { savedVideo: "source-media.mp4", durationSeconds: 3000 }, sampling: { everySeconds: 10, from: 0, to: 3000, width: 1280, keyframesOnly: true, frames: 300, kept: 300, skippedDuplicates: 0 }, model: { route: "api", model: "claude-haiku-4-5", promptVersion: 3 }, hints: { hero: fx.hero }, costUsd: 0.5, runs: [], readings: fx.readings, duplicates: [], spoken: fx.spoken, derived: { tournaments: [], events: [], segments: [], flags: [], misreads: [] }, updatedAt: "2026-10-15T00:00:00.000Z", }), }); await page.goto(`/channels/${SLUG}/videos/${FRAMES}`); const panel = page.getByTestId("frame-scan-panel"); await expect(panel.getByLabel("hero screen name")).toHaveValue(fx.hero); await expect(panel.getByLabel("frame scan events")).toHaveCount(0); await panel.getByRole("button", { name: "Re-derive (no model)" }).click(); await expect(panel.getByLabel("re-derive result")).toContainText("tournaments 0 → 1"); const events = panel.getByLabel("frame scan events"); await expect(events).toContainText("bust"); await expect(panel.getByLabel("frame scan summary")).toContainText("re-derived"); // The bust's reading at 48:20, opened from its event and set aside. await events.getByRole("link", { name: "Correct the reading at 48:20" }).first().click(); const form = panel.getByRole("region", { name: "frame reading" }); await expect(form.getByLabel("frame reading heading")).toContainText("Reading at 48:20"); await expect(form.getByLabel("Hero stack", { exact: true })).toHaveValue("0"); await form.getByRole("button", { name: "Mark misread" }).click(); await expect(form.getByLabel("frame reading status")).toContainText("Set aside as a misread; derived again"); await expect(panel.getByLabel("frame scan corrections")).toContainText("48:20"); await expect(panel.getByLabel("frame scan corrections")).toContainText("misread, set aside"); // A person's value for a field: saved, shown beside what the model read. await form.getByLabel("reading time").fill("25:00"); await form.getByRole("button", { name: "Open reading" }).click(); await expect(form.getByLabel("frame reading heading")).toContainText("Reading at 25:00"); await form.getByLabel("Hero stack", { exact: true }).fill("133,333"); await form.getByRole("button", { name: "Save correction" }).click(); await expect(form.getByLabel("frame reading status")).toContainText("Correction saved"); await expect(form).toContainText("read 120000"); await expect(panel.getByLabel("frame scan corrections")).toContainText("hero.stack 133,333"); }); test("the Configure form: an Odysee channel's audio check shows on by default", async ({ page }) => { await page.goto(channelStage(SLUG, "configure")); await expect(page.getByLabel("audio check default")).toContainText("on by default for Odysee"); await expect(page.getByLabel("audio-check enabled")).toBeChecked(); });