@@ -387,4 +387,93 @@ describe("Accessibility", () => {
387387 . should ( "have.attr" , "aria-label" , labelText ) ;
388388 } ) ;
389389 } ) ;
390- } ) ;
390+
391+ it ( "should provide correct accessibilityInfo properties" , ( ) => {
392+ cy . mount (
393+ < >
394+ < CheckBox
395+ id = "accessibilityTestCb"
396+ text = "Accessibility Test"
397+ required
398+ readonly
399+ accessibleName = "Custom Aria Label"
400+ > </ CheckBox >
401+ </ >
402+ ) ;
403+
404+ cy . get ( "#accessibilityTestCb" ) . then ( $checkbox => {
405+ const checkbox = $checkbox [ 0 ] as CheckBox ;
406+ const accInfo = checkbox . accessibilityInfo ;
407+
408+ expect ( accInfo . type ) . to . equal ( "Checkbox" ) ;
409+
410+ // Description should come from accessibleName property
411+ expect ( accInfo . description ) . to . equal ( "Custom Aria Label" ) ;
412+
413+ expect ( accInfo . readonly ) . to . be . true ;
414+ expect ( accInfo . required ) . to . be . true ;
415+ expect ( accInfo . disabled ) . to . be . false ;
416+
417+ expect ( accInfo . role ) . to . equal ( "checkbox" ) ;
418+ } ) ;
419+ } ) ;
420+
421+ // should provide correct accessibilityInfo description from associated label wits accessibleNameRef
422+ it ( "should provide correct accessibilityInfo description from accessibleNameRef" , ( ) => {
423+ cy . mount (
424+ < >
425+ < label id = "cb-label" > Label For Accessibility Test</ label >
426+ < CheckBox
427+ id = "accessibilityTestCb1"
428+ accessibleNameRef = "cb-label"
429+ > </ CheckBox >
430+ </ >
431+ ) ;
432+
433+ cy . get ( "#accessibilityTestCb1" ) . then ( $checkbox => {
434+ const checkbox = $checkbox [ 0 ] as CheckBox ;
435+ const accInfo = checkbox . accessibilityInfo ;
436+
437+ // Description should come from associated label
438+ expect ( accInfo . description ) . to . equal ( "Label For Accessibility Test" ) ;
439+ } ) ;
440+ } ) ;
441+
442+ it ( "should provide correct accessibilityInfo description from text" , ( ) => {
443+ cy . mount (
444+ < >
445+ < CheckBox
446+ id = "accessibilityTestCb2"
447+ text = "Accessibility Test Text"
448+ > </ CheckBox >
449+ </ >
450+ ) ;
451+
452+ cy . get ( "#accessibilityTestCb2" ) . then ( $checkbox => {
453+ const checkbox = $checkbox [ 0 ] as CheckBox ;
454+ const accInfo = checkbox . accessibilityInfo ;
455+
456+ // Description should come from text property
457+ expect ( accInfo . description ) . to . equal ( "Accessibility Test Text" ) ;
458+ } ) ;
459+ } ) ;
460+
461+ it ( "should provide correct accessibilityInfo description from associated label" , ( ) => {
462+ cy . mount (
463+ < >
464+ < label for = "accessibilityTestCb3" > Label For Accessibility Test</ label >
465+ < CheckBox
466+ id = "accessibilityTestCb3"
467+ > </ CheckBox >
468+ </ >
469+ ) ;
470+
471+ cy . get ( "#accessibilityTestCb3" ) . then ( $checkbox => {
472+ const checkbox = $checkbox [ 0 ] as CheckBox ;
473+ const accInfo = checkbox . accessibilityInfo ;
474+
475+ // Description should come from associated label
476+ expect ( accInfo . description ) . to . equal ( "Label For Accessibility Test" ) ;
477+ } ) ;
478+ } ) ;
479+ } ) ;
0 commit comments