feat: enhance Comfy API handling and add tests for branded non-Z diffusion models

This commit is contained in:
syntaxbullet
2026-07-09 21:56:25 +02:00
parent c3a75cf0d6
commit 317a7bbf5f
11 changed files with 532 additions and 37 deletions

View File

@@ -1,5 +1,5 @@
import { describe, expect, test } from "bun:test";
import { buildAnimaWorkflow, buildSdxlWorkflow, buildZImageTurboWorkflow, buildZImageWorkflow, selectGeneratedOutputImage } from "./comfy";
import { buildAnimaWorkflow, buildSdxlWorkflow, buildZImageTurboWorkflow, buildZImageWorkflow, handleComfyApi, selectGeneratedOutputImage } from "./comfy";
describe("Comfy adapter", () => {
test("selects SaveImage output instead of uploaded input or mask images", () => {
@@ -85,6 +85,44 @@ describe("Comfy adapter", () => {
expect(workflow["2"]?.inputs.clip_name).toBe("miaomiaoHarem_anima13_txt.safetensors");
expect(workflow["3"]?.inputs.vae_name).toBe("qwen_image_vae.safetensors");
});
test("lists branded non-Z diffusion models under Anima", async () => {
const originalFetch = globalThis.fetch;
const mockFetch: typeof fetch = Object.assign(async () => new Response(JSON.stringify({
CheckpointLoaderSimple: { input: { required: { ckpt_name: [["sd_xl_base_1.0.safetensors"]] } } },
KSampler: { input: { required: { sampler_name: [["euler"]], scheduler: [["normal"]] } } },
UNETLoader: {
input: {
required: {
unet_name: [[
"anima-base-v1.0.safetensors",
"miaomiaoHarem_anima13.safetensors",
"novaAnimeAM_v30.safetensors",
"z_image_bf16.safetensors",
"z_image_turbo_bf16.safetensors",
]],
},
},
},
CLIPLoader: { input: { required: { clip_name: [["qwen_3_06b_base.safetensors"]] } } },
VAELoader: { input: { required: { vae_name: [["qwen_image_vae.safetensors"]] } } },
}), { headers: { "content-type": "application/json" } }), { preconnect: originalFetch.preconnect });
globalThis.fetch = mockFetch;
try {
const response = await handleComfyApi(new Request("http://image-studio.test/api/comfy/models"));
const body = await response.json() as { architectures: { value: string; models: string[] }[] };
const anima = body.architectures.find((architecture) => architecture.value === "anima");
expect(response.status).toBe(200);
expect(anima?.models).toContain("novaAnimeAM_v30.safetensors");
expect(anima?.models).toContain("miaomiaoHarem_anima13.safetensors");
expect(anima?.models).not.toContain("z_image_bf16.safetensors");
expect(anima?.models).not.toContain("z_image_turbo_bf16.safetensors");
} finally {
globalThis.fetch = originalFetch;
}
});
});
function inpaintRequest(inpaint: { maskedContent: "neutral" | "original"; growMaskBy?: number }) {