screenshots.spec.ts
Language TypeScript2.0 KB53 lines
import { expect, test, type Page } from '@playwright/test'// `npm run screenshots` writes the README images from the sample data.// These are the web build over its own painted backdrop; on macOS the// panels sit on the native window frost instead.test.skip(!process.env.SCREENSHOTS, 'set SCREENSHOTS=1')test.use({ viewport: { width: 1280, height: 800 }, deviceScaleFactor: 2 })const shot = (page: Page, name: string) => page.screenshot({ path: `docs/screenshots/${name}.png` })async function open(page: Page, theme: 'light' | 'dark', chat: RegExp) {await page.emulateMedia({ colorScheme: theme })await page.goto('/')await page.getByRole('button', { name: chat }).click()await expect(page.getByTestId('msg-assistant').first()).toBeVisible()await page.waitForTimeout(300)}test('main, light', async ({ page }) => {await open(page, 'light', /Tidy a bash backup script/)await shot(page, 'main-light')})test('main, dark, with an image', async ({ page }) => {await open(page, 'dark', /Compare two pricing tiers/)await page.waitForTimeout(300)await shot(page, 'main-dark')})test('model picker', async ({ page }) => {await open(page, 'light', /How FTS5 bm25 ranking works/)await page.getByTestId('model-button').click()await page.waitForTimeout(250)await shot(page, 'model-picker')})test('usage', async ({ page }) => {await open(page, 'dark', /Tidy a bash backup script/)await page.getByTestId('spend-meter').click()await page.waitForTimeout(250)await shot(page, 'usage')})test('quick prompt', async ({ page }) => {await page.setViewportSize({ width: 640, height: 300 })await page.emulateMedia({ colorScheme: 'dark' })await page.goto('/quick.html')await page.getByLabel('Quick prompt').fill('What should I index in SQL?')await page.getByLabel('Quick prompt').press('Enter')await expect(page.getByTestId('cost-line')).toBeVisible()await page.waitForTimeout(200)await page.screenshot({ path: 'docs/screenshots/quick-prompt.png' })})