clipwright/dashboard/e2e/specs/real-backend.spec.js
pedro-bento d03ef799f4
All checks were successful
CI / unit (pull_request) Successful in 45s
CI / backend-e2e (pull_request) Successful in 1m16s
CI / dashboard-e2e (pull_request) Successful in 2m26s
test: unskip the main-module unit tests and enable the real-backend browser lane
- 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.
2026-10-05 10:46:45 +01:00

33 lines
1.8 KiB
JavaScript

import { test, expect } from '@playwright/test';
import { seedApp } from '../fixtures/app.js';
import { SIXTY_MP4 } from '../fixtures/media.js';
// Real-backend lane.
//
// Drives the built app against a real `uvicorn clipwright.api.app:app` whose
// pipeline runs the real CLI through tests/e2e/pipeline/stub_env (fake ML/ASR/
// Gemini, real ffmpeg). No route mocks: the preview server proxies /api,
// /videos and /thumbnails to the backend (vite.config.js preview.proxy), so
// every request in this spec is served by Python. The spec is only collected
// when CW_E2E_REAL is set; the `mock` lane ignores it.
test.describe('real backend', () => {
test('generates a clip against a real uvicorn + stub_env server', async ({ page }) => {
// Seed the BYOK Gemini key (and consent) exactly like the mock specs.
// No installApiMocks: this lane talks to the real server.
await seedApp(page, { geminiKey: 'e2e-gemini-key' });
await page.goto('/#app');
await expect(page.getByRole('heading', { name: /create viral shorts/i })).toBeVisible();
// Upload the ffmpeg-built fixture, attest rights, submit.
await page.setInputFiles('input[type="file"][accept="video/*"]', SIXTY_MP4);
await page.locator('form input[type="checkbox"]').first().check();
await page.getByRole('button', { name: /generate clips/i }).click();
// The app polls /api/status every 2s; the real pipeline (real ffmpeg,
// stubbed ML) finishes in well under a minute. Bounded auto-wait, no
// sleeps: the clip count badge only renders once results carry clips.
await expect(page.getByText(/\d+ Clips/)).toBeVisible({ timeout: 60_000 });
await expect(page.getByText('Clip 1', { exact: true })).toBeVisible({ timeout: 60_000 });
});
});