|
| 1 | +# Contributing |
| 2 | + |
| 3 | +## Accessibility Tooling |
| 4 | + |
| 5 | +Building accessible applications is a complex, multi-faceted, and mission critical endeavor. While tooling cannot guarantee an accessible experience, it can help raise the bar for the baseline experience in important ways. |
| 6 | + |
| 7 | +In addition to the W3C's [WAI Overview][], [WAI Authoring Practices Guide][], and [WAI-ARIA Specification][], along with MDN's [Accessibility Documentation][], the [thoughtbot handbook][] includes some high-level technical guidance. |
| 8 | + |
| 9 | +[WAI Overview]: https://www.w3.org/WAI/standards-guidelines/aria/ |
| 10 | +[WAI Authoring Practices Guide]: https://www.w3.org/WAI/ARIA/apg/ |
| 11 | +[WAI-ARIA Specification]: https://www.w3.org/TR/wai-aria/ |
| 12 | +[Accessibility Documentation]: https://developer.mozilla.org/en-US/docs/Web/Accessibility |
| 13 | +[thoughtbot guides]: https://github.com/thoughtbot/guides/blob/main/accessibility/README.md#development |
| 14 | + |
| 15 | +### Capybara and the System Test Suite |
| 16 | + |
| 17 | +[Capybara][] is responsible for driving the application's [System Test][] suite through Real Life browser sessions. |
| 18 | + |
| 19 | +Capybara drives the page and makes assertions about its state and content through utilities called [Selectors][]. They're a layer of abstraction that's a blend of HTML tag names and ARIA role semantics. For example, Capybara uses the `:link` selector whether it needs to locate and click on an `<a>` element through a call to [click_link][] or make an assertion about the presence and content of an `<a>` element through a call to [assert_link][]. |
| 20 | + |
| 21 | +Out of the box, Capybara provides a wide range of [built-in selectors][] that cover the majority of a System Test harness' needs. In addition to the out of the box selectors, this project also depends on the [capybara_accessible_selectors][] gem to expand Capybara's set of selectors. |
| 22 | + |
| 23 | +If you find yourself in a situation where you're reaching for CSS selectors or other means of resolving nodes, you might benefit from a built-in selector or one provided by `capybara_accessible_selectors`. Take this test block, for example: |
| 24 | + |
| 25 | +```ruby |
| 26 | +# <fieldset class="some-css selector-chain"> |
| 27 | +# <legend>Some fields</legend> |
| 28 | +# |
| 29 | +# <button class="my-button">Click me</button> |
| 30 | +# |
| 31 | +# <label> |
| 32 | +# Fill me in |
| 33 | +# <input class=".my-text-field"> |
| 34 | +# </label> |
| 35 | +# </fieldset> |
| 36 | + |
| 37 | +# BEFORE |
| 38 | +within ".some-css .selector-chain" do |
| 39 | + find(".my-button").click |
| 40 | + find(".my-text-field").set "Hello, world" |
| 41 | +end |
| 42 | + |
| 43 | +# AFTER |
| 44 | +within :fieldset, "Some field" do |
| 45 | + click_button "Click me" |
| 46 | + fill_in "Fill me in", with: "Hello, world" |
| 47 | +end |
| 48 | +``` |
| 49 | + |
| 50 | +The [Testing RSpec][] section of the `thoughtbot/guides` provides some general guidance for automated Acceptance Testing. |
| 51 | + |
| 52 | +[Capybara]: https://rubydoc.info/github/teamcapybara/capybara/master/ |
| 53 | +[System Test]: https://guides.rubyonrails.org/testing.html#system-testing |
| 54 | +[Selectors]: https://rubydoc.info/github/teamcapybara/capybara/master#selectors |
| 55 | +[click_link]: https://rubydoc.info/github/teamcapybara/capybara/master/Capybara/Node/Actions:click_link |
| 56 | +[assert_link]: https://rubydoc.info/github/teamcapybara/capybara/master/Capybara/Minitest/Assertions:assert_link |
| 57 | +[built-in selectors]: https://rubydoc.info/github/teamcapybara/capybara/master/Capybara/Selector#built-in-selectors |
| 58 | +[capybara_accessible_selectors]: https://github.com/citizensadvice/capybara_accessible_selectors |
| 59 | +[Testing RSpec]: https://github.com/thoughtbot/guides/blob/main/testing-rspec/README.md#acceptance-tests |
| 60 | + |
| 61 | +### `capybara_accessibility_audit` and `axe.js` |
| 62 | + |
| 63 | +This project depends on the [capybara_accessibility_audit][] gem to enhance the application's System Test suite to audit the browser's DOM for statically detectable accessibility violations. Under the hood, `capybara_accessibility_audit` utilizes [axe.js][] for auditing. |
| 64 | + |
| 65 | +The categories of violation that `capybara_accessibility_audit` can detect span a wide range from insufficient [color contrast][] to invalid or insufficient [landmark-based information hierarchy][landmark], to [unnamed form controls][] and beyond. |
| 66 | + |
| 67 | +Out of the box, `capybara_accessibility_audit` will extend Capybara to conduct an accessibility audit after a variety of actions like `visit` and `click_link`. That project can [be configured to suit this application's needs][capybara_accessibility_audit-configuration]. |
| 68 | + |
| 69 | +If you can integrate `capybara_accessibility_audit` from the project's inception, you can start with (and maintain!) accessibility violation bankruptcy. |
| 70 | + |
| 71 | +[capybara_accessibility_audit]: https://github.com/thoughtbot/capybara_accessibility_audit |
| 72 | +[capybara_accessibility_audit-configuration]: https://github.com/thoughtbot/capybara_accessibility_audit?tab=readme-ov-file#frequently-asked-questions |
| 73 | +[axe.js]: https://www.deque.com/axe/ |
| 74 | +[color contrast]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/Understanding_WCAG/Perceivable/Color_contrast |
| 75 | +[landmark]: https://developer.mozilla.org/en-US/blog/aria-accessibility-html-landmark-roles/ |
| 76 | +[unnamed form controls]: https://developer.mozilla.org/en-US/docs/Web/Accessibility/Understanding_WCAG/Text_labels_and_names#form_elements_must_be_labeled |
| 77 | + |
| 78 | +### VoiceOver on macos |
| 79 | + |
| 80 | +VoiceOver is a screen reader integrated directly into the macOS operating system. You can learn more from [Apple's Accessibility Support][]. |
| 81 | + |
| 82 | +VoiceOver and Safari are tightly integrated. If you're developing this |
| 83 | +application on a Mac, you should familiarize yourself with how to navigate in |
| 84 | +Safari using VoiceOver. You can learn more about how to use VoiceOver from the |
| 85 | +[Get started with VoiceOver on Mac][]. You might also enjoy [Screen Reader |
| 86 | +Basics: VoiceOver][] in the A11ycasts series of videos from the "Chrome for Developers" YouTube channel. |
| 87 | + |
| 88 | +[](https://www.youtube.com/watch?v=5R-6WvAihms) |
| 89 | + |
| 90 | +After you've written a System Test or have completed a feature, it can be **extremely** valuable to navigate to that part of the application and try your best to recreate the experience based on keyboard navigation and screen reader announcements alone. |
| 91 | + |
| 92 | +[Apple's Accessibility Support]: https://support.apple.com/accessibility |
| 93 | +[Get started with VoiceOver on Mac]: https://support.apple.com/guide/voiceover/get-started-vo4be8816d70/10/mac/14.0 |
| 94 | +[Screen Reader Basics: VoiceOver]: https://www.youtube.com/watch?v=5R-6WvAihms |
0 commit comments