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