From 97fdba06142001b7ae27e9488ef59c96b3bf9d2d Mon Sep 17 00:00:00 2001 From: Shakker Date: Fri, 8 May 2026 19:02:17 +0100 Subject: [PATCH] test: tighten image prompt assertions --- src/media-understanding/image.test.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/media-understanding/image.test.ts b/src/media-understanding/image.test.ts index 65a4d700662..6ad71796ac6 100644 --- a/src/media-understanding/image.test.ts +++ b/src/media-understanding/image.test.ts @@ -387,7 +387,12 @@ describe("describeImageWithModel", () => { throw new Error("Expected image completion call"); } const [, context] = firstCall; - expect(context.messages[0]?.content).toHaveLength(1); + const userMessage = context.messages[0]; + expect(userMessage).toBeDefined(); + if (!userMessage) { + throw new Error("expected image completion user message"); + } + expect(userMessage.content).toHaveLength(1); }); it("places OpenRouter image prompts in user content before images", async () => { @@ -432,7 +437,12 @@ describe("describeImageWithModel", () => { } const [, context] = firstCall; expect(context.systemPrompt).toBeUndefined(); - expect(context.messages[0]?.content).toEqual([ + const userMessage = context.messages[0]; + expect(userMessage).toBeDefined(); + if (!userMessage) { + throw new Error("expected OpenRouter image completion user message"); + } + expect(userMessage.content).toEqual([ { type: "text", text: "Describe the image." }, expect.objectContaining({ type: "image",