/
index.html
826 lines (729 loc) · 28.3 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Accessibility Testing in Angular - Marcy Sutton</title>
<meta name="description" content="A presentation on accessibility testing in Angular 1 and Angular 2">
<meta name="author" content="Marcy Sutton">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="plugin/accessibility-helpers/accessibility-helper.css">
<link rel="stylesheet" href="css/theme/custom.css" id="theme">
<!-- Code syntax highlighting -->
<link rel="stylesheet" href="lib/css/tomorrow.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<div class="slides">
<section data-state="deque-title-slide" class="title-slide">
<div class="left">
<img src="img/deque-logo.png" alt="Deque" class="plain deque">
</div>
<div class="right">
<h1>Accessibility Testing<br>with Angular</h1>
<p>
By <a href="http://marcysutton.com">Marcy Sutton</a> / <a href="http://twitter.com/marcysutton">@MarcySutton</a><br>
Senior Front-End Engineer, Deque Systems
</p>
</div>
</section>
<section>
<h2>Kdo je Marcy Sutton?</h2>
<div id="oh-hai-images" class="border-top">
<div>
<img data-src="img/axe-core.png" alt="axe-core" class="axe plain">
</div>
<img data-src="img/egghead-dot-io-logo.png" alt="Egghead.io" class="egghead plain">
<img data-src="img/angularjs-logo.png" alt="AngularJS" class="angular plain">
<img data-src="img/gdi_logo_badge.png" alt="Girl Develop It" class="gdi plain">
</div>
</section>
<section>
<h2 class="h1-style left-align">Why Accessibility?</h2>
<aside class="notes">
1/5 of the world's population has some kind of disability
It's the right thing to do
Lose potential customers
You might need it in the future
</aside>
</section>
<section>
<div class="left-align">
<h2 class="h1-style fancy">
15% of the population
<span class="subhead">has some kind of disability</span>
</h2>
<p><small><a href="http://www.who.int/mediacentre/factsheets/fs352/en/">Source: World Health Organization</a></small></p>
</div>
</section>
<section>
<div class="ability-table">
<div class="halfCol" style="padding-left: 5%">
<h3 class="h2-style">Some people can’t:</h3>
<ul>
<li>Use a mouse</li>
<li>View a screen</li>
<li>See low contrast text</li>
<li>Hear dialogue or music</li>
<li>Understand complex language</li>
</ul>
</div>
<div class="halfCol fragment" style="padding-left: 5%">
<h3 class="h2-style">Some people need:</h3>
<ul>
<li>Keyboard support</li>
<li>Screen reader support</li>
<li>High contrast text</li>
<li>Captions and transcripts</li>
<li>Plain language</li>
</ul>
</div>
</section>
<section data-background-color="#fff" class="light-theme">
<div class="">
<h3 class="h2-class fancy" style="margin-bottom:0.25em">Design and develop for ‘future you’</h3>
<p class="subhead"><a href="https://www.microsoft.com/en-us/design/practice#toolkit">Microsoft Inclusive Design Toolkit</a></p>
<figure>
<img src="img/injury.png" alt="Permanent disability to injury or situational disability" class="plain" style="max-width: 65%;">
</figure>
</div>
</section>
<section>
<h3 class="h1-style fancy">Guess what: you can help!</h3>
<p class="subhead">…by making the Internet more accessible.</p>
</section>
<section>
<div style="position:relative">
<h2 class="h1-style fancy">#A11y in Angular Apps</h2>
<h2 class="h1-style fancy fragment overlaidHeadline">#A11y in <strike>Angular</strike>
Apps<br>
<span>“Client-Rendered”</span>
</h2>
</div>
<ul class="larger" aria-hidden="true" style="visibility: hidden">
<li>Write meaningful HTML</li>
<li>Enable the keyboard</li>
<li>Handle focus</li>
<li>Alert the user</li>
<li>Coverage with tests</li>
</ul>
</section>
<!--
<section>
<figure class="image-with-caption" style="margin: 0 auto; width: 1000px;">
<img data-src="img/lifeOfARequestParts-khan4019.png" alt="Life of a request: Server vs. client" class="plain" style="padding-left: 10px;">
<figcaption><a href="http://khan4019.github.io/HighPerformanceJSandCSS/#/5/3">Navigation Timing API</a></figcaption>
</figure>
</section> -->
<section data-transition="none">
<h2 class="h1-style fancy">#A11y in <br>Client-Rendered Apps</h2>
<ul class="larger">
<li class="fragment">Write meaningful HTML</li>
<li class="fragment">Enable the keyboard</li>
<li class="fragment">Handle focus</li>
<li class="fragment">Alert the user</li>
<li class="fragment">Coverage with tests</li>
</ul>
<aside class="notes">
WebExpo: This stuff is all new and necessary. Accessibility basics that can be tested. How-to in ng1 and ng2.
Angular Connect: While the basics are important, testing is critical to success. Here's how-to in ng1 and ng2.
Back in 2014 I gave a talk at ngEurope that covered the basics of Angular accessibility. These are still the essential things to consider for accessibility as it relates to Angular and all client-rendered frameworks.
</aside>
</section>
<section>
<iframe width="1280" height="640" title="Old VirginAmerica.com VoiceOver Demo" src="//www.youtube.com/embed/8ZbYJSqE0EM" frameborder="0" allowfullscreen=""></iframe>
</section>
<section>
<div class="left-align snug">
<h3 class="h1-style">Meaningful HTML</h3>
<figure class="code">
<pre><code class="html large-tag">
<label for="roundTrip">
<input type="radio" id="roundTrip">
Round Trip
</label>
</code></pre>
<figcaption>HTML Radio Input</figcaption>
</figure>
</div>
</section>
<section>
<div class="left-align snug">
<h3 class="h1-style">
<span style="position: absolute;display: block;top: -1em;">Also</span>
Meaningful HTML</h3>
<figure class="code">
<pre><code class="html large-tag">
<button>Button</button>
</code></pre>
<figcaption>HTML Button</figcaption>
</figure>
</div>
</section>
<section data-background-image="img/ngmaterial-button-a11y-inspector.png">
<h3 class="offscreen">Angular Material button in Chrome Accessibility Inspector</h3>
<p class="offscreen">CSS changes button text to uppercase following the Material Design guidelines, which shows in the accessibility tree</p>
</section>
<section>
<div class="parentheses">
<h2>Enable the keyboard</h2>
<h2>Handle focus</h2>
<h2>Alert the user</h2>
</div>
</section>
<section>
<div class="left-align snug">
<h2 class="h1-style fancy">Intro to ARIA</h2>
<p><a href="https://www.w3.org/TR/wai-aria/">https://www.w3.org/TR/wai-aria/</a></p>
<dl>
<dt><span class="subhead">Role:</span> what is it?</dt>
<dd><code class="html hljs xml">
<span class="hljs-tag">
<span class="hljs-attribute">role</span>=<span class="hljs-value">"button"</span>
</span>
</code></dd>
<dt><span class="subhead">State:</span> what state is it in?</dt>
<dd><code class="html hljs xml">
<span class="hljs-tag">
<span class="hljs-attribute">aria-checked</span>=<span class="hljs-value">"false"</span>
</span>
</code></dd>
<dt><span class="subhead">Property:</span> what's the nature of it?</dt>
<dd><code class="html hljs xml">
<span class="hljs-tag">
<span class="hljs-attribute">aria-haspopup</span>=<span class="hljs-value">"true"</span> <br>
<span class="hljs-attribute">aria-label</span>=<span class="hljs-value">"Close modal"</span>
</span>
</code>
</dd>
</dl>
</div>
</section>
<section data-background-image="img/a11y-with-ngaria.png">
<h2 class="offscreen">Accessibility with ngAria: Angular 1 documentation</h2>
</section>
<section data-background-image="img/ngaria.png">
<div class="offscreen">
<h2>ngAria</h2>
<p>aria-checked code example and link to documentation https://docs.angularjs.org/api/ngAria</p>
</div>
</section>
<section>
<h2>While ngAria was a worthwhile effort,<br>it only helps certain use cases.</h2>
<img data-src="img/cat-flower.gif">
<!-- TRY NOT TO TRASH ngARIA BUT EXPLAIN WHY TESTING IS BETTER -->
</section>
<!--<section>
<h2 style="margin-bottom: 0;">It's been a while…</h2>
<img data-src="img/Angular-Material-RadioButtons.png" alt="A really old version of Angular Material" class="plain">
</section>-->
<section>
<h2 class="h1-style fancy">
<span class="subhead smaller">Build accessibility into your workflow <br><span class="muted">~ with ~</span></span>
Automated Testing</h2>
<aside class="notes">
DOM vs. accessibility/ ax tree
keyboard event stubbing
tests as documentation for accessibility features
</aside>
</section>
<section>
<h2 class="h1-style fancy">
<span class="subhead smaller muted">~ But ~</span>
It’s no substitute for real user feedback</h2>
<aside class="notes">
Because of the differences in screen readers vs. browser tools / best practices
</aside>
</section>
<section>
<div class="left-align">
<!-- highlight first topic, gray out second -->
<p class="subhead" style="margin-top: -60px;">Testing for accessibility in:</p>
<h2 class="big-heading">Angular 1*</h2>
<h2 class="big-heading" aria-hidden="true">Angular 2</h2>
</div>
</section>
<section>
<h2 class="h1-style fancy" style="margin-top:-50px;">Directive-Specific<br>Unit Tests</h2>
<div class="fragment">
<p class="subhead muted">Good for:</p>
<ul>
<li>Text alternatives / Labeling</li>
<li>Keyboard operability</li>
<li>ARIA attribute watching</li>
</ul>
</div>
<aside class="notes">
Escape key, tabbing, hitting Enter/Space, Arrow keys
offscreen/attribute text computation (stuff you don't see)
ARIA default values for custom elements
</aside>
</section>
<section>
<div class="left-align snug">
<h3 class="h2-style">Labeling unit test</h3>
<figure class="code">
<pre class="larger"><code class="javascript">
it('should apply aria-hidden="true" when parent has valid label',
inject(function() {
var el = make('<md-radio-button aria-label="Squishy Avatar" '+
'role="radio" tabindex="0"> '+
'<div class="md-container"></div> '+
'<div class="md-label"> '+
'<md-icon md-svg-icon="android"></md-icon> '+
'</div></md-radio-button>');
expect(el.find('md-icon').attr('aria-hidden')).toEqual('true');
}));
</code></pre>
<figcaption><a href="https://github.com/angular/material/blob/master/src/components/icon/icon.spec.js">mdIcon Spec</a></figcaption>
</figure>
</div>
</section>
<section>
<div class="left-align large-tag snug">
<h3 class="h2-style">Keyboard unit test</h3>
<figure class="code">
<pre class="larger"><code class="javascript">
it('closes on escape', inject(function($document, $mdConstant) {
var menu = setup();
openMenu(menu);
expect(getOpenMenuContainer(menu).length).toBe(1);
var openMenuEl = $document[0].querySelector('md-menu-content');
pressKey(openMenuEl, $mdConstant.KEY_CODE.ESCAPE);
waitForMenuClose();
expect(getOpenMenuContainer(menu).length).toBe(0);
}));
</code></pre>
<figcaption><a href="https://github.com/angular/material/blob/master/src/components/menu/menu.spec.js">mdMenu Spec</a></figcaption>
</figure>
</div>
</section>
<section>
<h2 class="h1-style fancy" style="margin-top:-50px;">Integration/ <br>End-to-End Tests</h2>
<div class="fragment">
<p class="subhead muted">Good for:</p>
<ul>
<li>Color contrast</li>
<li>Widget keyboard interrop</li>
<li>Document-level rules</li>
</ul>
</div>
<aside class="notes">
Escape key, tabbing, hitting Enter/Space, Arrow keys
offscreen/attribute text computation (stuff you don't see)
ARIA default values for custom elements
</aside>
</section>
<section>
<h2 class="fancy">Get help with an API</h2>
<div>
<p><em class="subhead">Save yourself from:</em></p>
<ul>
<li>Label/name computation</li>
<li>Incorrect ARIA usage</li>
<li>Color contrast</li>
<li>Data table markup</li>
<li>Viewport/zooming probz</li>
</ul>
</div>
<aside class="notes">
Escape key, tabbing, hitting Enter/Space, Arrow keys
offscreen/attribute text computation (stuff you don't see)
ARIA default values for custom elements
</aside>
</section>
<section>
<h3 class="fancy border-bottom" style="margin-top: -1em;">A11y test APIs: You’ve got options</h3>
<ul class="wordcloud" style="margin-left: 4em;">
<li class="word-cloud__word x-large" style="margin-left: 1.55em;">aXe</li>
<li class="word-cloud__word x-small">Chrome A11y Developer Tools</li>
<li class="word-cloud__word small">QUAIL</li>
<li class="word-cloud__word large">Tenon</li>
<li class="word-cloud__word small" style="margin-left: 2em;">WAVE</li>
</ul>
</section>
<section>
<h3 class="h2-style fancy">axe-core API</h3>
<p><a href="https://github.com/dequelabs/axe-core">https://github.com/dequelabs/axe-core</a></p>
<ul>
<li>Runs locally</li>
<li>Open source</li>
<li>Free <sup aria-describedby="footnote1" style="font-size: 0.75em;">†</sup></li>
<li>Good for integration tests</li>
<li>Also unit tests</li>
</ul>
<p id="footnote1" style="font-size: 0.75em;"><sup>†</sup>There’s also a supported/enterprise option, Worldspace Attest</p>
</section>
<section>
<figure class="left-align snug">
<figcaption style="margin-top: -1em;">
aXe Chrome extension ~ <a href="http://bit.ly/axe-chrome">http://bit.ly/axe-chrome</a></figcaption>
<img data-src="img/angularjs-docs-axe.png" alt="Angular.js Docs in the aXe Chrome extension" class="plain">
</figure>
</section>
<section>
<figure class="left-align snug">
<figcaption style="margin-top: -1em;">Angular Material Demo App</figcaption>
<img data-src="img/angular-material-muppet-app.jpg" alt="Angular Material Muppets app" class="plain">
</figure>
</section>
<section>
<div class="left-align snug">
<h3 class="h2-style">Demo App Template</h3>
<figure class="code">
<pre class="larger"><code class="javascript">
<md-toolbar layout="row">
<h1 layout-align-gt-sm="center center" class="md-toolbar-tools">My Favorite Muppets</h1>
</md-toolbar>
<div layout="row" flex class="content-wrapper">
<md-sidenav layout="column" class="md-sidenav-left md-whiteframe-z2" md-component-id="left">
<md-list class="muppet-list">
<md-item ng-repeat="it in muppets">
<md-item-content>
<md-button ng-click="selectMuppet(it)" ng-class="{'selected' : it === selected }">
<img ng-src="{{it.iconurl}}" class="face" alt="">
{{it.name}}
</md-button>
</md-item-content>
</md-item>
</md-list>
</md-sidenav>
<div layout="column" flex class="content-wrapper" id="primary-col">
<md-content layout="column" flex class="md-padding">
<h2>{{selected.name}}</h2>
<p>{{selected.content}}</p>
<div class="cell">
<img ng-src="{{selected.imgurl}}" alt="{{selected.imgalt}}">
</div>
</md-content>
</div>
</div>
</code></pre>
<figcaption><a href="http://bit.ly/ngmaterial-muppets">http://bit.ly/ngmaterial-muppets</a></figcaption>
</figure>
</div>
</section>
<section>
<div class="left-align snug">
<h3 class="h2-style">End-to-End Test</h3>
<figure class="code">
<pre class="larger"><code class="javascript">
var AxeBuilder = require('axe-webdriverjs');
describe('view1', function() {
beforeEach(function() { browser.get('index.html'); });
it('should change Muppets', function() {
element.all(by.css('[ng-click="selectMuppet(it)"]')).first().
sendKeys(protractor.Key.ENTER);
expect(element.all(by.css('#primary-col h2')).first().getText()).
toMatch('Animal');
});
it('should have no accessibility violations', function(done) {
AxeBuilder(browser)
.analyze(function(results) {
if (results.violations.length > 0) {
console.log(results.violations);
}
expect(results.violations.length).toBe(0);
done();
});
});
</code></pre>
<figcaption><a href="https://github.com/dequelabs/axe-webdriverjs">https://github.com/dequelabs/axe-webdriverjs</a></figcaption>
</div>
</section>
<section>
<h2 class="h1-style">Command-Line Demo</h2>
</section>
<section>
<div class="left-align">
<!-- highlight first topic, gray out second -->
<p class="subhead" style="margin-top: -60px;">Testing for accessibility in:</p>
<h2 class="big-heading" aria-hidden="true">Angular 1</h2>
<h2 class="big-heading">Angular 2*</h2>
</div>
</section>
<section>
<h2 class="fancy">Angular 2: Big differences</h2>
<ul class="larger">
<li>Component-based</li>
<li>TypeScript & ES6</li>
<li>Property bindings</li>
</ul>
<aside class="notes">
Controllers and $scope are no longer used. They have been replaced by components and directives. Components are directives with a template.
</aside>
</section>
<section data-background-image="img/angular2-test-strategies.png">
<h3 class="offscreen">Medium article by Victor Savkin: Three Ways to Test Angular 2 Components</h3>
</section>
<section>
<figure class="support-table">
<table>
<caption>
<h2 class="fancy">Test requirements for a11y</h2>
</caption>
<thead>
<tr>
<th scope="row">Test method</th>
<th scope="col">Rendered</th>
<th scope="col">Attached</th>
</tr>
</thead>
<tbody>
<tr>
<th colspan="3">Unit</th>
</tr>
<tr class="group-lead">
<td>Keyboard mechanics</td>
<td>X</td>
<td>X</td>
</tr>
<tr>
<td>Labeling</td>
<td></td>
<td></td>
</tr>
<tr class="group-end">
<td>ARIA attributes</td>
<td>~</td>
<td>~</td>
</tr>
<tr>
<th colspan="3">End-to-end</th>
</tr>
<tr class="group-lead">
<td>Color contrast</td>
<td>X</td>
<td>X</td>
</tr>
<tr>
<td>Event handlers</td>
<td>~</td>
<td>~</td>
</tr>
<tr class="group-end">
<td>A11y API Audit</td>
<td>X</td>
<td>X</td>
</tr>
</tbody>
</table>
</figure>
</section>
<section data-background-image="img/ngmaterial2.png">
<h3 class="offscreen">Angular Material 2 Preview</h3>
</section>
<section>
<figure class="image-with-caption" style="max-width: 1100px">
<img data-src="img/md-checkbox2-voiceover.png" alt="Material 2 checkbox operated with Voiceover">
<figcaption><a href="https://github.com/angular/material2/tree/master/src/components/checkbox">Material 2 checkbox using Voiceover</a></figcaption>
</figure>
</section>
<section>
<div class="left-align snug">
<h3 class="fancy">Material 2 Unit Test 1/2</h3>
<h4>Applying a text alternative with `aria-labelledby`</h4>
<figure class="code">
<pre class="large"><code class="javascript">
describe('mdCheckbox with provided aria-labelledby ', () => {
let checkboxDebugElement: DebugElement;
let checkboxNativeElement: HTMLElement;
let inputElement: HTMLInputElement;
it('should use the provided aria-labelledby', () => {
fixture = TestBed.createComponent(CheckboxWithAriaLabelledby);
checkboxDebugElement = fixture.debugElement.query(By.directive(MdCheckbox));
checkboxNativeElement = checkboxDebugElement.nativeElement;
inputElement = <HTMLInputElement>checkboxNativeElement.querySelector('input');
fixture.detectChanges();
expect(inputElement.getAttribute('aria-labelledby')).toBe('some-id');
});
</code></pre>
<figcaption><a href="https://github.com/angular/material2/blob/master/src/lib/checkbox/checkbox.spec.ts">Checkbox Spec</a></figcaption>
</figure>
</div>
</section>
<section>
<div class="left-align snug">
<h3 class="fancy">Material 2 Unit Test 2/2</h3>
<h4>ARIA attribute watching</h4>
<figure class="code">
<pre class="large"><code class="javascript">
it('toggles "aria-checked" on the host element', function() {
builder.createAsync(CheckboxController).then(function(fixture) {
let el = fixture.debugElement.query(By.css('.md-checkbox'));
expect(el.nativeElement.getAttribute('aria-checked')).toEqual('false');
controller = fixture.componentInstance;
changePromise = waitForChange();
controller.isChecked = true;
fixture.detectChanges();
expect(el.nativeElement.getAttribute('aria-checked')).toEqual('true');
});
});
</code></pre>
<figcaption>Older Material 2 Checkbox</figcaption>
</figure>
</div>
</section>
<section>
<div class="left-align snug">
<h3 class="fancy">Angular 2 Keyboard Unit Tests</h3>
<img data-src="img/bleeding-edge.gif" alt="Gif with Supergirl saying I'm Bleeding?">
</div>
<aside class="notes">
The pain: events not supported, even click is rough
TypeScript woes for third-party help
</aside>
</section>
<section data-background-image="img/angular2-test-event-request.png">
<h3 class="offscreen">Angular 2 issue on Github: Creating fake event objects for testing components</h3>
</section>
<!-- <section>
<h3>Simulant or aXe example</h3>
</section>
-->
<section>
<h2 class="fancy">End-to-End Testing in Angular 2</h2>
<p class="subhead muted">~ with ~</p>
<h3 class="fancy h1-style">Protractor</h3>
</section>
<section>
<div class="left-align snug">
<h2>Keyboard Test</h2>
<figure class="code">
<pre><code class="javascript">
/*----- menu.e2e.ts -------*/
import { MenuPage } from './menu-page';
describe('menu', () => {
let page: MenuPage;
beforeEach(function() {
page = new MenuPage();
});
describe('keyboard events', () => {
beforeEach(() => {
// click start button to avoid tabbing past navigation
page.start().click();
page.pressKey(protractor.Key.TAB);
});
it('should auto-focus the first item when opened with keyboard', () => {
page.pressKey(protractor.Key.ENTER);
page.expectFocusOn(page.items(0));
});
it('should focus subsequent items when down arrow is pressed', () => {
page.pressKey(protractor.Key.ENTER);
page.pressKey(protractor.Key.DOWN);
page.expectFocusOn(page.items(1));
});
});
});
/*----- menu-page.ts -------*/
pressKey(key: any): void {
browser.actions().sendKeys(key).perform();
}
expectFocusOn(el: ElementFinder): void {
expect(browser.driver.switchTo().activeElement().getInnerHtml())
.toBe(el.getInnerHtml());
}
</code></pre>
<figcaption><a href="https://github.com/angular/material2/blob/master/e2e/components/menu/">Material 2 Menu</a></figcaption>
</figure>
</div>
</section>
<section>
<div class="left-align">
<h2 class="fancy">Mocking Keyboard Events</h2>
<h3 style="margin: 0;">Bug in ChromeDriver</h3>
<p>DOM helper getKeyEvent does not use keyCode<br>
<a href="https://github.com/angular/angular/issues/9419">https://github.com/angular/angular/issues/9419</a></p>
</div>
</section>
<section>
<div class="left-align snug">
<h3 class="fancy">End-to-end Testing with aXe-core</h3>
<figure class="code">
<pre><code class="javascript">
import * as axe from 'axe-core';
...
it('should have no accessibility violations', function(done) {
browser.executeScript(axe.source);
// Run A11Y tests in the browsers event loop.
browser.executeAsyncScript((resolve: any) => {
return new Promise<axe.AxeResults>(res => {
axe.a11yCheck(document, {}, resolve)
});
}).then((results: any) => {
if (results.violations.length > 0) {
console.log(results.violations);
}
expect(results.violations.length).toBe(0);
done();
});
});
</code></pre>
<figcaption>Integration test</figcaption>
</figure>
</div>
</section>
<section>
<h2 class="h1-style fancy">Recap</h2>
<ul class="larger">
<li class="fragment">Accessibility is similar with all web frameworks.</li>
<li class="fragment">Unit tests provide a component accessibility contract.</li>
<li class="fragment">Use integration tests to redirect human resources.</li>
<li class="fragment">Use an API for extra a11y muscle.</li>
<li class="fragment">Prevent broken experiences from going out the door!</li>
</ul>
</section>
<section data-background-color="#ffffff">
<h2 class="fancy">Děkuji!</h2>
<h3 class="subhead"><a href="http://twitter.com/marcysutton">twitter.com/marcysutton</a></h3>
<h3 class="subhead"><a href="http://github.com/marcysutton">github.com/marcysutton</a></h3>
<img data-src="img/deque_logo_600p.jpg" alt="" style="width: 320px;">
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// Full list of configuration options available at:
// https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
width: '100%',
margin: 0,
controls: true,
progress: true,
history: true,
center: true,
keyboard: {
13: 'next', // go to the next slide when the ENTER key is pressed
27: function() {}/*, // do something custom when ESC is pressed
37: null,
39: null // don't do anything when SPACE is pressed (i.e. disable a reveal.js default binding)*/
},
transition: 'slide', // none/fade/slide/convex/concave/zoom
// Optional reveal.js plugins
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true },
{ src: 'plugin/notes/notes.js', async: true },
{ src: 'plugin/accessibility-helpers/accessibility-helpers.js', async: true}
]
});
</script>
</body>
</html>