6 lines
2.5 MiB
JSON
6 lines
2.5 MiB
JSON
|
|
|
||
|
|
> veza-frontend@1.0.0 lint
|
||
|
|
> eslint . --ext ts,tsx --format json
|
||
|
|
|
||
|
|
[{"filePath":"/home/senke/git/talas/veza/apps/web/e2e/auth-flow.spec.ts","messages":[{"ruleId":null,"message":"Unused eslint-disable directive (no problems were reported from 'no-console').","line":1,"column":1,"severity":1,"nodeType":null,"fix":{"range":[0,31],"text":" "}}],"suppressedMessages":[],"errorCount":0,"fatalErrorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":1,"source":"/* eslint-disable no-console */\nimport { test, expect } from '@playwright/test';\nimport {\n TEST_CONFIG,\n TEST_USERS,\n loginAsUser,\n forceSubmitForm,\n fillField,\n setupErrorCapture,\n getAuthToken,\n} from './utils/test-helpers';\n\n/**\n * E2E Test Suite: Complete Authentication Flow\n * \n * Tests the complete authentication flow as specified in INT-TEST-001:\n * 1. Register with valid email\n * 2. Verify email (simulated)\n * 3. Login and verify token\n * 4. Test automatic token refresh\n * 5. Logout and redirect\n * \n * This test suite ensures the entire auth flow works end-to-end with a real backend.\n */\n\ntest.describe('Complete Auth Flow E2E', () => {\n // Reset storage state for these tests to ensure we start unauthenticated\n test.use({ storageState: { cookies: [], origins: [] } });\n\n let consoleErrors: string[] = [];\n let networkErrors: Array<{ url: string; status: number; method: string }> = [];\n\n test.beforeEach(async ({ page }) => {\n const errorCapture = setupErrorCapture(page);\n consoleErrors = errorCapture.consoleErrors;\n networkErrors = errorCapture.networkErrors;\n });\n\n /**\n * TEST 1: Register with valid email\n * INT-TEST-001: Step 1 - Register with valid email\n */\n test('should register a new user with valid email', async ({ page }) => {\n console.log('🧪 [AUTH-FLOW] Step 1: Register with valid email');\n\n await page.goto(`${TEST_CONFIG.FRONTEND_URL}/register`);\n await page.waitForLoadState('domcontentloaded');\n\n // Wait for page to be fully loaded\n await page.waitForLoadState('networkidle', { timeout: 10000 }).catch(() => {\n console.warn('⚠️ [AUTH-FLOW] Timeout on networkidle, continuing...');\n });\n\n // Generate unique email to avoid conflicts\n const uniqueEmail = `test-flow-${Date.now()}@example.com`;\n const username = `testuser${Date.now()}`;\n const password = 'Test123456789!'; // 12+ characters required\n\n // Fill registration form\n await fillField(page, 'input[name=\"email\"], input#email', uniqueEmail);\n await page.waitForTimeout(200);\n\n await fillField(page, 'input[name=\"username\"], input#username', username);\n await page.waitForTimeout(200);\n\n await fillField(page, 'input[name=\"password\"], input#password', password);\n await page.waitForTimeout(200);\n\n await fillField(\n page,\n 'input[name=\"passwordConfirm\"], input[name=\"password_confirm\"], input[name=\"confirmPassword\"], input#passwordConfirm',\n password,\n );\n\n // Wait for React Hook Form to update state\n await page.waitForTimeout(500);\n\n // Submit form\n await forceSubmitForm(page, 'form');\n\n // Wait for either navigation or success message\n const navigationSuccess = await Promise.race([\n page\n .waitForURL(\n (url) => url.pathname === '/dashboard' || url.pathname === '/login',\n { timeout: 10000 },\n )\n .then(() => true)\n .catch(() => false),\n page.waitForTimeout(10000).then(() => false),\n ]);\n\n // Verify registration was successful\n if (navigationSuccess) {\n const currentUrl = page.url();\n if (currentUrl.includes('dashboard') || !currentUrl.includes('login')) {\n await expect(\n page.locator('nav[role=\"navigation\"], aside[role=\"navigation\"]'),\n ).toBeVisible({ timeout: 10000 });\n console.log('✅ [AUTH-FLOW] Registration successful with auto-login');\n } else {\n console.log('✅ [AUTH-FLOW] Registration successful, redirected to login');\n }\n } else {\n // Check for success message or auth state\n
|