From 3e68e6ba1a96c2272b1f3796d3510b0fea142b2e Mon Sep 17 00:00:00 2001 From: Austin Pickett Date: Sat, 26 Sep 2026 20:48:51 -0400 Subject: [PATCH] test(desktop): advance fake timers by BACKEND_BOOT_WAIT_TIMEOUT_MS, not a hardcoded 45s The boot-budget tests hardcoded the old 45s (and a 60s cushion) budget, so raising BACKEND_BOOT_WAIT_TIMEOUT_MS to 180s made them time out or assert before the deadline elapsed. Drive them from the constant so the next budget change moves both together. --- .../src/app/gateway/hooks/use-gateway-boot.test.tsx | 9 +++++---- apps/desktop/src/store/connections.test.ts | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) 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 2e1d64c331..f1498665b6 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 d5c3be5e96..8010b3fa05 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())