2
2
3
3
const { ariaTest } = require ( '..' ) ;
4
4
const { By, Key } = require ( 'selenium-webdriver' ) ;
5
- const assertAttributeValues = require ( '../util/assertAttributeValues' ) ;
6
5
const assertAriaControls = require ( '../util/assertAriaControls' ) ;
7
6
const assertAriaLabelledby = require ( '../util/assertAriaLabelledby' ) ;
8
7
@@ -45,9 +44,8 @@ const focusMatchesElement = async function (t, selector) {
45
44
// Attributes
46
45
47
46
ariaTest ( 'h3 element should wrap accordion button' , exampleFile , 'h3-element' , async ( t ) => {
48
- t . plan ( 3 ) ;
49
-
50
- const buttons = await t . context . session . findElements ( By . css ( ex . buttonSelector ) ) ;
47
+
48
+ const buttons = await t . context . queryElements ( t , ex . buttonSelector ) ;
51
49
52
50
for ( let button of buttons ) {
53
51
t . is (
@@ -59,9 +57,8 @@ ariaTest('h3 element should wrap accordion button', exampleFile, 'h3-element', a
59
57
} ) ;
60
58
61
59
ariaTest ( 'aria-expanded on button element' , exampleFile , 'button-aria-expanded' , async ( t ) => {
62
- t . plan ( 9 ) ;
63
-
64
- const buttons = await t . context . session . findElements ( By . css ( ex . buttonSelector ) ) ;
60
+
61
+ const buttons = await t . context . queryElements ( t , ex . buttonSelector ) ;
65
62
66
63
for ( let expandIndex = 0 ; expandIndex < buttons . length ; expandIndex ++ ) {
67
64
@@ -81,15 +78,13 @@ ariaTest('aria-expanded on button element', exampleFile, 'button-aria-expanded',
81
78
} ) ;
82
79
83
80
ariaTest ( 'aria-controls on button element' , exampleFile , 'button-aria-controls' , async ( t ) => {
84
- t . plan ( 1 ) ;
85
-
81
+
86
82
await assertAriaControls ( t , ex . buttonSelector ) ;
87
83
} ) ;
88
84
89
85
ariaTest ( '"aria-disabled" set on expanded sections' , exampleFile , 'button-aria-disabled' , async ( t ) => {
90
- t . plan ( 9 ) ;
91
-
92
- const buttons = await t . context . session . findElements ( By . css ( ex . buttonSelector ) ) ;
86
+
87
+ const buttons = await t . context . queryElements ( t , ex . buttonSelector ) ;
93
88
94
89
for ( let expandIndex = 0 ; expandIndex < buttons . length ; expandIndex ++ ) {
95
90
@@ -109,9 +104,8 @@ ariaTest('"aria-disabled" set on expanded sections', exampleFile, 'button-aria-d
109
104
} ) ;
110
105
111
106
ariaTest ( 'role "region" exists on accordion panels' , exampleFile , 'region-role' , async ( t ) => {
112
- t . plan ( 3 ) ;
113
-
114
- const buttons = await t . context . session . findElements ( By . css ( ex . buttonSelector ) ) ;
107
+
108
+ const buttons = await t . context . queryElements ( t , ex . buttonSelector ) ;
115
109
const panelIds = [ ] ;
116
110
for ( let button of buttons ) {
117
111
panelIds . push ( await button . getAttribute ( 'aria-controls' ) ) ;
@@ -127,18 +121,16 @@ ariaTest('role "region" exists on accordion panels', exampleFile, 'region-role',
127
121
} ) ;
128
122
129
123
ariaTest ( '"aria-labelledby" on region' , exampleFile , 'region-aria-labelledby' , async ( t ) => {
130
- t . plan ( 1 ) ;
131
- await assertAriaLabelledby ( t , ex . panelSelector ) ;
124
+ await assertAriaLabelledby ( t , ex . panelSelector ) ;
132
125
} ) ;
133
126
134
127
135
128
// Keys
136
129
137
130
ariaTest ( 'ENTER key expands section' , exampleFile , 'key-enter-or-space' , async ( t ) => {
138
- t . plan ( 12 ) ;
139
-
140
- const buttons = await t . context . session . findElements ( By . css ( ex . buttonSelector ) ) ;
141
- const panels = await t . context . session . findElements ( By . css ( ex . panelSelector ) ) ;
131
+
132
+ const buttons = await t . context . queryElements ( t , ex . buttonSelector ) ;
133
+ const panels = await t . context . queryElements ( t , ex . panelSelector ) ;
142
134
143
135
for ( let expandIndex of [ 1 , 2 , 0 ] ) {
144
136
await buttons [ expandIndex ] . sendKeys ( Key . ENTER ) ;
@@ -170,10 +162,9 @@ ariaTest('ENTER key expands section', exampleFile, 'key-enter-or-space', async (
170
162
} ) ;
171
163
172
164
ariaTest ( 'SPACE key expands section' , exampleFile , 'key-enter-or-space' , async ( t ) => {
173
- t . plan ( 12 ) ;
174
-
175
- const buttons = await t . context . session . findElements ( By . css ( ex . buttonSelector ) ) ;
176
- const panels = await t . context . session . findElements ( By . css ( ex . panelSelector ) ) ;
165
+
166
+ const buttons = await t . context . queryElements ( t , ex . buttonSelector ) ;
167
+ const panels = await t . context . queryElements ( t , ex . panelSelector ) ;
177
168
178
169
for ( let expandIndex of [ 1 , 2 , 0 ] ) {
179
170
await buttons [ expandIndex ] . sendKeys ( Key . SPACE ) ;
@@ -205,9 +196,8 @@ ariaTest('SPACE key expands section', exampleFile, 'key-enter-or-space', async (
205
196
} ) ;
206
197
207
198
ariaTest ( 'TAB moves focus between headers and displayed inputs' , exampleFile , 'key-tab' , async ( t ) => {
208
- t . plan ( 22 ) ;
209
-
210
- const buttons = await t . context . session . findElements ( By . css ( ex . buttonSelector ) ) ;
199
+
200
+ const buttons = await t . context . queryElements ( t , ex . buttonSelector ) ;
211
201
212
202
// Open a panel
213
203
await buttons [ 0 ] . click ( ) ;
@@ -280,9 +270,8 @@ ariaTest('TAB moves focus between headers and displayed inputs', exampleFile, 'k
280
270
} ) ;
281
271
282
272
ariaTest ( 'SHIFT+TAB moves focus between headers and displayed inputs' , exampleFile , 'key-shift-tab' , async ( t ) => {
283
- t . plan ( 22 ) ;
284
-
285
- const buttons = await t . context . session . findElements ( By . css ( ex . buttonSelector ) ) ;
273
+
274
+ const buttons = await t . context . queryElements ( t , ex . buttonSelector ) ;
286
275
287
276
// Open a panel
288
277
await buttons [ 0 ] . click ( ) ;
@@ -358,9 +347,8 @@ ariaTest('SHIFT+TAB moves focus between headers and displayed inputs', exampleFi
358
347
} ) ;
359
348
360
349
ariaTest ( 'DOWN ARROW moves focus between headers' , exampleFile , 'key-down-arrow' , async ( t ) => {
361
- t . plan ( 3 ) ;
362
-
363
- const buttons = await t . context . session . findElements ( By . css ( ex . buttonSelector ) ) ;
350
+
351
+ const buttons = await t . context . queryElements ( t , ex . buttonSelector ) ;
364
352
365
353
// Confirm focus moves through remaining items
366
354
for ( let index = 0 ; index < ex . buttonsInOrder . length - 1 ; index ++ ) {
@@ -387,7 +375,7 @@ ariaTest('DOWN ARROW moves focus between headers', exampleFile, 'key-down-arrow'
387
375
388
376
ariaTest ( 'UP ARROW moves focus between headers' , exampleFile , 'key-up-arrow' , async ( t ) => {
389
377
390
- const buttons = await t . context . session . findElements ( By . css ( ex . buttonSelector ) ) ;
378
+ const buttons = await t . context . queryElements ( t , ex . buttonSelector ) ;
391
379
392
380
// Confirm focus moves through remaining items
393
381
for ( let index = ex . buttonsInOrder . length - 1 ; index > 0 ; index -- ) {
@@ -413,9 +401,8 @@ ariaTest('UP ARROW moves focus between headers', exampleFile, 'key-up-arrow', as
413
401
} ) ;
414
402
415
403
ariaTest ( 'HOME key will always move focus to first button' , exampleFile , 'key-home' , async ( t ) => {
416
- t . plan ( 3 ) ;
417
-
418
- const buttons = await t . context . session . findElements ( By . css ( ex . buttonSelector ) ) ;
404
+
405
+ const buttons = await t . context . queryElements ( t , ex . buttonSelector ) ;
419
406
const lastIndex = ex . buttonsInOrder . length - 1 ;
420
407
421
408
// Confirm focus moves through remaining items
@@ -433,9 +420,8 @@ ariaTest('HOME key will always move focus to first button', exampleFile, 'key-ho
433
420
} ) ;
434
421
435
422
ariaTest ( 'END key will always move focus to last button' , exampleFile , 'key-end' , async ( t ) => {
436
- t . plan ( 3 ) ;
437
-
438
- const buttons = await t . context . session . findElements ( By . css ( ex . buttonSelector ) ) ;
423
+
424
+ const buttons = await t . context . queryElements ( t , ex . buttonSelector ) ;
439
425
const lastIndex = ex . buttonsInOrder . length - 1 ;
440
426
441
427
// Confirm focus moves through remaining items
0 commit comments