mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-06-27 11:22:03 +00:00
test(desktop): cover fallback timeout onboarding downgrade regression
This commit is contained in:
parent
66a0907c95
commit
7243111c57
1 changed files with 58 additions and 0 deletions
|
|
@ -63,6 +63,16 @@ function onboardingContext(requestGateway: OnboardingContext['requestGateway']):
|
|||
return { requestGateway }
|
||||
}
|
||||
|
||||
function fallbackTimeoutGateway(): OnboardingContext['requestGateway'] {
|
||||
return async method => {
|
||||
if (method === 'setup.status' || method === 'setup.runtime_check') {
|
||||
throw new Error(`request timed out: ${method}`)
|
||||
}
|
||||
|
||||
throw new Error(`unexpected gateway method: ${method}`)
|
||||
}
|
||||
}
|
||||
|
||||
describe('refreshOnboarding', () => {
|
||||
beforeEach(() => {
|
||||
window.localStorage.clear()
|
||||
|
|
@ -116,6 +126,54 @@ describe('refreshOnboarding', () => {
|
|||
expect($desktopOnboarding.get().providers?.map(p => p.id)).toEqual(['cached'])
|
||||
})
|
||||
|
||||
it('does not downgrade configured=true on fallback-only readiness failures', async () => {
|
||||
const api = vi.fn(async ({ path }: { path: string }) => {
|
||||
if (path === '/api/providers/oauth') {
|
||||
return { providers: [provider('fresh')] }
|
||||
}
|
||||
|
||||
throw new Error(`unexpected api path: ${path}`)
|
||||
})
|
||||
|
||||
installApiMock(api)
|
||||
$desktopOnboarding.set(
|
||||
baseState({
|
||||
configured: true,
|
||||
providers: [provider('cached')],
|
||||
reason: null,
|
||||
requested: false
|
||||
})
|
||||
)
|
||||
|
||||
const ready = await refreshOnboarding(onboardingContext(fallbackTimeoutGateway()))
|
||||
|
||||
expect(ready).toBe(false)
|
||||
expect(api).not.toHaveBeenCalled()
|
||||
expect($desktopOnboarding.get().configured).toBe(true)
|
||||
expect($desktopOnboarding.get().reason).toBeNull()
|
||||
expect(window.localStorage.getItem('hermes-desktop-onboarded-v1')).toBeNull()
|
||||
})
|
||||
|
||||
it('still surfaces onboarding when fallback failure happens before configured state', async () => {
|
||||
const api = vi.fn(async ({ path }: { path: string }) => {
|
||||
if (path === '/api/providers/oauth') {
|
||||
return { providers: [provider('fresh')] }
|
||||
}
|
||||
|
||||
throw new Error(`unexpected api path: ${path}`)
|
||||
})
|
||||
|
||||
installApiMock(api)
|
||||
$desktopOnboarding.set(baseState({ configured: false, providers: null, requested: true }))
|
||||
|
||||
const ready = await refreshOnboarding(onboardingContext(fallbackTimeoutGateway()))
|
||||
|
||||
expect(ready).toBe(false)
|
||||
expect(api).toHaveBeenCalledTimes(1)
|
||||
expect($desktopOnboarding.get().configured).toBe(false)
|
||||
expect($desktopOnboarding.get().reason).toContain('request timed out')
|
||||
})
|
||||
|
||||
it('deduplicates concurrent provider refresh calls', async () => {
|
||||
let resolveProviders!: (value: { providers: OAuthProvider[] }) => void
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue