mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-11 05:11:49 +01:00
test(memory-jobs): stabilize async dispatch coverage
This commit is contained in:
1 parent
6dd968d030
commit
6fa917ce9b
4 files changed
+16
-5
No files matched your search
@@ -666,7 +666,10 @@ describeEmbeddedPostgres("heartbeat orphaned process recovery", () => {
|
||||
expect(blockedIssue?.executionRunId).toBeNull();
|
||||
expect(blockedIssue?.checkoutRunId).toBe(continuationRun?.id ?? null);
|
||||
|
||||
const comments = await db.select().from(issueComments).where(eq(issueComments.issueId, issueId));
|
||||
const comments = await waitForValue(async () => {
|
||||
const rows = await db.select().from(issueComments).where(eq(issueComments.issueId, issueId));
|
||||
return rows.length > 0 ? rows : null;
|
||||
});
|
||||
expect(comments).toHaveLength(1);
|
||||
expect(comments[0]?.body).toContain("retried continuation");
|
||||
});
|
||||
|
||||
@@ -36,10 +36,11 @@ async function waitForJobStatus(
|
||||
jobId: string,
|
||||
status: string,
|
||||
now: Date,
|
||||
predicate: (detail: Awaited<ReturnType<ReturnType<typeof memoryJobStore>["getDetail"]>>) => boolean = () => true,
|
||||
) {
|
||||
for (let attempt = 0; attempt < 20; attempt += 1) {
|
||||
const detail = await store.getDetail(companyId, jobId, { now });
|
||||
if (detail?.status === status) {
|
||||
if (detail?.status === status && predicate(detail)) {
|
||||
return detail;
|
||||
}
|
||||
await new Promise((resolve) => setTimeout(resolve, 10));
|
||||
@@ -149,7 +150,14 @@ describeEmbeddedPostgres("memory job dispatcher", () => {
|
||||
|
||||
await dispatcher.tick();
|
||||
|
||||
const runningDetail = await waitForJobStatus(store, companyId, queued.id, "running", currentTime);
|
||||
const runningDetail = await waitForJobStatus(
|
||||
store,
|
||||
companyId,
|
||||
queued.id,
|
||||
"running",
|
||||
currentTime,
|
||||
(detail) => detail?.providerJobId === "provider-job-async",
|
||||
);
|
||||
expect(runningDetail).toMatchObject({
|
||||
id: queued.id,
|
||||
status: "running",
|
||||
|
||||
@@ -156,7 +156,7 @@ describeEmbeddedPostgres("memory job routes", () => {
|
||||
);
|
||||
|
||||
expect(res.status).toBe(400);
|
||||
expect(res.body.error).toContain("effectiveState and status cannot be used together");
|
||||
expect(JSON.stringify(res.body.details)).toContain("effectiveState and status cannot be used together");
|
||||
});
|
||||
|
||||
it("returns job detail scoped to the requested company", async () => {
|
||||
|
||||
@@ -214,7 +214,7 @@ describe("startServer feedback export wiring", () => {
|
||||
storageService: { id: "storage-service" },
|
||||
serverPort: 3210,
|
||||
});
|
||||
});
|
||||
}, 10_000);
|
||||
});
|
||||
|
||||
describe("startServer PAPERCLIP_API_URL handling", () => {
|
||||
|
||||
Reference in new issue
Block a user