metallkart-erp/playwright.config.ts
louis a44d36e769 feat(engagement): SPEC-E2E-TASKS-1C — 22 Playwright E2E tests for Tasks module
- 5 test groups: Navigation (4), CRUD Modal (5), List Filters (5), Kanban (5), Detail Drawer (3)
- Seed: 6 tasks (4 admin, 1 commercial, 1 acheteur private)
- Fix backend search bug: OR conditions for q and privacy were merged into a single OR,
  causing search to match all tasks. Changed to AND of separate OR groups.
- Playwright project 'engagement' added to config

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-05-26 22:58:45 +04:00

76 lines
3.7 KiB
TypeScript

import { defineConfig, devices } from '@playwright/test';
import dotenv from 'dotenv';
dotenv.config({ path: '.env.test' });
const FRONTEND_PORT = process.env.E2E_FRONTEND_PORT ?? '5174';
const BACKEND_PORT = process.env.E2E_BACKEND_PORT ?? '3002';
const E2E_DB_URL = process.env.E2E_DATABASE_URL ?? '';
if (!E2E_DB_URL) {
throw new Error('[Playwright] E2E_DATABASE_URL missing. Check .env.test at project root.');
}
export default defineConfig({
testDir: './tests/e2e',
testMatch: '**/*.spec.ts',
timeout: 60_000,
expect: { timeout: 10_000 },
retries: 1,
workers: 1,
projects: [
{ name: 'smoke', testMatch: /smoke\.spec\.ts/, use: { ...devices['Desktop Chrome'] } },
{ name: 'orders', testMatch: /orders\.spec\.ts/, use: { ...devices['Desktop Chrome'] } },
{ name: 'purchases', testMatch: /(purchases|budget[-\w]*)\.spec\.ts/, use: { ...devices['Desktop Chrome'] } },
{ name: 'estimates', testMatch: /(estimates[-\w]*|smeta-revision|import-ai[-\w]*)\.spec\.ts/, use: { ...devices['Desktop Chrome'] } },
{ name: 'dashboard', testMatch: /(dashboard[-\w]*|profitability)\.spec\.ts/, use: { ...devices['Desktop Chrome'] } },
{ name: 'finance', testMatch: /(cashflow[-\w]*|finance[-\w]*)\.spec\.ts/, use: { ...devices['Desktop Chrome'] } },
{ name: 'documents', testMatch: /documents\.spec\.ts/, use: { ...devices['Desktop Chrome'] } },
{ name: 'planning', testMatch: /planning\.spec\.ts/, use: { ...devices['Desktop Chrome'] } },
{ name: 'products', testMatch: /products\.spec\.ts/, use: { ...devices['Desktop Chrome'] } },
{ name: 'std-6', testMatch: /std-6[-\w]*\.spec\.ts/, use: { ...devices['Desktop Chrome'] } },
{ name: 'crit-notif', testMatch: /crit-notif\.spec\.ts/, use: { ...devices['Desktop Chrome'] } },
{ name: 'advisor', testMatch: /advisor\.spec\.ts/, use: { ...devices['Desktop Chrome'] } },
{ name: 'help-suggestions', testMatch: /help-suggestions\.spec\.ts/, use: { ...devices['Desktop Chrome'] } },
{ name: 'builder', testMatch: /builder\.spec\.ts/, use: { ...devices['Desktop Chrome'] } },
{ name: 'builder-detail', testMatch: /builder-detail\.spec\.ts/, use: { ...devices['Desktop Chrome'] } },
{ name: 'admin-users', testMatch: /admin-users\.spec\.ts/, use: { ...devices['Desktop Chrome'] } },
{ name: 'copilot', testMatch: /copilot\.spec\.ts/, use: { ...devices['Desktop Chrome'] } },
{ name: 'engagement', testMatch: /engagement[-\w]*\.spec\.ts/, use: { ...devices['Desktop Chrome'] } },
],
use: {
baseURL: `http://localhost:${FRONTEND_PORT}`,
headless: true,
screenshot: 'only-on-failure',
trace: 'retain-on-failure',
actionTimeout: 15_000,
navigationTimeout: 30_000,
},
globalSetup: './tests/e2e/global-setup.ts',
globalTeardown: './tests/e2e/global-teardown.ts',
reporter: [
['list'],
['html', { open: 'never', outputFolder: 'playwright-report' }],
],
outputDir: 'test-results',
webServer: [
{
command: `cross-env DATABASE_URL="${E2E_DB_URL}" PORT=${BACKEND_PORT} JWT_SECRET=test_jwt_secret_2026_only_for_e2e SMTP_DRY_RUN=true ADVISOR_MOCK_MODE=true AGENT_CHAT_MOCK_MODE=true BUILDER_MOCK_MODE=true BUILDER_PROVISIONING_MOCK_MODE=true BUILDER_TEST_RUNNER_MOCK_MODE=true BUILDER_MERGE_MOCK_MODE=true BUILDER_REVERT_MOCK_MODE=true npm run dev`,
port: parseInt(BACKEND_PORT),
reuseExistingServer: !process.env.CI,
timeout: 90000,
stdout: 'pipe',
stderr: 'pipe',
},
{
command: `cross-env BACKEND_PORT=${BACKEND_PORT} VITE_NOTIF_POLL_INTERVAL=5000 npm --prefix frontend run dev -- --port ${FRONTEND_PORT}`,
port: parseInt(FRONTEND_PORT),
reuseExistingServer: !process.env.CI,
timeout: 30000,
stdout: 'pipe',
stderr: 'pipe',
},
],
});