Skip to content

Commit

Permalink
feat: attach testinfo on finish
Browse files Browse the repository at this point in the history
  • Loading branch information
dtsanevmw committed Jul 3, 2024
1 parent 820086c commit 81d2cf0
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,10 @@ jobs:
- name: Discover Stories
run: npm run ts-node -- ./scripts/write-story-list.ts
- name: Run Accessibility Tests on Storybook
run: npx playwright test --retries=0 ./tests/accessibility.spec.ts
run: npx playwright test --retries=0 --reporter=html ./tests/accessibility.spec.ts
- name: Upload Changes
if: success() || failure()
uses: actions/upload-artifact@v3
with:
name: accessibility-report-${{matrix.browser}}.html
path: playwright-report/index.html
2 changes: 2 additions & 0 deletions .github/workflows/pr-comment-bot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ jobs:
* 🎉 The build for this PR has succeeded
* 🔍 The PR is now ready for review
* 🍿 In the meantime, view a [preview of this PR](https://${{steps.get-pr-event.outputs.pullRequestNumber}}--${{secrets.NETLIFY_SITE_NAME}}.netlify.app)
* 🔍 Review the [report](https://${{steps.get-pr-event.outputs.pullRequestNumber}}-a11y-report--${{secrets.NETLIFY_SITE_NAME}}.netlify.app) of a11y testing.
* 🖐 You can always follow up here. If you're a VMware employee, you can also reach us on our [internal Clarity Support space](https://chat.google.com/room/AAAA5GLgPr4)
Thank you,
Expand All @@ -80,6 +81,7 @@ jobs:
* 😭 The build for this PR has failed
* 🗒 Please check out the [build log](${{github.event.workflow_run.html_url}})
* 🍿 Although the build failed, you can still view a [preview of this PR](https://${{steps.get-pr-event.outputs.pullRequestNumber}}--${{secrets.NETLIFY_SITE_NAME}}.netlify.app)
* 🔍 Review the [report](https://${{steps.get-pr-event.outputs.pullRequestNumber}}-a11y-report--${{secrets.NETLIFY_SITE_NAME}}.netlify.app) of a11y testing.
* 🖐 You can always follow up here. If you're a VMware employee, you can also reach us on our [internal Clarity Support space](https://chat.google.com/room/AAAA5GLgPr4)
Thank you,
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/pr-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,10 @@ jobs:
NETLIFY_SITE_ID: ${{secrets.NETLIFY_SITE_ID}}
NETLIFY_AUTH_TOKEN: ${{secrets.NETLIFY_AUTH_TOKEN}}
run: npx netlify-cli deploy --alias ${{steps.get-pr-event.outputs.pullRequestNumber}}
- name: Deploy A11y Test Report
if: ${{steps.download-docs.outputs.found_artifact == 'true'}}
timeout-minutes: 5
env:
NETLIFY_SITE_ID: ${{secrets.NETLIFY_SITE_ID}}
NETLIFY_AUTH_TOKEN: ${{secrets.NETLIFY_AUTH_TOKEN}}
run: npx netlify-cli deploy --dir=/playwright-report --alias ${{steps.get-pr-event.outputs.pullRequestNumber}}-a11y-report
7 changes: 6 additions & 1 deletion tests/accessibility.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ for (const { storyId, component } of stories) {
for (const [_themeKey, theme] of Object.entries(THEMES)) {
test(`${storyName} ${theme} should not have any automatically detectable WCAG A or AA violations`, async ({
page,
}) => {
}, testInfo) => {
const storyParams = new URLSearchParams({
id: storyId,
args: 'highlight:false',
Expand All @@ -38,6 +38,11 @@ for (const { storyId, component } of stories) {
.withTags(['wcag2aa', 'wcag21aa', 'wcag22aa'])
.analyze();

await testInfo.attach('accessibility-scan-results', {
body: JSON.stringify(accessibilityScanResults, null, 2),
contentType: 'application/json',
});

expect(accessibilityScanResults.violations).toEqual([]);
});
}
Expand Down

0 comments on commit 81d2cf0

Please sign in to comment.