-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace pa11y with underlying HTML_CodeSniffer (#285)
* Replace pa11y with underlying HTML_CodeSniffer **Why**: - It currently duplicates and sometimes conflicts with our integration testing setup - Currently, we run two separate versions of Puppeteer, which each download separate copies of Chromium - Also helps me to avoid debugging a vague error occurring when upgrading dependencies to latest version - Consolidates testing tools to Jest - A step toward alignment of accessibility integration testing, as it could be reasonably substituted with aXe - Easier to run individual tests, which was difficult before since Jest setup occurred through scripts/jest.sh and did not support additional arguments. Now, test commands can go directly through the Jest CLI. - Fewer dependencies overall * Remove deleted accessibility job * Swap test-jest npm script with test * Remove unused pa11y configuration file
Showing
11 changed files
with
64 additions
and
1,726 deletions.
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
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
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
Large diffs are not rendered by default.
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
This file was deleted.
Oops, something went wrong.
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,35 @@ | ||
/* eslint-disable no-await-in-loop */ | ||
|
||
import path from 'path'; | ||
import { getURLsFromSitemap } from './support/sitemap'; | ||
|
||
const MESSAGE_TYPE_ERROR = 1; | ||
|
||
test('accessibility', async () => { | ||
const urls = await getURLsFromSitemap(); | ||
|
||
for (const url of urls) { | ||
await page.goto(url); | ||
await page.addScriptTag({ | ||
path: path.resolve(__dirname, '../node_modules/html_codesniffer/build/HTMLCS.js'), | ||
}); | ||
const messages = await page.evaluate( | ||
() => | ||
new Promise((resolve, reject) => { | ||
window.HTMLCS.process('WCAG2AA', window.document, (error) => { | ||
if (error) { | ||
reject(error); | ||
} else { | ||
resolve(window.HTMLCS.getMessages()); | ||
} | ||
}); | ||
}), | ||
); | ||
|
||
for (const message of messages) { | ||
if (message.type === MESSAGE_TYPE_ERROR) { | ||
throw message; | ||
} | ||
} | ||
} | ||
}, 1000000); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const LOCAL_HOST = `http://localhost:${process.env.JEST_PORT}`; | ||
const REMOTE_HOST = 'https://design.login.gov'; | ||
|
||
function getNormalizedURL(url) { | ||
return url.replace(REMOTE_HOST, LOCAL_HOST); | ||
} | ||
|
||
export async function getURLsFromSitemap() { | ||
await page.goto(`${LOCAL_HOST}/sitemap.xml`); | ||
const urls = await page.$$eval('url loc', (locs) => locs.map((loc) => loc.textContent)); | ||
return urls.map(getNormalizedURL); | ||
} |