test(desktop): keep the two invariant cases for the onboarding model pick

Trim the salvaged suite to the two behaviours the fix guarantees: a
cross-provider pick persists against (and re-labels the card with) the
provider that serves the model, and a failed persist reverts model,
provider and label together. The same-provider and model-only call
shapes are exercised by the existing flow and add no invariant of their
own.
This commit is contained in:
teknium1
2026-09-19 00:02:22 -07:00
committed by Teknium
parent c25892c8b8
commit b7ec75fc20

View File

@@ -929,60 +929,6 @@ describe('setOnboardingModel', () => {
}
})
it('keeps the sign-in provider when the picked model belongs to it', async () => {
const calls: { body?: unknown; path: string }[] = []
const api = vi.fn(async ({ body, path }: { body?: unknown; path: string }) => {
calls.push({ body, path })
if (path === '/api/model/set') {
return { ok: true, provider: 'openai', model: 'gpt-5.2' }
}
throw new Error(`unexpected api path: ${path}`)
})
installApiMock(api)
$desktopOnboarding.set(confirmingModelState())
await setOnboardingModel('gpt-5.2', 'openai', 'OpenAI OAuth (ChatGPT)')
const assign = calls.find(c => c.path === '/api/model/set')
expect(assign?.body).toMatchObject({ provider: 'openai', model: 'gpt-5.2' })
const flow = $desktopOnboarding.get().flow
expect(flow.status).toBe('confirming_model')
if (flow.status === 'confirming_model') {
expect(flow.providerSlug).toBe('openai')
expect(flow.label).toBe('OpenAI OAuth (ChatGPT)')
}
})
it('falls back to the flow provider when the caller passes no provider', async () => {
const calls: { body?: unknown; path: string }[] = []
const api = vi.fn(async ({ body, path }: { body?: unknown; path: string }) => {
calls.push({ body, path })
if (path === '/api/model/set') {
return { ok: true, provider: 'openai', model: 'gpt-5.2' }
}
throw new Error(`unexpected api path: ${path}`)
})
installApiMock(api)
$desktopOnboarding.set(confirmingModelState())
// Legacy call shape (model only) must keep persisting under the sign-in
// provider rather than writing an empty provider.
await setOnboardingModel('gpt-5.2')
const assign = calls.find(c => c.path === '/api/model/set')
expect(assign?.body).toMatchObject({ provider: 'openai', model: 'gpt-5.2' })
})
it('reverts the model, provider and label when persistence fails', async () => {
installApiMock(async () => {
throw new Error('backend down')