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 nanoBanana21: 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 `/v1beta/interactions` handler streams text and has no
19 * image branch, so this route/mount pair exists specifically to cover what
20 * aimock alone cannot. The route runs each model call as an independent
21 * stage, 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 `GEMINI_NATIVE_IMAGE_MODELS` membership), so checking
37 // its contents is the only way to observe the id addition without a
38 // TypeScript compile step. Before #1104 the array 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-nano-banana-2.1 routes to Interactions with aspect_ratio and image_size (#1640)', async ({
46 request,
47 }) => {
48 const res = await request.post('/api/gemini-image-ga-models')
49 expect(res.ok()).toBe(true)
50​
51 const { nanoBanana21 } = (await res.json()) as GeminiImageGaModelsResponse
52​
53 expect(nanoBanana21.error ?? null).toBeNull()
54 expect(nanoBanana21.imageCount).toBe(1)
55 })
56})