test(infra): vitest globalSetup teardown purges test-port-* leaks
Integration tests use makePort() which writes ports with slug 'test-port-{rand}'
and never cleans up. Result: 17,564 leaked rows in dev that slowed every page
load fetching the port-switcher list (and was contributing to smoke flakes).
Adds tests/global-setup.ts with a teardown() that DELETEs every 'test-port-%'
row plus its dependent rows across 30+ tables in one CTE. Wires it into
vitest.config.ts via globalSetup. Adds closeDb() helper so the teardown can
end the postgres-js pool cleanly (kills the 'Tests closed but Vite server
won't exit' warning).
Also lands docs/superpowers/specs/2026-04-28-country-phone-timezone-design.md
— full-scope agenda for the country dropdown / E.164 phone input /
country-driven timezone autofill work, ~7 dev days across 10 PRs. Per
user request: 'let's do this full-fledged if we're gonna do it'.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -17,4 +17,10 @@ export const db = drizzle(queryClient, {
|
||||
logger: process.env.NODE_ENV === 'development',
|
||||
});
|
||||
|
||||
/** Close the underlying connection pool. Used by the vitest teardown so
|
||||
* the parent process can exit cleanly. */
|
||||
export async function closeDb(): Promise<void> {
|
||||
await queryClient.end({ timeout: 5 });
|
||||
}
|
||||
|
||||
export type Database = typeof db;
|
||||
|
||||
Reference in New Issue
Block a user