test(heartbeat): clean up workspace_operations + execution_workspaces before deleting companies

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 <noreply@paperclip.ing>
This commit is contained in:
Devin FoleyandPaperclip committed 2026-05-29 00:30:05 -07:00
1 parent 4fe20b0ae0
commit ffe69805f6
2 files changed
+8

No files matched your search

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