Skip to content
Source
Sign inSign up
TanStack/ai
Open History to see the last commit

gemini-image-ga-models.spec.ts

56 lines2.1 KB

1import { test, expect } from './fixtures'
2​
3interface StageResult {
4 imageCount?: number
5 error?: string
6}
7​
8interface GeminiImageGaModelsResponse {
9 gaModelListed: boolean
10 gaModel: StageResult
11 legacyModel: StageResult
13​
14/**
15 * Regression coverage for #1104 (Gemini GA image model ids + per-model
16 * sizes). See `api.gemini-image-ga-models.ts` for the full mechanism and
17 * `geminiNativeImageMount` in `global-setup.ts` for the mock that makes it
18 * possible — aimock's native Gemini `generateContent` handler has no
19 * image-response branch, so this route/mount pair exists specifically to
20 * cover what aimock alone cannot. The route runs both model calls as
21 * independent stages, so each test below only depends on its own stage.
22 */
23test.describe('gemini — GA image model ids and per-model sizes (#1104)', () => {
24 test('gemini-3.1-flash-image is a listed GA id and generates an image', async ({
25 request,
26 }) => {
27 const res = await request.post('/api/gemini-image-ga-models')
28 expect(res.ok()).toBe(true)
29​
30 const { gaModelListed, gaModel } =
31 (await res.json()) as GeminiImageGaModelsResponse
32​
33 // Genuine runtime data, not a type check: `GeminiImageModels` is the
34 // package's exported `as const` array of supported image model ids.
35 // Nothing at runtime gates request routing on this array (the adapter
36 // dispatches on the model string's "gemini-" prefix, not membership), so
37 // checking its contents is the only way to observe the id addition
38 // without a TypeScript compile step. Before #1104 it only carried the
39 // shut-down `gemini-3.1-flash-image-preview` alias.
40 expect(gaModelListed).toBe(true)
41 expect(gaModel.error ?? null).toBeNull()
42 expect(gaModel.imageCount).toBe(1)
43 })
44​
45 test('gemini-2.5-flash-image sends imageConfig.aspectRatio with no imageSize', async ({
46 request,
47 }) => {
48 const res = await request.post('/api/gemini-image-ga-models')
49 expect(res.ok()).toBe(true)
50​
51 const { legacyModel } = (await res.json()) as GeminiImageGaModelsResponse
52​
53 expect(legacyModel.error ?? null).toBeNull()
54 expect(legacyModel.imageCount).toBe(1)
55 })
56})