-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the visual regression snapshots to use the Storybook add-on `jest-image-snapshot` rather than Percy. We can now remove Percy from the repo entirely. The workflow now checks snapshots and commits any that have changed. Also, the play functions for stories are fixed so async actions are properly awaited. The loading state for the `Geolocation` component includes animation, so the snapshot doesn't match perfectly each time. To account for this, the threshold for failure for this story is increased to a 0.005% difference in the image rather than an exact match. We also use this threshold for `MapboxMap` stories because the map canvas can have slight changes. The `MapboxMap` component takes some time to load. I wasn't able to find a good way to detect the correct time to take a snapshot, so I added a 7500ms wait for these stories to give the map time to load before taking the snapshot. Adding more robust detection logic will be part of another [item](https://yexttest.atlassian.net/browse/BACK-2843). This item will also address the snapshot for the loading story for `LocationBias`. Right now, we skip taking a snapshot for this story because the snapshot is blank. This is likely because geolocation permissions are disabled for the test runner, so the request for the location is automatically denied. J=BACK-2832 TEST=auto
- Loading branch information
Showing
80 changed files
with
1,927 additions
and
8,236 deletions.
There are no files selected for viewing
This file was deleted.
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,37 @@ | ||
name: Update Snapshots | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
update_snapshots: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
ref: ${{ github.head_ref }} | ||
token: ${{ secrets.BOT_REPO_SCOPED_TOKEN }} | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18.x | ||
registry-url: 'https://registry.npmjs.org' | ||
- run: npm ci | ||
- run: npm run build | ||
- run: ./tests/scripts/start-storybook.sh | ||
env: | ||
MAPBOX_API_KEY: ${{ secrets.MAPBOX_API_KEY }} | ||
- run: npm run update-snapshots | ||
- name: Push changes | ||
id: push-changes | ||
uses: EndBug/add-and-commit@v9 | ||
with: | ||
message: "Update snapshots" | ||
add: ".storybook/snapshots/__snapshots__" | ||
push: true | ||
pull: --rebase --autostash | ||
default_author: github_actions | ||
- name: Fail job if push changes | ||
if: steps.push-changes.outputs.pushed == 'true' | ||
uses: actions/github-script@v3 | ||
with: | ||
script: | | ||
core.setFailed('Snapshot updates were made. A new commit with new snapshots was pushed.') |
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
Binary file added
BIN
+23.5 KB
...ook/snapshots/__snapshots__/alternativeverticals--display-all-on-no-results.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
+26.9 KB
.storybook/snapshots/__snapshots__/directanswer--address-field-value.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
+16.5 KB
.storybook/snapshots/__snapshots__/directanswer--complex-url-field-value.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
+27.1 KB
.storybook/snapshots/__snapshots__/directanswer--list-field-value.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
+17.3 KB
.storybook/snapshots/__snapshots__/directanswer--number-field-value.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
+17.9 KB
.storybook/snapshots/__snapshots__/directanswer--plain-text-featured-snippet.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
+16.7 KB
.storybook/snapshots/__snapshots__/directanswer--string-field-value.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
+8.68 KB
.storybook/snapshots/__snapshots__/dropdown--always-select-expanded.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
+15.6 KB
.storybook/snapshots/__snapshots__/filtersearch--dropdown-sectioned.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
+12.7 KB
.storybook/snapshots/__snapshots__/filtersearch--dropdown-unsectioned.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file added
BIN
+7.65 KB
.storybook/snapshots/__snapshots__/pagination--on-mid-page-with-ellipses.png
Oops, something went wrong.
Oops, something went wrong.
Binary file added
BIN
+7.41 KB
.storybook/snapshots/__snapshots__/pagination--paginate-all-on-no-results.png
Oops, something went wrong.
Oops, something went wrong.
Binary file added
BIN
+11.9 KB
.storybook/snapshots/__snapshots__/rangeinput--disabled-force-display-tooltip.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file added
BIN
+8.54 KB
.storybook/snapshots/__snapshots__/resultscount--pagination-range.png
Oops, something went wrong.
Oops, something went wrong.
Binary file added
BIN
+30.2 KB
.storybook/snapshots/__snapshots__/searchbar--dropdown-expanded-vertical-links.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Binary file added
BIN
+17.4 KB
.storybook/snapshots/__snapshots__/standardfacets--no-option-counts.png
Oops, something went wrong.
Oops, something went wrong.
Binary file added
BIN
+19.7 KB
.storybook/snapshots/__snapshots__/standardfacets--show-more-limit-clicked.png
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
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,9 @@ | ||
import baseConfig from '../main'; | ||
import type { StorybookConfig } from '@storybook/react-webpack5'; | ||
|
||
const config: StorybookConfig = { | ||
...baseConfig, | ||
stories: baseConfig.stories.map((glob) => `../${glob}`), | ||
}; | ||
|
||
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,37 @@ | ||
import { Page } from 'playwright-core'; | ||
import { TestRunnerConfig, TestContext } from '@storybook/test-runner'; | ||
import { toMatchImageSnapshot } from 'jest-image-snapshot'; | ||
|
||
const customSnapshotsDir = `${process.cwd()}/.storybook/snapshots/__snapshots__`; | ||
|
||
/** | ||
* See https://storybook.js.org/docs/react/writing-tests/test-runner#test-hook-api-experimental | ||
* to learn more about the test-runner hooks API. | ||
*/ | ||
const renderFunctions: TestRunnerConfig = { | ||
setup() { | ||
expect.extend({ toMatchImageSnapshot }); | ||
}, | ||
async postVisit(page: Page, context: TestContext) { | ||
if (context.id === 'locationbias--loading') { | ||
return; | ||
} | ||
|
||
const isMapboxMapStory = context.id.startsWith('mapboxmap--'); | ||
if (isMapboxMapStory) { | ||
await page.waitForTimeout(7500); | ||
} | ||
|
||
const image = await page.screenshot(); | ||
expect(image).toMatchImageSnapshot({ | ||
customSnapshotsDir, | ||
customSnapshotIdentifier: context.id, | ||
failureThreshold: context.id === 'geolocation--loading' || isMapboxMapStory | ||
? 0.005 | ||
: 0, | ||
failureThresholdType: 'percent' | ||
}); | ||
}, | ||
}; | ||
|
||
export default renderFunctions; |
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,9 @@ | ||
import baseConfig from '../main'; | ||
import type { StorybookConfig } from '@storybook/react-webpack5'; | ||
|
||
const config: StorybookConfig = { | ||
...baseConfig, | ||
stories: baseConfig.stories.map((glob) => `../${glob}`), | ||
}; | ||
|
||
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
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
Oops, something went wrong.