Skip to content

armgit / fuobe

Public Imported from GitHub
0

The open creative studio on ComfyUI: images, video, 3D and audio on open weights, on your own GPU or the cloud. Camera motions, effects, apps, Cinema, Layers, Image to 3D and an AI agent.

Canvas: browser checks for the review fixes and the open-engine dub

Claude5b122f74d3bc
diff --git a/tests/e2e/canvas-board.mjs b/tests/e2e/canvas-board.mjs
index 87ab06a1..292432fc 100644
--- a/tests/e2e/canvas-board.mjs
+++ b/tests/e2e/canvas-board.mjs
@@ -7,6 +7,9 @@
// 2. A box selection grouped with Ctrl+G frames the nodes; Run group runs only the nodes inside it.
// 3. A second page holds its own board; switching back keeps the first one; everything is saved (read
// back from the API).
+// 4. An Undo clicked after switching pages lands on its own page; a page renamed just before a run is saved
+// by the run; ⌘↵ with only a drawing selected runs the board; C then Enter pins a comment, and an empty
+// one goes when focus leaves it; the arrow keys move between page tabs; scrolling pans the board.
import { DESKTOP, launch } from "./_browser.mjs";
const app = (process.argv.slice(2).find((a) => !a.startsWith("--")) ?? "http://localhost:3000").replace(/\/$/, "");
@@ -101,6 +104,77 @@ try {
const p1 = saved.pages[0].graph;
check("both pages are saved", saved.pages.length === 2 && saved.pages[1].graph.nodes.length === 0, saved.pages.map((p) => p.name).join(", "));
check("drawings, text, comment and group are saved", (p1.shapes ?? []).some((x) => x.kind === "rect") && (p1.shapes ?? []).some((x) => x.text === "Hello board") && p1.comments?.[0]?.text === "Check the light" && p1.groups?.length === 1);
+
+ // 4. Review fixes.
+ const pageNodes = async () => (await api(`/api/canvases/${c.id}`)).canvas.pages.map((p) => p.graph.nodes.map((x) => x.id).sort().join(","));
+ // Undo after a page switch: the deleted node comes back on page 1, and page 2 keeps its own board.
+ await page.locator('[data-testid="canvas-node-other"]').click({ position: { x: 20, y: 12 } });
+ await page.keyboard.press("Delete");
+ await page.getByText("Node deleted").waitFor({ timeout: 5000 });
+ await page.getByRole("tab", { name: "Page 2" }).click();
+ await page.waitForTimeout(300);
+ await page.getByRole("button", { name: "Undo" }).click();
+ await page.waitForTimeout(400);
+ check("Undo after a page switch leaves the open page as it is", (await page.locator('[data-testid^="canvas-node-"]').count()) === 0);
+ await page.waitForTimeout(1500);
+ const afterUndo = await pageNodes();
+ check("…and puts the node back on its own page", afterUndo[0] === "img,other,p" && afterUndo[1] === "", afterUndo.join(" | "));
+ // A rename just before ⌘↵ is saved by the run (the autosave hasn't gone yet).
+ await page.getByRole("tab", { name: "Page 2" }).dblclick();
+ await page.getByRole("textbox", { name: "Page name" }).fill("Shots");
+ await page.keyboard.press("Enter");
+ await page.getByRole("tab", { name: "Page 1" }).click();
+ await page.locator('[data-testid="canvas-node-img"]').waitFor({ timeout: 10_000 });
+ // A drawing alone is selected (a new rectangle is): ⌘↵ runs the board, not the drawing.
+ await page.keyboard.press("r");
+ const r2 = at(0.15, 0.85);
+ await page.mouse.move(r2.x, r2.y);
+ await page.mouse.down();
+ await page.mouse.move(r2.x + 60, r2.y + 40, { steps: 3 });
+ await page.mouse.up();
+ await page.keyboard.press("Control+Enter");
+ const toast = await page.locator("[data-sonner-toast]").filter({ hasText: /Running|up to date/ }).first().textContent({ timeout: 10_000 });
+ check("⌘↵ with only a drawing selected runs the board", /Running/.test(toast ?? ""), toast ?? "");
+ const named = (await api(`/api/canvases/${c.id}`)).canvas.pages.map((p) => p.name);
+ check("a page renamed right before a run is saved by it", named[1] === "Shots", named.join(", "));
+ // C, then Enter: a comment in the middle of the view, open for typing; leaving it empty removes it.
+ const pins = () => page.locator('[data-testid^="canvas-comment-"]').count();
+ const before = await pins();
+ await page.evaluate(() => document.activeElement?.blur());
+ await page.keyboard.press("c");
+ await page.keyboard.press("Enter");
+ await page.waitForFunction(() => document.activeElement?.getAttribute("aria-label") === "Comment", null, { timeout: 5000 }).catch(() => {});
+ check("C then Enter pins a comment from the keyboard", (await pins()) === before + 1);
+ await page.mouse.click(at(0.3, 0.5).x, at(0.3, 0.5).y);
+ await page.waitForTimeout(300);
+ check("an empty comment goes when focus leaves it", (await pins()) === before);
+ // Keyboard only: Tab to the Comment tool, Enter picks it, Enter again pins a comment.
+ await page.getByRole("button", { name: "Comment (C)" }).focus();
+ await page.keyboard.press("Enter");
+ await page.keyboard.press("Enter");
+ await page.waitForFunction(() => document.activeElement?.getAttribute("aria-label") === "Comment", null, { timeout: 5000 }).catch(() => {});
+ check("the Comment tool's button, pressed again with Enter, pins a comment", (await pins()) === before + 1);
+ await page.keyboard.type("From the keyboard");
+ await page.keyboard.press("Escape");
+ // Page tabs: one in the Tab order, arrows move between them.
+ await page.getByRole("tab", { name: "Page 1" }).focus();
+ await page.keyboard.press("ArrowRight");
+ await page.waitForTimeout(400);
+ const selectedTab = await page.locator('[role="tab"][aria-selected="true"]').textContent();
+ const focusedTab = await page.evaluate(() => document.activeElement?.textContent);
+ check("ArrowRight opens and focuses the next page tab", selectedTab === "Shots" && focusedTab === "Shots", `${selectedTab} / ${focusedTab}`);
+ check("only the open page's tab is in the Tab order", (await page.locator('[role="tab"][tabindex="0"]').count()) === 1);
+ await page.keyboard.press("Home");
+ await page.locator('[data-testid="canvas-node-img"]').waitFor({ timeout: 10_000 });
+ // Scrolling pans (pinch or ⌘-scroll zooms).
+ const transform = () => page.locator(".react-flow__viewport").evaluate((el) => getComputedStyle(el).transform);
+ const t0 = await transform();
+ await page.mouse.move(at(0.4, 0.4).x, at(0.4, 0.4).y);
+ await page.mouse.wheel(0, 200);
+ await page.waitForTimeout(400);
+ const t1 = await transform();
+ const scale = (t) => Number(/matrix\(([^,]+)/.exec(t)?.[1] ?? 1);
+ check("scrolling pans the board without zooming", t1 !== t0 && scale(t1) === scale(t0), `${t0} → ${t1}`);
} catch (e) {
failures.push(`script: ${e.message.split("\n")[0]}`);
console.log(`FAIL ${e.message.split("\n")[0]}`);
diff --git a/tests/e2e/canvas-open-dub.mjs b/tests/e2e/canvas-open-dub.mjs
new file mode 100644
index 00000000..87469bff
--- /dev/null
+++ b/tests/e2e/canvas-open-dub.mjs
@@ -0,0 +1,82 @@
+// Translate (video) on an open-source-only install, in a real browser (r4/canvas-plus).
+// Usage: node tests/e2e/canvas-open-dub.mjs [appUrl]
+//
+// Against a running app (demo mode is enough). Settings → Engine mode is set to open source only for the run and
+// put back afterwards. The open engine dubs in Translate & dub, where the translation is checked before it's
+// spoken: the node starts that dub with its clip and language, follows it, and once the dub is voiced ("Use the
+// dubbed video") the dubbed clip comes back to the board as a Video input, wired where the node went.
+import fs from "node:fs";
+import path from "node:path";
+import { DESKTOP, launch, root } from "./_browser.mjs";
+
+const app = (process.argv.slice(2).find((a) => !a.startsWith("--")) ?? "http://localhost:3000").replace(/\/$/, "");
+const json = async (p, init) => {
+ const res = await fetch(app + p, { headers: { "Content-Type": "application/json" }, ...init });
+ const body = await res.json();
+ if (!res.ok) throw new Error(`${p}: ${body.error ?? res.status}`);
+ return body;
+};
+const failures = [];
+const check = (label, ok, detail = "") => {
+ console.log(`${ok ? "ok " : "FAIL"} ${label}${detail ? ` (${detail})` : ""}`);
+ if (!ok) failures.push(label);
+};
+
+const was = (await json("/api/settings")).settings.find((s) => s.name === "engineMode").value;
+await json("/api/settings", { method: "PUT", body: JSON.stringify({ engineMode: "open" }) });
+const browser = await launch();
+try {
+ const form = new FormData();
+ form.append("file", new Blob([fs.readFileSync(path.join(root, "public/samples/demo-landscape.mp4"))], { type: "video/mp4" }), "talk.mp4");
+ const up = await (await fetch(`${app}/api/uploads`, { method: "POST", body: form })).json();
+ const n = (id, type, data, x, y) => ({ id, type, position: { x, y }, data });
+ const graph = {
+ nodes: [n("clip", "video-input", { url: up.url, label: "Talk" }, 0, 0), n("tr", "translate", { mediaKind: "video", label: "Dub", params: { targetLanguage: "es" } }, 400, 0), n("out", "output", {}, 800, 0)],
+ edges: [
+ { id: "e1", source: "clip", sourceHandle: "out", target: "tr", targetHandle: "video" },
+ { id: "e2", source: "tr", sourceHandle: "out", target: "out", targetHandle: "in" },
+ ],
+ };
+ const c = await json("/api/canvases", { method: "POST", body: JSON.stringify({ name: "Open dub check", graph }) });
+ const page = await (await browser.newContext(DESKTOP)).newPage();
+ page.on("pageerror", (e) => failures.push(`page error: ${e.message}`));
+ await page.goto(`${app}/canvas/${c.id}`, { waitUntil: "load" });
+ const node = page.locator('[data-testid="canvas-node-tr"]');
+ await node.waitFor({ timeout: 120_000 });
+ const start = node.getByRole("button", { name: /Start in Translate & dub/ });
+ await start.waitFor({ timeout: 10_000 });
+ check("the node offers to start the dub in Translate & dub", await start.isEnabled());
+ check("an open dub isn't counted as something to fix", !/need/.test((await page.locator("header").textContent()) ?? ""));
+ await start.click();
+ await page.getByText("Dub started").waitFor({ timeout: 30_000 });
+ await page.waitForTimeout(1500);
+ const dubId = (await json(`/api/canvases/${c.id}`)).canvas.pages[0].graph.nodes.find((x) => x.id === "tr").data.dubId;
+ check("the node keeps the dub it started (saved with the board)", !!dubId, dubId);
+ const session = await json(`/api/dub/${dubId}`);
+ check("the dub has the node's clip and language", session.video === up.url && session.engine === "open" && session.targets.join() === "es");
+ await node.getByText("Ready for you to check the translation").waitFor({ timeout: 120_000 });
+ check("the node follows the dub to its review", true);
+ check("it links to the review", (await node.getByRole("link", { name: "Check the translation" }).getAttribute("href")) === `/audio/translate?dub=${dubId}`);
+ // The person checks the lines in Translate & dub and has them spoken (here through its API).
+ await json(`/api/dub/${dubId}/voice`, { method: "POST", body: JSON.stringify({ lang: "es" }) });
+ await page.reload({ waitUntil: "load" });
+ const use = page.locator('[data-testid="canvas-node-tr"]').getByRole("button", { name: /Use the dubbed video/ });
+ await use.waitFor({ timeout: 180_000 });
+ await use.click();
+ await page.waitForTimeout(1500);
+ const board = (await json(`/api/canvases/${c.id}`)).canvas.pages[0].graph;
+ const input = board.nodes.find((x) => x.type === "video-input" && x.id !== "clip");
+ const done = await json(`/api/dub/${dubId}`);
+ const film = done.voices.es.at(-1).ids.film;
+ check("the dubbed video comes back as a Video input", !!input && input.data.url === done.generations[film].outputs.find((o) => o.kind === "video").url, input?.data.label);
+ check("…wired where the node went", board.edges.some((e) => e.source === input?.id && e.target === "out") && !board.edges.some((e) => e.source === "tr"));
+ check("…and offered once", (await use.count()) === 0 && (await page.getByText("it's on the board as a Video input").count()) === 1);
+} catch (e) {
+ failures.push(`script: ${e.message.split("\n")[0]}`);
+ console.log(`FAIL ${e.message.split("\n")[0]}`);
+} finally {
+ await browser.close();
+ await json("/api/settings", { method: "PUT", body: JSON.stringify({ engineMode: was }) });
+}
+console.log(failures.length ? `\n${failures.length} open dub check(s) failed` : "\nAll open dub checks passed.");
+process.exit(failures.length ? 1 : 0);