fix(e2e): stabilize auth, smoke, search, playlists specs
- Global setup no longer throws when API is unavailable; writes empty auth state so Playwright can start; specs that need auth use their own login or storageState override. - Ensure e2e/.auth dir exists before writing empty state.
This commit is contained in:
parent
670282989b
commit
a746026c56
1 changed files with 11 additions and 6 deletions
|
|
@ -1,4 +1,6 @@
|
|||
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { chromium, FullConfig } from '@playwright/test';
|
||||
import { TEST_CONFIG } from './utils/test-helpers';
|
||||
|
||||
|
|
@ -171,12 +173,15 @@ async function globalSetup(config: FullConfig) {
|
|||
|
||||
if (!loginResult.success) {
|
||||
const errorMsg = loginResult.error || 'Unknown error';
|
||||
console.error(`❌ [GLOBAL SETUP] API login failed: ${errorMsg}`);
|
||||
console.error(`❌ [GLOBAL SETUP] Make sure:`);
|
||||
console.error(` - Backend API is running at ${TEST_CONFIG.API_URL}`);
|
||||
console.error(` - Test user exists: ${testUser.email}`);
|
||||
console.error(` - CORS is configured correctly`);
|
||||
throw new Error(`API login failed: ${errorMsg}`);
|
||||
console.warn(`⚠️ [GLOBAL SETUP] API login failed: ${errorMsg}`);
|
||||
console.warn(`⚠️ [GLOBAL SETUP] Make sure Backend API is running at ${TEST_CONFIG.API_URL} and test user exists: ${testUser.email}`);
|
||||
// Write empty storage state so Playwright can start; specs that need auth use their own login or storageState override
|
||||
const storageStatePath = config.projects[0]?.use?.storageState as string || 'e2e/.auth/user.json';
|
||||
fs.mkdirSync(path.dirname(storageStatePath), { recursive: true });
|
||||
await context.storageState({ path: storageStatePath });
|
||||
console.warn(`⚠️ [GLOBAL SETUP] Saved empty auth state to ${storageStatePath}. Tests requiring API will fail until backend is running.`);
|
||||
await browser.close();
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('✅ [GLOBAL SETUP] API login successful!');
|
||||
|
|
|
|||
Loading…
Reference in a new issue