@@ -17,6 +17,7 @@ import {
1717 testSetup ,
1818 sendKeyAndWait ,
1919 keyRight ,
20+ keyDown ,
2021 getCurrentFocusedBlockId ,
2122 blockIsPresent ,
2223 keyUp ,
@@ -133,3 +134,52 @@ suite('Insert test', function () {
133134 ) ;
134135 } ) ;
135136} ) ;
137+
138+ suite ( 'Insert test with more blocks' , function ( ) {
139+ // Disable timeouts when non-zero PAUSE_TIME is used to watch tests run.
140+ if ( PAUSE_TIME ) this . timeout ( 0 ) ;
141+
142+ // Clear the workspace and load start blocks.
143+ setup ( async function ( ) {
144+ this . browser = await testSetup (
145+ testFileLocations . MORE_BLOCKS ,
146+ this . timeout ( ) ,
147+ ) ;
148+ await this . browser . pause ( PAUSE_TIME ) ;
149+ } ) ;
150+
151+ test ( 'Does not bump immovable input blocks on insert' , async function ( ) {
152+ // Focus the print block with a connected input block. Ordinarily, inserting
153+ // an input block would connect it to this block and bump its child, but
154+ // if all blocks are immovable the connected input block should not move
155+ // and the newly inserted block should be added as a top-level block on the
156+ // workspace.
157+ await focusOnBlock ( this . browser , 'text_print_2' ) ;
158+ await this . browser . execute ( ( ) => {
159+ Blockly . getMainWorkspace ( )
160+ . getAllBlocks ( )
161+ . forEach ( ( b ) => b . setMovable ( false ) ) ;
162+ } ) ;
163+ await tabNavigateToToolbox ( this . browser ) ;
164+
165+ // Insert number block
166+ await keyDown ( this . browser , 2 ) ;
167+ await keyRight ( this . browser ) ;
168+ // Choose.
169+ await sendKeyAndWait ( this . browser , Key . Enter ) ;
170+ // Confirm position.
171+ await sendKeyAndWait ( this . browser , Key . Enter ) ;
172+
173+ // Assert inserted at the top-level due to immovable block occupying the
174+ // selected block's input.
175+ chai . assert . equal ( 'math_number' , await getFocusedBlockType ( this . browser ) ) ;
176+ const focusedBlockIsParentless = await this . browser . execute ( ( ) => {
177+ const focusedNode = Blockly . getFocusManager ( ) . getFocusedNode ( ) ;
178+ return (
179+ focusedNode instanceof Blockly . BlockSvg &&
180+ focusedNode . getParent ( ) === null
181+ ) ;
182+ } ) ;
183+ chai . assert . isTrue ( focusedBlockIsParentless ) ;
184+ } ) ;
185+ } ) ;
0 commit comments