File tree Expand file tree Collapse file tree 3 files changed +39
-1
lines changed
Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -185,7 +185,10 @@ export class EnterAction {
185185 Events . setGroup ( true ) ;
186186 }
187187
188- const stationaryNode = FocusableTreeTraverser . findFocusedNode ( workspace ) ;
188+ // If the workspace has never had focus default the stationary node.
189+ const stationaryNode =
190+ FocusableTreeTraverser . findFocusedNode ( workspace ) ??
191+ workspace . getRestoredFocusableNode ( null ) ;
189192 const newBlock = this . createNewBlock ( workspace ) ;
190193 if ( ! newBlock ) return ;
191194 const insertStartPoint = stationaryNode
Original file line number Diff line number Diff line change @@ -15,6 +15,9 @@ import {
1515 testFileLocations ,
1616 testSetup ,
1717 keyRight ,
18+ tabNavigateForward ,
19+ keyUp ,
20+ tabNavigateToToolbox ,
1821} from './test_setup.js' ;
1922
2023suite ( 'Insert test' , function ( ) {
@@ -45,4 +48,23 @@ suite('Insert test', function () {
4548 await getFocusedBlockType ( this . browser ) ,
4649 ) ;
4750 } ) ;
51+
52+ test ( 'Insert without having focused the workspace' , async function ( ) {
53+ await tabNavigateToToolbox ( this . browser ) ;
54+
55+ // Insert 'if' block
56+ await keyRight ( this . browser ) ;
57+ // Choose.
58+ await this . browser . keys ( Key . Enter ) ;
59+ // Confirm position.
60+ await this . browser . keys ( Key . Enter ) ;
61+
62+ // Assert inserted inside first block p5_setup not at top-level.
63+ chai . assert . equal ( 'controls_if' , await getFocusedBlockType ( this . browser ) ) ;
64+ await keyUp ( this . browser ) ;
65+ chai . assert . equal (
66+ 'p5_background_color' ,
67+ await getFocusedBlockType ( this . browser ) ,
68+ ) ;
69+ } ) ;
4870} ) ;
Original file line number Diff line number Diff line change @@ -424,6 +424,19 @@ export async function tabNavigateToWorkspace(
424424 tabNavigateForward ( browser ) ; // Tab to the workspace itself.
425425}
426426
427+ /**
428+ * Uses tabs to navigate to the toolbox on the test page (i.e. by going
429+ * through top-level tab stops). Assumes initial load tab position.
430+ *
431+ * @param browser The active WebdriverIO Browser object.
432+ */
433+ export async function tabNavigateToToolbox ( browser : WebdriverIO . Browser ) {
434+ // Initial pre-injection focusable div element.
435+ await tabNavigateForward ( browser ) ;
436+ // Toolbox.
437+ await tabNavigateForward ( browser ) ;
438+ }
439+
427440/**
428441 * Navigates forward to the test page's next tab stop.
429442 *
You can’t perform that action at this time.
0 commit comments