import { describe, expect, it } from "vitest"; import { renderVisualBlockShell, visualBlockSummary, } from "../web/components/visual-block.js"; describe("ui visual block rendering", () => { it("renders widget fallback and ids", () => { expect( visualBlockSummary({ type: "widget_mount", widgetId: "widget-1", title: "Demo", fallback: "Fallback text", status: "mounted", }), ).toBe("Demo · widget-1 · mounted · Fallback text"); }); it("renders widget errors with a fix hint", () => { expect( visualBlockSummary({ type: "widget_error", widgetId: "widget-1", message: "boom", status: "error", }), ).toBe("widget-1 · error · boom · agent: fix widget HTML/JS"); }); it("renders bounded iframe shell", () => { const html = renderVisualBlockShell({ widgetId: "widget-1", title: "Demo", fallback: "Fallback", srcdoc: "
Hi
", }); expect(html).toContain("ui-visual-block"); expect(html).toContain("widget-1"); expect(html).toContain("iframe"); expect(html).toContain("Fallback"); }); });