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
Layouts everywhere: tests for the Layout node, drawn and keep-clear ads, Marketing's drawn words, Plan layout and the skill
Claudecb30029a9f63
diff --git a/src/lib/layout-plan.ts b/src/lib/layout-plan.tsindex 59d62baf..8d07a5f9 100644--- a/src/lib/layout-plan.ts+++ b/src/lib/layout-plan.ts@@ -66,9 +66,26 @@ export function planByRules(words: string, width: number, height: number): Layouconst quoted = QUOTED.exec(said)?.[1]?.trim();const offer = OFFER.exec(said)?.[1]?.trim();const whom = FOR_WHOM.exec(said)?.[1]?.replace(STOP, "").trim();- const headline = quoted ?? (offer ? offer.toUpperCase() : whom ? title(whom) : title(said.split(/[,.;:!?]/)[0].split(" ").slice(0, 5).join(" ")));+ const headline =+ quoted ??+ (offer+ ? offer.toUpperCase()+ : whom+ ? title(whom)+ : title(+ said+ .split(/[,.;:!?]/)[0]+ .split(" ")+ .slice(0, 5)+ .join(" "),+ ));const second = quoted && offer ? offer.toUpperCase() : !quoted && offer && whom ? title(whom) : "";- const subject = said.replace(QUOTED, "").replace(OFFER, "").replace(/[,\s]+$/, "").trim() || said;+ const subject =+ said+ .replace(QUOTED, "")+ .replace(OFFER, "")+ .replace(/[,\s]+$/, "")+ .trim() || said;const wide = width > height * 1.2;const items: LayoutItem[] = wide? [diff --git a/src/server/layout-plan.ts b/src/server/layout-plan.tsindex 424e6a1a..98f406c7 100644--- a/src/server/layout-plan.ts+++ b/src/server/layout-plan.ts@@ -14,7 +14,12 @@ export interface PlannedLayout {by: "llm" | "rules";}-export async function planLayoutFromWords(words: string, width: number, height: number, ask: (system: string, user: string) => Promise<string | null> = (s, u) => llmText(s, u, { json: "object" })): Promise<PlannedLayout> {+export async function planLayoutFromWords(+ words: string,+ width: number,+ height: number,+ ask: (system: string, user: string) => Promise<string | null> = (s, u) => llmText(s, u, { json: "object" }),+): Promise<PlannedLayout> {if (llmTextBackend()) {const planned = readPlanned(await ask(LAYOUT_PLAN_SYSTEM, planRequest(words, width, height)).catch(() => null), width, height);if (planned) return { layout: planned, by: "llm" };diff --git a/tests/layouts-everywhere.test.ts b/tests/layouts-everywhere.test.tsnew file mode 100644index 00000000..1134dc9c--- /dev/null+++ b/tests/layouts-everywhere.test.ts@@ -0,0 +1,379 @@+import fs from "node:fs";+import os from "node:os";+import path from "node:path";+import { afterAll, describe, expect, it } from "vitest";++// N7-8 (docs/research/new-models-7.md §5.9): layouts from Canvas, Marketing Studio, Ads Studio and Assist.+const tmp = fs.mkdtempSync(path.join(os.tmpdir(), "fuobe-layouts-everywhere-"));+process.env.FUOBE_DATA_DIR = tmp;+process.env.COMFYUI_URL = "http://127.0.0.1:9";+process.env.OLLAMA_URL = "http://127.0.0.1:9";+afterAll(() => fs.rmSync(tmp, { recursive: true, force: true }));++const { getModel, getPreset } = await import("@/lib/catalog");+const { planGeneration } = await import("@/lib/catalog/plan");+const { describeNode, cleanGraph } = await import("@/lib/catalog/canvas");+const { compileMoss, validateLayout, readsBoxes } = await import("@/lib/layout-prompt");+const { adDraft, adPlanDraft, fillLayout, layoutPlaceholders, productRect, roughMeasure } = await import("@/lib/layout-surfaces");+const { planAd, themeFrom } = await import("@/components/ads/layout");+const { DRAWN_WORDS_MODELS, drawnWordsModel, formatModels, FORMATS, wordsOnTop, MARKETING_IMAGE_MODEL } = await import("@/lib/catalog/marketing");+const { planByRules, readPlanned } = await import("@/lib/layout-plan");+const { setSetting } = await import("@/server/settings");+const mk = await import("@/server/marketing");+const ads = await import("@/server/ads");+const { planLayoutFromWords } = await import("@/server/layout-plan");+const skills = await import("@/server/skills");+const canvasServer = await import("@/server/canvas");++import type { CanvasEdge, CanvasGraph, CanvasNode } from "@/lib/catalog/canvas";+import type { BrandKit, Product } from "@/lib/catalog/marketing";+import type { GenerationRequest } from "@/lib/catalog/types";+import type { LayoutDraft } from "@/lib/layout-prompt";++setSetting("demoMode", "auto");++const brand = {+ id: "b1",+ name: "Ember & Wick",+ tagline: "Small-batch candles",+ colors: ["#a3411f", "#f6efe3", "#1d1a17"],+ fonts: { heading: "Fraunces", body: "Inter" },+ values: [],+ aesthetics: ["warm", "handmade"],+ tone: ["friendly"],+ sellingPoints: [],+ competitors: [],+ socials: [],+ images: [],+ details: [],+ status: "ready",+ source: "manual",+ logo: "/api/files/logo.png",+} as unknown as BrandKit;+const product = {+ id: "p1",+ brandId: "b1",+ name: "Autumn Soy Candle",+ description: "Amber glass jar, cedar and clove",+ sellingPoints: ["40-hour burn"],+ images: ["/api/files/candle.png"],+ createdAt: 0,+ updatedAt: 0,+} as unknown as Product;++const inside = (d: LayoutDraft) => d.items.every((it) => it.box.every((v) => v >= 0 && v <= 1) && it.box[2] > it.box[0] && it.box[3] > it.box[1]);+const overlaps = (a: number[], b: number[]) => a[0] < b[2] && b[0] < a[2] && a[1] < b[3] && b[1] < a[3];++// ---------------------------------------------------------------------------++describe("an ad plan as a layout (AdPlan → draft)", () => {+ const plan = planAd({+ ratio: "4:5",+ layout: "overlay",+ content: { headline: "Autumn Glow", body: "Hand-poured soy, cedar and clove.", cta: "Shop now" },+ theme: themeFrom(brand),+ image: { w: 1080, h: 1350 },+ logo: { w: 3, h: 1 },+ measure: roughMeasure,+ });++ it("maps the headline, body and button to text items with their words, the logo and the product to objects", () => {+ const d = adPlanDraft(plan, { mode: "words", product: "Autumn Soy Candle in amber glass", caption: "A finished social ad" });+ const texts = d.items.filter((i) => i.label === "text").map((i) => i.text?.replace(/\n/g, " "));+ expect(texts).toEqual(["Autumn Glow", "Hand-poured soy, cedar and clove.", "Shop now"]);+ expect(d.items.find((i) => i.caption === "The brand's logo, small and crisp")?.label).toBe("object");+ const prod = d.items.find((i) => i.caption.startsWith("Autumn Soy Candle"))!;+ expect(prod.label).toBe("object");+ // The product stays out of the words' space, and every box is inside the picture.+ for (const t of d.items.filter((i) => i.label === "text")) expect(overlaps(prod.box, t.box), t.text).toBe(false);+ expect(inside(d)).toBe(true);+ expect(d.aspect).toBe("4:5");+ expect(d.summary.caption).toMatch(/soft dark shade/);+ expect(validateLayout(d, 1088, 1360).filter((i) => i.level === "error")).toEqual([]);+ // The type is described by family and colour, never as a CSS font string.+ expect(d.items.find((i) => i.text === "Autumn Glow")?.caption).toMatch(/Fraunces-style typeface/);+ expect(JSON.stringify(d)).not.toMatch(/px "/);+ });++ it("keeps clear: only the product, in the part of the picture the words leave free", () => {+ const d = adPlanDraft(plan, { mode: "clear", product: "Autumn Soy Candle", caption: "Advertising photograph" });+ expect(d.items).toHaveLength(1);+ expect(d.items[0]).toMatchObject({ label: "object", caption: "Autumn Soy Candle" });+ const r = productRect(plan);+ expect(r.y + r.h).toBeLessThanOrEqual(plan.headline.y);+ expect(d.summary.caption).toMatch(/No text, letters or logos anywhere/);+ });++ it("uses the whole picture when the words sit beside it (Panel)", () => {+ const panel = planAd({ ratio: "4:5", layout: "panel", content: { headline: "Autumn Glow" }, theme: themeFrom(brand), image: { w: 1080, h: 1350 }, measure: roughMeasure });+ expect(productRect(panel)).toEqual({ x: panel.image!.x, y: panel.image!.y, w: panel.image!.w, h: panel.image!.h });+ const d = adPlanDraft(panel, { mode: "words", product: "candle", caption: "" });+ expect(d.items[0].caption).toMatch(/flat, solid #[0-9a-f]{6} colour panel/i);+ });+});++describe("a table row in a layout's {Column} placeholders", () => {+ const draft: LayoutDraft = {+ summary: { caption: "A poster for {Product}", meta: [], canvas: "single" },+ items: [+ { label: "text", caption: "Bold", text: "{Headline}", box: [0.1, 0.05, 0.9, 0.2] },+ { label: "text", caption: "Price tag", text: "Only {Price}", box: [0.6, 0.8, 0.95, 0.95] },+ { label: "object", caption: "{Product} on a table", box: [0.2, 0.3, 0.8, 0.75] },+ ],+ };+ it("finds the placeholders and fills them, leaving unknown ones as written", () => {+ expect(layoutPlaceholders(draft).sort()).toEqual(["Headline", "Price", "Product"]);+ const f = fillLayout(draft, ["Headline", " Price ", "Other"], ["Autumn Glow", "$18", "x"]);+ expect(f.items.map((i) => i.text ?? i.caption)).toEqual(["Autumn Glow", "Only $18", "{Product} on a table"]);+ expect(f.summary.caption).toBe("A poster for {Product}");+ expect(draft.items[0].text).toBe("{Headline}"); // not changed in place+ });+});++// ---------------------------------------------------------------------------++const node = (id: string, type: CanvasNode["type"], x: number, y: number, data: CanvasNode["data"] = {}): CanvasNode => ({ id, type, position: { x, y }, data });+const edge = (source: string, target: string, targetHandle = "prompt"): CanvasEdge => ({ id: `${source}>${target}:${targetHandle}`, source, sourceHandle: "out", target, targetHandle });+const poster: LayoutDraft = {+ summary: { caption: "A warm candle sale poster", meta: ["poster"], canvas: "single" },+ items: [+ { label: "text", caption: "Bold cream serif", text: "30% OFF", box: [0.1, 0.05, 0.9, 0.2] },+ { label: "object", caption: "Three lit candles", box: [0.25, 0.35, 0.75, 0.9] },+ ],+ aspect: "3:4",+};+const board = (modelId: string, params: CanvasNode["data"]["params"] = {}, layout: LayoutDraft = poster): CanvasGraph => ({+ nodes: [node("l", "layout", 0, 0, { layout }), node("m", "model", 400, 0, { modelId, mediaKind: "image", params })],+ edges: [edge("l", "m")],+});++describe("the Canvas Layout node", () => {+ it("is an Inputs node with a text output that a model's Prompt takes", () => {+ const g = cleanGraph(board("oss-moss-image"));+ expect(g.edges).toHaveLength(1);+ // A board saved and read back keeps the layout (the server's own check).+ const parsed = canvasServer.parseGraph(g)!;+ expect(parsed.nodes[0].data.layout?.items).toHaveLength(2);+ });++ it("compiles for each downstream model at the size it renders (sourceOf → planLayout)", () => {+ const at = (modelId: string, params: CanvasNode["data"]["params"] = {}) => {+ const g = board(modelId, params);+ const d = describeNode(g, g.nodes[1]);+ expect(d.error, modelId).toBeUndefined();+ expect(d.request?.params?.extra?.layout, modelId).toBeTruthy();+ return d.plan!;+ };+ // MOSS-Image on your GPU: its JSON at the canvas the picture takes (the layout's own 3:4, then 16:9 when the node picks it).+ const tall = at("oss-moss-image");+ expect(tall.layout).toMatchObject({ format: "moss", boxes: 2 });+ expect(tall.prompt).toBe(compileMoss({ ...poster, summary: { ...poster.summary, caption: "A warm candle sale poster" } }, tall.layout!.width!, tall.layout!.height!));+ expect(tall.layout!.height!).toBeGreaterThan(tall.layout!.width!);+ const wide = at("oss-moss-image", { aspectRatio: "16:9" });+ expect(wide.layout!.width!).toBeGreaterThan(wide.layout!.height!);+ expect(wide.prompt).not.toBe(tall.prompt);+ // MOSS-Image on fal: the same JSON, the size sent with it, expansion off.+ const fal = at("moss-image");+ expect(fal.layout?.format).toBe("moss");+ expect(fal.params.enhancePrompt).toBe(false);+ // FLUX.3 and Ideogram 4.5 read their own forms.+ expect(at("flux-3").layout?.format).toBe("flux3");+ expect(at("ideogram-4-5").layout?.format).toBe("ideogram");+ // A model that doesn't place boxes gets sentences.+ const words = at("nano-banana-pro");+ expect(readsBoxes(getModel("nano-banana-pro"))).toBe(false);+ expect(words.layout?.format).toBe("words");+ expect(words.prompt).toMatch(/30% OFF/);+ });++ it("reads as sentences in a text model, and asks for a box and for one layout at a time", () => {+ const text = board("text-llm");+ text.nodes[1].data.mediaKind = "text";+ const r = describeNode(text, text.nodes[1]);+ expect(r.request?.params?.extra?.layout).toBeUndefined();+ expect(r.request?.prompt).toMatch(/30% OFF/);+ const empty = board("oss-moss-image", {}, { ...poster, items: [] });+ expect(describeNode(empty, empty.nodes[1]).error).toMatch(/Draw a box in “Layout”/);+ const two = board("oss-moss-image");+ two.nodes.push(node("l2", "layout", 0, 300, { layout: poster }));+ two.edges.push(edge("l2", "m"));+ expect(describeNode(two, two.nodes[1]).error).toBe("Connect one layout at a time");+ });++ it("with a Table, fills {Column} in the layout's words row by row: one layout, a batch of posters", () => {+ const layout: LayoutDraft = {+ ...poster,+ items: [+ { ...poster.items[0], text: "{Offer}" },+ { ...poster.items[1], caption: "{Product}, lit, on a table" },+ ],+ };+ const g = board("oss-moss-image", {}, layout);+ g.nodes.push(+ node("t", "table", 0, 300, {+ columns: ["Offer", "Product"],+ rows: [+ ["30% OFF", "Soy candles"],+ ["2 FOR $30", "Beeswax tapers"],+ ],+ }),+ );+ g.edges.push(edge("t", "m"));+ const d = describeNode(g, g.nodes[1]);+ expect(d.error).toBeUndefined();+ expect(d.rows).toBe(2);+ const drafts = d.steps!.map((s) => s.request.params?.extra?.layout as LayoutDraft);+ expect(drafts.map((x) => x.items[0].text)).toEqual(["30% OFF", "2 FOR $30"]);+ expect(drafts.map((x) => x.items[1].caption)).toEqual(["Soy candles, lit, on a table", "Beeswax tapers, lit, on a table"]);+ // The row's cells went into the layout, so they aren't added to the prompt as well.+ expect(d.steps!.every((s) => !(s.request.prompt ?? "").includes("Soy candles, 30% OFF"))).toBe(true);+ });+});++// ---------------------------------------------------------------------------++describe("Marketing Studio: Words drawn by the model", () => {+ const ctx = { product, brand };+ it("keeps the words on top by default and says which models draw them in place", () => {+ expect([+ wordsOnTop("open", MARKETING_IMAGE_MODEL),+ wordsOnTop("open", MARKETING_IMAGE_MODEL, true),+ wordsOnTop("cloud", MARKETING_IMAGE_MODEL, true),+ wordsOnTop("cloud", "moss-image", true),+ ]).toEqual([true, false, false, false]);+ expect(formatModels(FORMATS.ads, "open", { product: true, avatar: false }, true).map((c) => c.id)).toEqual(["oss-moss-image"]);+ expect(formatModels(FORMATS.poster, "cloud", { product: false, avatar: false }, true).map((c) => c.id)).toEqual(["moss-image", "ideogram-4-5", "flux-3"]);+ // Formats without words don't change.+ expect(formatModels(FORMATS["product-standalone"], "open", { product: true, avatar: false }, true)[0].id).toBe(MARKETING_IMAGE_MODEL);+ for (const e of ["open", "cloud"] as const) for (const c of DRAWN_WORDS_MODELS[e]) expect(readsBoxes(getModel(c.id)), c.id).toBe(true);+ expect(drawnWordsModel("cloud", "flux-3")).toBe("flux-3");+ expect(drawnWordsModel("open", "flux-3")).toBe("oss-moss-image");+ });++ it("on your GPU: MOSS-Image draws the headline and button from the format's copy places", () => {+ const run = mk.planMarketing({ engine: "open", format: "ads", templateId: "ad-hero-headline", headline: "Crunch, sorted", drawnWords: true }, ctx);+ const r = run.steps[0].request;+ expect(r).toMatchObject({ modelId: "oss-moss-image", op: "t2i" });+ expect(r.inputs).toBeUndefined();+ const layout = r.params?.extra?.layout as LayoutDraft;+ expect(layout.items.filter((i) => i.label === "text").map((i) => i.text?.replace(/\n/g, " "))).toEqual(["Crunch, sorted", "Shop now"]);+ expect(layout.items.some((i) => i.label === "object" && i.caption.startsWith("Autumn Soy Candle"))).toBe(true);+ expect(r.prompt).not.toContain("“Crunch, sorted”");+ expect(run.meta.overlay).toBeNull();+ expect(run.notes.join(" ")).toMatch(/draws your product from its name and description/);+ // The plan compiles it for MOSS-Image at the size it renders.+ const p = planGeneration(r as GenerationRequest, getModel, getPreset);+ expect(p.layout).toMatchObject({ format: "moss" });+ expect(p.prompt).toMatch(/"text":"Crunch, sorted"/);+ });++ it("in the cloud: MOSS-Image hosted by default, FLUX.3 with the product photo", () => {+ const moss = mk.planMarketing({ engine: "cloud", format: "poster", prompt: "Autumn launch", headline: "Autumn Glow", drawnWords: true }, { brand, product: null });+ expect(moss.steps[0].request).toMatchObject({ modelId: "moss-image", op: "t2i" });+ expect((moss.steps[0].request.params?.extra?.layout as LayoutDraft).items.some((i) => i.text === "Autumn Glow")).toBe(true);+ const flux = mk.planMarketing({ engine: "cloud", format: "ads", templateId: "ad-hero-headline", modelId: "flux-3", drawnWords: true }, ctx);+ expect(flux.steps[0].request).toMatchObject({ modelId: "flux-3", op: "edit", inputs: { images: [product.images[0]] } });+ // The estimate prices the drawing model.+ const est = mk.estimateMarketing({ engine: "cloud", format: "ads", templateId: "ad-hero-headline", drawnWords: true, productImages: product.images });+ expect(est.steps?.[0]?.modelId ?? JSON.stringify(est)).toMatch(/moss-image/);+ });+});++// ---------------------------------------------------------------------------++describe("Ads Studio: drawn ads and the keep-clear layout", () => {+ const concept = { visual: "three candles on an oak table", headline: "Autumn Glow", body: "Hand-poured soy.", cta: "Shop now" };+ it("sends the words as a layout instead of the no-text instruction, on both engines", () => {+ const open = ads.visualRequest(concept, product, brand, "open", null, true);+ expect(open).toMatchObject({ modelId: "oss-moss-image", op: "t2i", params: { aspectRatio: "4:5" } });+ expect(open.prompt).not.toMatch(/No text, letters/);+ const layout = open.params?.extra?.layout as LayoutDraft;+ expect(layout.items.filter((i) => i.label === "text").map((i) => i.text?.replace(/\n/g, " "))).toEqual(["Autumn Glow", "Hand-poured soy.", "Shop now"]);+ expect(layout.items.some((i) => i.caption === "The brand's logo, small and crisp")).toBe(true);+ const cloud = ads.visualRequest(concept, product, brand, "cloud", "ideogram-4-5", true);+ expect(cloud.modelId).toBe("ideogram-4-5");+ expect(planGeneration(cloud, getModel, getPreset).layout?.format).toBe("ideogram");+ });++ it("without it: the visual alone, and a keep-clear layout only for a model that reads boxes", () => {+ const plain = ads.visualRequest(concept, product, brand, "cloud");+ expect(plain.params?.extra).toBeUndefined();+ expect(plain.prompt).toMatch(/No text, letters/);+ const flux = ads.visualRequest(concept, product, brand, "cloud", "flux-3");+ const layout = flux.params?.extra?.layout as LayoutDraft;+ expect(layout.items).toHaveLength(1);+ expect(layout.items[0].label).toBe("object");+ expect(flux.inputs?.images).toEqual(product.images);+ expect(planGeneration(flux, getModel, getPreset).layout).toMatchObject({ format: "flux3", boxes: 1 });+ });++ it("an estimate for drawn ads prices the model that draws them", () => {+ const e = ads.estimateBatch({ brandId: "b1", engine: "cloud", items: [{ productId: "p1", count: 2 }], drawnWords: true }, { brand, product });+ expect(e.modelId).toBe("moss-image");+ const draft = adDraft({ ratio: "4:5", layout: "overlay", content: { headline: "x" }, brand, mode: "clear", product: "y", caption: "" });+ expect(draft.aspect).toBe("4:5");+ });+});++// ---------------------------------------------------------------------------++describe("Plan layout and the Layout Poster skill", () => {+ it("lays out a poster from the sentence when no text model is there, and the result passes validateLayout", () => {+ const d = planByRules("a sale poster for my candle shop, 30% off", 768, 1024);+ expect(d.items.find((i) => i.label === "text")?.text).toBe("30% OFF");+ expect(d.items.map((i) => i.text).filter(Boolean)).toContain("Candle Shop");+ expect(d.aspect).toBe("3:4");+ expect(validateLayout(d, 768, 1024)).toEqual([]);+ const quoted = planByRules('a launch poster for our bakery that says "Fresh at 7"', 1536, 1024);+ expect(quoted.items[0].text).toBe("Fresh at 7");+ expect(validateLayout(quoted, 1536, 1024)).toEqual([]);+ });++ it("reads the planner's pixel draft (MOSS's abs / xyxy) into a layout that passes validateLayout", () => {+ const answer = JSON.stringify({+ width: 768,+ height: 1024,+ bbox_coord_space: "abs",+ bbox_format: "xyxy",+ summary: { caption: "A warm autumn sale poster", meta: ["poster"], canvas: "single" },+ items: [+ { label: "text", caption: "Large cream serif", text: "Autumn Glow", bbox: [64, 48, 704, 200] },+ { label: "object", caption: "Three lit candles", bbox: [112, 320, 656, 848] },+ ],+ });+ const d = readPlanned(`Here it is:\n${answer}`, 768, 1024)!;+ expect(d.items[0].box[0]).toBeCloseTo(64 / 768, 6);+ expect(d.items[1].box[3]).toBeCloseTo(848 / 1024, 6);+ expect(validateLayout(d, 768, 1024)).toEqual([]);+ // A text box without words doesn't run: not a plan.+ expect(readPlanned(answer.replace('"text":"Autumn Glow",', ""), 768, 1024)).toBeNull();+ expect(readPlanned("no layout here", 768, 1024)).toBeNull();+ });++ it("asks the AI helper first and falls back to the rules", async () => {+ setSetting("enhanceProvider", "local");+ const good =+ '{"width":1024,"height":1024,"bbox_coord_space":"abs","bbox_format":"xyxy","summary":{"caption":"x","meta":[],"canvas":"single"},"items":[{"label":"text","caption":"bold","text":"SALE","bbox":[100,50,900,250]}]}';+ const asked: string[] = [];+ const r = await planLayoutFromWords("a sale poster", 1024, 1024, async (system, user) => (asked.push(user), good));+ expect(r.by).toBe("llm");+ expect(asked[0]).toMatch(/Canvas: 1024 × 1024/);+ expect((await planLayoutFromWords("a sale poster, 20% off", 1024, 1024, async () => "sorry")).by).toBe("rules");+ setSetting("enhanceProvider", "none");+ expect((await planLayoutFromWords("a sale poster", 1024, 1024, async () => good)).by).toBe("rules");+ });++ it("ships skills/layout-poster, which Assist's skill loader picks up with its reference and the Apache-2.0 notice", () => {+ const s = skills.getSkill("layout-poster")!;+ expect(s).toBeTruthy();+ expect(s.source).toBe("builtin");+ expect(s.files?.map((f) => f.path)).toContain("references/layout.md");+ expect(skills.listSkills().some((x) => x.name === "layout-poster")).toBe(true);+ const md = fs.readFileSync(path.join(process.cwd(), "skills/layout-poster/SKILL.md"), "utf8");+ expect(md).toMatch(/Apache\s+License, Version 2\.0/);+ expect(fs.readFileSync(path.join(process.cwd(), "skills/layout-poster/references/layout.md"), "utf8")).toMatch(/2b46b1e0e13b5aaec253879e0d006a42564b8b27/);+ // The draft in its reference example is one the planner reads and validateLayout passes.+ const example = /```json\n([\s\S]+?)```/.exec(fs.readFileSync(path.join(process.cwd(), "skills/layout-poster/references/layout.md"), "utf8"))![1];+ expect(readPlanned(example, 768, 1024)?.items).toHaveLength(4);+ });+});diff --git a/tests/marketing-api.test.ts b/tests/marketing-api.test.tsindex a8940b4c..9d051032 100644--- a/tests/marketing-api.test.ts+++ b/tests/marketing-api.test.ts@@ -634,7 +634,9 @@ describe("Ads Studio", () => {// In the cloud Nano Banana Pro and GPT Image 2.5 stay choices; a model the studio doesn't offer runs the Original.expect((await (await adsEstimate.POST(json("POST", { brandId, engine: "cloud", items }))).json()).modelId).toBe("fuobe-marketing-image");expect((await (await adsEstimate.POST(json("POST", { brandId, engine: "cloud", items, modelId: "nano-banana-pro" }))).json()).modelId).toBe("nano-banana-pro");- expect((await (await adsEstimate.POST(json("POST", { brandId, engine: "cloud", items, modelId: "flux-3" }))).json()).modelId).toBe("fuobe-marketing-image");+ expect((await (await adsEstimate.POST(json("POST", { brandId, engine: "cloud", items, modelId: "recraft-4-1" }))).json()).modelId).toBe("fuobe-marketing-image");+ // FLUX.3 is a choice too (N7-8): it reads a "keep clear" layout that keeps the product out of the words' space.+ expect((await (await adsEstimate.POST(json("POST", { brandId, engine: "cloud", items, modelId: "flux-3" }))).json()).modelId).toBe("flux-3");const { batchId, creatives, run } = ads.createBatch({ brandId, engine: "open", items });expect(creatives).toHaveLength(5);expect(creatives.every((c) => c.status === "writing")).toBe(true);diff --git a/tests/public-signup-tools.test.ts b/tests/public-signup-tools.test.tsindex 8cae9d80..89f0a64b 100644--- a/tests/public-signup-tools.test.ts+++ b/tests/public-signup-tools.test.ts@@ -115,7 +115,7 @@ describe("the proxy: PR #15's routes as main treats their kind", () => {process.env.FUOBE_PUBLIC_SIGNUP = "1";for (const p of ["/api/turnaround/estimate", "/api/turnaround?preview=1", "/api/audio-tools?preview=1"]) expect(passed(proxy(req(p, { method: "POST" }))), p).toBe(true);// Signing up wouldn't run these (an account's own GPU or key doesn't either): the account's answer, not the card.- for (const p of ["/api/turnaround", "/api/audio-tools", "/api/shorts/sessions", "/api/katana", "/api/marketing/runs", "/api/layers/l1/jobs"]) {+ for (const p of ["/api/turnaround", "/api/audio-tools", "/api/shorts/sessions", "/api/katana", "/api/marketing/runs", "/api/layers/l1/jobs", "/api/layout/plan"]) {const r = proxy(req(p, { method: "POST" }));expect(r.status, p).toBe(403);expect(r.headers.get(access.GUEST_HEADER), p).toBeNull();@@ -153,7 +153,7 @@ describe("the proxy: PR #15's routes as main treats their kind", () => {const cookie = auth.createSession(a.id).value;auth.setAccountGpu(a.id, { url: "https://gpu.example" });expect(passed(proxy(req("/api/generations", { method: "POST", cookie })))).toBe(true);- for (const p of ["/api/turnaround", "/api/audio-tools", "/api/cinema/projects/p1/generate"]) {+ for (const p of ["/api/turnaround", "/api/audio-tools", "/api/cinema/projects/p1/generate", "/api/layout/plan"]) {const r = proxy(req(p, { method: "POST", cookie }));expect(r.status, p).toBe(403);expect(r.headers.get(access.CONNECT_GPU_HEADER), p).toBeNull();diff --git a/tests/public-signup.test.ts b/tests/public-signup.test.tsindex 26b9b12b..53d0d03a 100644--- a/tests/public-signup.test.ts+++ b/tests/public-signup.test.ts@@ -240,6 +240,8 @@ describe("accounts never run on the owner's keys or GPU", () => {// Restore & colourise (o/archive-restore): its run and its prompt writer."/api/restore","/api/restore/prompt",+ // Plan layout (N7-8) plans with the studio's own AI helper.+ "/api/layout/plan",]) {const r = proxy(req(p, { method: "POST", cookie }));expect(r.status, p).toBe(403);