diff --git a/apps/gateway/src/__tests__/cross-user-isolation.test.ts b/apps/gateway/src/__tests__/cross-user-isolation.test.ts index 439b750e..781aba79 100644 --- a/apps/gateway/src/__tests__/cross-user-isolation.test.ts +++ b/apps/gateway/src/__tests__/cross-user-isolation.test.ts @@ -190,7 +190,13 @@ beforeEach((ctx) => { }); afterAll(async () => { - if (!handle) return; + // Cleanup only when the fixture actually installed rows. `handle` is set + // before the first query (createDb connects lazily), so on an unreachable + // database `handle` is truthy while nothing was inserted — cleanup must + // honor `dbAvailable` or the skip path fails the file with ECONNREFUSED in + // afterAll (caught live by the publish pipeline's no-DATABASE_URL verify + // step, pipeline 2486). + if (!handle || !dbAvailable) return; const db = handle.db; // Delete in dependency order (FK constraints)