import { test, expect as baseExpect } from "@playwright/test"; import { readFileSync } 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 TITLE PANEL (umtool redesign L6, item 7; 9 Nov: four news projects' title/subtitle set with jq): the Cut // tab's Project panel writes the manifest's `title` and `subtitle` in the draft (`umtool title` is the twin), // an empty subtitle removes it, no take touched. inspector-title-fixture (WRITES). // --------------------------------------------------------------------------- test.describe.configure({ timeout: 120_000 }); const P = "reports/inspector-title-fixture"; const DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", ".e2e-song", "reports", "inspector-title-fixture"); const manifest = () => JSON.parse(readFileSync(path.join(DIR, "video.manifest.json"), "utf8")) as { title?: string; subtitle?: string }; const takeText = () => readFileSync(path.join(DIR, "takes", "short", "take.json"), "utf8"); test("retitle the project and drop its subtitle from the Cut tab", 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="title"]'); await expect(panel.locator('[data-title-field="title"]')).toHaveValue("The Inspector Title Fixture"); await expect(panel.locator('[data-title-field="subtitle"]')).toHaveValue("an old subtitle"); await panel.locator('[data-title-field="title"]').fill("Losing the same hundred pounds"); await panel.locator('[data-title-field="subtitle"]').fill("Every weight he has given on camera"); await panel.locator("[data-title-save]").click(); await expect(panel.locator('[data-title-said="ok"]')).toContainText("Saved to the draft."); expect(manifest()).toMatchObject({ title: "Losing the same hundred pounds", subtitle: "Every weight he has given on camera" }); // The head follows (the crumb is the title). await expect(page.locator("body")).toContainText("Losing the same hundred pounds"); await page.screenshot({ path: test.info().outputPath("title-panel.png") }); await panel.locator('[data-title-field="subtitle"]').fill(""); await panel.locator("[data-title-save]").click(); await expect(panel.locator('[data-title-said="ok"]')).toBeVisible(); expect("subtitle" in manifest()).toBe(false); // An empty title cannot be saved. await panel.locator('[data-title-field="title"]').fill(" "); await expect(panel.locator("[data-title-save]")).toBeDisabled(); expect(takeText()).toBe(take); });