From 08e18867fde31708410c39b7f648c550cce05850 Mon Sep 17 00:00:00 2001 From: diegosouzapw Date: Wed, 6 May 2026 03:32:04 -0300 Subject: [PATCH] test: stabilize cooldown abort coverage case --- tests/unit/chat-cooldown-aware-retry.test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/unit/chat-cooldown-aware-retry.test.ts b/tests/unit/chat-cooldown-aware-retry.test.ts index 4eda86f660..cf8f1e2d96 100644 --- a/tests/unit/chat-cooldown-aware-retry.test.ts +++ b/tests/unit/chat-cooldown-aware-retry.test.ts @@ -284,13 +284,13 @@ test("handleChat returns stream readiness timeout without entering cooldown-awar test("handleChat aborts the pending cooldown wait when the client disconnects", async () => { await seedConnection("openai", { apiKey: "sk-openai-cooldown-abort", - rateLimitedUntil: new Date(Date.now() + 250).toISOString(), + rateLimitedUntil: new Date(Date.now() + 5_000).toISOString(), lastError: "abort retry wait", errorCode: 429, }); await settingsDb.updateSettings({ requestRetry: 1, - maxRetryIntervalSec: 1, + maxRetryIntervalSec: 10, }); let fetchCalls = 0; @@ -302,6 +302,7 @@ test("handleChat aborts the pending cooldown wait when the client disconnects", const controller = new AbortController(); setTimeout(() => controller.abort(), 40); + const startedAt = Date.now(); const response = await handleChat( buildRequestWithSignal( { @@ -312,9 +313,11 @@ test("handleChat aborts the pending cooldown wait when the client disconnects", controller.signal ) ); + const elapsedMs = Date.now() - startedAt; const body = (await response.json()) as any; assert.equal(fetchCalls, 0); + assert.ok(elapsedMs < 1_000, `should abort cooldown wait promptly, got ${elapsedMs}ms`); assert.equal(response.status, 499); assert.equal(body.error.message, "Request aborted"); });