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

Add pa11y-ci for automated accessibility tests with htmlcs runner #2

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

julien-deramond
Copy link
Owner

@julien-deramond julien-deramond commented Oct 21, 2021

This Draft PR is originated from both twbs#29315 and Boosted use of pa11y / pa11y-ci

Run

Local

CLI mode

$ npm run docs accessibility-cli

  Your application is ready~! 🚀

  - Local:      http://localhost:9001
  - Network:    Add `--host` to expose

────────────────── LOGS ──────────────────

  [21:38:50] 200 ─ 3.85ms ─ /sitemap.xml
Running Pa11y on 137 URLs:
  [21:38:50] 200 ─ 4.32ms ─ /docs/5.1/about/overview/
  [21:38:50] 200 ─ 6.26ms ─ /docs/5.1/getting-started/accessibility/
  [21:38:50] 200 ─ 2.97ms ─ /docs/5.1/assets/css/docs.css
  [21:38:50] 200 ─ 3.45ms ─ /docs/5.1/dist/css/bootstrap.min.css
  [21:38:50] 200 ─ 1.41ms ─ /docs/5.1/assets/js/docs.min.js
  [21:38:50] 200 ─ 1.96ms ─ /docs/5.1/dist/js/bootstrap.bundle.min.js
 > http://localhost:9001/docs/5.1/about/overview/ - 8 errors
  [21:38:53] 200 ─ 1.25ms ─ /docs/5.1/components/accordion/
 > http://localhost:9001/docs/5.1/getting-started/accessibility/ - 8 errors
  [21:38:54] 200 ─ 0.71ms ─ /docs/5.1/examples/album/
 > http://localhost:9001/docs/5.1/examples/album/ - 0 errors
  [21:38:56] 200 ─ 1.12ms ─ /docs/5.1/components/alerts/
c > http://localhost:9001/docs/5.1/components/accordion/ - 8 errors
  [21:38:58] 200 ─ 0.64ms ─ /docs/5.1/extend/approach/

JSON mode

$ npm run docs-accessibility-json # Will generate `pa11y-ci-results.json`
$ npm run docs-pa11y-html

Focus on a specific page

diff --git a/build/.pa11yci.json b/build/.pa11yci.json
index a5b3d1e96..beb85877a 100644
--- a/build/.pa11yci.json
+++ b/build/.pa11yci.json
@@ -7,5 +7,8 @@
       "axe"
     ],
     "hideElements": ".bd-search"
-  }
+  },
+  "urls": [
+    "http://localhost:9001/docs/5.1/about/overview"
+  ]
 }
\ No newline at end of file
diff --git a/package.json b/package.json
index af3305af2..99b7e0733 100644
--- a/package.json
+++ b/package.json
@@ -35,8 +35,8 @@
     "css-prefix-main": "postcss --config build/postcss.config.js --replace \"dist/css/*.css\" \"!dist/css/*.rtl*.css\" \"!dist/css/*.min.css\"",
     "css-prefix-examples": "postcss --config build/postcss.config.js --replace \"site/content/**/*.css\"",
     "css-prefix-examples-rtl": "cross-env-shell NODE_ENV=RTL postcss --config build/postcss.config.js --dir \"site/content/docs/$npm_package_config_version_short/examples/\" --ext \".rtl.css\" --base \"site/content/docs/$npm_package_config_version_short/examples/\" \"site/content/docs/$npm_package_config_version_short/examples/{blog,carousel,dashboard,cheatsheet}/*.css\" \"!site/content/docs/$npm_package_config_version_short/examples/{blog,carousel,dashboard,cheatsheet}/*.rtl.css\"",
-    "docs-pa11y-cli": "delay 3 && pa11y-ci --config build/.pa11yci.json --sitemap http://localhost:9001/sitemap.xml --sitemap-find https://getbootstrap.com/ --sitemap-replace http://localhost:9001/",
-    "docs-pa11y-json": "delay 3 && pa11y-ci --config build/.pa11yci.json --sitemap http://localhost:9001/sitemap.xml --sitemap-find https://getbootstrap.com/ --sitemap-replace http://localhost:9001/ --json > pa11y-ci-results.json",
+    "docs-pa11y-cli": "delay 3 && pa11y-ci --config build/.pa11yci.json",
+    "docs-pa11y-json": "delay 3 && pa11y-ci --config build/.pa11yci.json --json > pa11y-ci-results.json",
     "docs-pa11y-html": "pa11y-ci-reporter-html",
     "docs-accessibility-cli": "npm-run-all --parallel --race docs-serve-only docs-pa11y-cli",
     "docs-accessibility-json": "npm-run-all --parallel --race docs-serve-only docs-pa11y-json",

GitHub CI

At the end, you can retrieve the HTML report:

Screenshot from 2021-10-20 21-35-25

Then, open the index.html file in the .zip file:

Screenshot from 2021-10-20 21-37-40

Topics to tackle

Find a way to use the HTML reporter but still log the results in CLI

It seems possible in the master branch of pa11y-ci via pa11y/pa11y-ci@5c842cf that allows multiple reporters.

We should be able to do something like:

{
    "defaults": {
        "reporters": [
            "cli",
            "pa11y-reporter-html" // or "json" maybe
        ]
    },

But we would have to wait for the 2.4.3 or 2.5.0 to be released.

For the moment, the CLI version is only available locally.

pa11y-ci crashes

XhmikosR: "due to our JS using ES6+, the puppeteer version pa11y-ci depends on is currently crashing. :/ We need them to cut a new pa11ci release with the update pa11y package at version 6."

See if we can use npx maybe, since Chromium is a huge download or see if we can cache puppeteer on CI

XhmikosR: "I don't want the huge puppeteer (which in turn downloads Chromium) devDependency, ~143MB... Not sure how to work around this, we could probably move the needed packages in the Action that needs them, but it's not a perfect solution either"

Which runner?

  • axe like Boosted?
  • htmlcs like Bootstrap POC
  • both?
  • others if any?

htmlcs runner: Analyze and fix the errors or use hideElements when necessary

Tests of the 21st of October

Total without any hideElements: 568 errors

First detected in Error Path HTML element hideElements rule Errors removed Fix (PR reference) or not?
/docs/5.1/about/overview/ This form does not contain a submit button, which creates issues for those who cannot submit the form using the keyboard. Submit buttons are INPUT elements with type attribute "submit" or "image", or BUTTON elements with type "submit" or omitted/invalid (html > body > nav > div > form) <form class="bd-search position-relative me-auto"> <span class="algolia-aut...</form> .bd-search 99 -
/docs/5.1/about/overview/ This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 4.45:1. Recommendation: change background to #fafbfc. (html > body > footer > div > div > div:nth-child(1) > ul > li:nth-child(1)) <li class="mb-2">Designed and built with all the...</li> footer > div > div > div:nth-child(1) > ul > li 306 -
/docs/5.1/examples/blog/ This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 4.27:1. Recommendation: change background to #fff. (html > body > footer > p:nth-child(1) > a:nth-child(1)) <a href="https://getbootstrap.com/">Bootstrap</a> footer > p > a 6 -
/docs/5.1/about/brand/ This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 4.3:1. Recommendation: change background to #feffff. (html > body > div:nth-child(4) > main > div:nth-child(3) > div:nth-child(9) > div:nth-child(1) > strong) <strong class="text-success">Correct</strong> div:nth-child(4) > main > div:nth-child(3) > div:nth-child(9) > div > strong 3 -
/docs/5.1/components/buttons This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 1.63:1. Recommendation: change text colour to #967100. (html > body > div:nth-child(4) > main > div:nth-child(3) > div:nth-child(17) > button:nth-child(5)) (but also number 6 and 7) <button type="button" class="btn btn-outline-warning">Warning</button> button.btn.btn-outline-warning, button.btn.btn-outline-info, button.btn.btn-outline-light 12 -
/docs/5.1/examples/carousel/ This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 3.4:1. Recommendation: change background to twbs#10509. (#navbarCollapse > form > button) <button class="btn btn-outline-success" type="submit">Search</button> nav.navbar-dark.bg-dark button.btn.btn-outline-success 6 -
/docs/5.1/examples/cheatsheet/ This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 4.45:1. Recommendation: change background to #fafbfc. (html > body > aside > h2) <h2 class="h6 pt-4 pb-3 mb-4 border-bottom">On this page</h2> aside > h2 2 -
/docs/5.1/examples/cheatsheet/ Fieldset does not contain a legend element. All fieldsets should contain a legend element that describes a description of the field group. (#disabled-forms > div:nth-child(2) > div > form > fieldset) <fieldset disabled="" aria-label="Disabled fieldset example"> <div class="mb-3">...</fieldset> fieldset *:not(legend) doesn't seem to work so #disabled-forms > div:nth-child(2) > div > form > fieldset 2 -
/docs/5.1/examples/cheatsheet/ This form does not contain a submit button, which creates issues for those who cannot submit the form using the keyboard. Submit buttons are INPUT elements with type attribute "submit" or "image", or BUTTON elements with type "submit" or omitted/invalid. (#floating-labels > div:nth-child(2) > div > form) <form> <div class="form-flo...</form> form:not(:has(> [type=submit])) doesn't work so #floating-labels > div:nth-child(2) > div > form 2 -
/docs/5.1/examples/cheatsheet/ This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 4.27:1. Recommendation: change background to #fff. (#navbar-example2 > ul > li:nth-child(2) > a) <a class="nav-link" href="#scrollspyHeading2">Second</a> .navbar.navbar-light > .nav.nav-pills > li > a.nav-link 6 -
/docs/5.1/examples/checkout/ This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 4.3:1. Recommendation: change background to #feffff. (html > body > div > main > div:nth-child(2) > div:nth-child(1) > ul > li:nth-child(4) > div > h6) <h6 class="my-0">Promo code</h6> .bg-light > .text-success 6 -
/docs/5.1/components/dropdowns/ This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 2.07:1. Recommendation: change text colour to #6f777f. (html > body > div:nth-child(4) > main > div:nth-child(3) > div:nth-child(79) > ul > li:nth-child(2) > a) <a class="dropdown-item disabled">Disabled link</a> ul.dropdown-menu > li > a.dropdown-item.disabled 1 -
/docs/5.1/helpers/colored-links/ This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 1.63:1. Recommendation: change text colour to #967100 (html > body > div:nth-child(4) > main > div:nth-child(2) > div:nth-child(2) > a:nth-child(5)) <a href="#" class="link-warning">Warning link</a> (same thing for link-info and link-light) (see outline buttons) a.link-warning, a.link-info, a.link-light 3 -
/docs/5.1/components/navbar/ This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 4.3:1. Recommendation: change background to #feffff. (#navbarSupportedContent > form > button) <button class="btn btn-outline-success" type="submit">Search</button> (same for btn-outline-secondary and btn-outline-primary) nav.navbar.navbar-light.bg-light .btn.btn-outline-success, nav.navbar.navbar-light.bg-light .btn.btn-outline-secondary, nav.navbar.navbar-light .btn.btn-outline-primary 10 -
/docs/5.1/components/list-group/ Duplicate id attribute value "constructor" found on the web page. (#constructor) <h4 id="constructor">constructor<a class="anchorjs-l...</h4> (I chose one to hide) h4#constructor 2 -
/docs/5.1/examples/list-groups/ This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 4.45:1. Recommendation: change background to #fafbfc. (html > body > div:nth-child(6) > label:nth-child(4) > span > small) <small class="d-block text-muted"> <svg class="bi me-1" w...</small> label.bg-light .text-muted 1
/docs/5.1/components/scrollspy This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 4.27:1. Recommendation: change background to #fff. (#navbar-example3 > nav > nav:nth-child(2) > a:nth-child(1)) <a class="nav-link ms-3 my-1" href="#item-1-1">Item 1-1</a> nav.navbar-light.bg-light nav.nav.nav-pills > a.nav-link 6
/docs/5.1/examples/dashboard/ This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 4.45:1. Recommendation: change background to #fafbfc. (#sidebarMenu > div > h6 > span) <span>Saved reports</span> .sidebar.bg-light .text-muted 2
/docs/5.1/forms/floating-labels/ This form does not contain a submit button, which creates issues for those who cannot submit the form using the keyboard. Submit buttons are INPUT elements with type attribute "submit" or "image", or BUTTON elements with type "submit" or omitted/invalid. (html > body > div:nth-child(4) > main > div:nth-child(3) > div:nth-child(7) > form) <form class="form-floating"> <input type="email" class="f...</form> form.form-floating 2
/docs/5.1/examples/jumbotron/ This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 4.45:1. Recommendation: change background to #fafbfc. (html > body > main > div > div:nth-child(3) > div:nth-child(2) > div > button) <button class="btn btn-outline-secondary" type="button">Example button</button> .bg-light .btn.btn-outline-secondary 2
/docs/5.1/examples/navbars/ This form does not contain a submit button, which creates issues for those who cannot submit the form using the keyboard. Submit buttons are INPUT elements with type attribute "submit" or "image", or BUTTON elements with type "submit" or omitted/invalid. (#navbarsExample02 > form) and other ids <form> <input class="form-c...</form> div[id^=navbarsExample] > form 10
/docs/5.1/examples/headers/ Anchor element found with a valid href attribute, but no link content has been supplied. (html > body > main > div:nth-child(6) > header > a) <a href="/" class="d-flex align-items-center col-md-3 mb-2 mb-md-0 text-dark text-decoration-none"> <svg class="bi me-2" w...</a> main > header > div > div > a, main > div > header > a, main header > div > div > div > a 5
/docs/5.1/examples/checkout/ This textinput element does not have a name available to an accessibility API. Valid names are: label element, title undefined, aria-label undefined, aria-labelledby undefined. /// This form field should be labelled in some way. Use the label element (either with a "for" attribute or wrapped around the form field), or "title", "aria-label" or "aria-labelledby" attributes as appropriate. (html > body > div > main > div:nth-child(2) > div:nth-child(1) > form > div > input) <input type="text" class="form-control" placeholder="Promo code"> input.form-control[placeholder='Promo code'], input.form-control[placeholder='رمز ترويجي'] 4
/docs/5.1/examples/checkout This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 4.45:1. Recommendation: change background to #fafbfc. (html > body > div > main > div:nth-child(2) > div:nth-child(2) > form > div:nth-child(1) > div:nth-child(4) > label > span) <span class="text-muted">(Optional)</span> .bg-light form small.text-muted, .bg-light form span.text-muted 6
/docs/5.1/examples/checkout/ This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 4.45:1. Recommendation: change background to #fafbfc. (html > body > div > footer > p) <p class="mb-1">© 2017–2021 Company Name</p> .bg-light footer.text-muted > p 2
/docs/5.1/examples/checkout This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 4.27:1. Recommendation: change background to #fff. (html > body > div > footer > ul > li:nth-child(1) > a) <a href="#">Privacy</a> .bg-light footer > ul > li > a 6
/docs/5.1/examples/dropdowns This form does not contain a submit button, which creates issues for those who cannot submit the form using the keyboard. Submit buttons are INPUT elements with type attribute "submit" or "image", or BUTTON elements with type "submit" or omitted/invalid. (#dropdownFilter > div:nth-child(1) > form) <form class="p-2 mb-2 bg-light border-bottom"> <input type="search" cla...</form> #dropdownFilter > div > form 4
/docs/5.1/examples/dropdowns This button element does not have a name available to an accessibility API. Valid names are: title undefined, element content, aria-label undefined, aria-labelledby undefined. (#dropdownCalendar > div > div > div:nth-child(1) > button:nth-child(1)) <button class="btn cal-btn" type="button"> <svg class="bi" widt...</button> and other elements of #dropdownCalendar #dropdownCalendar > div > div > div > select, #dropdownCalendar > div > div > div > button 4
/docs/5.1/examples/footers Anchor element found with a valid href attribute, but no link content has been supplied. (html > body > div:nth-child(2) > footer > a) and different combination of <a> in footers <a href="/" class="col-md-4 d-flex align-items-center justify-content-center mb-3 mb-md-0 me-md-auto link-dark text-decoration-none"> <svg class="bi me-2" wid...</a> footer > p + a[href='/'], footer > div > a[href='/'], footer ul > li > a[href='#'] 9
/docs/5.1/examples/footers This form does not contain a submit button, which creates issues for those who cannot submit the form using the keyboard. Submit buttons are INPUT elements with type attribute "submit" or "image", or BUTTON elements with type "submit" or omitted/invalid. (html > body > div:nth-child(10) > footer > div:nth-child(1) > div:nth-child(4) > form) <form> <h5>Subscribe to our...</form> div:nth-child(10) > footer > div:nth-child(1) > div:nth-child(4) > form 1
/docs/5.1/examples/grid This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 1.63:1. Recommendation: change text colour to #967100. (html > body > main > div:nth-child(1) > p:nth-child(25)) <p class="text-warning"> No grid classes are nece...</p> p.text-warning 1
/docs/5.1/examples/headers/ This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 3.29:1. Recommendation: change text colour to #fff. (html > body > main > header:nth-child(8) > div > div > ul > li:nth-child(1) > a) <a href="#" class="nav-link px-2 text-secondary">Home</a header div.bg-dark a.text-secondary, header.bg-dark a.text-secondary 2
/docs/5.1/examples/headers/ This form does not contain a submit button, which creates issues for those who cannot submit the form using the keyboard. Submit buttons are INPUT elements with type attribute "submit" or "image", or BUTTON elements with type "submit" or omitted/invalid. (html > body > main > header:nth-child(8) > div > div > form) and other header examples as well <form class="col-12 col-lg-auto mb-3 mb-lg-0 me-lg-3"> <input type="search"...</form> header:nth-child(8) > div > div form, header:nth-child(10) > div > div form, header:nth-child(12) > div > div form, header:nth-child(16) > div form, header:nth-child(18) > div > div form 5
/docs/5.1/examples/heroes/ This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 4.45:1. Recommendation: change background to #fafbfc. (html > body > main > div:nth-child(8) > div > div:nth-child(2) > form > small) <small class="text-muted">By clicking Sign up, you agree ...</small> form.bg-light small.text-muted 1
/docs/5.1/examples/heroes/ This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 3.29:1. Recommendation: change text colour to #fff. (html > body > main > div:nth-child(12) > div > div > p) <p class="fs-5 mb-4">Quickly design and customize re...</p> div.bg-dark.text-secondary p 1
/docs/5.1/examples/navbars/ This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 4.27:1. Recommendation: change background to #fff. (html > body > main > div:nth-child(12) > div > div > div > p:nth-child(2) > code) <code>.container</code> .bg-light code 6
/docs/5.1/exampless/navbars This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 4.27:1. Recommendation: change background to #fff.
(html > body > main > div:nth-child(12) > div > div > div > p:nth-child(2) > a:nth-child(2)) <a href="/docs/5.1/examples/navbar-static/">top</a> .bg-light a 10
/docs/5.1/examples/sticky-footer This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 4.45:1. Recommendation: change background to #fafbfc. (html > body > footer > div > span) <span class="text-muted">Place sticky footer content her...</span> footer.bg-light span.text-muted 2
/docs/5.1/components/navbar This form does not contain a submit button, which creates issues for those who cannot submit the form using the keyboard. Submit buttons are INPUT elements with type attribute "submit" or "image", or BUTTON elements with type "submit" or omitted/invalid. (html > body > div:nth-child(4) > main > div:nth-child(3) > div:nth-child(55) > nav > form) and another form + button <form class="container-fluid"> <div class="input-group"> ...</form> main > div:nth-child(3) > div:nth-child(55) > nav > form, main > div:nth-child(3) > div:nth-child(59) > nav > form, main > div:nth-child(3) > div:nth-child(133) > nav > div > button 3
/docs/5.1/utilities/opacity This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 4.27:1. Recommendation: change text colour to #fff. (html > body > div:nth-child(4) > main > div:nth-child(2) > div:nth-child(3) > div:nth-child(1)) but concerns the 4 examples <div class="opacity-100 p-3 m-2 bg-primary text-light fw-bold rounded">100%</div> .opacity-100.bg-primary.text-light, .opacity-75.bg-primary.text-light, .opacity-50.bg-primary.text-light, .opacity-25.bg-primary.text-light 4
/docs/5.1/examples/pricing Not all th elements in this table have a scope attribute. These cells should contain a scope attribute to identify their association with td elements (html > body > div > main > div:nth-child(3) > table) <table class="table text-center"> <thead> <tr>...</table> main > div:nth-child(3) > table.table.text-center 1
/docs/5.1/examples/sign-in This element has insufficient contrast at this conformance level. Expected a contrast ratio of at least 4.5:1, but text in this element has a contrast ratio of 4.3:1. Recommendation: change background to #fbfbfb. (html > body > main > form > p) <p class="mt-5 mb-3 text-muted">© 2017–2021</p> body > main > form > p.text-muted 1
/docs/5.1/components/toasts/ This form does not contain a submit button, which creates issues for those who cannot submit the form using the keyboard. Submit buttons are INPUT elements with type attribute "submit" or "image", or BUTTON elements with type "submit" or omitted/invalid. (html > body > div:nth-child(4) > main > div:nth-child(3) > div:nth-child(49) > form) <form> <div class="mb-3"> <labe...</form> main > div:nth-child(3) > div:nth-child(49) > form 1

@julien-deramond julien-deramond marked this pull request as draft October 21, 2021 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant