mattrguerra/cortexmainPrivate on GitHub, published here in full

screenshots.spec.ts

Language TypeScript2.0 KB53 lines

e2e/ui/screenshots.spec.ts

  1. import { expect, test, type Page } from '@playwright/test'
  2. // `npm run screenshots` writes the README images from the sample data.
  3. // These are the web build over its own painted backdrop; on macOS the
  4. // panels sit on the native window frost instead.
  5. test.skip(!process.env.SCREENSHOTS, 'set SCREENSHOTS=1')
  6. test.use({ viewport: { width: 1280, height: 800 }, deviceScaleFactor: 2 })
  7. const shot = (page: Page, name: string) => page.screenshot({ path: `docs/screenshots/${name}.png` })
  8. async function open(page: Page, theme: 'light' | 'dark', chat: RegExp) {
  9. await page.emulateMedia({ colorScheme: theme })
  10. await page.goto('/')
  11. await page.getByRole('button', { name: chat }).click()
  12. await expect(page.getByTestId('msg-assistant').first()).toBeVisible()
  13. await page.waitForTimeout(300)
  14. }
  15. test('main, light', async ({ page }) => {
  16. await open(page, 'light', /Tidy a bash backup script/)
  17. await shot(page, 'main-light')
  18. })
  19. test('main, dark, with an image', async ({ page }) => {
  20. await open(page, 'dark', /Compare two pricing tiers/)
  21. await page.waitForTimeout(300)
  22. await shot(page, 'main-dark')
  23. })
  24. test('model picker', async ({ page }) => {
  25. await open(page, 'light', /How FTS5 bm25 ranking works/)
  26. await page.getByTestId('model-button').click()
  27. await page.waitForTimeout(250)
  28. await shot(page, 'model-picker')
  29. })
  30. test('usage', async ({ page }) => {
  31. await open(page, 'dark', /Tidy a bash backup script/)
  32. await page.getByTestId('spend-meter').click()
  33. await page.waitForTimeout(250)
  34. await shot(page, 'usage')
  35. })
  36. test('quick prompt', async ({ page }) => {
  37. await page.setViewportSize({ width: 640, height: 300 })
  38. await page.emulateMedia({ colorScheme: 'dark' })
  39. await page.goto('/quick.html')
  40. await page.getByLabel('Quick prompt').fill('What should I index in SQL?')
  41. await page.getByLabel('Quick prompt').press('Enter')
  42. await expect(page.getByTestId('cost-line')).toBeVisible()
  43. await page.waitForTimeout(200)
  44. await page.screenshot({ path: 'docs/screenshots/quick-prompt.png' })
  45. })