import { expect, test } from "@playwright/test"; import { captureLoadedContinuation } from "./continuation-screenshot.js"; const shell = (busy: boolean, title = "Continuation example") => `

${title}

${busy ? '
Loading conversation
' : '

Saved note is ready

'}
`; test("capture waits through app loading and conversation loading", async ({ page }) => { await page.setContent(`

App loading

`); let captured = ""; await captureLoadedContinuation(page, "Continuation example", async () => { captured = await page.locator("body").innerText(); await page.screenshot(); }, 3000); expect(captured).toContain("Saved note is ready"); expect(captured).not.toContain("Loading"); }); for (const state of ["app-loader", "history-loader", "wrong-task"] as const) { test(`does not capture ${state} as a successful checkpoint`, async ({ page }) => { await page.setContent(state === "app-loader" ? "

App loading

" : shell(state === "history-loader", state === "wrong-task" ? "Unrelated task" : undefined)); let captures = 0; await expect(captureLoadedContinuation(page, "Continuation example", async () => { captures++; }, 250)).rejects.toThrow(); expect(captures).toBe(0); }); }