|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import type * as CodexSchema from "effect-codex-app-server/schema"; |
| 3 | + |
| 4 | +import { parseCodexModelListResponse } from "./CodexProvider.ts"; |
| 5 | + |
| 6 | +function makeModel( |
| 7 | + overrides: Partial<CodexSchema.V2ModelListResponse__Model> = {}, |
| 8 | +): CodexSchema.V2ModelListResponse__Model { |
| 9 | + return { |
| 10 | + id: "gpt-5.4", |
| 11 | + model: "gpt-5.4", |
| 12 | + upgrade: null, |
| 13 | + upgradeInfo: null, |
| 14 | + availabilityNux: null, |
| 15 | + displayName: "gpt-5.4", |
| 16 | + description: "Latest frontier agentic coding model.", |
| 17 | + hidden: false, |
| 18 | + supportedReasoningEfforts: [ |
| 19 | + { |
| 20 | + reasoningEffort: "medium", |
| 21 | + description: "Balances speed and reasoning depth for everyday tasks", |
| 22 | + }, |
| 23 | + ], |
| 24 | + defaultReasoningEffort: "medium", |
| 25 | + inputModalities: ["text", "image"], |
| 26 | + supportsPersonality: true, |
| 27 | + isDefault: true, |
| 28 | + ...overrides, |
| 29 | + }; |
| 30 | +} |
| 31 | + |
| 32 | +describe("parseCodexModelListResponse", () => { |
| 33 | + it("preserves fast mode for GPT-5 models when app-server omits additionalSpeedTiers", () => { |
| 34 | + const [model] = parseCodexModelListResponse({ |
| 35 | + data: [makeModel()], |
| 36 | + nextCursor: null, |
| 37 | + }); |
| 38 | + |
| 39 | + expect(model).toBeDefined(); |
| 40 | + expect(model?.capabilities).toMatchObject({ |
| 41 | + supportsFastMode: true, |
| 42 | + }); |
| 43 | + }); |
| 44 | + |
| 45 | + it("honors an explicit empty additionalSpeedTiers list", () => { |
| 46 | + const [model] = parseCodexModelListResponse({ |
| 47 | + data: [ |
| 48 | + makeModel({ |
| 49 | + additionalSpeedTiers: [], |
| 50 | + }), |
| 51 | + ], |
| 52 | + nextCursor: null, |
| 53 | + }); |
| 54 | + |
| 55 | + expect(model).toBeDefined(); |
| 56 | + expect(model?.capabilities).toMatchObject({ |
| 57 | + supportsFastMode: false, |
| 58 | + }); |
| 59 | + }); |
| 60 | +}); |
0 commit comments