hermes-agent/apps/desktop/electron/update-gate-cancellation.test.ts
teknium1 dbf6ba142b test(desktop): give the cancellation gate fixture the hand-off dep
The previous commit widened UpdateGateDeps with isHandoffActive; this
fixture predates it and would fail the tsc pass in check:lint.
2026-09-20 11:26:29 -07:00

42 lines
913 B
TypeScript

import assert from 'node:assert/strict'
import { test } from 'vitest'
import { waitForUpdateClearance } from './update-gate'
test('quit interrupts an update-gated wait instead of waiting for the next poll', async () => {
const controller = new AbortController()
let slept = false
const waiting = waitForUpdateClearance(
{ hasLiveMarker: () => true, isUpdateInFlight: () => false, isHandoffActive: () => false },
{
signal: controller.signal,
pollMs: 1000,
timeoutMs: 120000,
sleep: () => {
slept = true
return new Promise(() => {})
}
}
)
let outcome: unknown
void waiting.then(result => {
outcome = result
})
for (let i = 0; i < 10; i++) {
await Promise.resolve()
}
assert.equal(slept, true)
controller.abort()
for (let i = 0; i < 20; i++) {
await Promise.resolve()
}
assert.equal(outcome, 'cancelled')
})