-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using playwright to generate snapshots (#1589)
- Loading branch information
Showing
111 changed files
with
295 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
report/ | ||
results/ | ||
results.json |
Binary file added
BIN
+7.04 KB
...ght/screenshots/previews.test.ts-snapshots/primer/alpha/action_list/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+7.46 KB
...ght/screenshots/previews.test.ts-snapshots/primer/alpha/action_list/focused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.09 KB
...t/screenshots/previews.test.ts-snapshots/primer/alpha/auto_complete/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.15 KB
...t/screenshots/previews.test.ts-snapshots/primer/alpha/auto_complete/focused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.13 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/alpha/banner/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.13 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/alpha/banner/focused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.58 KB
...creenshots/previews.test.ts-snapshots/primer/alpha/button_marketing/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.54 KB
...creenshots/previews.test.ts-snapshots/primer/alpha/button_marketing/focused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.8 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/alpha/dialog/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.81 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/alpha/dialog/focused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+635 Bytes
...nshots/previews.test.ts-snapshots/primer/alpha/hidden_text_expander/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+684 Bytes
...nshots/previews.test.ts-snapshots/primer/alpha/hidden_text_expander/focused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+131 KB
...ight/screenshots/previews.test.ts-snapshots/primer/alpha/image_crop/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+131 KB
...ight/screenshots/previews.test.ts-snapshots/primer/alpha/image_crop/focused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.83 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/alpha/layout/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.83 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/alpha/layout/focused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+18.8 KB
...wright/screenshots/previews.test.ts-snapshots/primer/alpha/nav_list/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+19.2 KB
...wright/screenshots/previews.test.ts-snapshots/primer/alpha/nav_list/focused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.97 KB
...reenshots/previews.test.ts-snapshots/primer/alpha/segmented_control/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.99 KB
...reenshots/previews.test.ts-snapshots/primer/alpha/segmented_control/focused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.17 KB
...ight/screenshots/previews.test.ts-snapshots/primer/alpha/tab_panels/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.27 KB
...ight/screenshots/previews.test.ts-snapshots/primer/alpha/tab_panels/focused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.92 KB
...ight/screenshots/previews.test.ts-snapshots/primer/alpha/text_field/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.02 KB
...ight/screenshots/previews.test.ts-snapshots/primer/alpha/text_field/focused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.2 KB
...t/screenshots/previews.test.ts-snapshots/primer/alpha/toggle_switch/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.52 KB
...t/screenshots/previews.test.ts-snapshots/primer/alpha/toggle_switch/focused.png
Oops, something went wrong.
Binary file added
BIN
+1.86 KB
...ywright/screenshots/previews.test.ts-snapshots/primer/alpha/tooltip/default.png
Oops, something went wrong.
Binary file added
BIN
+2.03 KB
...ywright/screenshots/previews.test.ts-snapshots/primer/alpha/tooltip/focused.png
Oops, something went wrong.
Binary file added
BIN
+3.69 KB
...t/screenshots/previews.test.ts-snapshots/primer/alpha/underline_nav/default.png
Oops, something went wrong.
Binary file added
BIN
+4.06 KB
...t/screenshots/previews.test.ts-snapshots/primer/alpha/underline_nav/focused.png
Oops, something went wrong.
Binary file added
BIN
+3.94 KB
...creenshots/previews.test.ts-snapshots/primer/alpha/underline_panels/default.png
Oops, something went wrong.
Binary file added
BIN
+4.34 KB
...creenshots/previews.test.ts-snapshots/primer/alpha/underline_panels/focused.png
Oops, something went wrong.
Binary file added
BIN
+5.49 KB
...ht/screenshots/previews.test.ts-snapshots/primer/beta/auto_complete/default.png
Oops, something went wrong.
Binary file added
BIN
+5.5 KB
...ht/screenshots/previews.test.ts-snapshots/primer/beta/auto_complete/focused.png
Oops, something went wrong.
Binary file added
BIN
+2.28 KB
...reenshots/previews.test.ts-snapshots/primer/beta/auto_complete_item/default.png
Oops, something went wrong.
Binary file added
BIN
+2.28 KB
...reenshots/previews.test.ts-snapshots/primer/beta/auto_complete_item/focused.png
Oops, something went wrong.
Binary file added
BIN
+2.28 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/beta/avatar/default.png
Oops, something went wrong.
Binary file added
BIN
+2.28 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/beta/avatar/focused.png
Oops, something went wrong.
Binary file added
BIN
+1.37 KB
...ght/screenshots/previews.test.ts-snapshots/primer/beta/avatar_stack/default.png
Oops, something went wrong.
Binary file added
BIN
+1.37 KB
...ght/screenshots/previews.test.ts-snapshots/primer/beta/avatar_stack/focused.png
Oops, something went wrong.
Binary file added
BIN
+1.4 KB
...ight/screenshots/previews.test.ts-snapshots/primer/beta/base_button/default.png
Oops, something went wrong.
Binary file added
BIN
+1.38 KB
...ight/screenshots/previews.test.ts-snapshots/primer/beta/base_button/focused.png
Oops, something went wrong.
Binary file added
BIN
+3.83 KB
...right/screenshots/previews.test.ts-snapshots/primer/beta/blankslate/default.png
Oops, something went wrong.
Binary file added
BIN
+3.83 KB
...right/screenshots/previews.test.ts-snapshots/primer/beta/blankslate/focused.png
Oops, something went wrong.
Binary file added
BIN
+9.86 KB
...right/screenshots/previews.test.ts-snapshots/primer/beta/border_box/default.png
Oops, something went wrong.
Binary file added
BIN
+9.86 KB
...right/screenshots/previews.test.ts-snapshots/primer/beta/border_box/focused.png
Oops, something went wrong.
Binary file added
BIN
+4.13 KB
...ight/screenshots/previews.test.ts-snapshots/primer/beta/breadcrumbs/default.png
Oops, something went wrong.
Binary file added
BIN
+4.18 KB
...ight/screenshots/previews.test.ts-snapshots/primer/beta/breadcrumbs/focused.png
Oops, something went wrong.
Binary file added
BIN
+1.86 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/beta/button/default.png
Oops, something went wrong.
Binary file added
BIN
+1.83 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/beta/button/focused.png
Oops, something went wrong.
Binary file added
BIN
+4.7 KB
...ght/screenshots/previews.test.ts-snapshots/primer/beta/button_group/default.png
Oops, something went wrong.
Binary file added
BIN
+4.72 KB
...ght/screenshots/previews.test.ts-snapshots/primer/beta/button_group/focused.png
Oops, something went wrong.
Binary file added
BIN
+723 Bytes
...ght/screenshots/previews.test.ts-snapshots/primer/beta/close_button/default.png
Oops, something went wrong.
Binary file added
BIN
+774 Bytes
...ght/screenshots/previews.test.ts-snapshots/primer/beta/close_button/focused.png
Oops, something went wrong.
Binary file added
BIN
+1.58 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/beta/counter/default.png
Oops, something went wrong.
Binary file added
BIN
+1.58 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/beta/counter/focused.png
Oops, something went wrong.
Binary file added
BIN
+2.36 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/beta/details/default.png
Oops, something went wrong.
Binary file added
BIN
+2.35 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/beta/details/focused.png
Oops, something went wrong.
Binary file added
BIN
+4.12 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/beta/flash/default.png
Oops, something went wrong.
Binary file added
BIN
+4.12 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/beta/flash/focused.png
Oops, something went wrong.
Binary file added
BIN
+2.75 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/beta/heading/default.png
Oops, something went wrong.
Binary file added
BIN
+2.75 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/beta/heading/focused.png
Oops, something went wrong.
Binary file added
BIN
+1.54 KB
...ight/screenshots/previews.test.ts-snapshots/primer/beta/icon_button/default.png
Oops, something went wrong.
Binary file added
BIN
+1.74 KB
...ight/screenshots/previews.test.ts-snapshots/primer/beta/icon_button/focused.png
Oops, something went wrong.
Binary file added
BIN
+1.58 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/beta/label/default.png
Oops, something went wrong.
Binary file added
BIN
+1.58 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/beta/label/focused.png
Oops, something went wrong.
Binary file added
BIN
+1.6 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/beta/link/default.png
Oops, something went wrong.
Binary file added
BIN
+1.65 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/beta/link/focused.png
Oops, something went wrong.
Binary file added
BIN
+624 Bytes
...ght/screenshots/previews.test.ts-snapshots/primer/beta/progress_bar/default.png
Oops, something went wrong.
Binary file added
BIN
+624 Bytes
...ght/screenshots/previews.test.ts-snapshots/primer/beta/progress_bar/focused.png
Oops, something went wrong.
Binary file added
BIN
+1.13 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/beta/text/default.png
Oops, something went wrong.
Binary file added
BIN
+1.13 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/beta/text/focused.png
Oops, something went wrong.
Binary file added
BIN
+3.81 KB
...ywright/screenshots/previews.test.ts-snapshots/primer/beta/truncate/default.png
Oops, something went wrong.
Binary file added
BIN
+3.81 KB
...ywright/screenshots/previews.test.ts-snapshots/primer/beta/truncate/focused.png
Oops, something went wrong.
Binary file added
BIN
+769 Bytes
...wright/screenshots/previews.test.ts-snapshots/primer/clipboard_copy/default.png
Oops, something went wrong.
Binary file added
BIN
+676 Bytes
...wright/screenshots/previews.test.ts-snapshots/primer/clipboard_copy/focused.png
Oops, something went wrong.
Binary file added
BIN
+2.54 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/dropdown/default.png
Oops, something went wrong.
Binary file added
BIN
+2.53 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/dropdown/focused.png
Oops, something went wrong.
Binary file added
BIN
+723 Bytes
...ywright/screenshots/previews.test.ts-snapshots/primer/hellip_button/default.png
Oops, something went wrong.
Binary file added
BIN
+699 Bytes
...ywright/screenshots/previews.test.ts-snapshots/primer/hellip_button/focused.png
Oops, something went wrong.
Binary file added
BIN
+2.2 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/layout/default.png
Oops, something went wrong.
Binary file added
BIN
+2.2 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/layout/focused.png
Oops, something went wrong.
Binary file added
BIN
+4.51 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/local_time/default.png
Oops, something went wrong.
Binary file added
BIN
+4.51 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/local_time/focused.png
Oops, something went wrong.
Binary file added
BIN
+481 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/markdown/default.png
Oops, something went wrong.
Binary file added
BIN
+480 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/markdown/focused.png
Oops, something went wrong.
Binary file added
BIN
+8.49 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/menu/default.png
Oops, something went wrong.
Binary file added
BIN
+8.5 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/menu/focused.png
Oops, something went wrong.
Binary file added
BIN
+988 Bytes
.playwright/screenshots/previews.test.ts-snapshots/primer/octicon/default.png
Oops, something went wrong.
Binary file added
BIN
+988 Bytes
.playwright/screenshots/previews.test.ts-snapshots/primer/octicon/focused.png
Oops, something went wrong.
Binary file added
BIN
+9.9 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/popover/default.png
Oops, something went wrong.
Binary file added
BIN
+9.9 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/popover/focused.png
Oops, something went wrong.
Binary file added
BIN
+1.67 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/spinner/default.png
Oops, something went wrong.
Binary file added
BIN
+1.67 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/spinner/focused.png
Oops, something went wrong.
Binary file added
BIN
+2.33 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/state/default.png
Oops, something went wrong.
Binary file added
BIN
+2.33 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/state/focused.png
Oops, something went wrong.
Binary file added
BIN
+6.01 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/subhead/default.png
Oops, something went wrong.
Binary file added
BIN
+6.01 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/subhead/focused.png
Oops, something went wrong.
Binary file added
BIN
+1.1 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/time_ago/default.png
Oops, something went wrong.
Binary file added
BIN
+1.1 KB
.playwright/screenshots/previews.test.ts-snapshots/primer/time_ago/focused.png
Oops, something went wrong.
Binary file added
BIN
+2.79 KB
...ywright/screenshots/previews.test.ts-snapshots/primer/timeline_item/default.png
Oops, something went wrong.
Binary file added
BIN
+2.79 KB
...ywright/screenshots/previews.test.ts-snapshots/primer/timeline_item/focused.png
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Testing | ||
|
||
<!-- prettier-ignore-start --> | ||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
## Table of Contents | ||
|
||
- [Testing](#testing) | ||
- [Table of Contents](#table-of-contents) | ||
- [Overview](#overview) | ||
- [Prerequisites](#prerequisites) | ||
- [Continous Integration](#continous-integration) | ||
|
||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- prettier-ignore-end --> | ||
|
||
## Overview | ||
|
||
We use Playwright to run visual regression tests against our components along with automated accessibility checks. These tests are authored within the `test/playwright` directory and match the file pattern: | ||
`*.test.ts`. | ||
|
||
You can run these tests using Playwright locally but **we recommend you check the results** of | ||
these tests on GitHub through the CI workflow. | ||
|
||
To get started locally, make sure to follow the [Prerequisites](#prerequisites) | ||
section to setup your machine. If you're looking for a quick overview of the commands | ||
available, check out the table below. | ||
|
||
| Task | Command | | ||
| :---------------------------------------------------- | :---------------------------------------------- | | ||
| Run playwright tests | `npx playwright test` | | ||
| Run a specific test | `npx playwright test path/to/test` | | ||
| View the report from a test run | `npx playwright show-report .playwright/report` | | ||
|
||
## Prerequisites | ||
|
||
To run Playwright locally, it is recommended to open the repo in a codespace. This is to ensure that the browser | ||
rendering the screenshots will match the browser in CI. | ||
|
||
Once you have the codespace open, make sure you're up to date with `script/setup`. Then you can run the `npx playwright test` command. | ||
|
||
## Continous Integration | ||
|
||
Playwright tests are included in the `Tests > Visual Regressions` jobs of the CI workflow. | ||
The results of the test run are uploaded at the end of the job and are available | ||
to download and view locally. | ||
|
||
If you notice that `Tests > Visual Regressions` is failing, you can view the report of the | ||
failing run by visiting the CI workflow, clicking into the job that has failed | ||
and downloading the relevant report. | ||
|
||
When the workflow runs, it will check in screenshots of previews for visual diff checking. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// eslint-disable-next-line import/no-nodejs-modules | ||
import path from 'node:path' | ||
import type {PlaywrightTestConfig} from '@playwright/test' | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
const config: PlaywrightTestConfig = { | ||
testDir: path.join(__dirname, 'test', 'playwright'), | ||
testMatch: '**/*.test.ts', | ||
/* Maximum time one test can run for. */ | ||
timeout: 30 * 1000, | ||
|
||
// https://playwright.dev/docs/api/class-testconfig#test-config-output-dir | ||
outputDir: path.join(__dirname, '.playwright', 'results'), | ||
snapshotDir: path.join(__dirname, '.playwright', 'screenshots'), | ||
|
||
/* Run tests in files in parallel */ | ||
fullyParallel: true, | ||
workers: process.env.CI ? 4 : undefined, | ||
updateSnapshots: 'all', | ||
use: { | ||
baseURL: 'http://127.0.0.1:4000', | ||
browserName: 'chromium', | ||
headless: true, | ||
screenshot: 'only-on-failure' | ||
}, | ||
expect: { | ||
toHaveScreenshot: { | ||
animations: 'disabled' | ||
} | ||
}, | ||
/* Retry on CI only */ | ||
retries: process.env.CI ? 2 : 0, | ||
|
||
reporter: [ | ||
['line'], | ||
['html', {open: 'never', outputFolder: path.join(__dirname, '.playwright/report')}], | ||
['json', {outputFile: path.join(__dirname, '.playwright', 'results.json')}] | ||
], | ||
|
||
webServer: { | ||
command: 'cd demo; bin/rails s -p 4000', | ||
port: 4000 | ||
} | ||
} | ||
|
||
export default config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import {glob} from 'glob' | ||
|
||
// Previews we're ignoring because they're not ready to be tested yet | ||
const ignoredPreviews = ['primer/forms/forms'] | ||
|
||
interface ComponentPreview { | ||
componentName: string | ||
previewURL: string | ||
} | ||
|
||
export function componentPreviews(): ComponentPreview[] { | ||
// Glob for all the preview files | ||
const previews = glob.sync('previews/**/*_preview.rb') | ||
const result: ComponentPreview[] = [] | ||
|
||
for (const preview of previews) { | ||
// Remove prefixes and suffixes to get the component name and preview URL | ||
const previewURL = preview.replace('previews/', '').replace('_preview.rb', '').replace('_component', '') | ||
|
||
// If the preview is in the ignored list, skip it | ||
if (ignoredPreviews.includes(previewURL)) { | ||
continue | ||
} | ||
|
||
// Covert the preview URL to a component name ie. primer/beta/button => Primer::Beta::Button | ||
const componentName = previewURL | ||
.split('/') | ||
.map(module => { | ||
return module | ||
.split('_') | ||
.map(word => { | ||
return word[0].toUpperCase() + word.substring(1) | ||
}) | ||
.join('') | ||
}) | ||
.join('::') | ||
|
||
result.push({componentName, previewURL}) | ||
} | ||
return result | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
/* eslint-disable no-unused-vars */ | ||
import {test, expect} from '@playwright/test' | ||
import {componentPreviews} from './helpers' | ||
|
||
test.beforeEach(async ({page}, testInfo) => { | ||
testInfo.snapshotSuffix = '' | ||
}) | ||
|
||
for (const {componentName, previewURL} of componentPreviews()) { | ||
test(`renders ${componentName} preview`, async ({page}) => { | ||
await page.goto(`/lookbook/preview/${previewURL}/default`) | ||
const defaultScreenshot = await page.locator('#component-preview').screenshot({animations: 'disabled'}) | ||
expect(defaultScreenshot).toMatchSnapshot([previewURL, 'default.png']) | ||
|
||
// Focus state | ||
await page.keyboard.press('Tab') | ||
const focusedScreenshot = await page.locator('#component-preview').screenshot({animations: 'disabled'}) | ||
expect(focusedScreenshot).toMatchSnapshot([previewURL, 'focused.png']) | ||
}) | ||
} |