From 833f5acda1a22ad47364b89a6a7d34e37155c746 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 23 Jan 2026 06:37:04 +0000 Subject: [PATCH] test: stabilize cron + async search timings --- src/gateway/server.cron.test.ts | 9 +++++++-- src/memory/manager.async-search.test.ts | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/gateway/server.cron.test.ts b/src/gateway/server.cron.test.ts index 1a8f1eb9d..1235370a6 100644 --- a/src/gateway/server.cron.test.ts +++ b/src/gateway/server.cron.test.ts @@ -36,7 +36,11 @@ async function rmTempDir(dir: string) { await fs.rm(dir, { recursive: true, force: true }); } -async function waitForCronFinished(ws: { send: (data: string) => void }, jobId: string) { +async function waitForCronFinished( + ws: { send: (data: string) => void }, + jobId: string, + timeoutMs = 20_000, +) { await onceMessage( ws as never, (o) => @@ -44,7 +48,7 @@ async function waitForCronFinished(ws: { send: (data: string) => void }, jobId: o.event === "cron" && o.payload?.action === "finished" && o.payload?.jobId === jobId, - 20_000, + timeoutMs, ); } @@ -345,6 +349,7 @@ describe("gateway server cron", () => { const autoJobId = typeof autoJobIdValue === "string" ? autoJobIdValue : ""; expect(autoJobId.length > 0).toBe(true); + await waitForCronFinished(ws, autoJobId); await waitForCronFinished(ws, autoJobId); await waitForNonEmptyFile(path.join(dir, "cron", "runs", `${autoJobId}.jsonl`)); diff --git a/src/memory/manager.async-search.test.ts b/src/memory/manager.async-search.test.ts index 1efe714e6..1db9359ff 100644 --- a/src/memory/manager.async-search.test.ts +++ b/src/memory/manager.async-search.test.ts @@ -75,7 +75,7 @@ describe("memory search async sync", () => { const resolved = await Promise.race([ manager.search("hello").then(() => true), - new Promise((resolve) => setTimeout(() => resolve(false), 50)), + new Promise((resolve) => setTimeout(() => resolve(false), 1000)), ]); expect(resolved).toBe(true); });