@@ -99,6 +99,19 @@ describe('Critical Functionality', () => {
99
99
cy . get ( 'button' ) . click ( ) . should ( 'have.attr' , 'aria-expanded' , 'true' ) ;
100
100
} ) ;
101
101
102
+ it . only ( `GIVEN a Combobox component with a trigger
103
+ WHEN a trigger is clicked, the listbox is open, and the first open clicked
104
+ THEN the first option should be selected
105
+ ` , ( ) => {
106
+ cy . mount ( < StringCombobox /> ) ;
107
+
108
+ cy . get ( 'button' ) . click ( ) ;
109
+
110
+ cy . get ( 'li' ) . first ( ) . click ( ) ;
111
+
112
+ cy . get ( 'li' ) . first ( ) . should ( 'have.attr' , 'aria-selected' ) ;
113
+ } ) ;
114
+
102
115
it ( `GIVEN a Combobox component with an open listbox and trigger
103
116
WHEN the trigger is clicked,
104
117
THEN the listbox should close` , ( ) => {
@@ -235,11 +248,7 @@ describe('Default Label', () => {
235
248
236
249
cy . get ( 'input' ) . should ( 'have.value' , 'Jabuticaba' ) . type ( `{downarrow}` ) ;
237
250
238
- cy . findByRole ( 'option' , { name : 'Jabuticaba' } ) . should (
239
- 'have.attr' ,
240
- 'aria-selected' ,
241
- 'true' ,
242
- ) ;
251
+ cy . get ( '[data-highlighted]' ) . should ( 'have.text' , 'Jabuticaba' ) ;
243
252
} ) ;
244
253
} ) ;
245
254
@@ -265,7 +274,7 @@ describe('Keyboard Navigation', () => {
265
274
266
275
cy . get ( 'input' ) . type ( `{downarrow}` ) . type ( `{home}` ) ;
267
276
268
- cy . get ( 'li' ) . first ( ) . should ( 'have.attr' , 'aria-selected' , 'true ') ;
277
+ cy . get ( 'li' ) . first ( ) . should ( 'have.attr' , 'data-highlighted ' ) ;
269
278
} ) ;
270
279
271
280
it ( `GIVEN a Combobox component with a focused option inside a listbox,
@@ -275,7 +284,7 @@ describe('Keyboard Navigation', () => {
275
284
276
285
cy . get ( 'input' ) . type ( `{downarrow}` ) . type ( `{end}` ) ;
277
286
278
- cy . get ( 'li' ) . last ( ) . should ( 'have.attr' , 'aria-selected' , 'true ') ;
287
+ cy . get ( 'li' ) . last ( ) . should ( 'have.attr' , 'data-highlighted ' ) ;
279
288
} ) ;
280
289
281
290
it ( `GIVEN a Combobox component and selected text in an input field,
@@ -302,7 +311,7 @@ describe('Keyboard Navigation', () => {
302
311
cy . get ( 'input' ) . type ( `{downarrow}` ) . type ( `{downarrow}` ) ;
303
312
304
313
// grabs the 2nd element because the index is 1
305
- cy . get ( 'li' ) . filter ( ':visible' ) . eq ( 1 ) . should ( 'have.attr' , 'aria-selected' , 'true ') ;
314
+ cy . get ( 'li' ) . filter ( ':visible' ) . eq ( 1 ) . should ( 'have.attr' , 'data-highlighted ' ) ;
306
315
} ) ;
307
316
308
317
it ( `GIVEN a Combobox component with an open listbox and multiple filtered options
@@ -314,7 +323,7 @@ describe('Keyboard Navigation', () => {
314
323
315
324
cy . findByRole ( 'listbox' ) ;
316
325
317
- cy . get ( 'li' ) . filter ( ':visible' ) . first ( ) . should ( 'have.attr' , 'aria-selected' , 'true ') ;
326
+ cy . get ( 'li' ) . filter ( ':visible' ) . first ( ) . should ( 'have.attr' , 'data-highlighted ' ) ;
318
327
} ) ;
319
328
320
329
it ( `GIVEN a Combobox component with an open listbox and multiple filtered options
@@ -326,7 +335,7 @@ describe('Keyboard Navigation', () => {
326
335
327
336
cy . findByRole ( 'listbox' ) ;
328
337
329
- cy . get ( 'li' ) . filter ( ':visible' ) . last ( ) . should ( 'have.attr' , 'aria-selected' , 'true ') ;
338
+ cy . get ( 'li' ) . filter ( ':visible' ) . last ( ) . should ( 'have.attr' , 'data-highlighted ' ) ;
330
339
} ) ;
331
340
332
341
it ( `GIVEN a Combobox component with an open listbox and multiple filtered options
@@ -338,7 +347,7 @@ describe('Keyboard Navigation', () => {
338
347
339
348
cy . findByRole ( 'listbox' ) ;
340
349
341
- cy . get ( 'li' ) . filter ( ':visible' ) . first ( ) . should ( 'have.attr' , 'aria-selected' , 'true ') ;
350
+ cy . get ( 'li' ) . filter ( ':visible' ) . first ( ) . should ( 'have.attr' , 'data-highlighted ' ) ;
342
351
} ) ;
343
352
344
353
it ( `GIVEN a Combobox component with an open listbox and multiple filtered options
@@ -352,7 +361,7 @@ describe('Keyboard Navigation', () => {
352
361
353
362
cy . get ( 'input' ) . type ( `{downarrow}` ) ;
354
363
355
- cy . get ( 'li' ) . filter ( ':visible' ) . first ( ) . should ( 'have.attr' , 'aria-selected' , 'true ') ;
364
+ cy . get ( 'li' ) . filter ( ':visible' ) . first ( ) . should ( 'have.attr' , 'data-highlighted ' ) ;
356
365
} ) ;
357
366
358
367
it ( `GIVEN a Combobox component with an open listbox and an option is in focus,
@@ -493,11 +502,7 @@ describe('Disabled & Object Combobox', () => {
493
502
494
503
cy . get ( 'input' ) . type ( `{downarrow}` ) ;
495
504
496
- cy . findByRole ( 'option' , { name : `Malcolm` } ) . should (
497
- 'have.attr' ,
498
- 'aria-selected' ,
499
- 'true' ,
500
- ) ;
505
+ cy . findByRole ( 'option' , { name : `Malcolm` } ) . should ( 'have.attr' , 'data-highlighted' ) ;
501
506
} ) ;
502
507
503
508
it ( `GIVEN a Combobox component with an open listbox and disabled options,
@@ -507,11 +512,7 @@ describe('Disabled & Object Combobox', () => {
507
512
508
513
cy . get ( 'input' ) . type ( `{downarrow}` ) . type ( `{uparrow}` ) ;
509
514
510
- cy . findByRole ( 'option' , { name : `Mark` } ) . should (
511
- 'have.attr' ,
512
- 'aria-selected' ,
513
- 'true' ,
514
- ) ;
515
+ cy . findByRole ( 'option' , { name : `Mark` } ) . should ( 'have.attr' , 'data-highlighted' ) ;
515
516
} ) ;
516
517
517
518
it ( `GIVEN a Combobox component with an open listbox and disabled options,
@@ -523,11 +524,7 @@ describe('Disabled & Object Combobox', () => {
523
524
524
525
cy . get ( 'input' ) . type ( `{home}` ) ;
525
526
526
- cy . findByRole ( 'option' , { name : `Malcolm` } ) . should (
527
- 'have.attr' ,
528
- 'aria-selected' ,
529
- 'true' ,
530
- ) ;
527
+ cy . findByRole ( 'option' , { name : `Malcolm` } ) . should ( 'have.attr' , 'data-highlighted' ) ;
531
528
} ) ;
532
529
533
530
it ( `GIVEN a Combobox component with an open listbox and disabled options,
@@ -539,11 +536,7 @@ describe('Disabled & Object Combobox', () => {
539
536
540
537
cy . get ( 'input' ) . type ( `{end}` ) ;
541
538
542
- cy . findByRole ( 'option' , { name : `Mark` } ) . should (
543
- 'have.attr' ,
544
- 'aria-selected' ,
545
- 'true' ,
546
- ) ;
539
+ cy . findByRole ( 'option' , { name : `Mark` } ) . should ( 'have.attr' , 'data-highlighted' ) ;
547
540
} ) ;
548
541
549
542
it ( `GIVEN a Combobox component with an open listbox and disabled options,
@@ -556,11 +549,7 @@ describe('Disabled & Object Combobox', () => {
556
549
557
550
cy . get ( 'input' ) . type ( `{downarrow}` ) ;
558
551
559
- cy . findByRole ( 'option' , { name : `Brian` } ) . should (
560
- 'have.attr' ,
561
- 'aria-selected' ,
562
- 'true' ,
563
- ) ;
552
+ cy . findByRole ( 'option' , { name : `Brian` } ) . should ( 'have.attr' , 'data-highlighted' ) ;
564
553
} ) ;
565
554
566
555
it ( `GIVEN a Combobox component with an open listbox and disabled options,
@@ -575,11 +564,7 @@ describe('Disabled & Object Combobox', () => {
575
564
576
565
cy . get ( 'input' ) . type ( `{uparrow}` ) ;
577
566
578
- cy . findByRole ( 'option' , { name : `Malcolm` } ) . should (
579
- 'have.attr' ,
580
- 'aria-selected' ,
581
- 'true' ,
582
- ) ;
567
+ cy . findByRole ( 'option' , { name : `Malcolm` } ) . should ( 'have.attr' , 'data-highlighted' ) ;
583
568
} ) ;
584
569
585
570
it ( `GIVEN a Combobox component with an open listbox and disabled options,
@@ -595,19 +580,11 @@ describe('Disabled & Object Combobox', () => {
595
580
. type ( `{downarrow}` )
596
581
. type ( `{downarrow}` ) ;
597
582
598
- cy . findByRole ( 'option' , { name : `Randy` } ) . should (
599
- 'have.attr' ,
600
- 'aria-selected' ,
601
- 'true' ,
602
- ) ;
583
+ cy . findByRole ( 'option' , { name : `Randy` } ) . should ( 'have.attr' , 'data-highlighted' ) ;
603
584
604
585
cy . get ( 'input' ) . type ( `{downarrow}` ) ;
605
586
606
- cy . findByRole ( 'option' , { name : `Mark` } ) . should (
607
- 'have.attr' ,
608
- 'aria-selected' ,
609
- 'true' ,
610
- ) ;
587
+ cy . findByRole ( 'option' , { name : `Mark` } ) . should ( 'have.attr' , 'data-highlighted' ) ;
611
588
} ) ;
612
589
613
590
it ( `GIVEN a Combobox component with an open listbox and disabled options,
@@ -623,26 +600,14 @@ describe('Disabled & Object Combobox', () => {
623
600
. type ( `{downarrow}` )
624
601
. type ( `{downarrow}` ) ;
625
602
626
- cy . findByRole ( 'option' , { name : `Randy` } ) . should (
627
- 'have.attr' ,
628
- 'aria-selected' ,
629
- 'true' ,
630
- ) ;
603
+ cy . findByRole ( 'option' , { name : `Randy` } ) . should ( 'have.attr' , 'data-highlighted' ) ;
631
604
632
605
cy . get ( 'input' ) . type ( `{downarrow}` ) ;
633
606
634
- cy . findByRole ( 'option' , { name : `Mark` } ) . should (
635
- 'have.attr' ,
636
- 'aria-selected' ,
637
- 'true' ,
638
- ) ;
607
+ cy . findByRole ( 'option' , { name : `Mark` } ) . should ( 'have.attr' , 'data-highlighted' ) ;
639
608
640
609
cy . get ( 'input' ) . type ( `{uparrow}` ) ;
641
610
642
- cy . findByRole ( 'option' , { name : `Randy` } ) . should (
643
- 'have.attr' ,
644
- 'aria-selected' ,
645
- 'true' ,
646
- ) ;
611
+ cy . findByRole ( 'option' , { name : `Randy` } ) . should ( 'have.attr' , 'data-highlighted' ) ;
647
612
} ) ;
648
613
} ) ;
0 commit comments