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 }); }); });