test: stabilize cron + async search timings

This commit is contained in:
Peter Steinberger
2026-01-23 06:37:04 +00:00
parent d03c404cb4
commit 833f5acda1
2 changed files with 8 additions and 3 deletions

View File

@@ -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`));

View File

@@ -75,7 +75,7 @@ describe("memory search async sync", () => {
const resolved = await Promise.race([
manager.search("hello").then(() => true),
new Promise<boolean>((resolve) => setTimeout(() => resolve(false), 50)),
new Promise<boolean>((resolve) => setTimeout(() => resolve(false), 1000)),
]);
expect(resolved).toBe(true);
});