@@ -97,7 +97,7 @@ ariaTest('Alt + down arrow opens listbox', exampleFile, 'combobox-key-alt-down-a
97
97
t . false ( await listbox . isDisplayed ( ) , 'Listbox should be hidden on load' ) ;
98
98
99
99
// Send ALT + ARROW_DOWN to the combo
100
- await combobox . sendKeys ( Key . ALT , Key . ARROW_DOWN ) ;
100
+ await combobox . sendKeys ( Key . chord ( Key . ALT , Key . ARROW_DOWN ) ) ;
101
101
102
102
// Check that the listbox is displayed
103
103
t . true ( await listbox . isDisplayed ( ) , 'alt + down should show the listbox' ) ;
@@ -107,7 +107,27 @@ ariaTest('Alt + down arrow opens listbox', exampleFile, 'combobox-key-alt-down-a
107
107
t . is ( await combobox . getAttribute ( 'aria-activedescendant' ) , firstOptionId , 'Alt + Down should highlight the first option' ) ;
108
108
} ) ;
109
109
110
- ariaTest ( 'Down arrow opens listbox' , exampleFile , 'combobox-key-down-arrow' , async ( t ) => {
110
+ ariaTest ( 'Up arrow opens listbox' , exampleFile , 'combobox-key-up-arrow' , async ( t ) => {
111
+ const combobox = await t . context . session . findElement ( By . css ( ex . comboSelector ) ) ;
112
+ const listbox = await t . context . session . findElement ( By . css ( ex . listboxSelector ) ) ;
113
+ const firstOptionId = await t . context . session . findElement ( By . css ( `${ ex . listboxSelector } [role=option]` ) ) . getAttribute ( 'id' ) ;
114
+
115
+ // listbox starts collapsed
116
+ t . false ( await listbox . isDisplayed ( ) , 'Listbox should be hidden on load' ) ;
117
+
118
+ // Send ARROW_UP to the combo
119
+ await combobox . sendKeys ( Key . ARROW_UP ) ;
120
+
121
+ // Check that the listbox is displayed
122
+ t . true ( await listbox . isDisplayed ( ) , 'arrow up should show the listbox' ) ;
123
+ t . is ( await combobox . getAttribute ( 'aria-expanded' ) , 'true' , 'aria-expanded should be true when opened' ) ;
124
+
125
+ // the first option should be selected
126
+ t . is ( await combobox . getAttribute ( 'aria-activedescendant' ) , firstOptionId , 'arrow up should highlight the first option' ) ;
127
+ } ) ;
128
+
129
+
130
+ ariaTest ( ' arrow opens listbox' , exampleFile , 'combobox-key-down-arrow' , async ( t ) => {
111
131
const combobox = await t . context . session . findElement ( By . css ( ex . comboSelector ) ) ;
112
132
const listbox = await t . context . session . findElement ( By . css ( ex . listboxSelector ) ) ;
113
133
const firstOptionId = await t . context . session . findElement ( By . css ( `${ ex . listboxSelector } [role=option]` ) ) . getAttribute ( 'id' ) ;
@@ -215,7 +235,7 @@ ariaTest('End opens listbox to last option', exampleFile, 'combobox-key-end', as
215
235
t . is ( await combobox . getAttribute ( 'aria-activedescendant' ) , lastOptionId , 'end should always highlight the last option' ) ;
216
236
} ) ;
217
237
218
- ariaTest ( 'character keys open listbox to matching option' , exampleFile , 'listbox-key-char ' , async ( t ) => {
238
+ ariaTest ( 'character keys open listbox to matching option' , exampleFile , 'printable-chars ' , async ( t ) => {
219
239
const combobox = await t . context . session . findElement ( By . css ( ex . comboSelector ) ) ;
220
240
const listbox = await t . context . session . findElement ( By . css ( ex . listboxSelector ) ) ;
221
241
const secondOptionId = await t . context . session . findElement ( By . css ( `${ ex . listboxSelector } [role=option]:nth-child(2)` ) ) . getAttribute ( 'id' ) ;
@@ -291,6 +311,23 @@ ariaTest('Space closes listbox and selects option', exampleFile, 'listbox-key-sp
291
311
t . is ( await secondOption . getAttribute ( 'aria-selected' ) , 'true' , 'Second option has aria-selected set to true' ) ;
292
312
} ) ;
293
313
314
+ ariaTest ( 'Space closes listbox and selects option' , exampleFile , 'listbox-key-alt-up-arrow' , async ( t ) => {
315
+ const combobox = await t . context . session . findElement ( By . css ( ex . comboSelector ) ) ;
316
+ const listbox = await t . context . session . findElement ( By . css ( ex . listboxSelector ) ) ;
317
+ const secondOption = await t . context . session . findElement ( By . css ( `${ ex . listboxSelector } [role=option]:nth-child(2)` ) ) ;
318
+
319
+ // Open, move to third option, send ALT+UP ARROW
320
+ await combobox . sendKeys ( Key . ENTER , Key . ARROW_DOWN ) ;
321
+ const secondOptionText = await secondOption . getText ( ) ;
322
+ await combobox . sendKeys ( Key . chord ( Key . ALT , Key . ARROW_UP ) ) ;
323
+
324
+ // listbox is collapsed and the value is set to the third option
325
+ t . false ( await listbox . isDisplayed ( ) , 'Listbox should be hidden' ) ;
326
+ t . is ( await combobox . getText ( ) , secondOptionText , 'Combobox inner text should match the second option' ) ;
327
+ t . is ( await secondOption . getAttribute ( 'aria-selected' ) , 'true' , 'Second option has aria-selected set to true' ) ;
328
+ } ) ;
329
+
330
+
294
331
ariaTest ( 'Escape closes listbox without selecting option' , exampleFile , 'listbox-key-escape' , async ( t ) => {
295
332
const combobox = await t . context . session . findElement ( By . css ( ex . comboSelector ) ) ;
296
333
const listbox = await t . context . session . findElement ( By . css ( ex . listboxSelector ) ) ;
@@ -450,7 +487,7 @@ ariaTest('PageUp moves up 10 options, and does not wrap', exampleFile, 'listbox-
450
487
t . is ( await combobox . getAttribute ( 'aria-activedescendant' ) , optionId , 'aria-activedescendant points to the first option after second pageup' ) ;
451
488
} ) ;
452
489
453
- ariaTest ( 'Multiple single-character presses cycle through options' , exampleFile , 'listbox-key-char ' , async ( t ) => {
490
+ ariaTest ( 'Multiple single-character presses cycle through options' , exampleFile , 'printable-chars ' , async ( t ) => {
454
491
const combobox = await t . context . session . findElement ( By . css ( ex . comboSelector ) ) ;
455
492
const options = await t . context . queryElements ( t , `${ ex . listboxSelector } [role=option]` ) ;
456
493
@@ -484,7 +521,7 @@ ariaTest('Multiple single-character presses cycle through options', exampleFile,
484
521
t . is ( await combobox . getAttribute ( 'aria-activedescendant' ) , `${ matchingId } ` , 'aria-activedescendant points to the second option beginning with "b"' ) ;
485
522
} ) ;
486
523
487
- ariaTest ( 'Typing multiple characters refines search' , exampleFile , 'listbox-key-char ' , async ( t ) => {
524
+ ariaTest ( 'Typing multiple characters refines search' , exampleFile , 'printable-chars ' , async ( t ) => {
488
525
const combobox = await t . context . session . findElement ( By . css ( ex . comboSelector ) ) ;
489
526
const options = await t . context . queryElements ( t , `${ ex . listboxSelector } [role=option]` ) ;
490
527
@@ -505,4 +542,4 @@ ariaTest('Typing multiple characters refines search', exampleFile, 'listbox-key-
505
542
506
543
// now fourth option should be highlighted
507
544
t . is ( await combobox . getAttribute ( 'aria-activedescendant' ) , fourthId , 'The fourth option is highlighted after typing multiple letters' ) ;
508
- } ) ;
545
+ } ) ;
0 commit comments