From 57cbc9a506823a10b37cc6e8c715d1e50d0d6b4e Mon Sep 17 00:00:00 2001 From: Matt Ciaccio Date: Tue, 5 May 2026 02:45:45 +0200 Subject: [PATCH] fix(tests): cascade interest_berths in global teardown The Phase 2b refactor (commit 6e3d910) added a junction table whose berth_id has onDelete: 'restrict'. The vitest global teardown deletes test-port berths but never explicitly clears interest_berths first, so any test leaking junction rows (e.g. via the new createInterest write path) leaves berths un-deletable and ports stranded. Adds DELETE FROM interest_berths WHERE berth_id IN (test berths) to the WITH-chain so cascading teardown completes cleanly. Co-Authored-By: Claude Opus 4.7 (1M context) --- tests/global-setup.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/global-setup.ts b/tests/global-setup.ts index fb76747..a80d97f 100644 --- a/tests/global-setup.ts +++ b/tests/global-setup.ts @@ -47,6 +47,7 @@ export async function teardown() { , del_ft AS (DELETE FROM form_templates WHERE port_id IN (SELECT id FROM doomed) RETURNING 1) , del_gr AS (DELETE FROM generated_reports WHERE port_id IN (SELECT id FROM doomed) RETURNING 1) , del_int AS (DELETE FROM interests WHERE port_id IN (SELECT id FROM doomed) RETURNING 1) + , del_ib AS (DELETE FROM interest_berths WHERE berth_id IN (SELECT id FROM berths WHERE port_id IN (SELECT id FROM doomed)) RETURNING 1) , del_inv AS (DELETE FROM invoices WHERE port_id IN (SELECT id FROM doomed) RETURNING 1) , del_notif AS (DELETE FROM notifications WHERE port_id IN (SELECT id FROM doomed) RETURNING 1) , del_pro AS (DELETE FROM port_role_overrides WHERE port_id IN (SELECT id FROM doomed) RETURNING 1)