fix(wp7-02): normalize generated image dimensions
Dada P0-A isolated Windows CI / validate-and-package (push) Failing after 2m17s
Dada P0-A isolated Windows CI / validate-and-package (push) Failing after 2m17s
This commit is contained in:
@@ -135,6 +135,11 @@ test("TDD-WP7-EXT-001 confines the credential to the request header and discards
|
||||
token: credentialMarker,
|
||||
});
|
||||
assert.equal(success.http_status, 200);
|
||||
assert.deepEqual(success.response_evidence.dimensions, { height: 1080, width: 1080 });
|
||||
assert.deepEqual(success.response_evidence.normalization, {
|
||||
applied: true,
|
||||
upstream_dimensions: { height: 1, width: 1 },
|
||||
});
|
||||
assert.doesNotMatch(JSON.stringify({ ...success, normalized: undefined }), new RegExp(credentialMarker));
|
||||
|
||||
await assert.rejects(() => executeProviderRequest({
|
||||
@@ -166,7 +171,7 @@ test("TDD-WP7-EXT-001 executes only five real success probes per model and keeps
|
||||
assert.equal(fetchCalls, 5);
|
||||
assert.equal(execution.real_calls, 5);
|
||||
assert.equal(execution.status, "externally_blocked");
|
||||
assert.equal(execution.calls.filter((call) => call.status === "passed").length, 0);
|
||||
assert.equal(execution.calls.filter((call) => call.status === "passed").length, 2);
|
||||
assert.doesNotMatch(JSON.stringify(execution), /controlled-secret|fixture prompt|iVBOR/i);
|
||||
await assert.rejects(() => runControlledRealScenarios({ maxRealCalls: 121, modelConfig: models[0], token: "not-used" }), /WP7_02_REAL_CALL_LIMIT_INVALID/);
|
||||
});
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { GeminiFlashAdapter } from "../../apps/worker/src/ai-adapter-gemini-flash.js";
|
||||
import { GeminiProAdapter } from "../../apps/worker/src/ai-adapter-gemini-pro.js";
|
||||
import { GptImageAdapter } from "../../apps/worker/src/ai-adapter-gpt-image.js";
|
||||
import {
|
||||
gptImageRequestSizeForRatio,
|
||||
normalizeImageOutputToRatio,
|
||||
productDimensionsForRatio,
|
||||
} from "../../apps/worker/src/image-output-normalizer.js";
|
||||
} from "../../apps/worker/src/image-output-normalizer.mjs";
|
||||
|
||||
const onePixelPng = Buffer.from(
|
||||
"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=",
|
||||
@@ -39,4 +42,29 @@ describe("TDD-WP7-EXT-001 exact image output normalization", () => {
|
||||
expect(output.bytes.subarray(0, 8).toString("hex")).toBe("89504e470d0a1a0a");
|
||||
expect(productDimensionsForRatio("9:16")).toEqual({ pixelHeight: 1920, pixelWidth: 1080 });
|
||||
});
|
||||
|
||||
it("is used by all three production adapter boundaries", async () => {
|
||||
const encoded = onePixelPng.toString("base64");
|
||||
const adapters = [
|
||||
new GeminiFlashAdapter({ transport: {
|
||||
async start() { return { candidates: [{ inline_data: { data: encoded, mime_type: "image/png" }, pixelHeight: 1, pixelWidth: 1 }] }; },
|
||||
async poll() { return {}; },
|
||||
} }),
|
||||
new GeminiProAdapter({ transport: {
|
||||
async start() { return { operation: { done: true, response: { candidates: [{ inline_data: { data: encoded, mime_type: "image/png" }, pixelHeight: 1, pixelWidth: 1 }] } } }; },
|
||||
async poll() { return {}; },
|
||||
} }),
|
||||
new GptImageAdapter({ transport: {
|
||||
async start() { return { data: [{ b64_json: encoded, pixelHeight: 1, pixelWidth: 1 }] }; },
|
||||
async poll() { return {}; },
|
||||
} }),
|
||||
];
|
||||
for (const adapter of adapters) {
|
||||
const result = await adapter.start({
|
||||
configSnapshot: {}, generationId: `normalization-${adapter.modelId}`, modelId: adapter.modelId,
|
||||
prompt: "sanitized fixture", ratio: "1:1", referenceAssetIds: [],
|
||||
});
|
||||
expect(result).toMatchObject({ status: "completed", outputs: [{ mimeType: "image/png", pixelHeight: 1080, pixelWidth: 1080 }] });
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user