File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change 77import * as chai from 'chai' ;
88import * as Blockly from 'blockly' ;
99import {
10+ isDragging ,
1011 setCurrentCursorNodeById ,
1112 setCurrentCursorNodeByIdAndFieldName ,
1213 getCurrentFocusNodeId ,
@@ -247,6 +248,21 @@ suite('Keyboard navigation on Blocks', function () {
247248 . expect ( await getCurrentFocusedBlockId ( this . browser ) )
248249 . equal ( 'controls_repeat_1' ) ;
249250 } ) ;
251+
252+ test ( 'Losing focus cancels move' , async function ( ) {
253+ await tabNavigateToWorkspace ( this . browser ) ;
254+ await this . browser . pause ( PAUSE_TIME ) ;
255+ await setCurrentCursorNodeById ( this . browser , 'text_print_1' ) ;
256+ await this . browser . keys ( "m" ) ;
257+ await this . browser . pause ( PAUSE_TIME ) ;
258+
259+ chai . assert . isTrue ( await isDragging ( this . browser ) ) ;
260+
261+ await this . browser . keys ( Key . Tab ) ;
262+ await this . browser . pause ( PAUSE_TIME ) ;
263+
264+ chai . assert . isFalse ( await isDragging ( this . browser ) ) ;
265+ } ) ;
250266} ) ;
251267
252268// TODO(#499) These tests fail because focusing on a field doesn't update the cursor
Original file line number Diff line number Diff line change @@ -356,3 +356,15 @@ export async function tabNavigateForward(browser: WebdriverIO.Browser) {
356356 await browser . keys ( webdriverio . Key . Tab ) ;
357357 await browser . pause ( PAUSE_TIME ) ;
358358}
359+
360+ /**
361+ * Returns whether there's a drag in progress on the main workspace.
362+ *
363+ * @param browser The active WebdriverIO Browser object.
364+ */
365+ export async function isDragging ( browser : WebdriverIO . Browser ) : Promise < boolean > {
366+ return await browser . execute ( ( ) => {
367+ const workspaceSvg = Blockly . getMainWorkspace ( ) as Blockly . WorkspaceSvg ;
368+ return workspaceSvg . isDragging ( ) ;
369+ } ) ;
370+ }
You can’t perform that action at this time.
0 commit comments