66
77import * as chai from 'chai' ;
88import * as Blockly from 'blockly' ;
9- import { testSetup , testFileLocations , PAUSE_TIME } from './test_setup.js' ;
9+ import {
10+ focusWorkspace ,
11+ setCurrentCursorNodeById ,
12+ getCurrentCursorNodeFieldName ,
13+ getCurrentCursorNodeId ,
14+ getCurrentCursorNodeType ,
15+ testSetup ,
16+ testFileLocations ,
17+ PAUSE_TIME ,
18+ } from './test_setup.js' ;
1019import { Key } from 'webdriverio' ;
1120
1221suite ( 'Keyboard navigation' , function ( ) {
@@ -27,10 +36,7 @@ suite('Keyboard navigation', function () {
2736 } ) ;
2837
2938 test ( 'Selected block' , async function ( ) {
30- const workspace = await this . browser . $ (
31- '#blocklyDiv > div > svg.blocklySvg > g' ,
32- ) ;
33- await workspace . click ( ) ;
39+ await focusWorkspace ( this . browser ) ;
3440 await this . browser . pause ( PAUSE_TIME ) ;
3541
3642 for ( let i = 0 ; i < 9 ; i ++ ) {
@@ -43,4 +49,89 @@ suite('Keyboard navigation', function () {
4349 } ) ;
4450 chai . assert . equal ( selectedId , 'draw_circle_1' ) ;
4551 } ) ;
52+
53+ test ( 'Down from statement block selects next connection' , async function ( ) {
54+ await focusWorkspace ( this . browser ) ;
55+ await this . browser . pause ( PAUSE_TIME ) ;
56+ await setCurrentCursorNodeById ( this . browser , 'create_canvas_1' ) ;
57+ await this . browser . pause ( PAUSE_TIME ) ;
58+ await this . browser . keys ( Key . ArrowDown ) ;
59+ await this . browser . pause ( PAUSE_TIME ) ;
60+
61+ chai . assert . equal (
62+ await getCurrentCursorNodeId ( this . browser ) ,
63+ 'create_canvas_1' ,
64+ ) ;
65+ chai . assert . equal (
66+ await getCurrentCursorNodeType ( this . browser ) ,
67+ Blockly . ASTNode . types . NEXT ,
68+ ) ;
69+ } ) ;
70+
71+ test ( "Up from statement block selects previous block's connection" , async function ( ) {
72+ await focusWorkspace ( this . browser ) ;
73+ await this . browser . pause ( PAUSE_TIME ) ;
74+ await setCurrentCursorNodeById ( this . browser , 'set_background_color_1' ) ;
75+ await this . browser . pause ( PAUSE_TIME ) ;
76+ await this . browser . keys ( Key . ArrowUp ) ;
77+ await this . browser . pause ( PAUSE_TIME ) ;
78+
79+ chai . assert . equal (
80+ await getCurrentCursorNodeId ( this . browser ) ,
81+ 'create_canvas_1' ,
82+ ) ;
83+ chai . assert . equal (
84+ await getCurrentCursorNodeType ( this . browser ) ,
85+ Blockly . ASTNode . types . NEXT ,
86+ ) ;
87+ } ) ;
88+
89+ test ( 'Down from parent block selects input connection' , async function ( ) {
90+ await focusWorkspace ( this . browser ) ;
91+ await this . browser . pause ( PAUSE_TIME ) ;
92+ await setCurrentCursorNodeById ( this . browser , 'setup_root' ) ;
93+ await this . browser . pause ( PAUSE_TIME ) ;
94+ await this . browser . keys ( Key . ArrowDown ) ;
95+ await this . browser . pause ( PAUSE_TIME ) ;
96+
97+ chai . assert . equal ( await getCurrentCursorNodeId ( this . browser ) , 'setup_root' ) ;
98+ chai . assert . equal (
99+ await getCurrentCursorNodeType ( this . browser ) ,
100+ Blockly . ASTNode . types . INPUT ,
101+ ) ;
102+ } ) ;
103+
104+ test ( 'Up from child block selects input connection' , async function ( ) {
105+ await focusWorkspace ( this . browser ) ;
106+ await this . browser . pause ( PAUSE_TIME ) ;
107+ await setCurrentCursorNodeById ( this . browser , 'create_canvas_1' ) ;
108+ await this . browser . pause ( PAUSE_TIME ) ;
109+ await this . browser . keys ( Key . ArrowUp ) ;
110+ await this . browser . pause ( PAUSE_TIME ) ;
111+
112+ chai . assert . equal ( await getCurrentCursorNodeId ( this . browser ) , 'setup_root' ) ;
113+ chai . assert . equal (
114+ await getCurrentCursorNodeType ( this . browser ) ,
115+ Blockly . ASTNode . types . INPUT ,
116+ ) ;
117+ } ) ;
118+
119+ test ( 'Right from block selects field' , async function ( ) {
120+ await focusWorkspace ( this . browser ) ;
121+ await this . browser . pause ( PAUSE_TIME ) ;
122+ await setCurrentCursorNodeById ( this . browser , 'create_canvas_1' ) ;
123+ await this . browser . pause ( PAUSE_TIME ) ;
124+ await this . browser . keys ( Key . ArrowRight ) ;
125+ await this . browser . pause ( PAUSE_TIME ) ;
126+
127+ chai . assert . equal ( await getCurrentCursorNodeId ( this . browser ) , 'create_canvas_1' ) ;
128+ chai . assert . equal (
129+ await getCurrentCursorNodeType ( this . browser ) ,
130+ Blockly . ASTNode . types . FIELD ,
131+ ) ;
132+ chai . assert . equal (
133+ await getCurrentCursorNodeFieldName ( this . browser ) ,
134+ 'WIDTH' ,
135+ ) ;
136+ } ) ;
46137} ) ;
0 commit comments