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

UI: Add acceptance test accessibility auditing and fixes #8455

Merged
merged 10 commits into from
Jul 28, 2020

Conversation

backspace
Copy link
Contributor

@backspace backspace commented Jul 17, 2020

This is a first pass at incorporating axe/ember-a11y-testing and addressing some failures it catches. The commits can be read in order, they:

  1. introduce the addon
  2. set up a helper wrapper to ignore all initial rule violations
  3. add the wrapper to acceptance tests
  4. fix violations of one rule per commit

The wrapper for the a11yAudit helper let me globally skip certain axe rules for now:

  • color-contrast, which will be a significant undertaking to address but also self-contained and appropriate for a separate PR
  • heading-order, which ensures that h1 to h6 are always in order and don’t skip levels, I need to look more into how people handle this in dynamic applications

I chose to only add accessibility audits to acceptance tests for now, but will proceed with component tests in a subsequent pull request. Some other things to address/survey (in addition to the above):

  • tabbing into the CodeMirror component traps the cursor there, you can’t tab out
  • the CodeMirror component also fails scrollable-region-focusable, there’s a targeted exception for that rule
  • the possibility that randomness in test data will cause intermittent failures that aren’t fixed in this PR
    • for instance, I could only reliably reproduce the scrollable-region-focusable failure when I ensured the job definition was long enough that it would cause the container to be scrollable
  • the placeholder in the token-setting field gets read aloud by VoiceOver
  • a general overview of the experience of using the interface with VoiceOver to uncover other problems

The documentation shows adding a separate test for the audit, which is also the route Terraform Cloud is taking, but I’m torn about it… I wonder whether it might make more sense to include in an existing test, similarly to how there are assertions on document.title in most acceptance test files’s first tests. I’m leaning toward that direction but want to check in before doing it.

One possibility I looked into was adding a custom ESLint rule that would check each acceptance test file to ensure it uses the helper at least once. Does this seem worth it? 🤔

@github-actions
Copy link

github-actions bot commented Jul 17, 2020

Ember Asset Size action

As of 4095504

Files that got Bigger 🚨:

File raw gzip
nomad-ui.js +18.2 kB +3.69 kB
vendor.js +1.82 kB +506 B

Files that stayed the same size 🤷‍:

File raw gzip
nomad-ui.css 0 B 0 B
vendor.css 0 B -2 B

@github-actions
Copy link

github-actions bot commented Jul 17, 2020

Ember Test Audit comparison

master 4095504 change
passes 1315 1347 +32
failures 0 0 0
flaky 0 0 0
duration 6m 12s 741ms 6m 24s 644ms +11s 903ms

This lets us centralise rule exclusions instead of having them
sprinkled around in test files.
I’m torn about whether this approach of making separate tests
for the audit is preferable to embedding the audit in the
existing tests, perhaps similarly to how assertions on the
page title are embedded. 🤔
@backspace backspace force-pushed the f-ui/accessibility branch from f614b6c to d06919b Compare July 21, 2020 18:28
Some of these (color-contrast and heading-order) will be
harder to fix than others, but I will hopefully be able
to address the majority in subsequent commits.
This rule is described here:
https://dequeuniversity.com/rules/axe/3.5/label

While adding a label for the token input field, I noticed
that its placeholder produces a bad VoiceOver experience,
which I will address separately.

I removed the action to focus the stepper input when
clicking the label as I believe connecting the label
and input with an id is equivalent.

This includes an override for ivy-codemirror’s codemirror
dependency to take advantage of the screenReaderLabel
configuration option in 5.53; thanks to @adityatoshniwal
for that addition in codemirror/codemirror5#6197.
This rule is described here:
https://dequeuniversity.com/rules/axe/3.5/button-name

For the log streaming toggles, normally I would assert against
conditionals like these, but I couldn’t find any assertions
on the icons 😯
This turns off one rule for the job definition test, as the
CodeMirror component is failing:
https://dequeuniversity.com/rules/axe/3.5/scrollable-region-focusable
@backspace backspace changed the title UI: Add accessibility testing UI: Add preliminary accessibility testing and fixes Jul 23, 2020
@backspace backspace changed the title UI: Add preliminary accessibility testing and fixes UI: Add acceptance test accessibility auditing and fixes Jul 23, 2020
@backspace backspace marked this pull request as ready for review July 23, 2020 20:42
Copy link
Contributor

@DingoEatingFuzz DingoEatingFuzz left a comment

Choose a reason for hiding this comment

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

So many great little fixes 🤩

As for integrating tests into existing files vs. one big new file, I too prefer integrating into existing ones.

As for the eslint rule, I think if it existed it would be helpful, but without knowing how much work goes into making it, it's hard to say if it would be worth it.

class="stepper-input-label"
onClick={{action "focusInput"}}>{{yield}}</label>
for="stepper-input-{{this.elementId}}"
class="stepper-input-label">{{yield}}</label>
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a much nicer implementation than the action route I took.

@backspace
Copy link
Contributor Author

👍 thanks, I’ll change it around to have the audits in the existing tests.

re ESLint, it seemed to me to not be too difficult, I think there are some rules I can take inspiration from, I’ll make a timeboxed attempt 😀

@backspace
Copy link
Contributor Author

oh oops maybe we’re talking about slightly different things re my question about where the audits should happen. I followed the suggestion of the documentation in adding a separate test into each acceptance test file (almost), but I was asking about whether it would make more sense to add the a11yAudit to existing tests inside the file instead of having a separate it passes an accessibility audit test. I am slightly irked by it being separate and especially the assert.ok(true, 'a11y audit passes') that is only present (from what I can tell) to have a non-zero assertion count that QUnit errors on. I think putting the audit around where document.title is asserted on could work too.

@DingoEatingFuzz
Copy link
Contributor

Ah, I see what you mean now. I think it's good the way it is?

If I understand correctly, when a page doesn't pass the audit, then await a11yAudit(); throws an error and that's how the test fails?

If that's the case, then I think it's helpful to know that it passes the accessibility audit is the test that fails rather than correct page title or whatever. A theoretical assert.noThrow would be nice for this, lol.

@backspace
Copy link
Contributor Author

The assert.ok is only there so you don’t need assert.expect(0), I believe. I think something like this would be nicer particularly for tests that require duplicate Mirage setup:

image

I pushed a commit with that and a deliberate accessibility violation and you can see that the test fails without needing the assert.ok.

Unrelatedly, re ESLint, you saw that I got that PR merged, but I’ll make a separate PR to use it in Nomad 😀

@DingoEatingFuzz
Copy link
Contributor

My concern is around the presentation of errors given that the underlying failure condition is a promise error rather than an assertion error. Note the title differences in these two error cards.

image

But fewer lines of code is always compelling, and the error message body still says it's accessibility related, so maybe I'm just overthinking things.

@backspace
Copy link
Contributor Author

hmm yes, the test name does help emphasise… well I’ll merge for now, can always change later!

@backspace backspace merged commit 9d190a6 into master Jul 28, 2020
@backspace backspace deleted the f-ui/accessibility branch July 28, 2020 17:59
backspace added a commit that referenced this pull request Aug 25, 2020
This continues #8455 by adding accessibility audits to component integration
tests and fixing associated errors. It adds audits to existing tests rather than
adding separate ones to facilitate auditing the various permutations a
component’s rendering can go through.

It also adds linting to ensure audits happen in component tests. This
necessitated consolidating test files that were scattered.
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants