Skip to content

Commit

Permalink
Fix wcag github action mapbox issues (#337)
Browse files Browse the repository at this point in the history
paired with the changes in this [PR](yext/slapshot-reusable-workflows#22) in WCAG workflow, this PR updates the WCAG github action in the repo to pass in the mapbox key. Also updated the wcag test to exclude checking elements coming from mapbox canvas container as any potential violations coming from there is outside of our repo's control.

WCAG github action also run on pull request to feature branch now.

J=SLAP-2458
TEST=auto

see that WCAG github action now passes
  • Loading branch information
yen-tt authored and nmanu1 committed Dec 2, 2022
1 parent a46128b commit 5a67086
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/wcag_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ name: WCAG tests

on:
pull_request:
branches: [main, develop]
branches: [main, develop, feature/*]

jobs:
call_wcag_test:
uses: yext/slapshot-reusable-workflows/.github/workflows/wcag_test.yml@v1
secrets:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
MAPBOX_API_KEY: ${{ secrets.MAPBOX_API_KEY }}
with:
build_script: ./tests/scripts/start-storybook.sh
34 changes: 21 additions & 13 deletions .storybook/test-runner.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
import { injectAxe, checkA11y } from 'axe-playwright';
import { Page } from 'playwright-core';
import { runOnly } from './wcagConfig';
import { TestContext, TestRunnerConfig } from '@storybook/test-runner';

/**
* 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 = {
const renderFunctions: TestRunnerConfig = {
async preRender(page: Page) {
await injectAxe(page);
},
async postRender(page: Page, context) {
await checkA11y(page, '#root', {
axeOptions: {
runOnly,
rules: {
'color-contrast': { enabled: context.name !== 'Loading' }
},
},
detailedReport: true,
detailedReportOptions: {
html: true,
async postRender(page: Page, context: TestContext) {
await checkA11y(
page,
{
include: ['#root'],
exclude: ['#root .mapboxgl-canvas-container'],
},
});
{
axeOptions: {
runOnly,
rules: {
'color-contrast': { enabled: context.name !== 'Loading' },
},
},
detailedReport: true,
detailedReportOptions: {
html: true,
},
}
);
},
};

Expand Down

0 comments on commit 5a67086

Please sign in to comment.