mirror of
https://github.com/stablyai/orca.git
synced 2026-11-01 17:47:40 +00:00
Agent ids persist in automations and settings, so they outlive the build that wrote them. Direct config lookups fail with unclear "Cannot read properties of undefined" when an id becomes unknown. This function validates the agent and throws a clear error message naming the unknown id.
22 lines
969 B
TypeScript
22 lines
969 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import type { TuiAgent } from './tui-agent'
|
|
import { requireTuiAgentConfig } from './require-tui-agent-config'
|
|
|
|
describe('requireTuiAgentConfig', () => {
|
|
it('returns the config for a known agent', () => {
|
|
expect(requireTuiAgentConfig('codex').preflightTrust).toBe('codex')
|
|
})
|
|
|
|
it('names the unknown id instead of throwing a property-of-undefined error', () => {
|
|
// A custom-agent id persisted by a branch build, read back by one without the feature.
|
|
const stale = 'custom-agent:codex:b2e1ff6f-8932-413a-9133-edffa44e0ee9' as TuiAgent
|
|
expect(() => requireTuiAgentConfig(stale)).toThrow(
|
|
`Unknown agent "${stale}". This version of Orca has no such agent — pick a different agent and try again.`
|
|
)
|
|
})
|
|
|
|
it('rejects a prototype key that Object.hasOwn keeps off the config', () => {
|
|
expect(() => requireTuiAgentConfig('toString' as TuiAgent)).toThrow(/Unknown agent "toString"/)
|
|
})
|
|
})
|