import { test, expect } from "@playwright/test"; import { existsSync, readFileSync } from "node:fs"; import path from "node:path"; import { fileURLToPath } from "node:url"; import * as urls from "./urls"; // --------------------------------------------------------------------------- // The look of a highlights cut (release 36 lane C). The Build tab's Look // panel saves the header, the QR, the join, the loudness and the speaker // captions and room at the clips' edges into the manifest (and reads them // back); the clip editor's strip shades a clip's muted tail and its own // toggle writes `room: false`; the clip editor's // Speakers list names a voice for the captions (reactions.json); Frame the // short drags a 9:16 box on the player (the clip's vertical.crop); Make a // short runs the job (build-video --short) and the Deliver tab's Shorts list // shows it and plays it. Fixture: e2e/fixtures/clip-editor-fixture.mjs, as // reports/clip-look-fixture. // --------------------------------------------------------------------------- const HERE = path.dirname(fileURLToPath(import.meta.url)); const FIXTURE = path.join(HERE, "..", ".e2e-song"); const PROJECT = "reports/clip-look-fixture"; const DIR = path.join(FIXTURE, "reports", "clip-look-fixture"); const json = (name: string) => { try { return JSON.parse(readFileSync(path.join(DIR, name), "utf8")); } catch { return null; } }; const render = () => json("video.manifest.json")?.render ?? {}; const clip = (id: string) => (json("video.manifest.json")?.timeline ?? []).find((e: { id: string }) => e.id === id) ?? null; test("the look: the panel saves and reads back; a voice named; a short framed, made and listed", async ({ page }) => { test.setTimeout(240_000); await page.setViewportSize({ width: 1366, height: 900 }); // ---- the Look panel -------------------------------------------------------- await page.goto(urls.section(PROJECT, "build")); const panel = page.locator("[data-look-panel]"); await expect(panel).toHaveAttribute("data-look-panel", ""); await expect(page.locator("[data-look-header]")).toBeChecked(); await expect(page.locator("[data-look-save]")).toBeDisabled(); await page.locator("[data-look-header]").uncheck(); await page.locator("[data-look-qr]").uncheck(); await page.locator("[data-look-transition]").fill("0.5"); await page.locator("[data-look-style]").selectOption("blurslide"); // Room at the clips' edges (release 36 lane E). await page.locator("[data-look-room-tail]").check(); await page.locator("[data-look-room-head]").check(); await page.locator("[data-look-loudness]").selectOption("-16"); await page.locator("[data-look-captions]").check(); await page.locator("[data-look-label-host]").fill("The host"); await page.locator("[data-look-size]").selectOption("l"); // The brand intro (render.intro): a style by name. await expect(page.locator("[data-look-intro]")).toHaveValue(""); await page.locator("[data-look-intro]").selectOption("boot-wipe"); await page.locator("[data-look-save]").click(); await expect(page.locator("[data-look-status]")).toHaveText("Saved — the next render uses it"); const r = render(); expect(r.headerHeight).toBe(0); expect(r.qr).toBe(false); expect(r.transition).toBe(0.5); expect(r.transitionStyle).toBe("blurslide"); expect(r.room).toEqual({ tail: true, head: true }); expect(r.loudness).toEqual({ target: -16 }); expect(r.captions).toEqual({ style: "speakers", labels: { host: "The host" }, size: "l" }); expect(r.intro).toBe("boot-wipe"); expect(r.width).toBe(640); // Read back after a reload. await page.reload(); await expect(page.locator("[data-look-panel]")).toHaveAttribute("data-look-panel", ""); await expect(page.locator("[data-look-header]")).not.toBeChecked(); await expect(page.locator("[data-look-qr]")).not.toBeChecked(); await expect(page.locator("[data-look-style]")).toHaveValue("blurslide"); await expect(page.locator("[data-look-room-tail]")).toBeChecked(); await expect(page.locator("[data-look-room-head]")).toBeChecked(); await expect(page.locator("[data-look-loudness]")).toHaveValue("-16"); await expect(page.locator("[data-look-captions]")).toBeChecked(); await expect(page.locator("[data-look-label-host]")).toHaveValue("The host"); await expect(page.locator("[data-look-intro]")).toHaveValue("boot-wipe"); // None clears it: the cut opens as it did. await page.locator("[data-look-intro]").selectOption(""); await page.locator("[data-look-save]").click(); await expect(page.locator("[data-look-status]")).toHaveText("Saved — the next render uses it"); expect("intro" in render()).toBe(false); // ---- the clip editor: a voice named, the short framed -------------------- await page.goto(urls.clipEditorHref(PROJECT, { clip: "r001" })); await expect(page.locator("[data-clip-editor]")).toHaveAttribute("data-clip-editor", "r001"); const subject = page.locator('[data-speaker-label="1"]'); await subject.fill("The narrator"); await subject.press("Enter"); await expect.poll(() => json("reactions.json")?.speakers?.find((s: { index: number }) => s.index === 1)?.label).toBe("The narrator"); // Room at the edges: the strip shades the clip's muted tail; the clip's own toggle writes its override. await expect(page.locator('[data-strip-room="tail"]')).toBeVisible(); await expect(page.locator("[data-clip-room]")).toBeChecked(); await page.locator("[data-clip-room]").uncheck(); await expect.poll(() => clip("r001")?.room ?? null).toBe(false); await expect(page.locator('[data-strip-room="tail"]')).toHaveCount(0); await page.locator("[data-clip-room]").check(); await expect.poll(() => clip("r001")?.room === undefined).toBe(true); await expect(page.locator('[data-strip-room="tail"]')).toBeVisible(); await expect(page.locator("[data-editor-player]")).toHaveAttribute("data-editor-player", /^(?!looking|none)/, { timeout: 20_000 }); await page.locator("[data-frame-short]").click(); const box = page.locator("[data-crop-box]"); await expect(box).toBeVisible(); const at = await box.boundingBox(); if (!at) throw new Error("no crop box"); await page.mouse.move(at.x + at.width / 2, at.y + at.height / 2); await page.mouse.down(); await page.mouse.move(at.x + at.width / 2 + 120, at.y + at.height / 2, { steps: 6 }); await page.mouse.up(); await expect.poll(() => clip("r001")?.vertical?.crop?.[0] ?? null).toBeGreaterThan(0.36); const crop = clip("r001").vertical.crop as number[]; expect(crop[3]).toBe(1); expect(Math.abs((crop[2] * (640 / 360)) / crop[3] - 9 / 16)).toBeLessThan(0.01); await expect(page.locator("[data-short-maker]")).toContainText("Framed by you"); // ---- Make a short: the job, then the file -------------------------------- await page.locator('[data-make-short="r001"]').click(); await expect(page.locator("[data-short-job]")).toHaveAttribute("data-short-job", "done", { timeout: 180_000 }); expect(existsSync(path.join(DIR, "shorts", "r001.mp4"))).toBe(true); const rec = json("shorts/r001.json"); expect(rec.width).toBe(1080); expect(rec.height).toBe(1920); expect(rec.crop).toEqual(crop); await expect(page.locator('[data-make-short="r001"]')).toHaveText("Make the short again"); // ---- the Shorts list on the Deliver tab ---------------------------------- await page.goto(urls.section(PROJECT, "deliver")); const row = page.locator('[data-short="r001"]'); await expect(row).toBeVisible(); await expect(page.locator("[data-shorts]")).toHaveAttribute("data-shorts", "1"); await row.locator('[data-short-play="r001"]').click(); const player = page.locator('[data-short-player="r001"]'); await expect(player).toBeVisible(); await expect.poll(() => player.evaluate((v: HTMLVideoElement) => v.videoHeight)).toBe(1920); await expect(row.locator('[data-short-download="r001"]')).toHaveAttribute("href", /download=1/); });