Some checks failed
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { request } from '@playwright/test';
|
|
|
|
import { ApiHelpers } from './services/api-helper';
|
|
import { getBackendUrl } from './utils/url-helper';
|
|
|
|
async function globalSetup() {
|
|
console.log('🚀 Starting global setup...');
|
|
|
|
// Check if backend URL is set (N8N_BACKEND_URL or N8N_BASE_URL)
|
|
const n8nBaseUrl = getBackendUrl();
|
|
if (!n8nBaseUrl) {
|
|
console.log('⚠️ N8N_BASE_URL environment variable is not set, skipping database reset');
|
|
return;
|
|
}
|
|
|
|
const resetE2eDb = process.env.RESET_E2E_DB;
|
|
if (resetE2eDb !== 'true') {
|
|
console.log('⚠️ RESET_E2E_DB is not set to "true", skipping database reset');
|
|
return;
|
|
}
|
|
|
|
console.log(`🔄 Resetting database for ${n8nBaseUrl}...`);
|
|
// Quick hack till we find out a better health check for the database reset command!
|
|
await new Promise((resolve) => setTimeout(resolve, 3000));
|
|
// Create standalone API request context
|
|
const requestContext = await request.newContext({
|
|
baseURL: n8nBaseUrl,
|
|
});
|
|
|
|
try {
|
|
const api = new ApiHelpers(requestContext);
|
|
await api.resetDatabase();
|
|
console.log('✅ Database reset completed successfully');
|
|
} catch (error) {
|
|
console.error('❌ Failed to reset database', error);
|
|
throw error; // This will fail the entire test suite if database reset fails
|
|
} finally {
|
|
await requestContext.dispose();
|
|
}
|
|
|
|
console.log('🏁 Global setup completed');
|
|
}
|
|
|
|
// eslint-disable-next-line import-x/no-default-export
|
|
export default globalSetup;
|