test: stabilize cron + async search timings
This commit is contained in:
@@ -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`));
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user