Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessibility audit test #10513

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
dc8d2b1
Accessibility audit test
kodster28 Aug 30, 2023
b7740b4
rework check
kodster28 Aug 30, 2023
1494f0c
Update
kodster28 Aug 30, 2023
4251a8a
extra line at end
kodster28 Aug 30, 2023
45745b6
change trigger?
kodster28 Aug 30, 2023
6113cbd
Test both implementations simultaneously
kodster28 Aug 30, 2023
49afc8e
fix error
kodster28 Aug 30, 2023
cda6bc9
test again
kodster28 Aug 30, 2023
e07860b
replace with async
kodster28 Aug 30, 2023
fc3b9d5
Use pre-built action
kodster28 Aug 30, 2023
4b4ca07
fix version
kodster28 Aug 30, 2023
2e898ed
test fix for script
kodster28 Aug 30, 2023
8f8dae0
Test another implementation
kodster28 Aug 30, 2023
bc46a06
Test
kodster28 Aug 30, 2023
1a7f114
another test
kodster28 Aug 30, 2023
b0f9bdb
One more test
kodster28 Aug 30, 2023
9bd3e7b
Have two runners
kodster28 Aug 31, 2023
44a363c
small updates
kodster28 Aug 31, 2023
7335006
check dark mode too
kodster28 Aug 31, 2023
d4d1377
comment out a bit to test dark mode
kodster28 Aug 31, 2023
d51c3d8
add another comment
kodster28 Aug 31, 2023
e70a49b
whoops
kodster28 Aug 31, 2023
148d061
test another way
kodster28 Aug 31, 2023
c7dd22e
Remove notices
kodster28 Aug 31, 2023
e9ac25e
One more
kodster28 Aug 31, 2023
3d1d1f1
another error
kodster28 Aug 31, 2023
4e103a7
double quotes?
kodster28 Aug 31, 2023
0d1d153
Test another version
kodster28 Aug 31, 2023
f38ba3c
Remove dark mode tests
kodster28 Aug 31, 2023
9af233c
Test
kodster28 Aug 31, 2023
e83b83b
error fix
kodster28 Aug 31, 2023
ea573d2
print out all the results
kodster28 Sep 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/test-accessibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Accessibility

# **What it does**: Regularly audits our live site for accessibility issues
# **Why we have it**: Because this is too time-consuming for a commit-level check, but absolutely something we should pay attention to.
# **Who does it impact**: PCX team / FE dev.

on:
pull_request:
branches:
- production
schedule:
- cron: '0 0 1 * *' # This cron expression triggers the workflow at 00:00 on the 1st day of every month
workflow_dispatch:

jobs:
test:
name: Test accessibility
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.1

- name: Install dependencies
run: npm install @actions/core pa11y puppeteer

- name: Run accessibility test
id: test-accessibility
run: npm run test-accessibility
44 changes: 44 additions & 0 deletions bin/accessibility-check.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import pa11y from "pa11y";
import puppeteer from "puppeteer";
import core from "@actions/core";

const navigationTimeout = 120000; // Set the navigation timeout to 120 seconds (120,000 milliseconds)
let resultsArray = [];
let printArray = [];

async function checkLinks() {
const browser = await puppeteer.launch({
headless: "new",
});
const page = await browser.newPage();

const sitemapUrl = "https://developers.cloudflare.com/sitemap.xml";
await page.goto(sitemapUrl, { timeout: navigationTimeout });

const sitemapLinks = await page.$$eval("url loc", (elements) =>
elements.map((el) => el.textContent)
);

for (const link of sitemapLinks) {
if (!link) {
continue; // Skip if the link is empty
} else if (link.includes("/support/other-languages/")) {
continue; // Skip if the link is in a certain section
}

const testPage = await browser.newPage();
let result = await pa11y(link, {
browser,
page: testPage,
runners: ["axe", "htmlcs"],
});
console.log(result)

await testPage.close();
}
await page.close();
await browser.close();
console.log(resultsArray)
}

checkLinks();
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"scripts": {
"algolia-crawl": "node bin/algolia-crawl.js",
"crawl-api-links": "node bin/crawl-api-links.js",
"test-accessibility": "node bin/accessibility-check.js",
"dev:hugo": "hugo --environment development -D -w",
"dev:wrangler": "wrangler pages dev -- vite",
"dev:vite": "vite",
Expand Down
Loading