From 8bd23cddeebbd64ea062236cccd70ec9812d8722 Mon Sep 17 00:00:00 2001 From: Yuan Li Date: Wed, 30 Sep 2026 23:31:45 +0800 Subject: [PATCH] test(web): cover sidebar state replay --- web/src/components/ChatSidebar.test.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/web/src/components/ChatSidebar.test.tsx b/web/src/components/ChatSidebar.test.tsx index bd313e4f31..83b81eb544 100644 --- a/web/src/components/ChatSidebar.test.tsx +++ b/web/src/components/ChatSidebar.test.tsx @@ -184,6 +184,22 @@ describe('ChatSidebar event socket', () => { expect(reloadMocks.maybeReloadForLoopbackWsAuthFailure).toHaveBeenCalledWith(4401) }) + it("ignores the synchronous sidecar state replay", async () => { + const { ChatSidebar } = await import("./ChatSidebar"); + + await render(); + await vi.waitFor(() => expect(gatewayMocks.onState).toHaveBeenCalled()); + + const redialHandler = gatewayMocks.onState.mock.calls[1][0] as (s: string) => void; + // The mock invokes the initial replay synchronously during subscription. + // A later closed transition must still schedule a retry. + redialHandler("closed"); + await vi.waitFor( + () => expect(gatewayMocks.connect).toHaveBeenCalledTimes(2), + { timeout: 3000 }, + ); + }); + it("auto-redials the JSON-RPC sidecar after a transient close (#95951)", async () => { const { ChatSidebar } = await import("./ChatSidebar");