The per-clip download button now fetches a new
GET /api/jobs/{job_id}/clip/{clip_index}/download endpoint that packages the
saved clip as a ZIP shaped like a folder named after the clip title:
<title>/clip.mp4
<title>/description.txt
Titles are sanitized into a single filesystem-safe path segment, and the
archive is named <title>.zip. File resolution mirrors download-all (live
record, then metadata URL, then canonical derived name). The frontend keeps
its streaming progress UI and derives the filename from Content-Disposition.
Reviewed-on: #7
Co-authored-by: pedro-bento <mail@pbento.pt>
Co-committed-by: pedro-bento <mail@pbento.pt>
53 lines
2.6 KiB
JavaScript
53 lines
2.6 KiB
JavaScript
import { test, expect } from '@playwright/test';
|
|
import { openApp, completedSession, JOB_ID } from '../fixtures/app.js';
|
|
|
|
test.describe('results actions', () => {
|
|
test('downloads all clips as a zip', async ({ page }) => {
|
|
await openApp(page, { seed: { session: completedSession() } });
|
|
await expect(page.getByRole('heading', { name: 'First viral clip' })).toBeVisible();
|
|
|
|
const requestPromise = page.waitForRequest(
|
|
(r) => r.method() === 'GET' && r.url().includes(`/api/jobs/${JOB_ID}/download-all`),
|
|
);
|
|
const downloadPromise = page.waitForEvent('download');
|
|
await page.getByRole('button', { name: /download all/i }).click();
|
|
|
|
await requestPromise;
|
|
const download = await downloadPromise;
|
|
expect(download.suggestedFilename()).toContain('clipwright_clips_');
|
|
});
|
|
|
|
test('downloads a single clip as a titled zip', async ({ page }) => {
|
|
await openApp(page, { seed: { session: completedSession() } });
|
|
await expect(page.getByRole('heading', { name: 'First viral clip' })).toBeVisible();
|
|
|
|
const requestPromise = page.waitForRequest(
|
|
(r) => r.method() === 'GET' && r.url().includes(`/api/jobs/${JOB_ID}/clip/0/download`),
|
|
);
|
|
const downloadPromise = page.waitForEvent('download');
|
|
await page.getByRole('button', { name: 'download', exact: true }).first().click();
|
|
|
|
await requestPromise;
|
|
const download = await downloadPromise;
|
|
expect(download.suggestedFilename()).toBe('Test Clip.zip');
|
|
});
|
|
|
|
test('opens the generated descriptions', async ({ page }) => {
|
|
await openApp(page, { seed: { session: completedSession() } });
|
|
await expect(page.getByRole('heading', { name: 'First viral clip' })).toBeVisible();
|
|
|
|
await page.getByRole('button', { name: /view descriptions/i }).first().click();
|
|
const dialog = page.getByRole('dialog');
|
|
await expect(dialog.getByText('GENERATED COPY')).toBeVisible();
|
|
await expect(dialog.getByText('TikTok caption one #viral #shorts')).toBeVisible();
|
|
await expect(dialog.getByText('First viral clip')).toBeVisible();
|
|
});
|
|
|
|
test('removes a generated clip and resets the workspace', async ({ page }) => {
|
|
await openApp(page, { seed: { session: completedSession() } });
|
|
await expect(page.getByRole('heading', { name: 'First viral clip' })).toBeVisible();
|
|
|
|
await page.getByRole('button', { name: /new project/i }).click();
|
|
await expect(page.getByRole('heading', { name: /create viral shorts/i })).toBeVisible();
|
|
});
|
|
});
|