forked from just-the-docs/just-the-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Right now, no adaptions have been make to get specs to pass... tl;dr: Use axe through Google Chrome to audit accessibility of all pages. * add jekyll-sitemap necessary to iterate over all pages * add a new GitHub CI workflow to run specs * add Gems necessary to run specs * add support files for specs Run specs with: `bundle exec rspec` This runs two "specs" on each page: * WCAG 2.0 and 2.1 A and AA tests * WCAG 2.2 and all best practices tests This separation is done to make it easier to see what's often necessary for legal a11y compliance in both the US and EU where WCAG 2.1 AA is the typical standard. Failing specs have a screenshot of the page saved to tmp/capybara. If you have elements which cannot be made accessible, you can add them add the HTML attribute `[data-a11y-errors=true]` to the element. This allows tests to pass, but communicates that the element is not accessible for some reason. These tests have been adapted from a use of JtD: http://github.com/berkeley-cdss/berkeley-class-site Future work needs to be done to run the tests both on light mode and dark mode. (This can likely done by calling JS via Capybara to change the theme.)
- Loading branch information
1 parent
ac78bfe
commit 9d9ba9e
Showing
9 changed files
with
443 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Run all page tests | ||
|
||
# Run when a PR is opened, any branch is pushed | ||
# Also allow manually triggering workflows, and running if a release is created. | ||
on: | ||
- pull_request | ||
- push | ||
- workflow_dispatch | ||
- deployment | ||
- release | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: ruby/setup-ruby@v1 | ||
with: | ||
# The Ruby version is determined by either a `.ruby-version` or a `.tool-versions` file in root of the repo. | ||
bundler-cache: true | ||
- name: Run a11y tests | ||
run: | | ||
bundle exec rspec | ||
- name: summary | ||
if: failure() | ||
run: ruby spec/support/spec_summary.rb | ||
- name: Keep screenshots from failed tests | ||
uses: actions/upload-artifact@v4 | ||
if: failure() | ||
with: | ||
name: screenshots | ||
path: ${{ github.workspace }}/tmp/capybara | ||
if-no-files-found: ignore | ||
retention-days: 7 |
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 |
---|---|---|
|
@@ -28,3 +28,6 @@ node_modules | |
*.gem | ||
.bundle | ||
.ruby-version | ||
|
||
# Used for automated test results and metadata. | ||
tmp/ |
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 @@ | ||
-f documentation -f documentation --out tmp/rspec_output.txt -f json --out tmp/rspec_output.json -f html --out tmp/rspec_output.html |
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,53 @@ | ||
# frozen_string_literal: true | ||
|
||
# Run accessibility specs for all pages in the webiste. | ||
# This runs the axe accessibility checker on each page in a headless browser. | ||
|
||
# spec_helper ensures the webiste is built and can be served locally | ||
require 'spec_helper' | ||
|
||
# Axe-core test standards groups | ||
# See https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#axe-core-tags | ||
# Tests are segmented in 2.0, 2.1 and 2.2+ | ||
# In most places WCAG 2.1AA is the minimum requirement, but 2.2 is the current WCAG Standard. | ||
required_a11y_standards = %i[wcag2a wcag2aa wcag21a wcag21aa] | ||
complete_a11y_standards = %i[wcag22aa best-practice secion508] | ||
|
||
# axe-core rules that are not required to be accessible / do not apply | ||
# You may temporarily want to add rules here during development. | ||
# See: https://github.com/dequelabs/axe-core/blob/develop/doc/rule-descriptions.md | ||
skipped_rules = [] | ||
# These are elements that are not required to be accessible | ||
# It should be rare to add to this list. This disables all rules for an element. | ||
# e.g. <img data-a11y-errors="true" src="..." /> would pass even though it's missing alt text. | ||
excluded_elements = [ | ||
'[data-a11y-errors="true"]' | ||
] | ||
|
||
# We must call this to ensure the build it up-to-date. | ||
build_jekyll_site! | ||
ALL_PAGES = load_sitemap | ||
puts "Running tests on #{ALL_PAGES.count} pages." | ||
puts " - #{ALL_PAGES.join("\n - ")}\n\n" | ||
|
||
ALL_PAGES.each do |path| | ||
describe "#{path} is accessible", :js, type: :feature do | ||
before do | ||
visit(path) | ||
end | ||
|
||
it 'meets WCAG 2.1' do | ||
expect(page).to be_axe_clean | ||
.according_to(*required_a11y_standards) | ||
.skipping(*skipped_rules) | ||
.excluding(*excluded_elements) | ||
end | ||
|
||
it 'meets WCAG 2.2' do | ||
expect(page).to be_axe_clean | ||
.according_to(*complete_a11y_standards) | ||
.skipping(*skipped_rules) | ||
.excluding(*excluded_elements) | ||
end | ||
end | ||
end |
Oops, something went wrong.