fix(e2e): complete E2E_TEST_MODE isolation for session registry + rate limits
Three related fixes to prevent E2E test runs from disrupting real user sessions:
1. auth.ts: skip active_sessions registration in E2E mode
E2E logins now return early after setting token.sid without writing
to active_sessions. Prevents test sessions from kicking real user
sessions via the concurrent-session limit.
2. trpc/route.ts: skip active_sessions validation in E2E mode
Pairs with (1): if registration is skipped, validation must be too,
otherwise every storageState-based test gets a 401 "Session revoked".
3. docker-compose.yml: hardcode Docker-internal DATABASE_URL + E2E_TEST_MODE
Previously ${DATABASE_URL:-postgres:5432} picked up the host's
localhost:5433 override and passed it into the container, where
localhost refers to the container itself — breaking db:migrate:deploy
on container recreate. Now hardcoded to postgres:5432.
Also adds E2E_TEST_MODE=true to the dev container environment.
Result: 21/21 dev-system E2E tests pass, test runs leave zero footprint
in active_sessions and rate limiter counters for real user accounts.
The timeline disruption caused by test sessions kicking the admin's
real browser session is also resolved.
Co-Authored-By: claude-flow <ruv@ruv.net>
This commit is contained in:
@@ -170,6 +170,12 @@ const authConfig = {
|
||||
const jti = crypto.randomUUID();
|
||||
token.sid = jti;
|
||||
|
||||
// Skip active-session registration in E2E test mode.
|
||||
// Test logins must not pollute the active_sessions table — doing so
|
||||
// kicks real user sessions when the concurrent-session limit is reached.
|
||||
const isE2eTestMode = process.env["E2E_TEST_MODE"] === "true";
|
||||
if (isE2eTestMode) return token;
|
||||
|
||||
// Enforce concurrent session limit (kick-oldest strategy)
|
||||
try {
|
||||
const settings = await prisma.systemSettings.findUnique({
|
||||
|
||||
Reference in New Issue
Block a user