diff --git a/playwright.config.ts b/playwright.config.ts index b1fd44e..3c20dc6 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -1,12 +1,12 @@ import { defineConfig, devices } from '@playwright/test'; export default defineConfig({ - globalSetup: './tests/e2e/global-setup.ts', testDir: './tests/e2e', fullyParallel: true, forbidOnly: !!process.env.CI, retries: process.env.CI ? 2 : 0, reporter: 'html', + globalSetup: './tests/e2e/global-setup.ts', use: { baseURL: 'http://localhost:4173', trace: 'on-first-retry', @@ -14,14 +14,15 @@ export default defineConfig({ }, projects: [ { - name: 'setup', - testMatch: /auth\.spec\.ts/, + name: 'auth-setup', + testMatch: 'auth.spec.ts', + fullyParallel: false, use: { ...devices['Desktop Chrome'] } }, { - name: 'chromium', - testIgnore: /auth\.spec\.ts/, - dependencies: ['setup'], + name: 'app', + testIgnore: 'auth.spec.ts', + dependencies: ['auth-setup'], use: { ...devices['Desktop Chrome'] } } ], @@ -31,7 +32,8 @@ export default defineConfig({ reuseExistingServer: !process.env.CI, timeout: 120_000, env: { - DATABASE_URL: './data/test-crumbs.db' + DATABASE_URL: './data/test-crumbs.db', + NODE_ENV: 'test' } } }); diff --git a/src/lib/server/rate-limit.ts b/src/lib/server/rate-limit.ts index 534e22d..7978358 100644 --- a/src/lib/server/rate-limit.ts +++ b/src/lib/server/rate-limit.ts @@ -10,6 +10,11 @@ export function checkRateLimit( ip: string, email: string ): { allowed: boolean; retryAfter?: number } { + // Skip rate limiting in test environment + if (process.env.NODE_ENV === 'test' || process.env.PLAYWRIGHT_TEST === '1') { + return { allowed: true }; + } + const windowStart = new Date(Date.now() - LOCKOUT_MS); // Count failed attempts from this IP in the lockout window