Repository Public
1import { expect, test } from '@playwright/test';2import { FIX, mission, reveal, resetMock, seeded, setTheme, shot } from './helpers';34/** Phone screenshots (WebKit, iPhone 15), light and dark, of the seeded fixture state. Reviewed by eye. */5for (const theme of ['light', 'dark'] as const) {6 test.describe(`phone screenshots — ${theme}`, () => {7 test.beforeEach(async ({ page }) => {8 await seeded(page);9 await setTheme(page, theme);10 });11 test('home', async ({ page }) => {12 await page.goto('/home/');13 await expect(page.getByTestId('needs-you').getByTestId('wait-card')).toHaveCount(2);14 await page.waitForTimeout(700);15 await shot(page, `phone-home-${theme}`);16 await page.getByTestId('running').scrollIntoViewIfNeeded();17 await page.waitForTimeout(300);18 await shot(page, `phone-home-running-${theme}`);19 });20 test('mission timeline', async ({ page }) => {21 const m = await mission(page, FIX.approval);22 await page.goto(`/mission/?id=${m.id}`);23 await expect(page.getByTestId('timeline-wait').getByTestId('wait-approve')).toBeVisible();24 await page.waitForTimeout(700);25 await shot(page, `phone-mission-${theme}`);26 const edit = page.locator('[data-testid="tool-row"][data-tool="edit_file"]').first();27 await reveal(page, edit);28 await page.getByTestId('timeline-scroll').evaluate((el) => { el.scrollTop -= 150; });29 await page.waitForTimeout(400);30 await shot(page, `phone-mission-diff-${theme}`);31 });32 test('approvals', async ({ page }) => {33 await page.goto('/approvals/');34 await expect(page.getByTestId('wait-card')).toHaveCount(2);35 await page.waitForTimeout(700);36 await shot(page, `phone-approvals-${theme}`);37 });38 test('new mission', async ({ page }) => {39 await page.goto('/missions/');40 await expect(page.getByTestId('mission-row')).toHaveCount(6);41 await page.waitForTimeout(500);42 await shot(page, `phone-missions-${theme}`);43 await page.getByTestId('new-mission-page').tap();44 await page.getByTestId('mission-objective').fill('Some invoice totals are off by one cent. Find the cause and fix it with a regression test.');45 await expect(page.getByTestId('model-picker')).toBeVisible();46 await page.waitForTimeout(600);47 await shot(page, `phone-new-mission-${theme}`);48 });49 });50}5152test('phone: empty Home of a fresh instance', async ({ page }) => {53 await seeded(page);54 // resolve everything, cancel what runs: Home shows its empty states55 const csrf = (await (await page.request.get('/api/v1/auth/status')).json()).csrfToken as string;56 for (const w of (await (await page.request.get('/api/v1/waits?status=pending')).json()) as { id: string; kind: string }[]) {57 await page.request.post(`/api/v1/waits/${w.id}/resolve`, { headers: { 'X-CSRF-Token': csrf }, data: w.kind === 'approval' ? { kind: 'approval', decision: 'deny' } : { kind: 'question', answer: 'Yes — use these criteria' } });58 }59 for (const m of (await (await page.request.get('/api/v1/missions')).json()) as { id: string; status: string }[]) {60 if (['running', 'waiting', 'queued'].includes(m.status)) await page.request.post(`/api/v1/missions/${m.id}/cancel`, { headers: { 'X-CSRF-Token': csrf }, data: {} });61 }62 await page.goto('/home/');63 await expect(page.getByTestId('needs-you-empty')).toBeVisible();64 await expect(page.getByText('No mission is running')).toBeVisible();65 await page.waitForTimeout(500);66 await shot(page, 'phone-home-empty-light');67 await resetMock(page);68});69