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"; import { openPanel } from "./panels"; // --------------------------------------------------------------------------- // THE POST VIDEO, END TO END BY CLICKING (lane/ui-simplify, 5 Nov; the operator: // "a person can make a video end to end in umtool with no agent"). Fixture: // e2e/fixtures/post-happy-fixture.mjs -- an empty cut on the postchan-x // archive. Every step is a press: // // Cut tab → + Add posts → Preview → Add N posts (posts reel) // Options "Reads and voices" → a pronunciation → Try it (posts say) // the head's ▶ Play → Play of the cut (no /play typed) // Takes → New take → Make it → its render queued (the take maker) // --------------------------------------------------------------------------- const HERE = path.dirname(fileURLToPath(import.meta.url)); const P = "reports/post-happy-fixture"; const DIR = path.join(HERE, "..", ".e2e-song", "reports", "post-happy-fixture"); const timeline = () => (JSON.parse(readFileSync(path.join(DIR, "video.manifest.json"), "utf8")).timeline as { id: string; type: string }[]); test("a post video from Add posts to a queued render, all by clicking", async ({ page }) => { test.setTimeout(240_000); await page.goto(urls.projectHref(P, { tab: "cut" })); // 1. Add posts: what the archive holds that the cut does not play, previewed, then added in one write. await page.locator("[data-add-posts-open]").click(); await page.locator("[data-add-posts-channel]").fill("postchan-x"); await page.locator("[data-add-posts-preview]").click(); const plan = page.locator('[data-add-posts-result="plan"]'); await expect(plan).toBeVisible(); const n = Number(await plan.getAttribute("data-add-posts-added")); expect(n).toBeGreaterThan(0); await page.locator("[data-add-posts-go]").click(); await expect(page.locator('[data-add-posts-result="done"]')).toHaveAttribute("data-add-posts-added", String(n)); await expect.poll(() => timeline().filter((e) => e.type === "post").length).toBe(n); await expect(page.locator('li[data-kind="post"]')).toHaveCount(n); // The head now offers Play (the newest take; none yet, so the cut). await expect(page.locator('[data-play-link="header"]')).toHaveAttribute("href", urls.playHref(P)); // Every row plays from itself. await expect(page.locator('li[data-kind="post"]').first().locator('[data-play-link="row"]')).toBeVisible(); // 2. Reads and voices: a pronunciation, tried. await openPanel(page, "options", "cut-reads"); await page.locator("[data-lexicon-word]").fill("atm"); await page.locator("[data-lexicon-say]").fill("A-T-M"); await page.locator("[data-lexicon-add]").click(); await expect(page.locator('[data-lexicon-row="atm"]')).toBeVisible(); expect(existsSync(path.join(DIR, "narration", "lexicon.json"))).toBe(true); await page.locator("[data-lexicon-try]").fill("it is atm now"); await page.locator("[data-lexicon-try-go]").click(); await expect(page.locator("[data-lexicon-tried]")).toContainText("A-T-M"); // 3. Play, from the head: no /play typed. await page.locator('[data-play-link="header"]').click(); await expect(page).toHaveURL(/\/play\?cut=1(&|$)/); await expect(page.locator("[data-play-cut]")).toBeVisible(); // 5. A take, rendered: the take maker's job starts from a press. await page.goto(urls.takesHref(P)); await page.locator("[data-action='new-take-open']").click(); const style = page.locator("[data-take-style]"); await expect(style).toBeEnabled(); await style.selectOption("e2e-crisp"); await page.locator("[data-take-window='full']").check(); await page.locator("[data-action='make-take']").click(); const job = page.locator("[data-take-job]"); await expect(job).toBeVisible(); await expect(page.locator('[data-take-step="crisp"]')).toBeAttached(); await expect(job).toHaveAttribute("data-job-progress-of", "running"); // Queued and rendering is the happy path's end here (a whole cut of posts renders for minutes; takes.spec.ts judges // a finished take). Stopped by its own press, so it is not left running for the next spec. await job.getByRole("button", { name: "Stop" }).click(); await expect(job).not.toHaveAttribute("data-job-progress-of", "running", { timeout: 90_000 }); });