diff --git a/src/canvas/workspace/example/ExampleCanvasDialog.tsx b/src/canvas/workspace/example/ExampleCanvasDialog.tsx index 3293fcf24..b1b7a8293 100644 --- a/src/canvas/workspace/example/ExampleCanvasDialog.tsx +++ b/src/canvas/workspace/example/ExampleCanvasDialog.tsx @@ -36,6 +36,18 @@ export function ExampleCanvasDialog({ }, []); const busy = entries.some((entry) => isRunning(entry.id)); + const settled = entries.every((entry) => { + const phase = statuses[entry.id]?.phase; + return phase === undefined || phase === "done"; + }); + const done = settled && entries.some((entry) => statuses[entry.id]?.phase === "done"); + const closeRef = useRef(onClose); + closeRef.current = onClose; + useEffect(() => { + if (!done) return; + const timer = window.setTimeout(() => closeRef.current(), 600); + return () => window.clearTimeout(timer); + }, [done]); return ( document.querySelectorAll(".react-flow__node").length === 2); assert.equal(await page.locator(".react-flow__node").count(), 2); await image.getByRole("progressbar").waitFor({ state: "hidden" }); - await dialog.getByRole("button", { name: "关闭", exact: true }).last().click(); + await dialog.waitFor({ state: "hidden" }); // 2. The project menu still reaches the full picker. // The switch saves the new project first; the switcher is disabled until then. @@ -114,7 +114,13 @@ try { await dialog.waitFor(); // The catalog ships with the app, so the rows carry its titles. await dialog.getByText("图像创作示例画布", { exact: true }).waitFor(); - await dialog.getByRole("button", { name: "关闭", exact: true }).first().click(); + await dialog + .locator(".cw-example-item") + .filter({ hasText: "图像创作示例画布" }) + .getByRole("button", { name: "下载并导入", exact: true }) + .click(); + await dialog.waitFor({ state: "hidden" }); + await page.waitForFunction(() => document.querySelectorAll(".react-flow__node").length === 2); // 3. A page instead of an archive is reported inline, and nothing is imported. await page.unroute(samplePattern);