From 2425c7a30dfe6752d2d3980dab893bb20b69cb55 Mon Sep 17 00:00:00 2001 From: 404oops Date: Sat, 31 Oct 2026 17:08:17 +0100 Subject: [PATCH] test(puter-js): fail credential lookups until the relay hits one The reconnect test made the next credential lookup fail once, but the SDK's own socket.io connection could take that failure before the relay's reconnect attempt did, so the relay never saw a failed lookup and the test failed in CI. Lookups now fail until the relay has refused an attempt on one, then recover. Co-Authored-By: Claude Opus 5.5 --- src/puter-js/tests/api/realtime/convo.test.ts | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/puter-js/tests/api/realtime/convo.test.ts b/src/puter-js/tests/api/realtime/convo.test.ts index 6c0a84ed8..6f332d552 100644 --- a/src/puter-js/tests/api/realtime/convo.test.ts +++ b/src/puter-js/tests/api/realtime/convo.test.ts @@ -433,18 +433,26 @@ describe('convo built SDK and browser media', () => { const warn = vi.spyOn(console, 'warn'); try { await conversation.connect(); - auth.mockRejectedValueOnce(new Error('auth store unavailable')); + // Every lookup fails, the SDK's own socket.io connection included, + // until the relay has refused a reconnect attempt on one. + auth.mockRejectedValue(new Error('auth store unavailable')); for (const socket of proxied) socket.destroy(); + await vi.waitFor( + () => + expect(warn).toHaveBeenCalledWith( + '[realtime] credential lookup failed', + expect.objectContaining({ + message: 'auth store unavailable', + }), + ), + { timeout: 10_000 }, + ); + auth.mockRestore(); await log.until(() => log.events.some( (event) => event.type === 'ready' && event.reconnected, ), ); - // The first attempt failed its lookup, a later one went through. - expect(warn).toHaveBeenCalledWith( - '[realtime] credential lookup failed', - expect.objectContaining({ message: 'auth store unavailable' }), - ); expect(log.count('reconnecting')).toBe(1); conversation.sendText('Still there?'); await log.until(() => log.count('turn.done') === 1);