Files
hapi/web/src/lib/cursorCliSkusMerge.test.ts
T
ad038bbf2e fix(cursor): merge SKU catalog under ACP lock and refcount agent guard (#835)
Fixes incomplete cliModelSkus while agent acp holds the CLI lock (#831) and
replace single-pid ACP lock with cross-process refcount (#832). Web picker
merges machine/session catalogs and waits for SKU readiness before showing
variant labels.

Fixes #831
Fixes #832

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-08 13:30:43 +08:00

33 lines
1.2 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { mergeCursorCliModelSkus } from '@/lib/cursorPickerState'
describe('mergeCursorCliModelSkus', () => {
it('prefers the richer source and unions ids without duplicates', () => {
const partial = [
{ modelId: 'gpt-5.5-high-fast', name: 'GPT-5.5 High Fast' },
{ modelId: 'gpt-5.5-low', name: 'GPT-5.5 1M Low' }
]
const full = [
...partial,
{ modelId: 'gpt-5.5-medium', name: 'GPT-5.5 1M' },
{ modelId: 'gpt-5.5-high', name: 'GPT-5.5 High' }
]
expect(mergeCursorCliModelSkus(partial, full).map((row) => row.modelId)).toEqual([
'gpt-5.5-high-fast',
'gpt-5.5-low',
'gpt-5.5-medium',
'gpt-5.5-high'
])
})
it('prefers the richer source name for duplicate model ids', () => {
const machine = [{ modelId: 'gpt-5.5-medium', name: 'From Machine' }]
const session = [{ modelId: 'gpt-5.5-medium', name: 'From Session' }]
expect(mergeCursorCliModelSkus(machine, session)).toEqual([
{ modelId: 'gpt-5.5-medium', name: 'From Machine' }
])
})
})