-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #196 from wikimedia/bernard/wmf-a11y
Add a11y testing to pixel
- Loading branch information
Showing
12 changed files
with
824 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
report | ||
report-a11y | ||
package-lock.json | ||
coverage | ||
context.json |
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,58 @@ | ||
FROM node:16.15.1-bullseye | ||
|
||
ARG PA11Y_VERSION | ||
|
||
ENV \ | ||
PA11Y_VERSION=$PA11Y_VERSION | ||
|
||
# Base packages | ||
RUN apt-get update && \ | ||
apt-get install -y git sudo software-properties-common | ||
|
||
RUN set -ex && \ | ||
DEBIAN_VERSION=$(cat /etc/os-release | grep VERSION_ID | cut -d '=' -f2 | tr -d '"') && \ | ||
export DEBIAN_VERSION=$DEBIAN_VERSION && \ | ||
ARCH=`uname -m` && \ | ||
if [ "$ARCH" = "x86_64" ]; then \ | ||
sudo npm install -g --unsafe-perm=true --allow-root pa11y@${PA11Y_VERSION}; \ | ||
else \ | ||
sudo PUPPETEER_SKIP_DOWNLOAD=true PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true npm install -g --unsafe-perm=true --allow-root pa11y@${PA11Y_VERSION} && puppeteer-chromium-version-finder@^1.0.1 chromium-version-deb-finder@^2.0.1 && \ | ||
NODE_PATH="$(npm root -g):$(npm root -g)/backstopjs/node_modules" node -e " \ | ||
const versionFinder = require('puppeteer-chromium-version-finder'); \ | ||
const debFinder = require('chromium-version-deb-finder'); \ | ||
(async () => { \ | ||
const version = await versionFinder.getPuppeteerChromiumVersion(); \ | ||
const debUrls = await debFinder.getDebUrlsForVersionAndArch(version.MAJOR, version.MINOR, process.env.DEBIAN_VERSION, 'arm64'); \ | ||
console.log(debUrls.join('\n')); \ | ||
})(); \ | ||
" | \ | ||
xargs -I % sh -c 'set -x; echo "Downloading: %"; wget -c -t 10 -w 10 -T 120 %; echo "Downloaded: %"' && \ | ||
apt install -y ./*.deb && \ | ||
rm -f ./*.deb && \ | ||
sudo test -f /usr/bin/chromium && sudo ln -s /usr/bin/chromium /usr/bin/chromium-browser && sudo ln -s /usr/bin/chromium /usr/bin/chrome; \ | ||
fi | ||
|
||
RUN sudo npm install -g mustache | ||
|
||
RUN wget https://dl-ssl.google.com/linux/linux_signing_key.pub && sudo apt-key add linux_signing_key.pub | ||
RUN sudo add-apt-repository "deb http://dl.google.com/linux/chrome/deb/ stable main" | ||
|
||
RUN apt-get -qqy update \ | ||
&& apt-get -qqy --no-install-recommends install \ | ||
libxshmfence-dev \ | ||
libfontconfig \ | ||
libfreetype6 \ | ||
xfonts-cyrillic \ | ||
xfonts-scalable \ | ||
fonts-liberation \ | ||
fonts-ipafont-gothic \ | ||
fonts-wqy-zenhei \ | ||
libgbm-dev \ | ||
gconf-service libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxss1 libxtst6 libappindicator1 libnss3 libasound2 libatk1.0-0 libc6 ca-certificates fonts-liberation lsb-release xdg-utils wget \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& apt-get -qyy clean | ||
|
||
ENV NODE_PATH=/usr/local/lib/node_modules | ||
|
||
#ENTRYPOINT ["tail", "-f", "/dev/null"] | ||
ENTRYPOINT ["node", "src/a11y/runA11yTests.js"] |
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,48 @@ | ||
// @ts-nocheck | ||
const utils = require( './utils' ); | ||
|
||
const NAMESPACE = 'desktop'; | ||
const BASE_URL = process.env.PIXEL_MW_SERVER; | ||
|
||
const testDefaults = { | ||
viewport: { | ||
width: 1200, | ||
height: 1080 | ||
}, | ||
runners: [ | ||
'axe', | ||
'htmlcs' | ||
], | ||
includeWarnings: true, | ||
includeNotices: true, | ||
ignore: [ | ||
// Prevent axe-core from flagging all TOC links as incorrect color contrast | ||
'color-contrast', | ||
// Prevent contrast ratio error on absolutely positioned elements | ||
'WCAG2AA.Principle1.Guideline1_4.1_4_3.G18.Abs' | ||
], | ||
chromeLaunchConfig: { | ||
headless: true, | ||
args: [ | ||
'--no-sandbox', | ||
'--disable-setuid-sandbox' | ||
] | ||
} | ||
}; | ||
|
||
module.exports = { | ||
namespace: NAMESPACE, | ||
paths: utils.makeA11yPaths( NAMESPACE ), | ||
tests: [ | ||
{ | ||
name: 'default', | ||
url: BASE_URL + '/wiki/Test', | ||
...testDefaults | ||
}, | ||
{ | ||
name: 'logged_in', | ||
url: BASE_URL + '/wiki/Test', | ||
...testDefaults | ||
} | ||
] | ||
}; |
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
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,3 @@ | ||
# Ignore everything except this file | ||
* | ||
!.gitignore |
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,22 @@ | ||
<div id="{{type}}-{{name}}" class="container"> | ||
<h3>{{typeLabel}} ({{typeCount}})</h3> | ||
{{#codes}} | ||
<div class="message {{type}}"> | ||
<h4>{{message}}</h4> | ||
<p class="rule"><b>Rule:</b> {{runner}}, {{code}}</p> | ||
{{#runnerExtras}}<p><b>Impact:</b> {{impact}}</p>{{/runnerExtras}} | ||
<details class="details"> | ||
<summary> | ||
{{issueCount}} issue(s): | ||
</summary> | ||
<ul class="issues-list"> | ||
{{#issues}} | ||
<li class="issue"> | ||
<pre>{{selector}}<hr>{{context}}</pre> | ||
</li> | ||
{{/issues}} | ||
</ul> | ||
</details> | ||
</div> | ||
{{/codes}} | ||
</div> |
Oops, something went wrong.