clipwright/dashboard/e2e/specs/clip-editor.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

35 lines
1.7 KiB
JavaScript

import { test, expect } from '@playwright/test';
import { openApp, completedSession, JOB_ID } from '../fixtures/app.js';
test.describe('clip editor', () => {
test('edits the recipe and re-renders through /api/clip/rerender', async ({ page }) => {
await openApp(page, { seed: { session: completedSession() } });
await expect(page.getByRole('heading', { name: 'First viral clip' })).toBeVisible();
await page.getByRole('button', { name: 'edit clip' }).first().click();
await expect(page.getByRole('heading', { name: 'edit clip' })).toBeVisible();
// The EDL loaded (the loading state is gone) and its segment is listed.
await expect(page.getByRole('button', { name: /add segment/i })).toBeVisible();
await expect(page.getByLabel('segment 1 start')).toHaveValue('0');
// Add a second segment so the recipe is dirty and renderable.
await page.getByRole('button', { name: /add segment/i }).click();
await expect(page.getByLabel('segment 2 start')).toBeVisible();
const requestPromise = page.waitForRequest(
(r) => r.method() === 'POST' && r.url().includes('/api/clip/rerender'),
);
await page.getByRole('button', { name: /re-render/i }).click();
const request = await requestPromise;
const body = request.postDataJSON();
expect(body.job_id).toBe(JOB_ID);
expect(body.clip_index).toBe(0);
expect(body.segments).toHaveLength(2);
expect(body.framing).toBe('auto');
expect(body.reapply_captions).toBe(true);
// The new preview URL is adopted; the editor stays open.
await expect(page.getByRole('heading', { name: 'edit clip' })).toBeVisible();
});
});