-
Notifications
You must be signed in to change notification settings - Fork 21
chore(tests): visual regression tests for post-header
#6826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
alionazherdetska
wants to merge
19
commits into
main
Choose a base branch
from
visual-regression-tests-header
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
a32f849
initial setup
alionazherdetska b8e94c7
added test for one pager header
alionazherdetska f114473
added the tests for all the header variants
alionazherdetska 26b18f0
added the helpers
alionazherdetska 99d73c3
slight changes
alionazherdetska 0ebaad4
refactored tests
alionazherdetska a78e448
Merge branch 'main' into visual-regression-tests-header
alionazherdetska cb7b534
small refactors
alionazherdetska 4820c53
Update packages/components/visual-tests/components/post-header-jobs-lโฆ
alionazherdetska 4198ee9
Update packages/components/package.json
alionazherdetska db690f3
Update packages/components/visual-tests/components/post-header-jobs-lโฆ
alionazherdetska a35504f
Merge branch 'main' into visual-regression-tests-header
alionazherdetska fdb668c
Merge branch 'visual-regression-tests-header' of https://github.com/sโฆ
alionazherdetska 0a4251b
fixed sonar
alionazherdetska b166f79
fixed sonar
alionazherdetska afe421c
fixed sonar
alionazherdetska dac1559
Merge branch 'main' into visual-regression-tests-header
alionazherdetska f93480b
refactored the generate header script
alionazherdetska 19a4919
Merge branch 'main' into visual-regression-tests-header
alionazherdetska File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,91 @@ | ||
| name: Visual Regression Tests | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - 'packages/components/**' | ||
| push: | ||
| branches: | ||
| - main | ||
| paths: | ||
| - 'packages/components/**' | ||
| workflow_dispatch: | ||
| inputs: | ||
| update-snapshots: | ||
| description: 'Force update visual snapshots' | ||
| type: boolean | ||
| default: false | ||
|
|
||
| permissions: | ||
| contents: read | ||
| actions: read | ||
| pull-requests: read | ||
|
|
||
| jobs: | ||
| visual-tests-components: | ||
| name: Visual Tests - Components | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Setup | ||
| uses: ./.github/actions/setup-pnpm | ||
|
|
||
| - name: Install dependencies and build packages | ||
| run: pnpm bootstrap | ||
|
|
||
| - name: Install Playwright browsers | ||
| working-directory: packages/components | ||
| run: npx playwright install --with-deps | ||
|
|
||
| - name: Get baseline snapshots from cache | ||
| id: snapshot-cache | ||
| uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 | ||
| with: | ||
| path: packages/components/visual-tests/__screenshots__ | ||
| key: visual-snapshots-main-${{ hashFiles('packages/components/src/**/*.{tsx,ts,scss}') }} | ||
| restore-keys: | | ||
| visual-snapshots-main- | ||
|
|
||
| - name: Generate baseline snapshots | ||
| if: | | ||
| (github.ref == 'refs/heads/main' && steps.snapshot-cache.outputs.cache-hit != 'true') || | ||
| github.event.inputs.update-snapshots == 'true' | ||
| working-directory: packages/components | ||
| run: pnpm test:visual:update | ||
|
|
||
| - name: Optimize PNG screenshots | ||
| if: | | ||
| (github.ref == 'refs/heads/main' && steps.snapshot-cache.outputs.cache-hit != 'true') || | ||
| github.event.inputs.update-snapshots == 'true' | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y pngquant | ||
| find packages/components/visual-tests/__screenshots__ -name "*.png" -exec pngquant --force --ext .png --quality 80-95 {} \; | ||
|
|
||
alionazherdetska marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - name: Run visual regression tests | ||
| working-directory: packages/components | ||
| run: pnpm test:visual | ||
|
|
||
alionazherdetska marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - name: Upload test results | ||
| if: always() | ||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 | ||
| with: | ||
| name: playwright-report-components | ||
| path: packages/components/test-results | ||
| retention-days: 14 | ||
|
|
||
| - name: Upload diff screenshots | ||
| if: failure() | ||
| uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 | ||
| with: | ||
| name: playwright-screenshots-components | ||
| path: | | ||
| packages/components/test-results/**/*-diff.png | ||
| packages/components/test-results/**/*-actual.png | ||
| packages/components/test-results/**/*-expected.png | ||
| retention-days: 14 | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,55 @@ | ||
| import { defineConfig, devices } from '@playwright/test'; | ||
|
|
||
| export default defineConfig({ | ||
| testDir: './visual-tests', | ||
| timeout: 30000, | ||
|
|
||
| expect: { | ||
| toHaveScreenshot: { | ||
| threshold: 0.2, | ||
alionazherdetska marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| }, | ||
|
|
||
| fullyParallel: true, | ||
| forbidOnly: !!process.env.CI, | ||
| retries: process.env.CI ? 2 : 0, | ||
| workers: process.env.CI ? 1 : undefined, | ||
|
|
||
| reporter: [ | ||
| ['html', { outputFolder: 'test-results/html-report' }], | ||
| ['list'] | ||
| ], | ||
|
|
||
| snapshotPathTemplate: '{testDir}/__screenshots__/{projectName}/{testFilePath}/{arg}{ext}', | ||
|
|
||
| outputDir: 'test-results/artifacts', | ||
|
|
||
| use: { | ||
| baseURL: 'http://localhost:9300', | ||
| trace: 'on-first-retry', | ||
| screenshot: 'only-on-failure', | ||
| video: 'retain-on-failure', | ||
| }, | ||
|
|
||
| projects: [ | ||
| { | ||
| name: 'chromium', | ||
| use: { ...devices['Desktop Chrome'] }, | ||
| }, | ||
| { | ||
| name: 'firefox', | ||
| use: { ...devices['Desktop Firefox'] }, | ||
| }, | ||
| { | ||
| name: 'webkit', | ||
| use: { ...devices['Desktop Safari'] }, | ||
| }, | ||
| ], | ||
|
|
||
| webServer: { | ||
| command: 'npx http-server . -p 9300', | ||
| url: 'http://localhost:9300', | ||
| reuseExistingServer: true, | ||
| timeout: 60000, | ||
| }, | ||
| }); | ||
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.