import { test, expect } from "@playwright/test"; import { mkdir, writeFile } from "node:fs/promises"; import { join } from "node:path"; import { channelStage, resetData, testPaths } from "./helpers"; // Release 32 lane R6: the owed UI. "Cut from the stored media URL" offered on // the Articles tab's Fetch missing evidence once a preview finds a window on // an Odysee record that stores its CDN file (off by default); the channel's // whole-channel media tools (attach from a local archive, playable copies) // previewed from the Cleanup stage; and "Save these videos" on the Saved videos // page previewed and armed. Synthetic records only; nothing is fetched. const SLUG = "test-transcribe"; // an Odysee channel (one-transcribe-channel) const STORED = "v6stored01"; // Eleven characters: the archive names a file by a YouTube-shaped id (lib/attachMediaPlan.ts). const HELD = "v6held01abc"; const page = (id: string) => `https://odysee.com/@example:1/synthetic-${id}:1`; const channelDir = () => join(testPaths().transcriptsDir, "channels", SLUG); async function record(id: string, stored: boolean) { const dir = join(channelDir(), "data", id); await mkdir(dir, { recursive: true }); await writeFile( join(dir, "metadata.info.json"), JSON.stringify({ id, title: `Synthetic ${id}`, webpage_url: page(id), duration: 600, ...(stored ? { formats: [{ format_id: "original", url: `https://player.odycdn.com/v6/streams/${id}/f0.mp4`, protocol: "https", ext: "mp4" }] } : {}), }), ); } test.beforeEach(async () => { await resetData("one-transcribe-channel"); }); test("Fetch missing evidence offers the stored media URL once a preview finds an Odysee window that has one", async ({ page: p }) => { await record(STORED, true); const reports = join(testPaths().transcriptsDir, "reports"); await mkdir(join(reports, "fixture-stored"), { recursive: true }); await writeFile( join(reports, "fixture-stored", "report.json"), JSON.stringify({ format: "archilyzer-report", version: 1, id: "fixture-stored", kind: "sweep", title: "Fixture stored article", sections: [{ id: "s1", title: "One", claims: [{ id: "k01", text: "It is said: \"a synthetic line\"", citations: ["c01"] }] }], citations: { c01: { kind: "video", channel: SLUG, id: STORED, start: 10, end: 14, quote: "a synthetic line" } }, }), ); await writeFile(join(reports, "index.json"), JSON.stringify({ published: ["fixture-stored"] })); await p.goto("/sites/articles"); await expect(p.locator("[data-stored-url-option]")).toHaveCount(0); await p.getByRole("button", { name: "Preview missing evidence" }).click(); const summary = p.getByLabel("Missing evidence"); await expect(summary).toContainText("odysee: 1 window(s) on clips:odysee ยท 1 with a stored media URL", { timeout: 30_000 }); const option = p.locator("[data-stored-url-option]"); await expect(option).toBeVisible(); await expect(option).toContainText("Cut from the stored media URL"); await expect(option).toContainText("Odysee only."); await expect(option.getByRole("checkbox")).not.toBeChecked(); }); test("the channel's media tools: attach from a local archive and playable copies, each previewed first", async ({ page: p }) => { test.setTimeout(90_000); await record(HELD, false); // Inside the test corpus, which resetData clears. const archive = join(testPaths().transcriptsDir, "r32r6-archive"); await mkdir(archive, { recursive: true }); await writeFile(join(archive, `Synthetic held recording [${HELD}].mp4`), "synthetic media bytes\n"); await p.goto(channelStage(SLUG, "cleanup")); const tools = p.getByRole("group", { name: "channel media tools" }); await tools.locator("summary").click(); const attach = tools.getByLabel("attach media from a local archive"); await expect(attach.getByRole("button", { name: "Attach", exact: true })).toBeDisabled(); await attach.getByLabel("archive path").fill(archive); await attach.getByRole("button", { name: "Preview attach" }).click(); await expect(attach.getByRole("status", { name: "attach preview" })).toContainText("Would attach 1 held video.", { timeout: 30_000 }); await expect(attach.getByRole("status", { name: "attach preview" }).getByRole("link", { name: /^job / })).toBeVisible(); await expect(attach.getByRole("button", { name: "Attach", exact: true })).toBeEnabled(); // Other settings than the preview's disarm it. await attach.getByText("Replace files already saved").click(); await expect(attach.getByRole("button", { name: "Attach", exact: true })).toBeDisabled(); const playable = tools.getByLabel("playable copies", { exact: true }); await playable.getByRole("button", { name: "Preview playable copies" }).click(); await expect(playable.getByRole("status", { name: "playable preview" })).toContainText("Would make 0 playable copies", { timeout: 30_000 }); await expect(playable.getByRole("button", { name: "Make playable copies" })).toBeEnabled(); }); test("Save these videos: a preview buckets the list and arms the run; a line that names no video is refused", async ({ page: p }) => { await record(HELD, false); await p.goto("/saved-videos"); const box = p.getByRole("region", { name: "save these videos" }); const save = box.getByRole("button", { name: "Save videos" }); await box.getByLabel("videos to save").fill("just-one-word"); await box.getByRole("button", { name: "Preview" }).click(); await expect(box.getByRole("alert")).toContainText('line 1 "just-one-word"'); await expect(save).toBeDisabled(); await box.getByLabel("videos to save").fill(`${SLUG}/${HELD}\nno-such-channel/x1`); await box.getByRole("button", { name: "Preview" }).click(); const preview = box.getByRole("status", { name: "save preview" }); await expect(preview).toContainText("A run would download 1 video."); await expect(preview.locator('[data-bucket="toFetch"]')).toContainText(`${SLUG}/${HELD}`); await expect(preview.locator('[data-bucket="unknown"]')).toContainText("no-such-channel/x1"); await expect(save).toBeEnabled(); await box.getByLabel("quality to save").selectOption("video_720"); await expect(save).toBeDisabled(); });