From d7a24a5ecb58ab35572ad7c9645ece65ebc8f983 Mon Sep 17 00:00:00 2001 From: suyx Date: Tue, 4 Aug 2026 18:27:55 +0800 Subject: [PATCH] test(wp7-02): require Gemini interactions image contract --- .../wp7-02-controlled-executor.test.mjs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/package/wp7-02-controlled-executor.test.mjs b/tests/package/wp7-02-controlled-executor.test.mjs index c106e8e..b0959d7 100644 --- a/tests/package/wp7-02-controlled-executor.test.mjs +++ b/tests/package/wp7-02-controlled-executor.test.mjs @@ -49,6 +49,17 @@ const models = [ }, ]; +const stableFlashInteractionModel = { + config_version: 4, + model_id: "gemini-3.1-flash-image-preview", + route_profile: { + endpoint: "https://oneapi.intelligrow.cn/v1beta/interactions", + mode: "sync", + protocol_version: "gemini-interactions-v1beta", + provider_model_id: "gemini-3.1-flash-image", + }, +}; + const onePixelPng = Buffer.from( "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=", "base64", @@ -90,6 +101,23 @@ test("TDD-WP7-EXT-001 builds protocol-specific requests without auth in argument assert.equal("responseFormat" in gemini.body.generationConfig, false); assert.equal("authorization" in gemini.headers, false); + const interaction = buildProviderRequest({ + modelConfig: stableFlashInteractionModel, + prompt: "controlled fixture prompt", + ratio: "3:4", + reference, + }); + assert.deepEqual(interaction.body, { + input: [ + { text: "controlled fixture prompt", type: "text" }, + { data: onePixelPng.toString("base64"), mime_type: "image/png", type: "image" }, + ], + model: "gemini-3.1-flash-image", + response_format: { aspect_ratio: "3:4", image_size: "1K", type: "image" }, + }); + assert.equal(interaction.url, "https://oneapi.intelligrow.cn/v1beta/interactions"); + assert.equal("authorization" in interaction.headers, false); + const openai = buildProviderRequest({ modelConfig: models[2], prompt: "controlled fixture prompt", ratio: "9:16" }); assert.deepEqual(openai.body, { model: "gpt-image-2", @@ -121,6 +149,15 @@ test("TDD-WP7-EXT-001 retains only response metadata and hashes", () => { assert.deepEqual(evidence.usage_summary, { input_units: 5, output_units: 7, total_units: 12 }); assert.doesNotMatch(JSON.stringify(evidence), /iVBOR|bytes|data|prompt|authorization|token/i); assert.equal(validateSanitizedEvidence(evidence), evidence); + + const interactionNormalized = normalizeProviderResponse(stableFlashInteractionModel, { + status: "completed", + steps: [{ content: [{ data: onePixelPng.toString("base64"), mime_type: "image/png", type: "image" }], type: "model_output" }], + usage: { total_input_tokens: 11, total_output_tokens: 13, total_tokens: 24 }, + }); + 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 }); }); test("TDD-WP7-EXT-001 rejects sensitive or shared evidence fields", () => {