From b21433af4eb09df933e346dfa3a0f215ab17a13f Mon Sep 17 00:00:00 2001 From: claude code agent 227 Date: Sun, 21 Jun 2026 05:46:35 +0300 Subject: [PATCH] test(mcp): round-trip the htmlEmbed passthrough node (#99, #98) Add htmlEmbed to the schema toYdoc/fromYdoc acceptance cases, asserting source + height survive, so removing the passthrough node (which prevents 'Unknown node type: htmlEmbed' on MCP/AI edits of an embed page) fails CI. Co-Authored-By: Claude Opus 4.8 --- packages/mcp/test/unit/schema.test.mjs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/mcp/test/unit/schema.test.mjs b/packages/mcp/test/unit/schema.test.mjs index b1b9d417..131a5432 100644 --- a/packages/mcp/test/unit/schema.test.mjs +++ b/packages/mcp/test/unit/schema.test.mjs @@ -53,6 +53,10 @@ const cases = { video: docOf({ type: "video", attrs: { src: "http://x/v.mp4" } }), youtube: docOf({ type: "youtube", attrs: { src: "http://y/watch" } }), embed: docOf({ type: "embed", attrs: { src: "http://e", provider: "iframe" } }), + htmlEmbed: docOf({ + type: "htmlEmbed", + attrs: { source: "", height: 320 }, + }), drawio: docOf({ type: "drawio", attrs: { src: "http://d" } }), excalidraw: docOf({ type: "excalidraw", attrs: { src: "http://e" } }), columns: docOf({ @@ -75,3 +79,19 @@ for (const [name, doc] of Object.entries(cases)) { }); }); } + +// htmlEmbed is the sandboxed raw-HTML block. The MCP write path carries it +// through Yjs (toYdoc -> fromYdoc) without rendering, so a full round-trip must +// preserve both the `source` snippet and the numeric `height`. +test("htmlEmbed round-trips source and height through Yjs", () => { + const doc = docOf({ + type: "htmlEmbed", + attrs: { source: "", height: 480 }, + }); + const ydoc = TiptapTransformer.toYdoc(doc, "default", docmostExtensions); + const back = TiptapTransformer.fromYdoc(ydoc, "default"); + const node = back.content.find((n) => n.type === "htmlEmbed"); + assert.ok(node, "htmlEmbed node survives the round-trip"); + assert.equal(node.attrs.source, ""); + assert.equal(node.attrs.height, 480); +});