From ffe69805f6b79ce3ee5e2eeec6c698813c175107 Mon Sep 17 00:00:00 2001 From: Devin Foley Date: Fri, 29 May 2026 00:30:05 -0700 Subject: [PATCH] test(heartbeat): clean up workspace_operations + execution_workspaces before deleting companies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The PAPA-432 finalize fix writes workspace_operations rows during normal heartbeat execution. Both heartbeat-process-recovery and heartbeat-dependency-scheduling reuse a shared DB across tests and delete companies between cases, but neither cleared workspace_operations or execution_workspaces — the company_id FK then blocked teardown. Add both tables to the cleanup ordering (before companies). All other heartbeat suites either use tempDb.cleanup() or already clear these tables. Verified locally: pnpm exec vitest run \ src/__tests__/heartbeat-process-recovery.test.ts \ src/__tests__/heartbeat-dependency-scheduling.test.ts → 49/49 pass Co-Authored-By: Paperclip --- server/src/__tests__/heartbeat-dependency-scheduling.test.ts | 4 ++++ server/src/__tests__/heartbeat-process-recovery.test.ts | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/server/src/__tests__/heartbeat-dependency-scheduling.test.ts b/server/src/__tests__/heartbeat-dependency-scheduling.test.ts index 62b488dd280..12b70a45269 100644 --- a/server/src/__tests__/heartbeat-dependency-scheduling.test.ts +++ b/server/src/__tests__/heartbeat-dependency-scheduling.test.ts @@ -13,6 +13,7 @@ import { documents, environmentLeases, environments, + executionWorkspaces, heartbeatRunEvents, heartbeatRuns, issueComments, @@ -20,6 +21,7 @@ import { issueRelations, issueTreeHolds, issues, + workspaceOperations, } from "@paperclipai/db"; import { getEmbeddedPostgresTestSupport, @@ -142,6 +144,8 @@ describeEmbeddedPostgres("heartbeat dependency-aware queued run selection", () = await db.delete(agents); await db.delete(companySkills); await db.delete(environments); + await db.delete(workspaceOperations); + await db.delete(executionWorkspaces); await db.delete(companies); }); diff --git a/server/src/__tests__/heartbeat-process-recovery.test.ts b/server/src/__tests__/heartbeat-process-recovery.test.ts index 8930b073059..0f6fcaf75a4 100644 --- a/server/src/__tests__/heartbeat-process-recovery.test.ts +++ b/server/src/__tests__/heartbeat-process-recovery.test.ts @@ -16,6 +16,7 @@ import { documents, environmentLeases, environments, + executionWorkspaces, heartbeatRunEvents, heartbeatRuns, issueComments, @@ -26,6 +27,7 @@ import { issueTreeHolds, issueWorkProducts, issues, + workspaceOperations, } from "@paperclipai/db"; import { getEmbeddedPostgresTestSupport, @@ -368,6 +370,8 @@ describeEmbeddedPostgres("heartbeat orphaned process recovery", () => { } for (let attempt = 0; attempt < 5; attempt += 1) { await db.delete(companySkills); + await db.delete(workspaceOperations); + await db.delete(executionWorkspaces); try { await db.delete(companies); break;