Files
orca/src/shared/agent-session-availability.test.ts
T
Brennan Benson ff4a51c872 Show sign-in guidance for all native chat agents (#26544)
* Recognize native chat sign-in failures across structured agents

* Fix authentication failures and chat sign-in guidance

* Preserve sign-in diagnostics and command retry context

* fix(native-chat): keep visible sign-in guidance and localize startup rows

* fix(native-chat): separate auth diagnostics from retry guidance

* test(native-chat): align startup guidance expectations

* fix(native-chat): start a new agent for the send after it reports not signed in

* fix(native-chat): scope the signed-out check by fence and read without a snapshot

* fix(native-chat): keep a signed-out agent while it owes work, and read only its own rows

* fix(native-chat): keep a signed-out agent that may owe a wake-up turn, and skip the check during a Stop
2026-10-08 14:38:47 -07:00

46 lines
1.9 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { readAgentSessionUnavailable, agentSessionSignInCopyId } from './agent-session-availability'
import { agentSessionFailureSentence } from './agent-session-failure-words'
import { AGENT_SESSION_FAILURE_COPY } from './agent-session-failure-copy'
describe("the host's sign-in and CLI verdict", () => {
it.each([undefined, null, {}, { reason: 'future' }, { state: 'notSignedIn' }, 'notSignedIn'])(
'reads an unknown or malformed verdict as unknown %j',
(value) => {
expect(readAgentSessionUnavailable(value)).toBeNull()
}
)
it.each(['managed', 'system'] as const)('keeps %s account context', (account) => {
expect(readAgentSessionUnavailable({ reason: 'notSignedIn', account })).toEqual({
reason: 'notSignedIn',
account
})
})
it('drops account context this build does not know', () => {
expect(readAgentSessionUnavailable({ reason: 'notSignedIn', account: 'future' })).toEqual({
reason: 'notSignedIn'
})
expect(readAgentSessionUnavailable({ reason: 'cliMissing', account: 'system' })).toEqual({
reason: 'cliMissing'
})
})
it.each([
['claude', 'system', 'claudeSystemNotSignedIn'],
['claude', 'managed', 'claudeManagedNotSignedIn'],
['claude', undefined, 'claudeSystemNotSignedIn'],
['codex', 'system', 'codexSystemNotSignedIn'],
['codex', 'managed', 'codexManagedNotSignedIn'],
['codex', undefined, 'codexSystemNotSignedIn']
] as const)('uses the same %s %s fix after sending', (provider, account, key) => {
expect(agentSessionSignInCopyId(provider, account)).toBe(key)
expect(
agentSessionFailureSentence({ kind: 'notSignedIn', account }, 'rejection', { provider })
).toBe(
AGENT_SESSION_FAILURE_COPY[key].replace(
'{{loginCommand}}',
provider === 'claude' ? 'claude auth login' : 'codex login'
)
)
})
})