From 43af3dd5f1b596eccee1742482a8a59687f0b8e0 Mon Sep 17 00:00:00 2001 From: claude code agent 227 Date: Mon, 29 Jun 2026 01:43:18 +0300 Subject: [PATCH] test(mcp): cover captioned image inside a column round-trip (F5) A captioned image in a column is emitted via the imageToHtml helper, a separate path from the top-level image case whose data-caption branch was untested. Add a round-trip test with special chars (Tom & "Jerry") that fails if the imageToHtml caption branch breaks. Co-Authored-By: Claude Opus 4.8 (1M context) --- packages/mcp/test/unit/roundtrip.test.mjs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/mcp/test/unit/roundtrip.test.mjs b/packages/mcp/test/unit/roundtrip.test.mjs index 56852cee..1b80e554 100644 --- a/packages/mcp/test/unit/roundtrip.test.mjs +++ b/packages/mcp/test/unit/roundtrip.test.mjs @@ -82,6 +82,24 @@ test("round-trip: image inside a column survives as an image node (not literal m assert.ok(!JSON.stringify(out).includes("![pic]"), "image must not become literal markdown text"); }); +test("round-trip: captioned image inside a column preserves its caption (imageToHtml branch)", async () => { + // A captioned image in a column is emitted via the imageToHtml helper (raw + // HTML container), a different path from the top-level image case. Special + // chars in the caption exercise attribute escaping on the way out and in. + const caption = 'Tom & "Jerry"'; + const input = doc({ + type: "columns", + content: [ + { type: "column", content: [{ type: "image", attrs: { src: "/api/files/a/p.png", alt: "pic", caption } }] }, + { type: "column", content: [para(text("right"))] }, + ], + }); + const out = await roundtrip(input); + const imgs = findNodes(out, "image"); + assert.equal(imgs.length, 1, "captioned image inside a column must survive"); + assert.equal(imgs[0].attrs?.caption, caption, "caption (incl. special chars) must be preserved"); +}); + test("round-trip: blockquote inside a column survives as a blockquote node", async () => { const input = doc({ type: "columns",