fix(coding-agent): expect saved image label in codemode MCP test (#10463)

The codemode image() output now names the saved temp file before each
image, so the MCP integration test must expect the extra text item.
This commit is contained in:
Armin Ronacher 2026-10-05 00:58:33 +02:00 • committed by GitHub
parent 4c6b724ea6
commit b2b5c42f61
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,3 +1,4 @@
import { readFileSync, rmSync } from "node:fs";
import { fauxAssistantMessage, fauxToolCall } from "@earendil-works/pi-ai";
import type { SystemMessage, ToolResultMessage } from "@earendil-works/pi-ai/compat";
import { type JsonRpcRequest, LATEST_PROTOCOL_VERSION } from "@earendil-works/pi-mcp";
@ -254,15 +255,24 @@ describe("AgentSession MCP integration", () => {
const result = toolResult(harness, "codemode");
expect(result.isError).toBe(false);
// Output items keep the order the script produced them in.
expect(result.content[1]).toEqual({ type: "image", data: TINY_PNG_BASE64, mimeType: "image/png" });
expect(JSON.parse((result.content[2] as { text: string }).text)).toEqual({
// Output items keep the order the script produced them in; each image follows the path it was saved to.
const savedPath = /^\[Image saved to (\S+\.png) \(image\/png, \d+B\)\]$/.exec(
(result.content[1] as { text: string }).text,
)?.[1];
expect(savedPath).toBeDefined();
try {
expect(readFileSync(savedPath!).toString("base64")).toBe(TINY_PNG_BASE64);
} finally {
if (savedPath) rmSync(savedPath, { force: true });
}
expect(result.content[2]).toEqual({ type: "image", data: TINY_PNG_BASE64, mimeType: "image/png" });
expect(JSON.parse((result.content[3] as { text: string }).text)).toEqual({
hits: ["mcp guide", "mcp faq", "pi guide", "pi faq"],
failed: true,
failure: "server exploded",
found: [searchName],
});
expect(result.content).toHaveLength(3);
expect(result.content).toHaveLength(4);
expect(calls).toEqual(['search:{"query":"mcp"}', 'search:{"query":"pi"}', "fail:{}", "shot:{}"]);
});