import { test, expect as baseExpect } from "@playwright/test"; import { readFileSync, writeFileSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; import { openPanel } from "./panels"; import * as urls from "./urls"; // A write is a request under the app's lock, and this machine runs other suites beside this one: room for it. const expect = baseExpect.configure({ timeout: 15_000 }); // --------------------------------------------------------------------------- // THE RUMBLE CITE FIX (umtool redesign L6, item 5; components/projects/inspector/LinksInspector.tsx): the Cut // tab's Project panel lists each clip citing a Rumble URL-slug FOLDER the archive does not serve, with the embed // id it does (L1's siteVideoFor, from the folder's metadata), and "Use the published embed id" writes `siteVideo` // into the draft -- per row, and once for every dead Rumble row; one undo point per press, no network, no take // touched (`umtool links
--embed-ids` is the twin). inspector-rumble-fixture (WRITES): r01 v7slug1 -> v7emb01, // r02 v7slug2 -> v7emb02 (both dead at the last check), r03 its own id. // --------------------------------------------------------------------------- test.describe.configure({ mode: "serial", timeout: 120_000 }); const P = "reports/inspector-rumble-fixture"; const DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", ".e2e-song", "reports", "inspector-rumble-fixture"); type Clip = { id: string; video: string; siteVideo?: string }; const clips = () => (JSON.parse(readFileSync(path.join(DIR, "video.manifest.json"), "utf8")) as { timeline: Clip[] }).timeline; const sv = () => Object.fromEntries(clips().map((c) => [c.id, c.siteVideo ?? null])); const takeText = () => readFileSync(path.join(DIR, "takes", "short", "take.json"), "utf8"); test("one row: Use the published embed id -- siteVideo in the draft, the folder id kept", async ({ page, request }) => { await page.setViewportSize({ width: 1366, height: 768 }); const take = takeText(); await page.goto(urls.projectHref(P, { tab: "cut" })); await openPanel(page, "options", "cut-project"); const panel = page.locator('[data-inspector="links"]'); await expect(panel.locator("[data-embed-row]")).toHaveCount(2); await expect(panel.locator('[data-embed-row="r01"]')).toHaveAttribute("data-embed-state", "dead"); await expect(panel.locator('[data-embed-row="r01"]')).toContainText("inspectrumble/v7slug1 → v7emb01"); await expect(panel.locator('[data-embed-row="r03"]')).toHaveCount(0); await expect(panel.locator("[data-embed-use-all]")).toContainText("for all 2 dead"); await page.screenshot({ path: test.info().outputPath("rumble-cites.png") }); await panel.locator('[data-embed-use="r01"]').click(); await expect(panel.locator('[data-embed-said="ok"]')).toContainText("r01 → v7emb01"); expect(sv()).toEqual({ r01: "v7emb01", r02: null, r03: null }); expect(clips().find((c) => c.id === "r01")?.video).toBe("v7slug1"); await expect(panel.locator("[data-embed-row]")).toHaveCount(1); expect(takeText()).toBe(take); // A write without the token the panel read is refused, never blind. const bare = await request.post("/api/report/embed-ids", { data: { project: P, clips: ["r02"] } }); expect(bare.status()).toBe(400); expect(sv().r02).toBeNull(); // One press, one undo step. const r = await request.post("/api/report/timeline", { data: { project: P, op: "undo" } }); expect(r.ok(), await r.text()).toBe(true); expect((await r.json()).op).toBe("embed-ids"); expect(sv()).toEqual({ r01: null, r02: null, r03: null }); }); test("every dead Rumble row in one press", async ({ page }) => { await page.setViewportSize({ width: 1366, height: 768 }); const take = takeText(); await page.goto(urls.projectHref(P, { tab: "cut" })); await openPanel(page, "options", "cut-project"); const panel = page.locator('[data-inspector="links"]'); await expect(panel.locator("[data-embed-row]")).toHaveCount(2); await panel.locator("[data-embed-use-all]").click(); await expect(panel.locator('[data-embed-said="ok"]')).toContainText("r01 → v7emb01, r02 → v7emb02"); expect(sv()).toEqual({ r01: "v7emb01", r02: "v7emb02", r03: null }); await expect(panel.locator("[data-embed-none]")).toBeVisible(); expect(takeText()).toBe(take); }); test("a check that found the folder links open: no 'all' press, a row is fixed only by its own", async ({ page, request }) => { await page.setViewportSize({ width: 1366, height: 768 }); // Back to the folder ids, then a check that read both links open. const r = await request.post("/api/report/timeline", { data: { project: P, op: "undo" } }); expect(r.ok(), await r.text()).toBe(true); expect(sv()).toEqual({ r01: null, r02: null, r03: null }); const file = path.join(DIR, "out", "links.json"); const doc = JSON.parse(readFileSync(file, "utf8")) as { links: { state: string; fix?: string; fixSiteVideo?: string; why?: string }[] }; doc.links = doc.links.map(({ fix: _f, fixSiteVideo: _s, why: _w, ...l }) => ({ ...l, state: "ok" })); writeFileSync(file, JSON.stringify(doc, null, 2) + "\n"); await page.goto(urls.projectHref(P, { tab: "cut" })); await openPanel(page, "options", "cut-project"); const panel = page.locator('[data-inspector="links"]'); await expect(panel.locator("[data-embed-row]")).toHaveCount(2); await expect(panel.locator('[data-embed-row="r01"]')).toHaveAttribute("data-embed-state", "ok"); await expect(panel.locator("[data-embed-no-dead]")).toContainText("no dead links at the last check"); await expect(panel.locator("[data-embed-use-all]")).toHaveCount(0); expect(sv()).toEqual({ r01: null, r02: null, r03: null }); });