Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

test(cli): wait for canary completion before checking backoff (#860)

Dee3e56169124de
diff --git a/cli/src/lib/selfUpdate.spec.ts b/cli/src/lib/selfUpdate.spec.ts
index 4b5ba9cf3..41d4503f2 100644
--- a/cli/src/lib/selfUpdate.spec.ts
+++ b/cli/src/lib/selfUpdate.spec.ts
@@ -695,6 +695,8 @@ describe('a build that fails on its own merits (e2e/updateHostile.e2e.ts)', () =
it.each([
['whose bytes do not match its manifest', (state: { cli: Buffer; named?: string }) => { state.named = sha(Buffer.from('other bytes')) }, 'does not match its manifest (sha256 mismatch'],
['that fails its canary', (state: { cli: Buffer; named?: string }) => { state.cli = Buffer.from('process.exit(3)\n') }, 'failed its canary (exit 3)'],
+ // Found by QA on a quiet machine: a canary can finish after the test's fixed 55 ms wait.
+ ['that fails its delayed canary', (state: { cli: Buffer; named?: string }) => { state.cli = Buffer.from('setTimeout(() => process.exit(3), 150)\n') }, 'failed its canary (exit 3)'],
['that says it is another version', (state: { cli: Buffer; named?: string }) => { state.cli = Buffer.from('console.log("9.9.8")\n') }, 'failed its canary (it says it is 9.9.8)'],
])('is not downloaded again at every check: a build %s waits two intervals, then four, eight, …', async (_, breakIt, why) => {
const state = { cli: Buffer.from('console.log("9.9.9")\n'), named: undefined as string | undefined, downloads: 0 }
@@ -711,6 +713,7 @@ describe('a build that fails on its own merits (e2e/updateHostile.e2e.ts)', () =
})
try {
await vi.waitFor(() => expect(state.downloads).toBe(1), { timeout: 5_000 })
+ await vi.waitFor(() => expect(errors).toEqual([expect.stringContaining(`[update] 9.9.9 ${why}`)]), { timeout: 5_000 })
await ticks(5)
expect(state.downloads).toBe(1)
expect(errors).toEqual([expect.stringContaining(`[update] 9.9.9 ${why}`)])