-
Notifications
You must be signed in to change notification settings - Fork 779
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
Conversation
@@ -13,12 +13,10 @@ describe('region pass test', function() { | |||
}); | |||
|
|||
describe('passes', function() { | |||
it('should find one', function() { | |||
assert.lengthOf(results.passes[0].nodes, 1); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Co-Authored-By: Wilco Fiers <[email protected]>
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
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)