test(agents): share verbose media fixture

This commit is contained in:
Vincent Koc
2026-04-12 11:06:05 +01:00
parent a5689accc4
commit ecebc4541a

View File

@@ -220,11 +220,11 @@ describe("handleToolExecutionEnd media emission", () => {
expect(ctx.state.pendingToolAudioAsVoice).toBe(true);
});
it("does not queue structured media already emitted in plain verbose output", async () => {
async function handleVerboseGeneratedImage(toolResultFormat: "plain" | "markdown") {
const ctx = createMockContext({
shouldEmitToolOutput: true,
onToolResult: vi.fn(),
toolResultFormat: "plain",
toolResultFormat,
});
await handleToolExecutionEnd(ctx, {
@@ -247,36 +247,18 @@ describe("handleToolExecutionEnd media emission", () => {
},
});
return ctx;
}
it("does not queue structured media already emitted in plain verbose output", async () => {
const ctx = await handleVerboseGeneratedImage("plain");
expect(ctx.emitToolOutput).toHaveBeenCalled();
expect(ctx.state.pendingToolMediaUrls).toEqual([]);
});
it("still queues structured media for markdown verbose output", async () => {
const ctx = createMockContext({
shouldEmitToolOutput: true,
onToolResult: vi.fn(),
toolResultFormat: "markdown",
});
await handleToolExecutionEnd(ctx, {
type: "tool_execution_end",
toolName: "image_generate",
toolCallId: "tc-1",
isError: false,
result: {
content: [
{
type: "text",
text: "Generated 1 image with google/gemini-3.1-flash-image-preview.\nMEDIA:/tmp/generated.png",
},
],
details: {
media: {
mediaUrls: ["/tmp/generated.png"],
},
},
},
});
const ctx = await handleVerboseGeneratedImage("markdown");
expect(ctx.emitToolOutput).toHaveBeenCalled();
expect(ctx.state.pendingToolMediaUrls).toEqual(["/tmp/generated.png"]);