From 6e5313e28358e27df9b7918858a9f7f78c6f7522 Mon Sep 17 00:00:00 2001 From: suyx Date: Tue, 4 Aug 2026 18:37:37 +0800 Subject: [PATCH] test(wp7-02): require Gemini chat image relay --- .../wp7-02-controlled-executor.test.mjs | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tests/package/wp7-02-controlled-executor.test.mjs b/tests/package/wp7-02-controlled-executor.test.mjs index 5fe3ea2..ae916f1 100644 --- a/tests/package/wp7-02-controlled-executor.test.mjs +++ b/tests/package/wp7-02-controlled-executor.test.mjs @@ -72,6 +72,17 @@ const stableFlashOpenAiImageModel = { }, }; +const stableFlashOpenAiChatModel = { + config_version: 7, + model_id: "gemini-3.1-flash-image-preview", + route_profile: { + endpoint: "https://oneapi.intelligrow.cn/v1/chat/completions", + mode: "sync", + protocol_version: "gemini-openai-chat-v1", + provider_model_id: "gemini-3.1-flash-image", + }, +}; + const onePixelPng = Buffer.from( "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=", "base64", @@ -142,6 +153,27 @@ test("TDD-WP7-EXT-001 builds protocol-specific requests without auth in argument size: "1408x1056", }); + const stableOpenAiChat = buildProviderRequest({ + modelConfig: stableFlashOpenAiChatModel, + prompt: "controlled fixture prompt", + ratio: "4:3", + reference, + }); + assert.deepEqual(stableOpenAiChat.body, { + extra_body: { google: { image_config: { aspect_ratio: "4:3", image_size: "1K" } } }, + messages: [{ + content: [ + { text: "controlled fixture prompt", type: "text" }, + { image_url: { url: `data:image/png;base64,${onePixelPng.toString("base64")}` }, type: "image_url" }, + ], + role: "user", + }], + model: "gemini-3.1-flash-image", + stream: false, + }); + assert.equal(stableOpenAiChat.url, "https://oneapi.intelligrow.cn/v1/chat/completions"); + assert.equal("authorization" in stableOpenAiChat.headers, false); + const openai = buildProviderRequest({ modelConfig: models[2], prompt: "controlled fixture prompt", ratio: "9:16" }); assert.deepEqual(openai.body, { model: "gpt-image-2", @@ -182,6 +214,14 @@ test("TDD-WP7-EXT-001 retains only response metadata and hashes", () => { assert.deepEqual(interactionNormalized.dimensions, { height: 1, width: 1 }); assert.equal(interactionNormalized.mime, "image/png"); assert.deepEqual(interactionNormalized.usage_summary, { input_units: 11, output_units: 13, total_units: 24 }); + + const chatNormalized = normalizeProviderResponse(stableFlashOpenAiChatModel, { + choices: [{ message: { content: `![image](data:image/png;base64,${onePixelPng.toString("base64")})` } }], + usage: { completion_tokens: 17, prompt_tokens: 15, total_tokens: 32 }, + }); + assert.deepEqual(chatNormalized.dimensions, { height: 1, width: 1 }); + assert.equal(chatNormalized.mime, "image/png"); + assert.deepEqual(chatNormalized.usage_summary, { input_units: 15, output_units: 17, total_units: 32 }); }); test("TDD-WP7-EXT-001 rejects sensitive or shared evidence fields", () => {