No Bad Legos: Building a Toy Box for Everybody

A presentation at EmberConf 2019 in March 2019 in Portland, OR, USA by Howie Bollinger

Slide 1

Slide 1

No Bad Legos: Building a Toy Box For Everybody Howie Bollinger howie@redshelf.com Front End Developer // RedShelf (@HelloRedshelf)

Slide 2

Slide 2

Step 1: Make Your Legos

Slide 3

Slide 3

Search Results Pride And Prejudice Search Term: Jane Austen Jane Austen At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint … Emma Jane Austen At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint … Sense and Sensibility Jane Austen At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint … Persuasion Jane Austen At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint …

Slide 4

Slide 4

search-results.hbs

<h1>Search Results</h1> <ul> {{#each search_results as |book_object|}} <li> <img src=”{{book.cover_image}}”> <div>{{book_object.title}}</div> <div>{{book_object.author}}</div> <div>{{book_object.description}}</div> </li> {{/each}} </ul>

Slide 5

Slide 5

book-summary.hbs <img src=”{{book.cover_image}}”> <div>{{book.title}}</div> <div>{{book.author}}</div> <div>{{book.description}}</div>

Slide 6

Slide 6

search-results.hbs

<h1>Search Results</h1> <ul> {{#each search_results as |book_object|}} <li> <BookSummary @book=book_object /> </li> {{/each}} </ul>

Slide 7

Slide 7

<BookSummary @book=book_object /> Search Results Pride And Prejudice Cart Jane Austen At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas Checkout Pride And Prejudice Jane Austen At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas Pride And Prejudice Jane Austen At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas

Slide 8

Slide 8

book-summary-test.js this.book = { title:’Emma’, author: ‘Jane Austen’, … }; await render(hbs<BookSummary @book=book>); assert.equal(find(‘.book-summary .title’), ‘Emma’); assert.equal(find(‘.book-summary .author’), ‘Jane Austen’);

Slide 9

Slide 9

We’ve built some legos

Slide 10

Slide 10

Step 2: Build Some Stuff With Your Legos

Slide 11

Slide 11

But what about a11y?

Slide 12

Slide 12

CEO Stakeholders Product Owner Designers QA Developers Customer Experience

Slide 13

Slide 13

Everything is awesome because you’re part of a team

Slide 14

Slide 14

Accessibility is not just a checklist

Slide 15

Slide 15

… but, there is still a checklist

Slide 16

Slide 16

WCAG 2.1 Web Content Accessibility Guidelines - https://www.w3.org/TR/WCAG21/

Slide 17

Slide 17

What does that mean for the developers?

Slide 18

Slide 18

Step 1: Make Your Accessible Legos

Slide 19

Slide 19

book-summary-test.js this.book = { title:’Emma’, author: ‘Jane Austen’, … }; await render(hbs<BookSummary @book=book>); assert.equal(find(‘.book-summary .title’), ‘Emma’); assert.equal(find(‘.book-summary .author’), ‘Jane Austen’); assert.ok(find(‘.book-summary img’).getAttribute(‘alt’));

Slide 20

Slide 20

“That Sounds Hard?”

Slide 21

Slide 21

Axe Accessibility Engine https://github.com/dequelabs/axe-core

Slide 22

Slide 22

Example: Chrome + AXE Checker

Slide 23

Slide 23

Example: Chrome + AXE Checker Issue description Ensures every form element has a label Impact: critical Learn more Element location #username Element source <input id=”username” name=”email” title=”Email” type=”text” placeholder=”email@address.com” class=“form-control”> To solve this violation, you need to: Fix the following: Form element has explicit <label> that is hidden

Slide 24

Slide 24

Automating AXE Testing

Slide 25

Slide 25

Are you there, Axe? It’s me, Ember.

Slide 26

Slide 26

ember-a11y-testing https://github.com/ember-a11y/ember-a11y-testing

Slide 27

Slide 27

book-summary-test.js test(‘it renders a book summary’, async function(assert) { this.book = { title:’Emma’, author: ‘Jane Austen’, … }; await render(hbs<BookSummary @book=book>); assert.equal(find(‘.book-summary .title’), ‘Emma’); assert.equal(find(‘.book-summary .author’), ‘Jane Austen’); });

Slide 28

Slide 28

book-summary-test.js import a11yAudit from ‘ember-a11y-testing/test-support/audit’; test(‘it renders a book summary’, async function(assert) { this.book = { title:’Emma’, author: ‘Jane Austen’, … }; await render(hbs<BookSummary @book=book>); assert.equal(find(‘.book-summary .title’), ‘Emma’); assert.equal(find(‘.book-summary .author’), ‘Jane Austen’); await a11yAudit(‘.book-summary’); assert.ok(true, ‘assert no violations found’); });

Slide 29

Slide 29

a11yAudit(‘.book-summary’); a11yAudit ( Emma Jane Austen At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint … Click to expand for more details )

Slide 30

Slide 30

Fast Feedback - Terminal Output ‘ACCESSIBILITY VIOLATIONS: 1’ ‘CRITICAL: Images must have alternate text’ ‘Offending markup (1)’ ‘Additional info: https://dequeuniversity.com/rules/axe/2.6/ image-alt?application=axeAPI’

Slide 31

Slide 31

Fast Feedback - Dev Tools Output

Slide 32

Slide 32

Benefits of ember-a11y-testing • Continuous and passive learning (WCAG and basic HTML) • Prevent introducing a11y regressions into codebase • Leverages existing best practices • Reusable and robust library of components tested for accessibility

Slide 33

Slide 33

Slide 34

Slide 34

Don’t build bad legos!

Slide 35

Slide 35

Limitations

Slide 36

Slide 36

This is not a replacement for the whole process

Slide 37

Slide 37

It’s mostly static a11yAudit ( Emma Jane Austen At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint … )

Slide 38

Slide 38

Still Need Application Tests acceptance/application-test.js import import import import { module, test } from ‘qunit’; { visit, currentURL } from ‘@ember/test-helpers’; { setupApplicationTest } from ‘ember-qunit’; a11yAudit from ‘ember-a11y-testing/test-support/audit’; module(‘Acceptance | login’, function(hooks) { setupApplicationTest(hooks); test(‘visiting /login’, async function(assert) { await visit(‘/login’); assert.equal(currentURL(), ‘/login’); await a11yAudit(); assert.ok(true, ‘no a11y errors found’); }); });

Slide 39

Slide 39

No “Seal of Approval” ✅ ember-a11y-tested

Slide 40

Slide 40

a11yAudit(‘.book-summary’); a11yAudit ( Emma Jane Austen At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint … Click to expand for more details )

Slide 41

Slide 41

So, let’s fix the web

Slide 42

Slide 42

Thank you! Howie Bollinger howie@redshelf.com Front End Developer // RedShelf (@HelloRedshelf)