@@ -371,7 +371,7 @@ suite('ARIA', function () {
371371 assert . notInclude ( label , 'Begin stack' ) ;
372372 } ) ;
373373
374- test ( 'Nested statement blocks in first statement input do not include their parent input in their label' , function ( ) {
374+ test ( 'Statement blocks in first statement input do not include their parent input in their label' , function ( ) {
375375 const ifBlock = this . makeBlock ( 'controls_ifelse' ) ;
376376 const printBlock = this . makeBlock ( 'text_print' ) ;
377377 ifBlock . getInput ( 'IF0' ) . connection . connect ( printBlock . previousConnection ) ;
@@ -382,7 +382,7 @@ suite('ARIA', function () {
382382 assert . isFalse ( label . startsWith ( 'Begin do' ) ) ;
383383 } ) ;
384384
385- test ( 'Nested statement blocks in subsequent statement inputs include their parent input in their label' , function ( ) {
385+ test ( 'Statement blocks in subsequent statement inputs include their parent input in their label' , function ( ) {
386386 const ifBlock = this . makeBlock ( 'controls_ifelse' ) ;
387387 const printBlock = this . makeBlock ( 'text_print' ) ;
388388 ifBlock
@@ -395,6 +395,75 @@ suite('ARIA', function () {
395395 assert . isTrue ( label . startsWith ( 'Begin else' ) ) ;
396396 } ) ;
397397
398+ test ( 'A custom statement input label is wrapped in the "Begin" prefix' , function ( ) {
399+ const ifBlock = this . makeBlock ( 'controls_ifelse' ) ;
400+ ifBlock . getInput ( 'ELSE' ) . setAriaLabelProvider ( 'otherwise do' ) ;
401+ const printBlock = this . makeBlock ( 'text_print' ) ;
402+ ifBlock
403+ . getInput ( 'ELSE' )
404+ . connection . connect ( printBlock . previousConnection ) ;
405+ const label = Blockly . utils . aria . getState (
406+ printBlock . getFocusableElement ( ) ,
407+ Blockly . utils . aria . State . LABEL ,
408+ ) ;
409+ assert . include ( label , 'Begin otherwise do' ) ;
410+ } ) ;
411+
412+ test ( 'A custom label on the first statement input is prepended to its child block label' , function ( ) {
413+ const ifBlock = this . makeBlock ( 'controls_ifelse' ) ;
414+ ifBlock . getInput ( 'DO0' ) . setAriaLabelProvider ( 'then do' ) ;
415+ const printBlock = this . makeBlock ( 'text_print' ) ;
416+ ifBlock . getInput ( 'DO0' ) . connection . connect ( printBlock . previousConnection ) ;
417+ const label = Blockly . utils . aria . getState (
418+ printBlock . getFocusableElement ( ) ,
419+ Blockly . utils . aria . State . LABEL ,
420+ ) ;
421+ assert . include ( label , 'Begin then do' ) ;
422+ } ) ;
423+
424+ test ( 'A custom input label is only used for the first child block in a statement input stack' , function ( ) {
425+ const ifBlock = this . makeBlock ( 'controls_ifelse' ) ;
426+ ifBlock . getInput ( 'ELSE' ) . setAriaLabelProvider ( 'otherwise do' ) ;
427+ const firstPrintBlock = this . makeBlock ( 'text_print' ) ;
428+ ifBlock
429+ . getInput ( 'ELSE' )
430+ . connection . connect ( firstPrintBlock . previousConnection ) ;
431+ const secondPrintBlock = this . makeBlock ( 'text_print' ) ;
432+ firstPrintBlock . nextConnection . connect (
433+ secondPrintBlock . previousConnection ,
434+ ) ;
435+ const subsequentLabel = Blockly . utils . aria . getState (
436+ secondPrintBlock . getFocusableElement ( ) ,
437+ Blockly . utils . aria . State . LABEL ,
438+ ) ;
439+ assert . notInclude ( subsequentLabel , 'otherwise do' ) ;
440+ } ) ;
441+
442+ test ( 'A custom input label is prepended to the child block of a value input' , function ( ) {
443+ const ifBlock = this . makeBlock ( 'controls_ifelse' ) ;
444+ ifBlock . getInput ( 'IF0' ) . setAriaLabelProvider ( 'condition' ) ;
445+ const boolBlock = this . makeBlock ( 'logic_boolean' ) ;
446+ ifBlock . getInput ( 'IF0' ) . connection . connect ( boolBlock . outputConnection ) ;
447+ const label = Blockly . utils . aria . getState (
448+ boolBlock . getFocusableElement ( ) ,
449+ Blockly . utils . aria . State . LABEL ,
450+ ) ;
451+ assert . include ( label , 'condition' ) ;
452+ } ) ;
453+
454+ test ( 'A block connected to a value input without a custom label does not include the input label' , function ( ) {
455+ const negateBlock = this . makeBlock ( 'logic_negate' ) ;
456+ const boolBlock = this . makeBlock ( 'logic_boolean' ) ;
457+ negateBlock
458+ . getInput ( 'BOOL' )
459+ . connection . connect ( boolBlock . outputConnection ) ;
460+ const label = Blockly . utils . aria . getState (
461+ boolBlock . getFocusableElement ( ) ,
462+ Blockly . utils . aria . State . LABEL ,
463+ ) ;
464+ assert . notInclude ( label , 'not' ) ;
465+ } ) ;
466+
398467 test ( 'Disabled blocks indicate that in their label' , function ( ) {
399468 const block = this . makeBlock ( 'text_print' ) ;
400469 let label = Blockly . utils . aria . getState (
0 commit comments