test(web): cover sidebar state replay

This commit is contained in:
Yuan Li
2026-09-30 23:31:45 +08:00
committed by Austin Pickett
parent d3c3a1ea2d
commit 8bd23cddee

View File

@@ -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(<ChatSidebar channel="chat-1" />);
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");