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(region): return outermost regionless node instead of html #1980

Merged
merged 9 commits into from
Jan 29, 2020

Conversation

straker
Copy link
Contributor

@straker straker commented Jan 13, 2020

Have region rule return the outermost container element as the failure node rather than html.

Since the rule returns outer elements, we cannot fail on a specific target easily. So the test cases look at the data property to look at which container element was returned. The end result is that all outer container elements will return as violations while every other node on the page will return as passes.

Closes issue: #878

Reviewer checks

Required fields, to be filled out by PR reviewer(s)

  • Follows the commit message policy, appropriate for next version
  • Code is reviewed for security

@straker straker requested a review from a team as a code owner January 13, 2020 17:57
lib/checks/navigation/region.js Outdated Show resolved Hide resolved
lib/checks/navigation/region.js Outdated Show resolved Hide resolved
@@ -13,12 +13,10 @@ describe('region pass test', function() {
});

describe('passes', function() {
it('should find one', function() {
assert.lengthOf(results.passes[0].nodes, 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Lets test the number of elements we expect from the fixture, just to make sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem I had with that is that it was inconsistent. You can see from this test that the number failed in the unix test but will pass in localhost.

image

Screen Shot 2020-01-24 at 11 45 55 AM

test/integration/full/region/region-fail.js Show resolved Hide resolved
lib/checks/navigation/region.js Outdated Show resolved Hide resolved
test/checks/navigation/region.js Show resolved Hide resolved
test/checks/navigation/region.js Outdated Show resolved Hide resolved
@straker straker merged commit 8d77be2 into develop Jan 29, 2020
@straker straker deleted the regionRule branch January 29, 2020 17:43
lfdebrux added a commit to alphagov/govuk-design-system that referenced this pull request 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][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
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