- tests/conftest.py installs minimal ultralytics/mediapipe stand-ins only when the real packages are absent, so clipwright.pipeline.main imports in the thin unit env instead of pytest.importorskip skipping 15 modules (63 tests). Unit suite is now 779 passed / 0 skipped. - requirements-test.txt pins uvicorn==0.46.0 (the real-backend server). - dashboard: vite preview proxies /api,/videos,/thumbnails to a locally-launched backend; Playwright gains a gated (CW_E2E_REAL) real project + uvicorn webServer running the pipeline stub_env; real-backend.spec.js drives the real upload->process->clip flow. CI dashboard job installs the backend test deps. - Verified: real lane 20 passed twice in the CI container; mock-only 19 passed without the flag; backend unit/API/pipeline 779/209/127.
94 lines
3.3 KiB
JavaScript
94 lines
3.3 KiB
JavaScript
// Browser E2E config. Two projects:
|
|
// - `mock` (default): every network edge is intercepted, no retries, one
|
|
// worker. This is the lane that must stay green in CI.
|
|
// - `real`: drives the real backend (uvicorn + stub pipeline). Kept separate
|
|
// so the mocked lane never depends on Python.
|
|
//
|
|
// The `real` project and its backend webServer only exist when CW_E2E_REAL is
|
|
// set (CI sets it). A bare `npm run test:e2e` therefore stays mock-only and
|
|
// needs no Python deps.
|
|
/* global process */
|
|
import { defineConfig, devices } from '@playwright/test';
|
|
import { fileURLToPath } from 'node:url';
|
|
import path from 'node:path';
|
|
|
|
const dashboardDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
|
const repoRoot = path.resolve(dashboardDir, '..');
|
|
|
|
const realBackend = !!process.env.CW_E2E_REAL;
|
|
|
|
const webServers = [
|
|
{
|
|
command: 'npm run build && npx vite preview --port 4173 --strictPort --host 127.0.0.1',
|
|
cwd: dashboardDir,
|
|
url: 'http://127.0.0.1:4173',
|
|
reuseExistingServer: !process.env.CI,
|
|
timeout: 120_000,
|
|
stdout: 'ignore',
|
|
stderr: 'pipe',
|
|
},
|
|
];
|
|
|
|
if (realBackend) {
|
|
// Real `uvicorn clipwright.api.app:app` with the pipeline's stub_env on
|
|
// PYTHONPATH: sitecustomize stubs the ML/network edges so the real CLI runs
|
|
// with real ffmpeg, no model downloads and no outbound requests. The env
|
|
// values mirror tests/e2e/pipeline's deterministic, no-ML configuration.
|
|
webServers.push({
|
|
command: 'python -m uvicorn clipwright.api.app:app --host 127.0.0.1 --port 8000 --log-level warning',
|
|
cwd: repoRoot,
|
|
url: 'http://127.0.0.1:8000/health',
|
|
reuseExistingServer: !process.env.CI,
|
|
timeout: 120_000,
|
|
stdout: 'ignore',
|
|
stderr: 'pipe',
|
|
env: {
|
|
PYTHONPATH: ['tests/e2e/pipeline/stub_env', '.'].join(path.delimiter),
|
|
GEMINI_API_KEY: 'test',
|
|
MIN_SOURCE_SECONDS: '0',
|
|
QUALITY_GATE_MIN_HEIGHT: '0',
|
|
AUTO_LAYOUT: '0',
|
|
SCENE_ENGINE: 'pyscenedetect',
|
|
ASR_HOST_SLOTS: '0',
|
|
FFMPEG_ENCODER: 'x264',
|
|
TZ: 'UTC',
|
|
},
|
|
});
|
|
}
|
|
|
|
export default defineConfig({
|
|
testDir: './specs',
|
|
// No retries anywhere: a flaky test is a bug, not a coin flip.
|
|
retries: 0,
|
|
// One worker keeps the shared preview server and the deterministic fixtures
|
|
// predictable.
|
|
workers: 1,
|
|
fullyParallel: false,
|
|
timeout: 30_000,
|
|
expect: { timeout: 5_000 },
|
|
reporter: [['list']],
|
|
outputDir: './.test-results',
|
|
globalSetup: './fixtures/global-setup.js',
|
|
use: {
|
|
baseURL: 'http://127.0.0.1:4173',
|
|
trace: 'retain-on-failure',
|
|
screenshot: 'only-on-failure',
|
|
video: 'retain-on-failure',
|
|
},
|
|
projects: [
|
|
{
|
|
name: 'mock',
|
|
testIgnore: /real-backend\.spec\.js/,
|
|
use: { ...devices['Desktop Chrome'] },
|
|
},
|
|
// The real lane runs the full pipeline, which needs more than the 30s
|
|
// default. Gated so a mock-only run never tries to boot Python.
|
|
...(realBackend ? [{
|
|
name: 'real',
|
|
testMatch: /real-backend\.spec\.js/,
|
|
timeout: 120_000,
|
|
use: { ...devices['Desktop Chrome'] },
|
|
}] : []),
|
|
],
|
|
webServer: webServers,
|
|
});
|