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.

AI Influencer builder: binding test for the open engine's two graphs

Claude86b2d807c92e
diff --git a/tests/influencer-comfy.test.ts b/tests/influencer-comfy.test.ts
new file mode 100644
index 00000000..d33910ec
--- /dev/null
+++ b/tests/influencer-comfy.test.ts
@@ -0,0 +1,46 @@
+import fs from "node:fs";
+import os from "node:os";
+import path from "node:path";
+import { afterAll, describe, expect, it } from "vitest";
+import type { GenInput, Operation } from "@/lib/catalog/types";
+import { compileCastPrompt, compileDressPrompt, planInfluencer, type InfluencerState } from "@/lib/influencer";
+
+// The comfyui provider driving the AI Influencer builder's open engine on the library graphs: the Soul Cast
+// sheet (Z-Image Turbo) with the compiled character, then Qwen-Image-Edit 2511 with the sheet first.
+const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-influencer-comfy-"));
+process.env.FUOBE_DATA_DIR = tmp;
+process.env.COMFYUI_URL = "http://comfy.test:8188";
+const { prepareWorkflow } = await import("@/server/providers/comfyui");
+afterAll(() => fs.rmSync(tmp, { recursive: true, force: true }));
+
+const prepare = (id: string, input: GenInput, op: Operation) => prepareWorkflow(id, input, { generationId: "g1", op, upload: async (_d, _t, name) => `up_${name}` });
+const at = (wf: Record<string, { inputs: Record<string, unknown> }>, node: string, input: string) => wf[node]?.inputs[input];
+const state: InfluencerState = { tier: "cats", picks: { gender: ["female"], hair: ["hs_beehive"], aesthetic: ["goth"] }, species: "maine_coon", bodyColor: "#f4c2d7", locked: [] };
+
+describe("the builder's open engine through the provider", () => {
+ it("Soul Cast sheet: the compiled character goes after the graph's own turnaround wording", async () => {
+ const [sheet] = planInfluencer({ engine: "open", state, start: "scratch", direction: "Runs a night bakery" }, { higgsfield: false }).steps;
+ const { workflow: wf } = await prepare("soul-cast-sheet-zimage", { prompt: sheet.request.prompt, seed: 11 }, "t2i");
+ expect(at(wf, "20", "string_b")).toBe(compileCastPrompt({ state, direction: "Runs a night bakery" }));
+ expect(at(wf, "20", "string_b")).toMatch(/^A female anthropomorphic Maine Coon cat with pale pink fur, with a tall beehive updo, wearing an all-black goth outfit\. Anthropomorphic Maine Coon cat/);
+ expect(String(at(wf, "20", "string_a"))).toMatch(/^Character turnaround reference sheet/);
+ expect(at(wf, "24", "seed")).toBe(11);
+ });
+
+ it("Qwen-Image-Edit 2511: the sheet is image 1, your face image 2, the clothing image 3", async () => {
+ const plan = planInfluencer({ engine: "open", state, start: "face", photo: "face.png", clothing: ["coat.png", "boots.png"] }, { higgsfield: false });
+ const dress = plan.steps[1].request;
+ // What the chain hands the step when the sheet is done (position "first").
+ const images = ["sheet.png", ...(dress.inputs?.images ?? [])];
+ const { workflow: wf } = await prepare("qwen-image-edit-2511-multi", { prompt: dress.prompt, images, seed: 3 }, "edit");
+ expect([at(wf, "41", "image"), at(wf, "83", "image"), at(wf, "1201", "image")]).toEqual(["sheet.png", "face.png", "coat.png"]);
+ expect(at(wf, "170:151", "prompt")).toBe(compileDressPrompt({ state, start: "face", clothing: 1 }));
+ });
+
+ it("with the face only, the third image slot is left out rather than refused", async () => {
+ const plan = planInfluencer({ engine: "open", state, start: "face", photo: "face.png" }, { higgsfield: false });
+ const dress = plan.steps[1].request;
+ const { workflow: wf } = await prepare("qwen-image-edit-2511-multi", { prompt: dress.prompt, images: ["sheet.png", ...(dress.inputs?.images ?? [])] }, "edit");
+ expect([at(wf, "41", "image"), at(wf, "83", "image")]).toEqual(["sheet.png", "face.png"]);
+ });
+});