|
|
|
@ -1020,6 +1020,60 @@ describe("/api/generate route", () => { |
|
|
|
expect(data.image).toMatch(/^data:image\/png;base64,/); |
|
|
|
expect(data.contentType).toBe("image"); |
|
|
|
}); |
|
|
|
|
|
|
|
it("should pass top-level aspect ratio and resolution to native NewApiWG image models", async () => { |
|
|
|
mockFetch.mockResolvedValueOnce({ |
|
|
|
ok: true, |
|
|
|
json: () => Promise.resolve({ |
|
|
|
candidates: [ |
|
|
|
{ |
|
|
|
content: { |
|
|
|
parts: [ |
|
|
|
{ |
|
|
|
inlineData: { |
|
|
|
mimeType: "image/png", |
|
|
|
data: "nativeImageData", |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
}, |
|
|
|
}, |
|
|
|
], |
|
|
|
}), |
|
|
|
}); |
|
|
|
|
|
|
|
const request = createMockPostRequest( |
|
|
|
{ |
|
|
|
prompt: "A tall poster", |
|
|
|
aspectRatio: "9:16", |
|
|
|
resolution: "2K", |
|
|
|
selectedModel: { |
|
|
|
provider: "newapiwg", |
|
|
|
modelId: "apiyi_nano_banana_2", |
|
|
|
displayName: "PopiArt Nano Pro", |
|
|
|
capabilities: ["text-to-image", "image-to-image"], |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ "X-NewApiWG-Key": "test-newapiwg-key" } |
|
|
|
); |
|
|
|
|
|
|
|
const response = await POST(request); |
|
|
|
const data = await response.json(); |
|
|
|
|
|
|
|
expect(response.status).toBe(200); |
|
|
|
expect(data.success).toBe(true); |
|
|
|
expect(mockFetch).toHaveBeenCalledWith( |
|
|
|
expect.stringContaining("/models/gemini-3.1-flash-image-preview:generateContent"), |
|
|
|
expect.objectContaining({ |
|
|
|
body: expect.stringContaining('"aspectRatio":"9:16"'), |
|
|
|
}) |
|
|
|
); |
|
|
|
const body = JSON.parse(mockFetch.mock.calls[0][1].body as string); |
|
|
|
expect(body.generationConfig.imageConfig).toMatchObject({ |
|
|
|
aspectRatio: "9:16", |
|
|
|
imageSize: "2K", |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
describe("Replicate provider", () => { |
|
|
|
|