-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add WCAG PR check #274
Merged
Merged
Add WCAG PR check #274
Changes from 16 commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
37874b6
Add WCAG PR check
nmanu1 8780aec
Automated update to THIRD-PARTY-NOTICES from github action's 3rd part…
github-actions[bot] a1c7241
Try sleeping
nmanu1 16c8437
Sleep longer
nmanu1 9882621
Fix wrong port and update package versions
nmanu1 4dc074b
Revert "Fix wrong port and update package versions"
nmanu1 931c341
Fix port and update some imports
nmanu1 e983c1e
Remove build
nmanu1 8dfe7c7
Remove extra steps
nmanu1 6012358
Bump some package versions
nmanu1 9fcac7f
Update more packages
nmanu1 cd16587
Bump a11y
nmanu1 fe13233
Bump actions
nmanu1 b7d9c6e
Bump links to 6.5.0
nmanu1 ea9fa1c
Upgrade percy
nmanu1 bfaae61
Bump links to 6.5.9
nmanu1 301c281
Try smoke-test
nmanu1 1123603
Revert "Try smoke-test"
nmanu1 1c0172f
Try bash script
nmanu1 6402c37
Try wrapping script
nmanu1 a7c0dbc
Try one long line
nmanu1 8bc9017
Remove |
nmanu1 4e77d97
Semicolons
nmanu1 6110549
Shorten
nmanu1 5e59685
Update packages and use TS
nmanu1 022bf2a
Upgrade percy/storybook
nmanu1 740ae60
Format and make quiet
nmanu1 cc9c956
Export default
nmanu1 e23d88c
Merge branch 'main' into dev/wcag-pr-check
nmanu1 5043813
Reuse script
nmanu1 ee5e7cf
Fix paths
nmanu1 7bd00a5
Try npm run command
nmanu1 212892a
oops
nmanu1 174bcba
Try some TS
nmanu1 074458d
Revert "Try some TS"
nmanu1 2fadcdd
Fix spacing
nmanu1 14ca6f8
Add asterisk
nmanu1 31f31fa
Abstract out wcag config
nmanu1 8e581aa
Update package-lock
nmanu1 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 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,14 @@ | ||
name: WCAG tests | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
call_wcag_test: | ||
uses: yext/slapshot-reusable-workflows/.github/workflows/wcag_test.yml@v1 | ||
secrets: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
with: | ||
build_script: 'npm run storybook & sleep 10 && curl http://localhost:6006 -I' | ||
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,35 @@ | ||
const { injectAxe, checkA11y } = require('axe-playwright'); | ||
oshi97 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const config = { | ||
runOnly: { | ||
type: 'tag', | ||
values: ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa'] | ||
} | ||
}; | ||
|
||
/* | ||
* See https://storybook.js.org/docs/react/writing-tests/test-runner#test-hook-api-experimental | ||
* to learn more about the test-runner hooks API. | ||
*/ | ||
module.exports = { | ||
async preRender(page) { | ||
await injectAxe(page); | ||
}, | ||
async postRender(page, context) { | ||
const axeOptions = context.name === 'Loading' | ||
alextaing marked this conversation as resolved.
Show resolved
Hide resolved
|
||
? { | ||
...config, | ||
rules: { | ||
'color-contrast': { enabled: false } | ||
} | ||
} | ||
: config; | ||
await checkA11y(page, '#root', { | ||
axeOptions, | ||
detailedReport: true, | ||
detailedReportOptions: { | ||
html: true, | ||
}, | ||
}); | ||
}, | ||
}; |
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.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sure you looked into this but can we avoid the
sleep 10
? Maybe some option in start-storybook?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I tried finding a way to not use
sleep
and checked again in thestart-storybook
options. The closest option to what we want is --smoke-test, but that stops serving the site once it successfully starts. We need the site to be running when thetest-storybook
command is run. The only other way I saw to do this as part of a GH workflow was either to host the site somewhere public, or involved setting up service containers. Service containers seemed like they might be overkill, but I can look into it moreThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is something like this possible? I don't have any experience trying stuff like this https://stackoverflow.com/questions/21475639/wait-until-service-starts-in-bash-script
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure! I updated it to be a while loop instead so it keeps checking every second, instead of having an arbitrary sleep time of 10 seconds
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! this is very cool