From 0304d0ce4ee6e36cd696544a37f8e1acf193d4da Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 24 Apr 2026 05:55:07 +0100 Subject: [PATCH] test: stabilize gateway test helpers --- .../server-methods/chat.directive-tags.test.ts | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/gateway/server-methods/chat.directive-tags.test.ts b/src/gateway/server-methods/chat.directive-tags.test.ts index 425b0f35be6..5d4412318c7 100644 --- a/src/gateway/server-methods/chat.directive-tags.test.ts +++ b/src/gateway/server-methods/chat.directive-tags.test.ts @@ -234,23 +234,7 @@ vi.mock("../../media/store.js", async () => { const { chatHandlers } = await import("./chat.js"); async function waitForAssertion(assertion: () => void, timeoutMs = 1000, stepMs = 2) { - vi.useFakeTimers(); - try { - let lastError: unknown; - for (let elapsed = 0; elapsed <= timeoutMs; elapsed += stepMs) { - try { - assertion(); - return; - } catch (error) { - lastError = error; - } - await Promise.resolve(); - await vi.advanceTimersByTimeAsync(stepMs); - } - throw lastError ?? new Error("assertion did not pass in time"); - } finally { - vi.useRealTimers(); - } + await vi.waitFor(assertion, { interval: stepMs, timeout: timeoutMs }); } function createTranscriptFixture(prefix: string) {