import { test, expect, type APIRequestContext, type Page } from "@playwright/test"; import { readFileSync, readdirSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; import * as urls from "./urls"; // --------------------------------------------------------------------------- // The gap mark set and seen in umtool (lane gap-cue, slice 1b; common // lib/report/gapCue.mjs is the rule, lib/report/gapCueView.mjs lays it out on a // page's clock): // // - the bench: a click on a gap's band picks it; its mark, why, own words and // corner, and the clip's mark settings, each written through the window // route (gapEdit / gapCue) as an undo point; the bench's Undo; Remove // - Play the cut: the mark is up at the join for its life, then gone, saying // the gap's reason // - the Modules panel: the project's label, and the mark in Play says it // // Fixture: gapcue-fixture (make-fixture.mjs), which this spec WRITES: gc01 // gapcuevid 0.5-8.5 and gc02 1.0-3.0, on the tone window gapcuevid_0.00-9.00.mp4. // Every test starts from one gap, 3.5-5.5 (2 s: the default shortest marked), // and no mark settings. // --------------------------------------------------------------------------- const HERE = path.dirname(fileURLToPath(import.meta.url)); const PROJECT = "reports/gapcue-fixture"; const DIR = path.join(HERE, "..", ".e2e-song", "reports", "gapcue-fixture"); const MANIFEST = path.join(DIR, "video.manifest.json"); type Gap = { from: number; to: number; mark?: boolean; why?: string; reason?: string; corner?: string }; type Manifest = { render: { gapCue?: Record }; timeline: { id: string; gaps?: Gap[]; gapCue?: Record }[] }; const read = () => JSON.parse(readFileSync(MANIFEST, "utf8")) as Manifest; const clipOf = (id = "gc01") => read().timeline.find((e) => e.id === id)!; const undoPoints = () => { try { return readdirSync(path.join(DIR, "revisions")).filter((f) => f.includes("auto-before-gaps")).length; } catch { return 0; } }; const token = async (request: APIRequestContext, clip = "gc01") => ((await (await request.get(`/api/report/clip?project=${encodeURIComponent(PROJECT)}&clip=${clip}`)).json()) as { token: string }).token; const putWindow = async (request: APIRequestContext, data: Record, clip = "gc01") => request.put("/api/report/window", { data: { project: PROJECT, clip, token: await token(request, clip), ...data } }); const putLook = async (request: APIRequestContext, patch: Record) => { const t = ((await (await request.get(`/api/report/render?project=${encodeURIComponent(PROJECT)}`)).json()) as { token: string }).token; return request.put("/api/report/render", { data: { project: PROJECT, token: t, patch } }); }; const openBench = async (page: Page) => { await page.goto(urls.clipBenchHref(PROJECT, "gc01")); await page.locator("[data-wave-box]").scrollIntoViewIfNeeded(); await expect(page.locator("[data-gap-band]")).toHaveCount(1); }; test.beforeEach(async ({ request }) => { test.setTimeout(120_000); let r = await putWindow(request, { gaps: [{ from: 3.5, to: 5.5 }], gapCue: null }); expect(r.ok(), await r.text()).toBeTruthy(); r = await putLook(request, { gapCue: null }); expect(r.ok(), await r.text()).toBeTruthy(); }); test("the bench: a gap's band picks it; its mark, why, words and corner, and the clip's settings, are written as the CLI writes them, each an undo point", async ({ page }) => { await openBench(page); const row = page.locator("[data-gap-picked-row]"); await expect(row).toHaveCount(0); // The clip's settings are there with a gap, each saying the project's. await expect(page.locator("[data-gap-cue-mark]")).toContainText("as the project"); await page.locator("[data-gap-band]").click(); await expect(page.locator("[data-gap-band][data-gap-picked]")).toHaveCount(1); await expect(row).toBeVisible(); // Fast-forward is said, not offered. await expect(row.locator("[data-gap-show=skip]")).toContainText("fast-forward: not built yet"); // Its mark on: gapEdit, an undo point. The picture is the SAME