Skip to content

Commit

Permalink
Merge 8e581aa into f3c4ad0
Browse files Browse the repository at this point in the history
  • Loading branch information
nmanu1 committed Aug 4, 2022
2 parents f3c4ad0 + 8e581aa commit 0d25cca
Show file tree
Hide file tree
Showing 25 changed files with 966 additions and 2,574 deletions.
14 changes: 14 additions & 0 deletions .github/workflows/wcag_test.yml
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: ./tests/scripts/start-storybook.sh
6 changes: 2 additions & 4 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import './index.css';
import { SearchCoreDecorator } from '../tests/__fixtures__/core/SearchCore';
import { runOnly } from './wcagConfig';

export const parameters = {
actions: { argTypesRegex: '^on[A-Z].*' },
Expand All @@ -12,10 +13,7 @@ export const parameters = {
},
a11y: {
options: {
runOnly: {
type: 'tag',
values: ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa']
}
runOnly
}
},
options: {
Expand Down
29 changes: 29 additions & 0 deletions .storybook/test-runner.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { injectAxe, checkA11y } from 'axe-playwright';
import { Page } from 'playwright-core';
import { runOnly } from './wcagConfig';

/**
* 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 = {
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,
},
});
},
};

export default renderFunctions;
6 changes: 6 additions & 0 deletions .storybook/wcagConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { axeOptionsConfig } from 'axe-playwright';

export const runOnly: axeOptionsConfig['axeOptions']['runOnly'] = {
type: 'tag',
values: ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa']
};

0 comments on commit 0d25cca

Please sign in to comment.