import { test, expect as baseExpect } from "@playwright/test"; import { readFileSync, readdirSync, statSync } 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 }); // --------------------------------------------------------------------------- // A STILL AT SECOND N (umtool redesign L6, item 6; components/projects/inspector/StillInspector.tsx): Play's Still // button keeps the frame on screen -- the clip's fetched window at the playhead's source second, one ffmpeg frame -- // as shots/still--s.png, listed on the Cut tab's Project panel; the cut itself is never written // (`umtool still` is the twin). inspector-still-fixture (WRITES shots/): play-cut-fixture's cut, its window cached. // --------------------------------------------------------------------------- test.describe.configure({ timeout: 120_000 }); const P = "reports/inspector-still-fixture"; const DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", ".e2e-song", "reports", "inspector-still-fixture"); const manifestText = () => readFileSync(path.join(DIR, "video.manifest.json"), "utf8"); const takeText = () => readFileSync(path.join(DIR, "takes", "short", "take.json"), "utf8"); test("Still in Play: the frame at the playhead into shots/, listed on the Cut tab, the draft untouched", async ({ page }) => { await page.setViewportSize({ width: 1366, height: 768 }); const before = manifestText(); const take = takeText(); await page.goto(urls.playHref(P, { clip: "c01", at: 0.5 })); const root = page.locator("[data-play-cut]"); await expect(root).toHaveAttribute("data-play-state", "paused", { timeout: 30_000 }); await expect(page.locator("[data-play-readout]")).toContainText("c01"); await page.locator("[data-play-still]").click(); const said = page.locator('[data-play-still-said="ok"]'); await expect(said).toContainText("shots/still-c01-", { timeout: 20_000 }); await page.screenshot({ path: test.info().outputPath("play-still.png") }); const shots = readdirSync(path.join(DIR, "shots")).filter((f) => f.startsWith("still-c01-")); expect(shots).toHaveLength(1); expect(statSync(path.join(DIR, "shots", shots[0])).size).toBeGreaterThan(100); // Its second is the clip's source second (c01 plays 1.0-3.0): inside the clip. const at = Number(/still-c01-(\d+)_(\d{2})s\.png/.exec(shots[0])?.slice(1, 3).join(".")); expect(at).toBeGreaterThanOrEqual(1); expect(at).toBeLessThanOrEqual(3); expect(manifestText()).toBe(before); expect(takeText()).toBe(take); await page.goto(urls.projectHref(P, { tab: "cut" })); await openPanel(page, "options", "cut-project"); const panel = page.locator('[data-inspector="still"]'); await expect(panel.locator(`[data-shot="shots/${shots[0]}"]`)).toBeVisible(); await expect(panel.locator(`[data-shot="shots/${shots[0]}"] img`)).toHaveJSProperty("complete", true); });