32 lines
1.5 KiB
TypeScript
32 lines
1.5 KiB
TypeScript
|
|
/**
|
||
|
|
* Visual regression tests against Storybook stories.
|
||
|
|
*
|
||
|
|
* Run: npx playwright test --config=e2e/visual.config.ts
|
||
|
|
* First run creates baseline screenshots; subsequent runs compare.
|
||
|
|
*/
|
||
|
|
|
||
|
|
import { test, expect } from '@playwright/test'
|
||
|
|
|
||
|
|
const STORIES = [
|
||
|
|
{ name: 'Avatar', path: '/iframe.html?id=components-avatar--default' },
|
||
|
|
{ name: 'ChatMessage-User', path: '/iframe.html?id=components-chatmessage--user-message' },
|
||
|
|
{ name: 'ChatMessage-Assistant', path: '/iframe.html?id=components-chatmessage--assistant-message' },
|
||
|
|
{ name: 'ChatMessage-Code', path: '/iframe.html?id=components-chatmessage--with-code-block' },
|
||
|
|
{ name: 'Markdown-Basic', path: '/iframe.html?id=components-markdown--basic-text' },
|
||
|
|
{ name: 'Markdown-Code', path: '/iframe.html?id=components-markdown--code-block' },
|
||
|
|
{ name: 'Skeleton-Single', path: '/iframe.html?id=components-skeleton--single-line' },
|
||
|
|
{ name: 'Skeleton-Multi', path: '/iframe.html?id=components-skeleton--multiple-lines' },
|
||
|
|
{ name: 'Toast-Info', path: '/iframe.html?id=components-toast--info' },
|
||
|
|
{ name: 'Toast-Error', path: '/iframe.html?id=components-toast--error' },
|
||
|
|
{ name: 'FilePreview-Text', path: '/iframe.html?id=components-filepreview--text-file' },
|
||
|
|
{ name: 'FilePreview-Image', path: '/iframe.html?id=components-filepreview--image-file' },
|
||
|
|
]
|
||
|
|
|
||
|
|
for (const story of STORIES) {
|
||
|
|
test(`Visual: ${story.name}`, async ({ page }) => {
|
||
|
|
await page.goto(story.path)
|
||
|
|
await page.waitForLoadState('networkidle')
|
||
|
|
await expect(page).toHaveScreenshot(`${story.name}.png`)
|
||
|
|
})
|
||
|
|
}
|