Cover websocket disconnect rejection in adapter tests

Co-authored-by: Theo Browne <[email protected]>
This commit is contained in:
Cursor AgentandTheo Browne committed 2026-02-09 23:13:53 +00:00
1 parent 2cb6ed9615
commit b5a830b328
1 file changed
+13
+13
View File
@@ -177,4 +177,17 @@ describe("wsNativeApi", () => {
await expect(request).rejects.toThrow("boom");
});
it("rejects pending requests when websocket disconnects", async () => {
setWindowSearch("?ws=ws%3A%2F%2F127.0.0.1%3A4403");
const { getOrCreateWsNativeApi } = await import("./wsNativeApi");
const api = getOrCreateWsNativeApi();
const request = api.todos.list();
const socket = MockWebSocket.instances[0];
await waitForCondition(() => (socket?.sentMessages.length ?? 0) > 0);
socket?.close();
await expect(request).rejects.toThrow("websocket disconnected");
});
});