File tree Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Expand file tree Collapse file tree 3 files changed +38
-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,8 @@ import {
1515 testFileLocations ,
1616 testSetup ,
1717 keyRight ,
18+ keyUp ,
19+ tabNavigateToToolbox ,
1820} from './test_setup.js' ;
1921
2022suite ( 'Insert test' , function ( ) {
@@ -45,4 +47,23 @@ suite('Insert test', function () {
4547 await getFocusedBlockType ( this . browser ) ,
4648 ) ;
4749 } ) ;
50+
51+ test ( 'Insert without having focused the workspace' , async function ( ) {
52+ await tabNavigateToToolbox ( this . browser ) ;
53+
54+ // Insert 'if' block
55+ await keyRight ( this . browser ) ;
56+ // Choose.
57+ await this . browser . keys ( Key . Enter ) ;
58+ // Confirm position.
59+ await this . browser . keys ( Key . Enter ) ;
60+
61+ // Assert inserted inside first block p5_setup not at top-level.
62+ chai . assert . equal ( 'controls_if' , await getFocusedBlockType ( this . browser ) ) ;
63+ await keyUp ( this . browser ) ;
64+ chai . assert . equal (
65+ 'p5_background_color' ,
66+ await getFocusedBlockType ( this . browser ) ,
67+ ) ;
68+ } ) ;
4869} ) ;
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