import path from 'node:path'; import { defineConfig, devices } from '@playwright/test'; // eslint-disable-next-line @typescript-eslint/no-var-requires const { resolveChromeBinary } = require('./scripts/chrome-path'); const webRoot = __dirname; const repoRoot = path.resolve(__dirname, '..', '..', '..'); const appPort = process.env.PLAYWRIGHT_PORT ? Number.parseInt(process.env.PLAYWRIGHT_PORT, 10) : 4400; const appBaseUrl = process.env.PLAYWRIGHT_BASE_URL ?? `https://127.0.0.1:${appPort}`; const liveSearchBaseUrl = process.env.LIVE_ADVISORYAI_SEARCH_BASE_URL?.trim() || 'http://127.0.0.1:10451'; const advisoryConnectionString = process.env.AdvisoryAI__KnowledgeSearch__ConnectionString?.trim() || 'Host=localhost;Port=55432;Database=advisoryai_knowledge_test;Username=stellaops_knowledge;Password=stellaops_knowledge'; process.env.LIVE_ADVISORYAI_SEARCH_BASE_URL = liveSearchBaseUrl; process.env.LIVE_ADVISORYAI_TENANT = process.env.LIVE_ADVISORYAI_TENANT?.trim() || 'test-tenant'; process.env.LIVE_ADVISORYAI_SCOPES = process.env.LIVE_ADVISORYAI_SCOPES?.trim() || 'advisory-ai:view advisory-ai:operate advisory-ai:admin'; const chromiumExecutable = resolveChromeBinary(__dirname) as string | null; export default defineConfig({ testDir: 'tests/e2e', timeout: 120_000, expect: { timeout: 10_000 }, fullyParallel: false, retries: process.env.CI ? 1 : 0, workers: 1, reporter: [['list'], ['html', { open: 'never' }]], use: { baseURL: appBaseUrl, ignoreHTTPSErrors: true, trace: 'retain-on-failure', screenshot: 'only-on-failure', video: 'retain-on-failure', ...(chromiumExecutable ? { launchOptions: { executablePath: chromiumExecutable } } : {}), }, webServer: [ { command: 'npm run serve:test', cwd: webRoot, reuseExistingServer: !process.env.CI, url: appBaseUrl, ignoreHTTPSErrors: true, stdout: 'ignore', stderr: 'ignore', timeout: 120_000, }, { command: 'dotnet run --project src/AdvisoryAI/StellaOps.AdvisoryAI.WebService/StellaOps.AdvisoryAI.WebService.csproj --no-launch-profile', cwd: repoRoot, reuseExistingServer: !process.env.CI, url: `${liveSearchBaseUrl}/health`, stdout: 'ignore', stderr: 'ignore', timeout: 180_000, env: { ...process.env, AdvisoryAI__KnowledgeSearch__ConnectionString: advisoryConnectionString, ASPNETCORE_URLS: liveSearchBaseUrl, }, }, ], projects: [ { name: 'live-search-setup', testMatch: /live-search\.setup\.ts/, }, { name: 'live-search-chromium', testMatch: /unified-search-contextual-suggestions\.live\.e2e\.spec\.ts/, use: { ...devices['Desktop Chrome'] }, dependencies: ['live-search-setup'], }, ], });