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.
This commit is contained in:
Austin Pickett
2026-09-26 20:48:51 -04:00
parent 895ef9b839
commit 3e68e6ba1a
2 changed files with 8 additions and 6 deletions

View File

@@ -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)

View File

@@ -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())