Skip to content

Commit 05daedd

Browse files
committed
test(ui): stabilize connected send retry timing
CI run 32125741781 exposed the wall-clock race in the connected retry test.
1 parent 7ad70aa commit 05daedd

1 file changed

Lines changed: 16 additions & 6 deletions

File tree

‎ui/src/pages/chat/chat-send.test.ts‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6665,13 +6665,23 @@ describe("handleSendChat", () => {
66656665
chatMessage: "retry without disconnecting",
66666666
});
66676667

6668-
await handleSendChat(host);
6668+
vi.useFakeTimers();
6669+
try {
6670+
await handleSendChat(host);
66696671

6670-
expect(host.connected).toBe(true);
6671-
expect(host.chatQueue[0]).toMatchObject({ sendAttempts: 0, sendState: "waiting-reconnect" });
6672-
await waitForFast(() => expect(sendAttempts).toBe(2));
6673-
expect(sendRunIds[1]).toBe(sendRunIds[0]);
6674-
await waitForFast(() => expect(listStoredChatOutboxes(host)).toStrictEqual([]));
6672+
expect(host.connected).toBe(true);
6673+
expect(host.chatQueue[0]).toMatchObject({
6674+
sendAttempts: 0,
6675+
sendState: "waiting-reconnect",
6676+
});
6677+
expect(sendAttempts).toBe(1);
6678+
await vi.advanceTimersByTimeAsync(100);
6679+
expect(sendAttempts).toBe(2);
6680+
expect(sendRunIds[1]).toBe(sendRunIds[0]);
6681+
expect(listStoredChatOutboxes(host)).toStrictEqual([]);
6682+
} finally {
6683+
vi.useRealTimers();
6684+
}
66756685
});
66766686

66776687
it("retries reconnect history after a retryable response without a socket close", async () => {

0 commit comments

Comments
 (0)