clipwright/dashboard/e2e/specs/quality-gate.spec.js
pedro-bento 0040aa49da
All checks were successful
CI / dashboard-e2e (push) Successful in 1m44s
CI / unit (push) Successful in 29s
CI / backend-e2e (push) Successful in 1m17s
test/e2e-coverage (#5)
Reviewed-on: #5
Co-authored-by: pedro-bento <mail@pbento.pt>
Co-committed-by: pedro-bento <mail@pbento.pt>
2026-10-04 22:28:46 +01:00

38 lines
1.8 KiB
JavaScript

import { test, expect } from '@playwright/test';
import { openApp } from '../fixtures/app.js';
test.describe('quality gate', () => {
test('asks before processing a low-resolution source and resends with force_low_quality', async ({ page }) => {
await openApp(page, { mocks: { processSequence: ['needs_confirmation', 'queued'] } });
await page.getByRole('button', { name: /video url/i }).click();
await page.getByPlaceholder(/paste a video link/i).fill('https://www.youtube.com/watch?v=dQw4w9WgXcQ');
await page.locator('form input[type="checkbox"]').first().check();
const firstPromise = page.waitForRequest(
(r) => r.method() === 'POST' && r.url().includes('/api/process'),
);
await page.getByRole('button', { name: /generate clips/i }).click();
const first = await firstPromise;
expect(first.postDataJSON()).toMatchObject({ force_low_quality: false });
// The gate opens instead of starting the job.
const dialog = page.getByRole('dialog');
await expect(dialog.getByText(/low source quality/i)).toBeVisible();
await expect(dialog.getByText(/360p/)).toBeVisible();
const secondPromise = page.waitForRequest(
(r) => r.method() === 'POST'
&& r.url().includes('/api/process')
&& JSON.parse(r.postData()).force_low_quality === true,
);
await page.getByRole('button', { name: /process anyway/i }).click();
const second = await secondPromise;
expect(second.postDataJSON()).toMatchObject({
url: 'https://www.youtube.com/watch?v=dQw4w9WgXcQ',
force_low_quality: true,
});
await expect(page.getByRole('heading', { name: 'First viral clip' })).toBeVisible();
});
});