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.
TypeScript ai-videocomfyuicreative-toolsgenerative-aiideogramimage-generationimage-to-3dimage-to-videoltx-videominimax-h3nextjsopen-sourceopen-weightsqwen-imagetext-to-imagevideo-generationwan
Originals O6: tests and browser checks for the review fixes
Claude63de294df0ce
diff --git a/tests/cinema-api.test.ts b/tests/cinema-api.test.tsindex 91c049c6..4592cf7f 100644--- a/tests/cinema-api.test.ts+++ b/tests/cinema-api.test.ts@@ -12,7 +12,7 @@ process.env.OLLAMA_URL = "http://127.0.0.1:9";const { setSetting } = await import("@/server/settings");const gens = await import("@/server/generations");const cinema = await import("@/server/cinema");-const { generateInProject, swatchUrl } = await import("@/server/cinema-generate");+const { cinemaContext, generateInProject, swatchUrl } = await import("@/server/cinema-generate");const { askDirector, ideaOf, offlineDirector, parseDirectorAnswer } = await import("@/server/cinema-director");const projectsRoute = await import("@/app/api/cinema/projects/route");const projectRoute = await import("@/app/api/cinema/projects/[id]/route");@@ -174,13 +174,47 @@ describe("Cinema API", () => {// Demo mode runs are free, so the guard only bites on real (paid) routes; previewing with a fake key shows the message.setSetting("falKey", "test-key");try {- // 20 s on Fuobe Cinema at 720p is about $0.69 ($0.0347/s).+ // 20 s on Fuobe Cinema at 720p 16:9 is about $0.70 (1280 × 704 × 481 frames at $0.001605 per megapixel).expect(() => generateInProject(p.id, { ...VIDEO, duration: 20 })).toThrow(/past its \$0\.50 limit/);} finally {setSetting("falKey", "");}});+ it("an edit carries the take's facts through the API: its model picks the editor, its length prices it", async () => {+ const p = cinema.createProject({ name: "Edits" });+ const src = gens.createGenerations({ feature: "cinema", modelId: "seedance-2-5", prompt: "source take", params: { duration: 5 } })[0];+ const take = await settle(src.id);+ const source = { url: take.outputs[0].url, kind: "video", modelId: "seedance-2-5", prompt: "A detective lights a match in the rain", seconds: 5.04, resolution: "720p", aspectRatio: "16:9" };+ // A Seedance take is edited with Kling O3, whatever the menu says.+ const partner = await generateRoute.POST(json("POST", { input: { ...VIDEO, action: "edit", prompt: "make it snow", source } }), params({ id: p.id }));+ expect(partner.status).toBe(201);+ const pj = await partner.json();+ expect(pj.plan.modelId).toBe("kling-o3");+ // A Fuobe Cinema take: LTX-2.3 video-to-video with the take's scene, the take held and its sound kept.+ const own = await generateRoute.POST(json("POST", { input: { ...VIDEO, action: "edit", prompt: "make it snow", source: { ...source, modelId: "fuobe-cinema" } } }), params({ id: p.id }));+ expect(own.status).toBe(201);+ const oj = await own.json();+ expect(oj.plan.modelId).toBe("fuobe-cinema");+ const g = gens.getGeneration(oj.items[0].id)!;+ expect(g.op).toBe("v2v");+ expect(g.prompt).toMatch(/^A detective lights a match in the rain\. The same shot with one change: make it snow\./);+ expect(g.request.params?.extra).toMatchObject({ video_strength: 0.5, audio_strength: 1 });+ expect((await settle(g.id)).status).toBe("succeeded");+ // Facts out of range are refused rather than trusted.+ const bad = await generateRoute.POST(json("POST", { input: { ...VIDEO, action: "edit", prompt: "x", source: { ...source, seconds: -1 } } }), params({ id: p.id }));+ expect(bad.status).toBe(400);+ // The planner (and the project page's context) knows whether a civitai key is set: cloud moves whose LoRA downloads+ // from civitai need one.+ expect(cinemaContext()).toMatchObject({ cloudAllowed: true, civitai: false });+ setSetting("civitaiKey", "test-key");+ try {+ expect(cinemaContext().civitai).toBe(true);+ } finally {+ setSetting("civitaiKey", "");+ }+ }, 60_000);+it("extend backward chains first frame → the moment before → a clip ending on it", async () => {const p = cinema.createProject({ name: "Prequel" });const src = gens.createGenerations({ feature: "cinema", modelId: "seedance-2-5", prompt: "source take", params: { duration: 5 } })[0];diff --git a/tests/cinema-original.test.ts b/tests/cinema-original.test.tsindex d3d6cede..3578fb61 100644--- a/tests/cinema-original.test.ts+++ b/tests/cinema-original.test.ts@@ -20,7 +20,9 @@ const { falProvider } = await import("@/server/providers/fal");const { getModel, modelsFor } = await import("@/lib/catalog");const { onEngine } = await import("@/lib/catalog/engines");const { estimateCost } = await import("@/lib/catalog/plan");-const { planCinema, CINEMA_MODEL, ORIGINAL_LINES, modelLine } = await import("@/lib/catalog/cinema");+const { planCinema, CINEMA_MODEL, ORIGINAL_LINES, modelLine, CAMERA_MOVES, CINEMA_EDIT_STRENGTH, CINEMA_MAX_SECONDS, cinemaMoveRoute, editPrompt } = await import("@/lib/catalog/cinema");+const { needsToken } = await import("@/lib/catalog/loras");+const { finishedUrl } = await import("@/lib/soul-post");beforeAll(() => setSetting("demoMode", "auto"));afterAll(() => fs.rmSync(dir, { recursive: true, force: true }));@@ -52,6 +54,9 @@ const ctx = () => ({serverRam: async () => undefined,});+/** fal bills LTX-2.3 per megapixel of video made (width × height × frames), rounded up. */+const videoMp = (w: number, h: number, frames: number) => Math.ceil((w * h * frames) / 1e6);+const LTX_LORA: LoraRef = {file: "my-ltx-style.safetensors",url: "https://huggingface.co/someone/ltx-style/resolve/main/my-ltx-style.safetensors",@@ -85,15 +90,24 @@ describe("Fuobe Cinema on both engines", () => {expect(modelLine(getModel("kling-3")!, "cloud")).toBe(getModel("kling-3")!.tagline);});- it("prices a second of video from fal's per-megapixel price, by resolution and with LoRAs; free on the GPU", () => {+ it("prices a take on fal's per-megapixel price: its tier and shape's size × its frames, rounded up; free on the GPU", () => {const cloud = view("cloud");- expect(estimateCost(cloud, { duration: 5, resolution: "720p" })).toBeCloseTo(5 * 0.0347, 3);- expect(estimateCost(cloud, { duration: 5, resolution: "480p" })).toBeCloseTo(5 * 0.016, 3);- expect(estimateCost(cloud, { duration: 5, resolution: "1080p" })).toBeCloseTo(5 * 0.0805, 2);- expect(estimateCost(cloud, { duration: 5, resolution: "720p" }, 1, "t2v", true)).toBeCloseTo(5 * 0.039, 3);- expect(estimateCost(cloud, { duration: 5, resolution: "1080p" }, 1, "t2v", true)).toBeCloseTo(5 * 0.0905, 2);- // 1280 × 704 × 24 frames per second at $0.001605 per megapixel.+ // 5 s = 121 frames at 24 fps; fal bills width × height × frames in whole megapixels.+ expect(estimateCost(cloud, { duration: 5, resolution: "720p", aspectRatio: "16:9" })).toBeCloseTo(videoMp(1280, 704, 121) * 0.001605, 3);+ expect(estimateCost(cloud, { duration: 5, resolution: "480p", aspectRatio: "16:9" })).toBeCloseTo(videoMp(864, 480, 121) * 0.001605, 3);+ expect(estimateCost(cloud, { duration: 5, resolution: "1080p", aspectRatio: "16:9" })).toBeCloseTo(videoMp(1920, 1088, 121) * 0.001605, 3);+ // Each shape at its own size: 480p 21:9 is 1120 × 480 and 4:3 is 640 × 480, not the 16:9 frame.+ expect(estimateCost(cloud, { duration: 10, resolution: "480p", aspectRatio: "21:9" })).toBeCloseTo(videoMp(1120, 480, 241) * 0.001605, 3);+ expect(estimateCost(cloud, { duration: 10, resolution: "480p", aspectRatio: "4:3" })).toBeCloseTo(videoMp(640, 480, 241) * 0.001605, 3);+ expect(estimateCost(cloud, { duration: 10, resolution: "720p", aspectRatio: "21:9" })).toBeCloseTo(videoMp(1504, 640, 241) * 0.001605, 3);+ // The model's defaults fill a missing tier or shape (720p, 16:9).+ expect(estimateCost(cloud, { duration: 5 })).toBeCloseTo(videoMp(1280, 704, 121) * 0.001605, 3);+ // The /lora endpoint's rate when a LoRA rides along.+ expect(estimateCost(cloud, { duration: 5, resolution: "720p", aspectRatio: "16:9" }, 1, "t2v", true)).toBeCloseTo(videoMp(1280, 704, 121) * 0.001805, 3);+ expect(estimateCost(cloud, { duration: 5, resolution: "1080p", aspectRatio: "9:16" }, 2, "t2v", true)).toBeCloseTo(2 * videoMp(1088, 1920, 121) * 0.001805, 3);+ // The per-second table stays the 16:9 rate for display: 1280 × 704 × 24 frames per second at $0.001605 per megapixel.expect(cloud.pricing!.byResolution!["720p"]).toBeCloseTo((1280 * 704 * 24 * 0.001605) / 1e6, 4);+ expect(cloud.pricing!.videoMegapixel).toEqual({ usd: 0.001605, withLoras: 0.001805 });expect(estimateCost(view("open"), { duration: 5 })).toBe(0);});@@ -143,7 +157,7 @@ describe("Fuobe Cinema on both engines", () => {try {const cloud = previewGeneration({ ...req, engine: "cloud" });expect(cloud).toMatchObject({ engine: "cloud", demo: false, route: { provider: "fal", endpoint: "fal-ai/ltx-2.3-22b/text-to-video" } });- expect(cloud.costUsd).toBeCloseTo(5 * 0.0347, 3);+ expect(cloud.costUsd).toBeCloseTo(videoMp(1280, 704, 121) * 0.001605, 3);} finally {setSetting("falKey", "");}@@ -172,6 +186,134 @@ describe("Fuobe Cinema on the GPU", () => {});});+describe("Fuobe Cinema edits, extends and casts (review fixes)", () => {+ const take = (over: Record<string, unknown> = {}) => ({ url: "/api/files/take.mp4", kind: "video" as const, modelId: CINEMA_MODEL, prompt: "A lighthouse keeper climbs the stairs at dusk", seconds: 10, resolution: "720p", aspectRatio: "16:9", ...over });+ const edit = (source: ReturnType<typeof take>, over: Record<string, unknown> = {}) =>+ planCinema({ engine: "cloud", mode: "video", action: "edit", prompt: "make it snow", settings: {}, source, ...over }, { cloudAllowed: true });++ it("edits a Fuobe Cinema take on LTX-2.3 video-to-video: the take's scene with the change, the take held, its sound kept", async () => {+ const plan = edit(take(), { brief: "Muted 1970s Kodachrome" });+ expect(plan.model.id).toBe(CINEMA_MODEL);+ const req = plan.steps[0].request;+ expect(req).toMatchObject({ modelId: CINEMA_MODEL, engine: "cloud", op: "v2v", inputs: { video: "/api/files/take.mp4" } });+ // The endpoint renders a scene, not an instruction: the take's own scene with the change, and what stays.+ expect(req.prompt).toBe(`Project brief: Muted 1970s Kodachrome. ${editPrompt("make it snow", "A lighthouse keeper climbs the stairs at dusk")}`);+ expect(req.prompt).toMatch(/A lighthouse keeper climbs the stairs at dusk\. The same shot with one change: make it snow\. Everything else stays as it is/);+ expect(editPrompt("make it snow")).toBe("The same shot with one change: make it snow. Everything else stays as it is: the same people, place, framing, camera move, light and sound.");+ expect(req.params).toMatchObject({ duration: 10, resolution: "720p", aspectRatio: "16:9", generateAudio: true, extra: { video_strength: CINEMA_EDIT_STRENGTH, audio_strength: 1 } });+ expect(req.params!.extra!.match_video_length).toBeUndefined();+ expect(CINEMA_EDIT_STRENGTH).toBeGreaterThan(0.01);+ // Priced on the take's own length and size (10 s at 720p 16:9 = 241 frames), not a flat 5 s.+ expect(plan.costUsd).toBeCloseTo(videoMp(1280, 704, 241) * 0.001605, 3);+ expect(edit(take({ seconds: 4, resolution: "480p", aspectRatio: "9:16" })).costUsd).toBeCloseTo(videoMp(480, 864, 97) * 0.001605, 3);+ // What fal receives: the take, the strengths, the frames from the clip's own length (its header), prompt expansion off.+ const { url, body } = await submit(view("cloud"), fal("v2v"), { ...req.params, prompt: req.prompt, video: "https://x/take.mp4", sourceDuration: 10 });+ expect(url).toMatch(/\/fal-ai\/ltx-2\.3-22b\/video-to-video$/);+ expect(body).toMatchObject({ video_url: "https://x/take.mp4", video_strength: CINEMA_EDIT_STRENGTH, audio_strength: 1, num_frames: 241, enable_prompt_expansion: false, generate_audio: true });+ expect(body.video_size).toBeUndefined();+ });++ it("edits the first 20 s of a longer take (481 frames), and says so; unknown lengths are priced as 5 s", async () => {+ const plan = edit(take({ seconds: 30.04 }));+ const req = plan.steps[0].request;+ expect(req.params).toMatchObject({ duration: CINEMA_MAX_SECONDS, extra: { match_video_length: false } });+ expect(plan.notes).toContain("Fuobe Cinema edits up to 20s of a take (481 frames), so this edit is the take's first 20s");+ expect(plan.costUsd).toBeCloseTo(videoMp(1280, 704, 481) * 0.001605, 3);+ const { body } = await submit(view("cloud"), fal("v2v"), { ...req.params, prompt: req.prompt, video: "https://x/take.mp4", sourceDuration: 30.04 });+ expect(body).toMatchObject({ match_video_length: false, num_frames: 481 });+ // A 20 s take (481 frames = 20.04 s) is whole.+ expect(edit(take({ seconds: 20.04 })).steps[0].request.params!.extra!.match_video_length).toBeUndefined();+ // Length unknown: the default 5 s; the clip's header still sets the frames fal makes.+ const unknown = edit(take({ seconds: undefined }));+ expect(unknown.steps[0].request.params!.duration).toBe(5);+ // Reference pictures and clips aren't used by this edit, and say so.+ const refs = edit(take(), { images: ["/api/files/a.png"], videos: ["/api/files/r.mp4"] });+ expect(refs.steps[0].request.inputs).toEqual({ video: "/api/files/take.mp4" });+ expect(refs.notes.join(" ")).toMatch(/reference images aren't used/);+ });++ it("the editor follows the take's model: a partner take goes to Kling O3 whatever the menu says", () => {+ // A Seedance take, the menu back on Fuobe Cinema: Kling O3, named after the take's model.+ const partner = edit(take({ modelId: "seedance-2-5" }));+ expect(partner.model.id).toBe("kling-o3");+ expect(partner.notes).toContain("Takes made on Seedance 2.5 are edited with Kling O3 Omni");+ expect(partner.steps[0].request.prompt).toBe("make it snow");+ // A Fuobe Cinema take with Kling 3.0 still picked: LTX-2.3.+ expect(edit(take(), { modelId: "kling-3" }).model.id).toBe(CINEMA_MODEL);+ // A Fuobe DoP take (a camera LoRA move) or an open-engine take: LTX-2.3 too.+ expect(edit(take({ modelId: "fuobe-dop" })).model.id).toBe(CINEMA_MODEL);+ // Without the take's model (an older take): the menu's pick decides.+ expect(edit(take({ modelId: undefined }), { modelId: "veo-3-1" }).model.id).toBe("kling-o3");+ expect(edit(take({ modelId: undefined })).model.id).toBe(CINEMA_MODEL);+ });++ it("an extend or a prequel longer than 20 s says it is 20 s on Fuobe Cinema in the cloud", () => {+ const run = (action: "extend-forward" | "extend-backward", duration: number, engine: "cloud" | "open" = "cloud") =>+ planCinema({ engine, mode: "video", action, prompt: "", settings: {}, duration, source: take() }, { cloudAllowed: true });+ const fwd = run("extend-forward", 30);+ expect(fwd.steps[0].request.params!.duration).toBe(20);+ expect(fwd.notes).toContain("Fuobe Cinema extends by up to 20s at a time, so this one is 20s — run it again for more");+ const back = run("extend-backward", 25);+ expect(back.steps[0].request.params).toMatchObject({ duration: 20, extra: { extend_direction: "backward" } });+ expect(back.notes).toContain("Fuobe Cinema makes a prequel of up to 20s at a time, so this one is 20s — run it again for more");+ // Up to 20 s: no note; on the GPU the extend graphs set their own lengths.+ expect(run("extend-forward", 20).notes.join(" ")).not.toMatch(/at a time/);+ expect(run("extend-forward", 30, "open").notes.join(" ")).not.toMatch(/at a time/);+ });++ it("a cloud move whose Wan LoRA downloads from civitai runs on its words without a civitai key", () => {+ const civitai = CAMERA_MOVES.filter((m) => {+ const r = cinemaMoveRoute(m.slug, "cloud", true);+ return r.via === "lora" && r.loras.some((l) => !l.hostedUrl && needsToken(l.url));+ }).map((m) => m.slug);+ expect(civitai).toEqual(expect.arrayContaining(["handheld", "tracking"]));+ for (const slug of civitai) {+ expect(cinemaMoveRoute(slug, "cloud", true, { civitai: false }), slug).toEqual({ via: "prompt", key: true });+ expect(cinemaMoveRoute(slug, "cloud", false, { civitai: false }), slug).toMatchObject({ via: "prompt", frame: false, key: true });+ expect(cinemaMoveRoute(slug, "cloud", true, { civitai: true }).via, slug).toBe("lora");+ }+ // Moves whose LoRA is hosted elsewhere, and LTX-2.3's camera LoRAs, don't need the key.+ for (const m of CAMERA_MOVES.filter((x) => !civitai.includes(x.slug))) expect(cinemaMoveRoute(m.slug, "cloud", true, { civitai: false }), m.slug).toEqual(cinemaMoveRoute(m.slug, "cloud", true));+ // The plan: Fuobe Cinema keeps the take, the move goes into the words, the note says what would drive it.+ const input = { engine: "cloud" as const, mode: "video" as const, action: "generate" as const, prompt: "a chase down a market street", moves: ["handheld"], settings: {}, images: ["/api/files/a.png"], duration: 5 };+ const without = planCinema(input, { cloudAllowed: true, civitai: false });+ expect(without.model.id).toBe(CINEMA_MODEL);+ expect(without.steps[0].request.loras).toBeUndefined();+ expect(without.notes).toContain("Handheld is written into the prompt — its camera LoRA downloads from civitai, which needs your free API key (Settings → LoRAs)");+ const withKey = planCinema(input, { cloudAllowed: true, civitai: true });+ expect(withKey.model.id).toBe("fuobe-dop");+ expect(withKey.steps[0].request.loras?.length).toBeGreaterThan(0);+ // The GPU fetches through the user's own ComfyUI: unchanged.+ expect(planCinema({ ...input, engine: "open" }, { cloudAllowed: true, civitai: false }).steps[0].request.loras?.length).toBeGreaterThan(0);+ });++ it("open Soul Cast runs the sheet graph with the Realistic look's LoRAs chained after Z-Image Turbo's loader", async () => {+ const plan = planCinema({ engine: "open", mode: "image", action: "cast", prompt: "", settings: {}, cast: { genre: "Western", gender: "Female", age: 35 } }, { cloudAllowed: true });+ const req = plan.steps[0].request;+ expect(req.modelId).toBe("oss-zimage-soul-cast");+ const { manifest, workflow } = await prepareWorkflow(+ "soul-cast-sheet-zimage",+ { ...req.params, prompt: req.prompt, loras: req.loras, seed: 3 },+ { generationId: "g", op: "t2i", upload: async (_d: Buffer, _t: string, name: string) => `up_${name}`, media: (() => undefined) as never, serverRam: async () => undefined },+ );+ expect(manifest.id).toBe("soul-cast-sheet-zimage");+ const chain = Object.values(workflow as ComfyWorkflow)+ .filter((n) => n.class_type === "LoraLoaderModelOnly")+ .map((n) => [n.inputs.lora_name, n.inputs.strength_model]);+ expect(chain).toEqual(req.loras!.map((l) => [l.file, l.strength]));+ // Its outputs: the sheet, then the four views as their own pictures.+ expect(Object.values(workflow as ComfyWorkflow).filter((n) => n.class_type === "SaveImage").length).toBe(2);+ });++ it("a variant picked before its grade was applied resolves to the finished picture", () => {+ const gens = [{ outputs: [{ url: "/api/files/finished.png", kind: "image" as const, meta: { finished: true, original: "/api/files/raw.png" } }, { url: "/api/files/other.png", kind: "image" as const }] }];+ expect(finishedUrl(gens, "/api/files/raw.png")).toBe("/api/files/finished.png");+ expect(finishedUrl(gens, "/api/files/finished.png")).toBe("/api/files/finished.png");+ expect(finishedUrl(gens, "/api/files/other.png")).toBe("/api/files/other.png");+ expect(finishedUrl(gens, "/api/files/gone.png")).toBe("/api/files/gone.png");+ });+});+describe("the cinema evaluation suite measures what Cinema sends", () => {// The Director behind each case (scripts/eval/cases/cinema.json carries only the compiled words and camera_lora).const DIRECTOR: Record<string, { prompt: string; settings: DirectorSettings; moves: string[] }> = {diff --git a/tests/cinema-refs.test.ts b/tests/cinema-refs.test.tsindex 93072e14..d2f58468 100644--- a/tests/cinema-refs.test.ts+++ b/tests/cinema-refs.test.ts@@ -45,8 +45,8 @@ describe("reference clips", () => {expect(plan.model.id).toBe("kling-3");expect(plan.steps[0].request.inputs).toBeUndefined();expect(plan.notes.join(" ")).toMatch(/Kling 3\.0 doesn't take reference videos and reference audio — Seedance 2\.5 does/);- // Fuobe Cinema (the default) takes none yet: Seedance 2.5 is named.- const original = planCinema({ ...VIDEO, ...CLIPS }, ctx);+ // Fuobe Cinema picked from the menu takes none yet: Seedance 2.5 is named.+ const original = planCinema({ ...VIDEO, ...CLIPS, modelId: "fuobe-cinema" }, ctx);expect(original.model.id).toBe("fuobe-cinema");expect(original.steps[0].request.op).toBeUndefined();expect(original.notes.join(" ")).toMatch(/Fuobe Cinema doesn't take reference videos and reference audio — Seedance 2\.5 does/);@@ -73,7 +73,22 @@ describe("reference clips", () => {const original = planCinema({ ...VIDEO, ...CLIPS, action: "edit", prompt: "make it snow", source }, ctx);expect(original.model.id).toBe("fuobe-cinema");expect(original.steps[0].request.inputs).toEqual({ video: source.url });- expect(original.notes.join(" ")).toMatch(/aren't sent to Fuobe Cinema/);+ expect(original.notes.join(" ")).toMatch(/Fuobe Cinema edits from the take alone — reference videos and audio aren't used/);+ });++ it("move a take on the default model to the first partner model that takes them all, with a note", () => {+ // Nothing picked in the menu (the cloud default, Fuobe Cinema): the clips aren't dropped.+ const plan = planCinema({ ...VIDEO, ...CLIPS }, ctx);+ expect(plan.model.id).toBe("seedance-2-5");+ expect(plan.steps[0].request).toMatchObject({ modelId: "seedance-2-5", op: "ref2v", inputs: CLIPS });+ expect(plan.notes[0]).toBe("Fuobe Cinema doesn't take reference clips yet, so this take runs on Seedance 2.5 (a partner model) with them — pick Fuobe Cinema in the menu to leave them out");+ expect(plan.costUsd).toBeGreaterThan(0);+ // Only a reference video, or only audio: the same.+ expect(planCinema({ ...VIDEO, videos: CLIPS.videos }, ctx).model.id).toBe("seedance-2-5");+ expect(planCinema({ ...VIDEO, audios: CLIPS.audios }, ctx).model.id).toBe("seedance-2-5");+ // No clips, or the GPU, or a still: Fuobe Cinema stays.+ expect(planCinema(VIDEO, ctx).model.id).toBe("fuobe-cinema");+ expect(planCinema({ ...VIDEO, ...CLIPS, engine: "open" }, ctx).model.id).toBe("fuobe-cinema");});});@@ -101,4 +116,14 @@ describe("draftToInput", () => {expect(grid.source).toBeUndefined();expect(draftToInput({ ...d, mode: "image", source, action: "edit" }, "cloud", {}).action).toBe("generate");});++ it("sends what the browser knows about the picked take: its model, scene, length and size", () => {+ const d = initialDraft();+ const take = { generationId: "g1", url: "/api/files/take.mp4", kind: "video" as const, label: "Take", modelId: "seedance-2-5", prompt: " a lighthouse at dusk ", seconds: 30.0417, resolution: "720p", aspectRatio: "21:9" };+ const edit = draftToInput({ ...d, source: take, action: "edit", prompt: "make it snow" }, "cloud", {});+ expect(edit.source).toEqual({ url: take.url, kind: "video", modelId: "seedance-2-5", prompt: "a lighthouse at dusk", seconds: 30.04, resolution: "720p", aspectRatio: "21:9" });+ // Unknown facts are left out rather than sent empty.+ const bare = draftToInput({ ...d, source: { ...take, modelId: undefined, prompt: " ", seconds: Number.NaN, resolution: undefined, aspectRatio: undefined }, action: "edit" }, "cloud", {});+ expect(bare.source).toEqual({ url: take.url, kind: "video" });+ });});diff --git a/tests/cinema.test.ts b/tests/cinema.test.tsindex 163c37e2..1e061bb7 100644--- a/tests/cinema.test.ts+++ b/tests/cinema.test.ts@@ -200,6 +200,8 @@ const base = (over: Partial<CinemaGenerateInput>): CinemaGenerateInput => ({});const ctx = { cloudAllowed: true };+/** fal bills LTX-2.3 per megapixel of video made (width × height × frames), rounded up. */+const videoMp = (w: number, h: number, frames: number) => Math.ceil((w * h * frames) / 1e6);const route = (id: string, op: string, engine: "open" | "cloud" = "cloud") => onEngine(getModel(id)!, engine).routes.find((r) => r.op === op)!;describe("planCinema", () => {@@ -213,8 +215,8 @@ describe("planCinema", () => {expect(req.prompt).toContain("Noir film");expect(req.prompt).toMatch(/Camera moves, in this order: first .*; finally /);expect(plan.notes).toContain("Dolly In drives LTX-2.3's dolly in camera LoRA");- // 2 takes × 10 s × the 1080p rate ($0.001605 per megapixel of 1920×1088×24 frames).- expect(plan.costUsd).toBeCloseTo(2 * 10 * 0.0805, 3);+ // 2 takes of 2240×960 (1080p at 21:9) × 241 frames, at $0.001605 per megapixel rounded up.+ expect(plan.costUsd).toBeCloseTo(2 * videoMp(2240, 960, 241) * 0.001605, 3);// What fal receives: the tier's exact size, 241 frames at 24 fps (8n+1), the camera LoRA, prompt expansion off.const payload = buildPayload(route("fuobe-cinema", "t2v").map!, { ...req.params, prompt: req.prompt });expect(payload).toMatchObject({ video_size: { width: 2240, height: 960 }, num_frames: 241, camera_lora: "dolly_in", enable_prompt_expansion: false, generate_audio: true });@@ -233,7 +235,8 @@ describe("planCinema", () => {// 20 s at 481 frames; the extend adds 241 frames; both takes are extended.expect(buildPayload(route("fuobe-cinema", "t2v").map!, { ...plan.steps[0].request.params, prompt: "x" })).toMatchObject({ num_frames: 481 });expect(buildPayload(route("fuobe-cinema", "extend").map!, { ...plan.steps[1].request.params, prompt: "x", video: "https://x/take.mp4" })).toMatchObject({ num_frames: 241, video_url: "https://x/take.mp4" });- expect(plan.costUsd).toBeCloseTo(2 * 30 * 0.0805, 3);+ // Each take: 481 frames, then the extend's 241, at the 21:9 1080p size.+ expect(plan.costUsd).toBeCloseTo(2 * (videoMp(2240, 960, 481) + videoMp(2240, 960, 241)) * 0.001605, 3);// Any whole second up to 20 in one call (no rounding to a preset length).expect(planCinema(base({ duration: 7 }), ctx).steps[0].request.params!.duration).toBe(7);});@@ -425,8 +428,21 @@ describe("planCinema", () => {const cast = planCinema(base({ action: "cast", mode: "image", cast: values, prompt: "" }), ctx);expect(cast.blocker).toBeUndefined();expect(cast.steps[0].request).toMatchObject({ feature: "cinema-cast", modelId: "fuobe-soul", engine: "cloud", presetId: "v1-realistic", params: { aspectRatio: "16:9", resolution: "1080p" } });- expect(planCinema(base({ action: "cast", mode: "image", cast: values, engine: "open" }), ctx).model).toMatchObject({ id: "fuobe-soul", engine: "open" });- expect(planCinema(base({ action: "cast", mode: "image", cast: values, engine: "open", modelId: "oss-zimage-soul-cast" }), ctx).model.id).toBe("oss-zimage-soul-cast");+ // On the GPU: the Soul Cast sheet graph with Fuobe Soul's Realistic look (its LoRAs and words), which also cuts the+ // sheet's four views; Fuobe Soul alone when the graph is missing or picked.+ const open = planCinema(base({ action: "cast", mode: "image", cast: values, engine: "open" }), ctx);+ expect(open.model.id).toBe("oss-zimage-soul-cast");+ const sheet = open.steps[0].request;+ expect(sheet.presetId).toBeUndefined();+ expect(sheet.loras?.map((l) => l.file).length).toBeGreaterThan(0);+ expect(sheet.prompt).toMatch(/No filters, flawless clarity/);+ expect(sheet.prompt).toMatch(/35-year-old latino woman, the rebel archetype/);+ expect(open.notes.join(" ")).toMatch(/Realistic look on the Soul Cast sheet graph: the sheet, then its four views/);+ expect(CAST_MODELS.open).toEqual(["oss-zimage-soul-cast", "fuobe-soul"]);+ const noSheet = planCinema(base({ action: "cast", mode: "image", cast: values, engine: "open" }), { ...ctx, has: (id: string) => id !== "oss-zimage-soul-cast" });+ expect(noSheet.model).toMatchObject({ id: "fuobe-soul", engine: "open" });+ expect(noSheet.steps[0].request).toMatchObject({ presetId: "v1-realistic" });+ expect(planCinema(base({ action: "cast", mode: "image", cast: values, engine: "open", modelId: "fuobe-soul" }), ctx).model.id).toBe("fuobe-soul");expect(planCinema(base({ action: "cast", mode: "image", cast: values, modelId: "nano-banana-pro" }), ctx).model.id).toBe("nano-banana-pro");expect(CAST_MODELS.cloud).not.toContain("soul-2");@@ -443,6 +459,10 @@ describe("planCinema", () => {expect(high.steps[0].request.prompt).toMatch(/^<sks> front view high-angle shot medium shot\. Show the same location from a high angle/);expect(high.steps[0].request.loras?.[0].file).toMatch(/multiple-angles/);expect(planCinema(base({ action: "location-view", mode: "image", view: "wide", prompt: "" }), ctx).blocker).toBe("Pick the location image to re-angle");+ // The project brief keeps the project's look in other views too, on both engines (after the LoRA's own words).+ const briefed = (engine: "open" | "cloud") => planCinema(base({ action: "location-view", mode: "image", view: "high", source: still, prompt: "", engine, brief: "Muted 1970s Kodachrome" }), ctx).steps[0].request;+ expect(briefed("cloud").prompt).toMatch(/Project brief: Muted 1970s Kodachrome/);+ expect(briefed("open").prompt).toMatch(/^<sks> front view high-angle shot medium shot\. .*Project brief: Muted 1970s Kodachrome/s);});});diff --git a/tests/e2e/cinema-original.mjs b/tests/e2e/cinema-original.mjsindex 6356b9a3..1b15ea94 100644--- a/tests/e2e/cinema-original.mjs+++ b/tests/e2e/cinema-original.mjs@@ -2,7 +2,8 @@// At 1440 and 390 px, light and dark: the model menu lists Fuobe Cinema first with an "Original" badge and what runs on// each engine; a camera move says how the Original drives it (LTX-2.3's camera LoRA in the cloud); the price shows// before running ("Free" on the open engine); a take is made in demo mode; Soul Cast and Soul Location name Fuobe Soul-// and their look; nothing scrolls sideways.+// and their look; Soul's post steps (a still's 21:9 crop and grade, the location's Movie grade) run in Cinema's feed and+// builders; the Director panel's move list drops its badges for a partner model; nothing scrolls sideways.// Usage: node tests/e2e/cinema-original.mjs [appUrl] [--shots <dir>] (app running in demo mode, ComfyUI unreachable).// Exits 1 on a failed check.import fs from "node:fs";@@ -47,6 +48,15 @@ const check = (label, ok, extra = "") => {if (!ok) failures.push(label);};if (shots) fs.mkdirSync(shots, { recursive: true });+/** Poll until `get` answers something (or 30 s pass). */+async function waitFor(get, ms = 30_000) {+ const until = Date.now() + ms;+ for (;;) {+ const v = await get();+ if (v || Date.now() > until) return v;+ await new Promise((r) => setTimeout(r, 750));+ }+}async function session(width, height, scheme) {const context = await browser.newContext({ viewport: { width, height }, colorScheme: scheme });@@ -120,6 +130,31 @@ async function session(width, height, scheme) {await page.getByRole("button", { name: "5s", exact: true }).click();await page.keyboard.press("Escape");}+ // The Director panel's move list badges like the prompt bar's: none when a partner model gets the moves in words.+ const directorMoves = async () => {+ const chip = page.getByRole("button", { name: "Camera settings" }).locator("visible=true");+ if (!(await chip.count())) await page.getByRole("button", { name: /^Director/ }).locator("visible=true").first().click();+ await chip.first().click();+ await page.getByRole("tab", { name: /Movement/ }).click();+ const opt = page.getByRole("option", { name: /Dolly In/ }).locator("visible=true").first();+ await opt.waitFor();+ const text = await opt.innerText();+ await page.keyboard.press("Escape");+ await page.waitForTimeout(300);+ // A phone's folded Director sheet closes too.+ if (await page.getByRole("dialog").locator("visible=true").count()) await page.keyboard.press("Escape");+ return text;+ };+ check(`${tag}: the Director's move list badges Dolly In on Fuobe Cinema`, /Camera LoRA/.test(await directorMoves()));+ const pickModel = async (name) => {+ await modelChip.click();+ await menu.waitFor();+ await menu.getByRole("menuitem").filter({ hasText: name }).first().click();+ await menu.waitFor({ state: "hidden" });+ };+ await pickModel(/^Seedance 2\.5/);+ check(`${tag}: no move badges in the Director's list for a partner model`, !/Camera LoRA|LoRA|Focus move|Fun Camera/.test(await directorMoves()));+ await pickModel(/^Fuobe Cinema/);const generate = page.getByRole("button", { name: /^Generate/ }).first();check(`${tag}: the price shows before running`, /Demo|≈ \$|Free/.test(body));await shot("cloud-bar");@@ -130,6 +165,23 @@ async function session(width, height, scheme) {check(`${tag}: Generate makes a Fuobe Cinema take (demo)`, takes.length === before + 1 && takes[0]?.modelId === "fuobe-cinema", takes.map((g) => g.modelId).join(","));check(`${tag}: the take asked for the camera LoRA`, takes[0]?.request?.params?.extra?.camera_lora === "dolly_in");+ // A still on Fuobe Soul Cinema at 21:9: the feed crops the 16:9 render to 21:9 and grades it in the browser.+ const still = await call(`/api/cinema/projects/${project.id}/generate`, "POST", {+ input: { engine: "cloud", mode: "image", action: "generate", prompt: "A lighthouse keeper at the window", settings: { camera: "modern", lens: "clean-sharp", focal: "50mm" }, aspectRatio: "21:9", batch: 1 },+ });+ const stillId = still.items?.[0]?.id;+ check(`${tag}: a still runs on Fuobe Soul Cinema`, still.plan?.modelId === "fuobe-soul-cinema", still.plan?.modelId ?? JSON.stringify(still).slice(0, 200));+ // Made through the API, so the open feed learns of it on its next load.+ await waitFor(async () => (await call(`/api/cinema/projects/${project.id}/items`)).items.find((x) => x.id === stillId && x.status === "succeeded"));+ await page.reload({ waitUntil: "load" });+ await prompt.waitFor({ timeout: 120_000 });+ const graded = await waitFor(async () => {+ const g = (await call(`/api/cinema/projects/${project.id}/items`)).items.find((x) => x.id === stillId);+ return g?.outputs?.[0]?.meta?.finished ? g : null;+ });+ const meta = graded?.outputs?.[0]?.meta;+ check(`${tag}: the Cinema feed finishes the still (21:9 crop, grade)`, !!meta && meta.crop === "21:9" && meta.grade === "teal-orange" && !!meta.original, JSON.stringify(meta ?? null));+// The open engine: free, Wan 2.2 Lightning, a Fun Camera badge for pans.await pick(/Open source/);const openBody = await page.locator("body").innerText();@@ -171,6 +223,12 @@ async function session(width, height, scheme) {await page.waitForTimeout(3000);const made = (await call(`/api/cinema/projects/${project.id}/items`)).items.filter((g) => g.feature === "cinema-location");check(`${tag}: a location is made on Fuobe Soul with the Movie look`, made.length > 0 && made.every((g) => g.modelId === "fuobe-soul" && g.presetId === "v1-movie"), made.map((g) => `${g.modelId}/${g.presetId}`).join(","));+ // The Movie look's grade is applied in the browser (the builder runs Soul's post steps), so a saved element is finished.+ const finished = await waitFor(async () => {+ const rows = (await call(`/api/cinema/projects/${project.id}/items`)).items.filter((g) => g.feature === "cinema-location" && g.status === "succeeded");+ return rows.length > 0 && rows.every((g) => g.outputs.every((o) => o.kind !== "image" || o.meta?.finished)) ? rows : null;+ });+ check(`${tag}: the location's grade is applied in the browser`, !!finished && finished[0].outputs[0].meta?.grade === "teal-orange", JSON.stringify(finished?.[0]?.outputs?.[0]?.meta ?? null));check(`${tag}: no sideways scroll in Soul Location`, (await sideways()) <= 1);await shot("soul-location");await page.keyboard.press("Escape");diff --git a/tests/e2e/cinema-scene.mjs b/tests/e2e/cinema-scene.mjsindex b2d3fc67..4f6b4033 100644--- a/tests/e2e/cinema-scene.mjs+++ b/tests/e2e/cinema-scene.mjs@@ -105,7 +105,10 @@ try {const rec = await until(async () => (await items()).find((g) => g.feature === "cinema-recompose"), "the recomposition");const [capture, ref] = rec.request.inputs.images;assert.match(capture, /^\/api\/files\/uploads\/.+\.png$/);- assert.equal(ref, still.outputs[0].url);+ // The still as the feed shows it: Fuobe Soul Cinema's grade is applied in the browser, so its finished picture (the raw+ // one stays as meta.original).+ const shown = (await items()).find((g) => g.id === still.id).outputs[0];+ assert.ok([shown.url, shown.meta?.original].includes(ref), `the reference is the still (${ref})`);assert.match(rec.request.prompt, /^Re-render this exact camera view of the scene/);const png = Buffer.from(await (await (await api).fetch(app + capture)).body());assert.deepEqual([png.readUInt32BE(16), png.readUInt32BE(20)], [864, 1536], "the capture is the 9:16 frame");