Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/canvas/workspace/example/ExampleCanvasDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<dialog
Expand Down
10 changes: 8 additions & 2 deletions tests/browser/example_canvas_picker.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ try {
await page.waitForFunction(() => 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.
Expand All @@ -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);
Expand Down
Loading