Skip to content

The agent that grows with you

test: flush the prune-lease dial by condition, not by hop count

Teknium2c495acb83a8
diff --git a/apps/desktop/src/store/gateway-activation-prune-lease.test.ts b/apps/desktop/src/store/gateway-activation-prune-lease.test.ts
index 4142ac80f40..d2fc190d8b6 100644
--- a/apps/desktop/src/store/gateway-activation-prune-lease.test.ts
+++ b/apps/desktop/src/store/gateway-activation-prune-lease.test.ts
@@ -94,6 +94,16 @@ afterEach(() => {
delete (window as unknown as { hermesDesktop?: unknown }).hermesDesktop
})
+
+// Flush microtasks until the dial registers its secondary (or bail). The dial
+// path's hop count is an implementation detail — #95343's withTimeout wrapper
+// added an await hop and broke the previous exactly-two-Promise.resolve flush.
+async function flushUntilSecondaryRegistered(max = 20): Promise<void> {
+ for (let i = 0; i < max && secondaryGateways.length === 0; i++) {
+ await Promise.resolve()
+ }
+}
+
describe('activation lease vs. the live-work pruner (#89622)', () => {
it('a prune during the switch dial does not dispose the target and the switch lands', async () => {
let releaseConnect: () => void = () => undefined
@@ -103,8 +113,7 @@ describe('activation lease vs. the live-work pruner (#89622)', () => {
const switching = ensureGatewayForProfile('bot')
// Let the dial start (createSecondary + connect() now pending on the gate).
- await Promise.resolve()
- await Promise.resolve()
+ await flushUntilSecondaryRegistered()
expect(secondaryGateways).toHaveLength(1)
// The exact recompute that killed the switch: no live sessions, target not
@@ -159,8 +168,7 @@ describe('activation lease vs. the live-work pruner (#89622)', () => {
// Dial starts and never settles (wedged bridge call).
void ensureGatewayForProfile('bot')
- await Promise.resolve()
- await Promise.resolve()
+ await flushUntilSecondaryRegistered()
expect(secondaryGateways).toHaveLength(1)
// Inside the lease window: spared.