feat: add comprehensive authentication debug test suite
Add automated authentication testing infrastructure: - AUTH-DEBUG-GUIDE.md: Complete guide for auth debugging - auth-debug.spec.ts: Comprehensive auth flow validation tests - playwright.auth.config.ts: Specialized config with extended timeouts - auth-debug-setup.ts: Global test environment setup - auth-debug-teardown.ts: Test cleanup and environment reset Features: - Admin user validation and permissions testing - Email format validation including localhost domains - User registration and OAuth integration testing - Database connectivity and session management - Password security and error handling validation - Cross-browser testing with mobile support - Enhanced reporting and interactive debugging - CI/CD integration with artifacts and JUnit reports Replaces manual browser console debugging scripts with automated, cross-browser E2E tests for better reliability and maintainability.
This commit is contained in:
158
tests/e2e/playwright.auth.config.ts
Normal file
158
tests/e2e/playwright.auth.config.ts
Normal file
@@ -0,0 +1,158 @@
|
||||
import { defineConfig, devices } from '@playwright/test';
|
||||
|
||||
/**
|
||||
* Specialized Playwright configuration for authentication debug tests
|
||||
* Optimized for debugging auth flows with extended timeouts and detailed reporting
|
||||
*/
|
||||
export default defineConfig({
|
||||
testDir: './tests/e2e',
|
||||
testMatch: '**/auth-debug.spec.ts',
|
||||
|
||||
/* Run tests in files in parallel */
|
||||
fullyParallel: false, // Auth tests should run sequentially to avoid conflicts
|
||||
|
||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||
forbidOnly: !!process.env.CI,
|
||||
|
||||
/* Retry on CI only */
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
|
||||
/* Opt out of parallel tests on CI. */
|
||||
workers: process.env.CI ? 1 : 1, // Auth tests work better with single worker
|
||||
|
||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||
reporter: [
|
||||
['html', { outputFolder: 'playwright-report-auth' }],
|
||||
['json', { outputFile: 'playwright-report-auth.json' }],
|
||||
['list'],
|
||||
['junit', { outputFile: 'playwright-auth-results.xml' }],
|
||||
],
|
||||
|
||||
/* Shared settings for all the projects below. */
|
||||
use: {
|
||||
/* Base URL to use in actions like `await page.goto('/')`. */
|
||||
baseURL: 'http://localhost:8080',
|
||||
|
||||
/* Collect trace when retrying the failed test. */
|
||||
trace: 'retain-on-failure',
|
||||
|
||||
/* Take screenshot on failure */
|
||||
screenshot: 'only-on-failure',
|
||||
|
||||
/* Record video on failure */
|
||||
video: 'retain-on-failure',
|
||||
|
||||
/* Extended timeouts for auth operations */
|
||||
actionTimeout: 15000,
|
||||
navigationTimeout: 30000,
|
||||
|
||||
/* Ignore HTTPS errors */
|
||||
ignoreHTTPSErrors: true,
|
||||
|
||||
/* Accept downloads */
|
||||
acceptDownloads: false,
|
||||
|
||||
/* Viewport settings */
|
||||
viewport: { width: 1280, height: 720 },
|
||||
|
||||
/* Locale for testing */
|
||||
locale: 'en-US',
|
||||
|
||||
/* Timezone for consistent testing */
|
||||
timezoneId: 'America/New_York',
|
||||
},
|
||||
|
||||
/* Configure projects for major browsers */
|
||||
projects: [
|
||||
{
|
||||
name: 'auth-debug-chromium',
|
||||
use: {
|
||||
...devices['Desktop Chrome'],
|
||||
// Additional Chrome flags for debugging
|
||||
launchOptions: {
|
||||
args: [
|
||||
'--disable-web-security',
|
||||
'--disable-features=VizDisplayCompositor',
|
||||
'--no-sandbox',
|
||||
'--disable-dev-shm-usage',
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
name: 'auth-debug-firefox',
|
||||
use: {
|
||||
...devices['Desktop Firefox'],
|
||||
// Firefox specific settings
|
||||
launchOptions: {
|
||||
firefoxUserPrefs: {
|
||||
'security.tls.insecure_fallback_hosts': 'localhost',
|
||||
'network.stricttransportsecurity.preloadlist': false,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
name: 'auth-debug-webkit',
|
||||
use: { ...devices['Desktop Safari'] },
|
||||
},
|
||||
|
||||
/* Test against mobile viewports for responsive auth */
|
||||
{
|
||||
name: 'auth-debug-mobile-chrome',
|
||||
use: { ...devices['Pixel 5'] },
|
||||
},
|
||||
{
|
||||
name: 'auth-debug-mobile-safari',
|
||||
use: { ...devices['iPhone 12'] },
|
||||
},
|
||||
],
|
||||
|
||||
/* Global setup and teardown */
|
||||
globalSetup: require.resolve('./auth-debug-setup.ts'),
|
||||
globalTeardown: require.resolve('./auth-debug-teardown.ts'),
|
||||
|
||||
/* Test timeout for auth operations */
|
||||
timeout: 60000, // 1 minute per test
|
||||
expect: {
|
||||
timeout: 10000, // 10 seconds for assertions
|
||||
},
|
||||
|
||||
/* Run your local dev server before starting the tests */
|
||||
webServer: [
|
||||
{
|
||||
command: 'bun run dev',
|
||||
port: 8080,
|
||||
timeout: 120000,
|
||||
reuseExistingServer: !process.env.CI,
|
||||
stdout: 'pipe',
|
||||
stderr: 'pipe',
|
||||
env: {
|
||||
NODE_ENV: 'test',
|
||||
VITE_COUCHDB_URL: 'http://localhost:5984',
|
||||
VITE_COUCHDB_USERNAME: 'admin',
|
||||
VITE_COUCHDB_PASSWORD: 'password',
|
||||
},
|
||||
},
|
||||
{
|
||||
command: 'docker-compose -f docker/docker-compose.yaml up -d',
|
||||
timeout: 60000,
|
||||
reuseExistingServer: !process.env.CI,
|
||||
},
|
||||
],
|
||||
|
||||
/* Output directories */
|
||||
outputDir: 'test-results-auth/',
|
||||
|
||||
/* Metadata for reporting */
|
||||
metadata: {
|
||||
testType: 'Authentication Debug',
|
||||
environment: process.env.NODE_ENV || 'test',
|
||||
version: process.env.APP_VERSION || 'development',
|
||||
author: 'Medication Reminder App Team',
|
||||
description:
|
||||
'Comprehensive authentication flow debugging and validation tests',
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user