mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
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:
parent
4c6b724ea6
commit
b2b5c42f61
1 changed files with 14 additions and 4 deletions
|
|
@ -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:{}"]);
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue