@@ -17,6 +17,10 @@ import {
1717 testFileLocations ,
1818 PAUSE_TIME ,
1919 tabNavigateToWorkspace ,
20+ keyLeft ,
21+ keyRight ,
22+ keyUp ,
23+ keyDown ,
2024} from './test_setup.js' ;
2125import { Key } from 'webdriverio' ;
2226
@@ -40,10 +44,7 @@ suite('Keyboard navigation on Blocks', function () {
4044 test ( 'Selected block' , async function ( ) {
4145 await tabNavigateToWorkspace ( this . browser ) ;
4246
43- for ( let i = 0 ; i < 14 ; i ++ ) {
44- await this . browser . keys ( Key . ArrowDown ) ;
45- await this . browser . pause ( PAUSE_TIME ) ;
46- }
47+ await keyDown ( this . browser , 14 ) ;
4748
4849 chai
4950 . expect ( await getCurrentFocusedBlockId ( this . browser ) )
@@ -55,8 +56,7 @@ suite('Keyboard navigation on Blocks', function () {
5556 await this . browser . pause ( PAUSE_TIME ) ;
5657 await focusOnBlock ( this . browser , 'p5_canvas_1' ) ;
5758 await this . browser . pause ( PAUSE_TIME ) ;
58- await this . browser . keys ( Key . ArrowDown ) ;
59- await this . browser . pause ( PAUSE_TIME ) ;
59+ await keyDown ( this . browser ) ;
6060
6161 chai
6262 . expect ( await getCurrentFocusedBlockId ( this . browser ) )
@@ -68,8 +68,7 @@ suite('Keyboard navigation on Blocks', function () {
6868 await this . browser . pause ( PAUSE_TIME ) ;
6969 await focusOnBlock ( this . browser , 'simple_circle_1' ) ;
7070 await this . browser . pause ( PAUSE_TIME ) ;
71- await this . browser . keys ( Key . ArrowUp ) ;
72- await this . browser . pause ( PAUSE_TIME ) ;
71+ await keyUp ( this . browser ) ;
7372
7473 chai
7574 . expect ( await getCurrentFocusedBlockId ( this . browser ) )
@@ -81,8 +80,7 @@ suite('Keyboard navigation on Blocks', function () {
8180 await this . browser . pause ( PAUSE_TIME ) ;
8281 await focusOnBlock ( this . browser , 'p5_setup_1' ) ;
8382 await this . browser . pause ( PAUSE_TIME ) ;
84- await this . browser . keys ( Key . ArrowDown ) ;
85- await this . browser . pause ( PAUSE_TIME ) ;
83+ await keyDown ( this . browser ) ;
8684 chai
8785 . expect ( await getCurrentFocusedBlockId ( this . browser ) )
8886 . equal ( 'p5_canvas_1' ) ;
@@ -93,8 +91,7 @@ suite('Keyboard navigation on Blocks', function () {
9391 await this . browser . pause ( PAUSE_TIME ) ;
9492 await focusOnBlock ( this . browser , 'p5_canvas_1' ) ;
9593 await this . browser . pause ( PAUSE_TIME ) ;
96- await this . browser . keys ( Key . ArrowUp ) ;
97- await this . browser . pause ( PAUSE_TIME ) ;
94+ await keyUp ( this . browser ) ;
9895 chai
9996 . expect ( await getCurrentFocusedBlockId ( this . browser ) )
10097 . equal ( 'p5_setup_1' ) ;
@@ -105,8 +102,7 @@ suite('Keyboard navigation on Blocks', function () {
105102 await this . browser . pause ( PAUSE_TIME ) ;
106103 await focusOnBlock ( this . browser , 'p5_canvas_1' ) ;
107104 await this . browser . pause ( PAUSE_TIME ) ;
108- await this . browser . keys ( Key . ArrowRight ) ;
109- await this . browser . pause ( PAUSE_TIME ) ;
105+ await keyRight ( this . browser ) ;
110106
111107 chai
112108 . expect ( await getCurrentFocusNodeId ( this . browser ) )
@@ -120,8 +116,7 @@ suite('Keyboard navigation on Blocks', function () {
120116 await this . browser . pause ( PAUSE_TIME ) ;
121117 await focusOnBlock ( this . browser , 'simple_circle_1' ) ;
122118 await this . browser . pause ( PAUSE_TIME ) ;
123- await this . browser . keys ( Key . ArrowRight ) ;
124- await this . browser . pause ( PAUSE_TIME ) ;
119+ await keyRight ( this . browser ) ;
125120
126121 chai . assert . equal (
127122 await getCurrentFocusedBlockId ( this . browser ) ,
@@ -134,8 +129,7 @@ suite('Keyboard navigation on Blocks', function () {
134129 await this . browser . pause ( PAUSE_TIME ) ;
135130 await focusOnBlock ( this . browser , 'math_number_2' ) ;
136131 await this . browser . pause ( PAUSE_TIME ) ;
137- await this . browser . keys ( Key . ArrowUp ) ;
138- await this . browser . pause ( PAUSE_TIME ) ;
132+ await keyUp ( this . browser ) ;
139133
140134 chai . assert . equal (
141135 await getCurrentFocusedBlockId ( this . browser ) ,
@@ -148,8 +142,7 @@ suite('Keyboard navigation on Blocks', function () {
148142 await this . browser . pause ( PAUSE_TIME ) ;
149143 await focusOnBlock ( this . browser , 'math_number_2' ) ;
150144 await this . browser . pause ( PAUSE_TIME ) ;
151- await this . browser . keys ( Key . ArrowLeft ) ;
152- await this . browser . pause ( PAUSE_TIME ) ;
145+ await keyLeft ( this . browser ) ;
153146
154147 chai . assert . equal (
155148 await getCurrentFocusedBlockId ( this . browser ) ,
@@ -162,8 +155,7 @@ suite('Keyboard navigation on Blocks', function () {
162155 await this . browser . pause ( PAUSE_TIME ) ;
163156 await focusOnBlock ( this . browser , 'math_number_2' ) ;
164157 await this . browser . pause ( PAUSE_TIME ) ;
165- await this . browser . keys ( Key . ArrowRight ) ;
166- await this . browser . pause ( PAUSE_TIME ) ;
158+ await keyRight ( this . browser ) ;
167159
168160 chai . assert . equal (
169161 await getCurrentFocusedBlockId ( this . browser ) ,
@@ -176,8 +168,7 @@ suite('Keyboard navigation on Blocks', function () {
176168 await this . browser . pause ( PAUSE_TIME ) ;
177169 await focusOnBlock ( this . browser , 'math_number_3' ) ;
178170 await this . browser . pause ( PAUSE_TIME ) ;
179- await this . browser . keys ( Key . ArrowLeft ) ;
180- await this . browser . pause ( PAUSE_TIME ) ;
171+ await keyLeft ( this . browser ) ;
181172
182173 chai . assert . equal (
183174 await getCurrentFocusedBlockId ( this . browser ) ,
@@ -190,8 +181,7 @@ suite('Keyboard navigation on Blocks', function () {
190181 await this . browser . pause ( PAUSE_TIME ) ;
191182 await focusOnBlock ( this . browser , 'colour_picker_1' ) ;
192183 await this . browser . pause ( PAUSE_TIME ) ;
193- await this . browser . keys ( Key . ArrowRight ) ;
194- await this . browser . pause ( PAUSE_TIME ) ;
184+ await keyRight ( this . browser ) ;
195185
196186 chai
197187 . expect ( await getCurrentFocusedBlockId ( this . browser ) )
@@ -203,8 +193,7 @@ suite('Keyboard navigation on Blocks', function () {
203193 await this . browser . pause ( PAUSE_TIME ) ;
204194 await focusOnBlock ( this . browser , 'colour_picker_1' ) ;
205195 await this . browser . pause ( PAUSE_TIME ) ;
206- await this . browser . keys ( Key . ArrowDown ) ;
207- await this . browser . pause ( PAUSE_TIME ) ;
196+ await keyDown ( this . browser ) ;
208197
209198 chai
210199 . expect ( await getCurrentFocusedBlockId ( this . browser ) )
@@ -216,8 +205,7 @@ suite('Keyboard navigation on Blocks', function () {
216205 await this . browser . pause ( PAUSE_TIME ) ;
217206 await focusOnBlock ( this . browser , 'logic_boolean_1' ) ;
218207 await this . browser . pause ( PAUSE_TIME ) ;
219- await this . browser . keys ( Key . ArrowDown ) ;
220- await this . browser . pause ( PAUSE_TIME ) ;
208+ await keyDown ( this . browser ) ;
221209
222210 chai
223211 . expect ( await getCurrentFocusedBlockId ( this . browser ) )
@@ -229,20 +217,17 @@ suite('Keyboard navigation on Blocks', function () {
229217 await this . browser . pause ( PAUSE_TIME ) ;
230218 await focusOnBlock ( this . browser , 'text_print_1' ) ;
231219 await this . browser . pause ( PAUSE_TIME ) ;
232- await this . browser . keys ( Key . ArrowRight ) ;
233- await this . browser . pause ( PAUSE_TIME ) ;
220+ await keyRight ( this . browser ) ;
234221
235222 chai . assert . equal ( await getCurrentFocusedBlockId ( this . browser ) , 'text_1' ) ;
236223
237- await this . browser . keys ( Key . ArrowRight ) ;
238- await this . browser . pause ( PAUSE_TIME ) ;
224+ await keyRight ( this . browser ) ;
239225
240226 chai
241227 . expect ( await getCurrentFocusNodeId ( this . browser ) )
242228 . to . include ( 'text_1_field_' ) ;
243229
244- await this . browser . keys ( Key . ArrowRight ) ;
245- await this . browser . pause ( PAUSE_TIME ) ;
230+ await keyRight ( this . browser ) ;
246231
247232 chai
248233 . expect ( await getCurrentFocusedBlockId ( this . browser ) )
@@ -283,8 +268,7 @@ suite('Keyboard navigation on Fields', function () {
283268 'WIDTH' ,
284269 ) ;
285270 await this . browser . pause ( PAUSE_TIME ) ;
286- await this . browser . keys ( Key . ArrowUp ) ;
287- await this . browser . pause ( PAUSE_TIME ) ;
271+ await keyUp ( this . browser ) ;
288272
289273 chai . assert . equal (
290274 await getCurrentFocusedBlockId ( this . browser ) ,
@@ -301,8 +285,7 @@ suite('Keyboard navigation on Fields', function () {
301285 'WIDTH' ,
302286 ) ;
303287 await this . browser . pause ( PAUSE_TIME ) ;
304- await this . browser . keys ( Key . ArrowLeft ) ;
305- await this . browser . pause ( PAUSE_TIME ) ;
288+ await keyLeft ( this . browser ) ;
306289
307290 chai . assert . equal (
308291 await getCurrentFocusedBlockId ( this . browser ) ,
@@ -319,8 +302,7 @@ suite('Keyboard navigation on Fields', function () {
319302 'WIDTH' ,
320303 ) ;
321304 await this . browser . pause ( PAUSE_TIME ) ;
322- await this . browser . keys ( Key . ArrowRight ) ;
323- await this . browser . pause ( PAUSE_TIME ) ;
305+ await keyRight ( this . browser ) ;
324306
325307 chai
326308 . expect ( await getCurrentFocusNodeId ( this . browser ) )
@@ -338,8 +320,7 @@ suite('Keyboard navigation on Fields', function () {
338320 'HEIGHT' ,
339321 ) ;
340322 await this . browser . pause ( PAUSE_TIME ) ;
341- await this . browser . keys ( Key . ArrowLeft ) ;
342- await this . browser . pause ( PAUSE_TIME ) ;
323+ await keyLeft ( this . browser ) ;
343324
344325 chai
345326 . expect ( await getCurrentFocusNodeId ( this . browser ) )
@@ -357,8 +338,7 @@ suite('Keyboard navigation on Fields', function () {
357338 'HEIGHT' ,
358339 ) ;
359340 await this . browser . pause ( PAUSE_TIME ) ;
360- await this . browser . keys ( Key . ArrowRight ) ;
361- await this . browser . pause ( PAUSE_TIME ) ;
341+ await keyRight ( this . browser ) ;
362342
363343 chai
364344 . expect ( await getCurrentFocusedBlockId ( this . browser ) )
@@ -374,8 +354,7 @@ suite('Keyboard navigation on Fields', function () {
374354 'WIDTH' ,
375355 ) ;
376356 await this . browser . pause ( PAUSE_TIME ) ;
377- await this . browser . keys ( Key . ArrowDown ) ;
378- await this . browser . pause ( PAUSE_TIME ) ;
357+ await keyDown ( this . browser ) ;
379358
380359 chai
381360 . expect ( await getCurrentFocusedBlockId ( this . browser ) )
@@ -391,8 +370,7 @@ suite('Keyboard navigation on Fields', function () {
391370 'TIMES' ,
392371 ) ;
393372 await this . browser . pause ( PAUSE_TIME ) ;
394- await this . browser . keys ( Key . ArrowDown ) ;
395- await this . browser . pause ( PAUSE_TIME ) ;
373+ await keyDown ( this . browser ) ;
396374
397375 chai
398376 . expect ( await getCurrentFocusedBlockId ( this . browser ) )
0 commit comments