From f8e827cba78d09b3d3e3e2bb4e114ddcb7793b2f Mon Sep 17 00:00:00 2001 From: Eduard Ruzga Date: Fri, 5 Jun 2026 11:53:46 +0300 Subject: [PATCH] test: align read_file image-content assertions with #488 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #488 added the image bytes back into read_file's MCP `content` array so the host model can see images, but test-file-handlers.js was never updated and still asserted the pre-#488 contract ("avoid image content item for host compatibility"). That assertion is now inverted from the shipped behaviour and was the only failing test in the suite. Update Test 9 to assert the current contract for both raster (PNG) and SVG reads: the `content` array includes an `image` item carrying base64 `data` and the correct `mimeType` (image/png, image/svg+xml), alongside the existing structuredContent checks. No production code change — handler behaviour is unchanged. --- test/test-file-handlers.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/test-file-handlers.js b/test/test-file-handlers.js index a741fe58..caf04337 100644 --- a/test/test-file-handlers.js +++ b/test/test-file-handlers.js @@ -327,7 +327,10 @@ async function testReadFilePreviewMetadata() { const imageResult = await handleReadFile({ path: IMAGE_FILE }); assert.ok(Array.isArray(imageResult.content), 'Image result should include content array'); - assert.ok(!imageResult.content.some((item) => item.type === 'image'), 'Image result should avoid image content item for host compatibility'); + const imageContentItem = imageResult.content.find((item) => item.type === 'image'); + assert.ok(imageContentItem, 'Image result should include an image content item so the host model can see the image'); + assert.strictEqual(imageContentItem.mimeType, 'image/png', 'Image content item should carry the png mimeType'); + assert.ok(typeof imageContentItem.data === 'string' && imageContentItem.data.length > 0, 'Image content item should carry non-empty base64 data'); assert.ok(imageResult.structuredContent, 'Image should include structuredContent'); assert.strictEqual(imageResult.structuredContent.fileType, 'image', 'Image fileType should map to image preview state'); assert.strictEqual(typeof imageResult.structuredContent.imageData, 'string', 'Image structured payload should include imageData'); @@ -339,7 +342,10 @@ async function testReadFilePreviewMetadata() { const svgResult = await handleReadFile({ path: SVG_FILE }); assert.ok(Array.isArray(svgResult.content), 'SVG result should include content array'); - assert.ok(!svgResult.content.some((item) => item.type === 'image'), 'SVG result should avoid image content item for host compatibility'); + const svgContentItem = svgResult.content.find((item) => item.type === 'image'); + assert.ok(svgContentItem, 'SVG result should include an image content item so the host model can see the image'); + assert.strictEqual(svgContentItem.mimeType, 'image/svg+xml', 'SVG content item should carry the svg mimeType'); + assert.ok(typeof svgContentItem.data === 'string' && svgContentItem.data.length > 0, 'SVG content item should carry non-empty base64 data'); assert.ok(svgResult.structuredContent, 'SVG should include structuredContent'); assert.strictEqual(svgResult.structuredContent.fileType, 'image', 'SVG should map to image preview state'); assert.strictEqual(svgResult.structuredContent.mimeType, 'image/svg+xml', 'SVG structured payload should include SVG mimeType');