Files
orca/src/shared/structured-agent-session-option-codec.spec.ts
T
OrcaWinandOrcaWin 70c4c55db9 test: remove duplicate coverage and strengthen boundary assertions (#33047)
* test: strengthen launch, subject identity, and release witnesses

* test: strengthen approval paths and prompt answer boundaries

* test: strengthen conversation names and mobile log persistence

* refactor: group background task stop contract with stop operations

* test: strengthen question, title, and release validation

* test: distinguish row text and generated dispatch titles

* test: verify mobile revival events and retry exclusivity

* test: reject incomplete child row output assertions

* test: verify copied modules and option selection contracts

* test: verify mobile host state and status retry boundaries

* test: observe connector refusals and real diagnostic delivery

* test: consolidate platform memory coverage and verify bounded work

* test: allow cached legacy failure reads within work bounds

* test: verify packaging boundaries with independent fixtures

---------

Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
2026-10-24 00:13:25 -07:00

37 lines
1.6 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import {
decodeStructuredAgentSessionOptionValue,
encodeStructuredAgentSessionOptionValue
} from './structured-agent-session-option-codec'
describe('structured agent session option codec', () => {
it('encodes and decodes explicit Fast mode booleans', () => {
expect(encodeStructuredAgentSessionOptionValue('fastMode', true)).toBe('true')
expect(encodeStructuredAgentSessionOptionValue('fastMode', false)).toBe('false')
expect(decodeStructuredAgentSessionOptionValue('fastMode', 'true')).toBe(true)
expect(decodeStructuredAgentSessionOptionValue('fastMode', 'false')).toBe(false)
})
it('rejects string booleans on the UI side and non-canonical strings on the wire side', () => {
for (const value of ['true', 'false']) {
expect(encodeStructuredAgentSessionOptionValue('fastMode', value)).toBeNull()
}
for (const value of ['TRUE', '1', 'False', ' true', 'false ', '', '0']) {
expect(decodeStructuredAgentSessionOptionValue('fastMode', value)).toBeNull()
}
})
it('preserves string options in both directions and rejects boolean values', () => {
for (const [id, value] of [
['model', 'gpt-example'],
['effort', 'high'],
['serviceTier', 'flex']
] as const) {
expect(encodeStructuredAgentSessionOptionValue(id, value)).toBe(value)
expect(decodeStructuredAgentSessionOptionValue(id, value)).toBe(value)
expect(encodeStructuredAgentSessionOptionValue(id, true)).toBeNull()
expect(encodeStructuredAgentSessionOptionValue(id, false)).toBeNull()
}
})
})