Skip to content

The agent that grows with you

test(desktop): advance fake timers by BACKEND_BOOT_WAIT_TIMEOUT_MS, not a hardcoded 45s

Austin Pickett3e68e6ba1a96
diff --git a/apps/desktop/src/app/gateway/hooks/use-gateway-boot.test.tsx b/apps/desktop/src/app/gateway/hooks/use-gateway-boot.test.tsx
index 2e1d64c3318..f1498665b6a 100644
--- a/apps/desktop/src/app/gateway/hooks/use-gateway-boot.test.tsx
+++ b/apps/desktop/src/app/gateway/hooks/use-gateway-boot.test.tsx
@@ -3,6 +3,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import type { DesktopBootstrapState, DesktopConnectionsRegistry } from '@/global'
import { createClientSessionState } from '@/lib/chat-runtime'
+import { BACKEND_BOOT_WAIT_TIMEOUT_MS } from '@/lib/with-timeout'
import { $desktopBoot } from '@/store/boot'
import {
$connectionsRegistry,
@@ -1781,11 +1782,11 @@ describe('useGatewayBoot remote reconnect loop (real hook, fake socket)', () =>
expect($desktopBoot.get().error).toBeNull()
- // Advance past the shared backend-boot budget (45s) — the
+ // Advance past the shared backend-boot budget — the
// stalled await must reject on its own so boot()'s catch runs instead of
// waiting indefinitely on main.
await act(async () => {
- await vi.advanceTimersByTimeAsync(45_000)
+ await vi.advanceTimersByTimeAsync(BACKEND_BOOT_WAIT_TIMEOUT_MS)
})
expect($desktopBoot.get().error).toBeTruthy()
@@ -1819,11 +1820,11 @@ describe('useGatewayBoot remote reconnect loop (real hook, fake socket)', () =>
expect($gatewaySwitching.get()).toBe(true)
- // Advance past the shared backend-boot budget (45s) — the
+ // Advance past the shared backend-boot budget — the
// stalled await must reject so the `finally` clears $gatewaySwitching
// instead of latching the switch UI frozen forever.
await act(async () => {
- await vi.advanceTimersByTimeAsync(45_000)
+ await vi.advanceTimersByTimeAsync(BACKEND_BOOT_WAIT_TIMEOUT_MS)
})
expect($gatewaySwitching.get()).toBe(false)
diff --git a/apps/desktop/src/store/connections.test.ts b/apps/desktop/src/store/connections.test.ts
index d5c3be5e96e..8010b3fa053 100644
--- a/apps/desktop/src/store/connections.test.ts
+++ b/apps/desktop/src/store/connections.test.ts
@@ -3,6 +3,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
import { setApiRequestConnection, setApiRequestProfile } from '@/api/client'
import type { DesktopConnectionsRegistry } from '@/global'
+import { BACKEND_BOOT_WAIT_TIMEOUT_MS } from '@/lib/with-timeout'
import { deferred } from '../test/deferred'
@@ -898,7 +899,7 @@ describe('selectConnection', () => {
expect($showAllProfiles.get()).toBe(true)
})
- it('boot restore proceeds after the descriptor wait deadline (bounded wait)', async () => {
+ it('boot restore proceeds after the descriptor wait deadline (bounded wait)', { timeout: 30_000 }, async () => {
// A primary that never publishes (spawn failure, dead SSH target) must
// not strand the registry restore forever: after the deadline the restore
// runs exactly as it did before the wait existed.
@@ -913,7 +914,7 @@ describe('selectConnection', () => {
expect(ensureGatewayAgent).not.toHaveBeenCalled()
// Descriptor never arrives; deadline elapses.
- await vi.advanceTimersByTimeAsync(60_000)
+ await vi.advanceTimersByTimeAsync(BACKEND_BOOT_WAIT_TIMEOUT_MS + 15_000)
await restoring
expect(ensureGatewayAgent).toHaveBeenCalledWith('homelab', 'default', expect.anything())