Files
metabuilder/e2e/playwright.config.ts
Claude 9c982a6b93 fix(e2e): use Testcontainers for smoke stack instead of docker compose in CI
Replace manual docker compose start/stop in the CI workflow with
Testcontainers in Playwright global setup/teardown. This gives:
- Automatic container lifecycle tied to the test run
- Health-check-based wait strategies per service
- Clean teardown even on test failures
- No CI workflow coupling to Docker orchestration

Changes:
- e2e/global.setup.ts: Start smoke stack via DockerComposeEnvironment
  (nginx, phpMyAdmin, Mongo Express, RedisInsight) with health check waits
- e2e/global.teardown.ts: New file — stops Testcontainers environment
- e2e/playwright.config.ts: Register globalSetup/globalTeardown, bind dev
  servers to 0.0.0.0 in CI so nginx can proxy via host.docker.internal
- gated-pipeline.yml: Remove docker compose start/stop/verify steps,
  add 10min timeout to Playwright step
- e2e/deployment-smoke.spec.ts: Update doc comment
- package.json: Add testcontainers@^11.12.0 devDependency

https://claude.ai/code/session_018rmhuicK7L7jV2YBJDXiQz
2026-03-11 18:31:06 +00:00

71 lines
2.3 KiB
TypeScript

import { defineConfig, devices } from '@playwright/test';
/**
* See https://playwright.dev/docs/test-configuration.
*
* baseURL resolution:
* CI / local dev server: http://localhost:3000/workflowui/ (Next.js dev, port 3000)
* Docker stack: http://localhost/workflowui/ (nginx, port 80)
*
* Override via PLAYWRIGHT_BASE_URL env var, e.g.:
* PLAYWRIGHT_BASE_URL=http://localhost/workflowui/ npx playwright test
*/
const baseURL = process.env.PLAYWRIGHT_BASE_URL ?? 'http://localhost:3000/workflowui/';
export default defineConfig({
testDir: './',
testMatch: '**/*.spec.ts',
globalSetup: './global.setup.ts',
globalTeardown: './global.teardown.ts',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: 'html',
use: {
baseURL,
trace: 'on-first-retry',
screenshot: 'only-on-failure',
},
/* Start dev servers automatically when not running against a live Docker stack.
* In CI the smoke stack's nginx (in Docker) proxies to the host dev servers via
* host.docker.internal. On Linux this resolves to the Docker bridge gateway IP
* (e.g. 172.17.0.1), NOT 127.0.0.1 — so dev servers MUST listen on 0.0.0.0. */
webServer: process.env.PLAYWRIGHT_BASE_URL ? undefined : [
{
command: `npm run dev -w workflowui -- --hostname ${process.env.CI ? '0.0.0.0' : 'localhost'}`,
url: 'http://localhost:3000/workflowui/',
reuseExistingServer: !process.env.CI,
timeout: 120_000,
env: {
NODE_ENV: 'development',
NEXT_PUBLIC_API_URL: 'http://localhost:8080',
NEXTAUTH_SECRET: 'test-secret',
NEXTAUTH_URL: 'http://localhost:3000',
},
},
{
command: `PORT=3001 npm run dev -w codesnippet -- --hostname ${process.env.CI ? '0.0.0.0' : 'localhost'}`,
url: 'http://localhost:3001/pastebin/',
reuseExistingServer: !process.env.CI,
timeout: 120_000,
env: {
NODE_ENV: 'development',
PORT: '3001',
NEXT_PUBLIC_DBAL_API_URL: 'http://localhost:8080',
NEXT_PUBLIC_FLASK_BACKEND_URL: 'http://localhost:5000',
NEXTAUTH_SECRET: 'test-secret',
NEXTAUTH_URL: 'http://localhost:3001',
},
},
],
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
});