Open History to see the last commit
1import { describe, expect, it } from 'vitest'
2
3import { parseLovableModels, provider } from './lovable.ts'
4
5const row = (over: Record<string, unknown>) => ({
6 id: 'openai/gpt-5.5',
7 name: 'GPT-5.5',
8 created: 1_776_000_000,
9 released: 1_775_000_000,
10 deprecated: false,
11 context_window: 1_000_000,
12 max_tokens: 128_000,
13 knowledge: '2026-06',
14 modalities: { input: ['text', 'image'], output: ['text'] },
15 supported_surfaces: ['chat-completions', 'responses'],
16 pricing: { cost_currency: 'credits' },
17 ...over,
18})
19
20describe('lovable listing', () => {
21 it('reads the facts the listing states and binds the first routed surface', () => {
22 const [model] = parseLovableModels({ data: [row({})] })
23 expect(model).toMatchObject({
24 rawId: 'openai/gpt-5.5',
25 activity: 'chat',
26 schemaEndpointId: 'chat/completions',
27 contextWindow: 1_000_000,
28 maxOutput: 128_000,
29 knowledgeCutoff: '2026-06',
30 releasedAt: 1_775_000_000,
31 deprecated: false,
32 })
33 expect(model?.pricing).toBeUndefined()
34 })
35
36 it('leaves a messages-only or live-only model unbound', () => {
37 const models = parseLovableModels({
38 data: [
39 row({
40 id: 'anthropic/claude-opus-5',
41 supported_surfaces: ['messages'],
42 }),
43 row({ id: 'openai/gpt-live-1', supported_surfaces: ['live'] }),
44 row({ id: 'google/veo-3.1', supported_surfaces: ['videos'] }),
45 ],
46 })
47 expect(models.map((m) => [m.activity, m.schemaEndpointId])).toEqual([
48 ['chat', null],
49 ['audio', null],
50 ['video', 'videos'],
51 ])
52 })
53
54 it('refuses an unreadable payload or an unknown surface', () => {
55 expect(() => parseLovableModels({})).toThrow('no data array')
56 expect(() => parseLovableModels({ data: [{ name: 'x' }] })).toThrow('no id')
57 expect(() =>
58 parseLovableModels({ data: [row({ supported_surfaces: ['realtime'] })] }),
59 ).toThrow('unknown surface realtime')
60 const [decision] = parseLovableModels({
61 data: [
62 row({ id: 'typesafe/jev-1.13', supported_surfaces: ['systemone'] }),
63 ],
64 })
65 expect(decision).toMatchObject({ activity: null, schemaEndpointId: null })
66 const [unreleased] = parseLovableModels({ data: [row({ released: null })] })
67 expect(unreleased?.releasedAt).toBeNull()
68 })
69
70 it('states the maker from the id', () => {
71 expect(provider.upstreamModelIdentity?.('openai/gpt-5.5')).toMatchObject({
72 providerNamespace: 'openai',
73 rawId: 'gpt-5.5',
74 })
75 expect(provider.classify('/images/edits', {})).toBe('image')
76 })
77})