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

Fix excludes for accessibility audit tests #1803

Merged
merged 1 commit into from
Aug 3, 2021

Conversation

lfdebrux
Copy link
Member

@lfdebrux lfdebrux commented Aug 3, 2021

Fixes the accessibility audit tests so we can exclude multiple different selectors from tests. Previously the selector
.app-phase-banner__wrapper was in the list of things to exclude, but was not being excluded (see comment from @hannalaakso in PR #784).

This change is needed to be able to bump axe-core or @axe-core/puppeteer.

Details

It isn't clear from the axe-puppeteer documentation, but AxePuppeteer.exclude accepts only one argument, which is either a string or a list of strings. If a list of strings is provided, this is used to select an element within an iframe [2]. So to exclude several different elements, we need to call .exclude multiple times.

The easiest way to call .exclude multiple times for each test is to create a function (replacing the thingsToExclude object), which this commit does.

This is required to upgrade axe-core to version 3.5.0 or greater. The tests we passing before this commit because the rule 'all page content must be contained by landmarks' was not working fully: it treated regions as being part of the html element (and thus not covered by .include('body')) [4].

Fixes the accessibility audit tests so we can exclude multiple different
selectors from tests. Previously the selector
`.app-phase-banner__wrapper` was in the list of things to exclude, but
was not being excluded (see [comment from @hannalaakso in PR #784][1]).

It isn't clear from the `axe-puppeteer` documentation, but
`AxePuppeteer.exclude` accepts only one argument, which is either a
string or a list of strings. If a list of strings is provided, this is
used to select an element within an iframe [[2]]. So to exclude several
different elements, we need to call `.exclude` multiple times.

The easiest way to call `.exclude` multiple times for each test is to
create a function (replacing the `thingsToExclude` object), which this
commit does.

This is required to upgrade `axe-core` to version 3.5.0 or greater. The
tests we passing before this commit because the rule ['all page content
must be contained by landmarks'][3] was not working fully: it treated
regions as being part of the `html` element (and thus not covered by
`.include('body')`) [[4]].

[1]: https://github.com/alphagov/govuk-design-system/pull/784/files#r260285048
[2]: https://deque.com/axe/core-documentation/api-documentation/#context-parameter
[3]: https://dequeuniversity.com/rules/axe/4.3/region
[4]: dequelabs/axe-core#1980
@netlify
Copy link

netlify bot commented Aug 3, 2021

✔️ You can preview this change here:

🔨 Explore the source changes: 87dbe10

🔍 Inspect the deploy log: https://app.netlify.com/sites/govuk-design-system-preview/deploys/610911582ae8a600074e0bdb

😎 Browse the preview: https://deploy-preview-1803--govuk-design-system-preview.netlify.app

Copy link
Contributor

@vanitabarrett vanitabarrett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work, this makes sense to me 🎉

@lfdebrux lfdebrux merged commit 3a4fedb into main Aug 3, 2021
@lfdebrux lfdebrux deleted the ldeb-fix-axe-things-to-exclude branch August 3, 2021 11:56
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.

2 participants