@@ -15,6 +15,7 @@ import {
1515 testFileLocations ,
1616 PAUSE_TIME ,
1717 tabNavigateToWorkspace ,
18+ sendKeyAndWait ,
1819 keyRight ,
1920 focusOnBlockField ,
2021} from './test_setup.js' ;
@@ -40,8 +41,7 @@ suite('Deleting Blocks', function () {
4041 . expect ( await blockIsPresent ( this . browser , 'controls_if_2' ) )
4142 . equal ( true ) ;
4243
43- await this . browser . keys ( Key . Backspace ) ;
44- await this . browser . pause ( PAUSE_TIME ) ;
44+ await sendKeyAndWait ( this . browser , Key . Backspace ) ;
4545
4646 chai
4747 . expect ( await blockIsPresent ( this . browser , 'controls_if_2' ) )
@@ -62,8 +62,7 @@ suite('Deleting Blocks', function () {
6262 . expect ( await blockIsPresent ( this . browser , 'controls_if_2' ) )
6363 . equal ( true ) ;
6464
65- await this . browser . keys ( [ Key . Ctrl , 'x' ] ) ;
66- await this . browser . pause ( PAUSE_TIME ) ;
65+ await sendKeyAndWait ( this . browser , [ Key . Ctrl , 'x' ] ) ;
6766
6867 chai
6968 . expect ( await blockIsPresent ( this . browser , 'controls_if_2' ) )
@@ -85,8 +84,7 @@ suite('Deleting Blocks', function () {
8584 . equal ( true ) ;
8685 chai . expect ( await blockIsPresent ( this . browser , 'text_print_1' ) ) . equal ( true ) ;
8786
88- await this . browser . keys ( Key . Backspace ) ;
89- await this . browser . pause ( PAUSE_TIME ) ;
87+ await sendKeyAndWait ( this . browser , Key . Backspace ) ;
9088
9189 chai
9290 . expect ( await blockIsPresent ( this . browser , 'logic_boolean_1' ) )
@@ -107,8 +105,7 @@ suite('Deleting Blocks', function () {
107105 . equal ( true ) ;
108106 chai . expect ( await blockIsPresent ( this . browser , 'text_print_1' ) ) . equal ( true ) ;
109107
110- await this . browser . keys ( [ Key . Ctrl , 'x' ] ) ;
111- await this . browser . pause ( PAUSE_TIME ) ;
108+ await sendKeyAndWait ( this . browser , [ Key . Ctrl , 'x' ] ) ;
112109
113110 chai
114111 . expect ( await blockIsPresent ( this . browser , 'logic_boolean_1' ) )
@@ -128,8 +125,7 @@ suite('Deleting Blocks', function () {
128125 . expect ( await blockIsPresent ( this . browser , 'logic_boolean_1' ) )
129126 . equal ( true ) ;
130127
131- await this . browser . keys ( Key . Backspace ) ;
132- await this . browser . pause ( PAUSE_TIME ) ;
128+ await sendKeyAndWait ( this . browser , Key . Backspace ) ;
133129
134130 chai
135131 . expect ( await blockIsPresent ( this . browser , 'logic_boolean_1' ) )
@@ -150,8 +146,7 @@ suite('Deleting Blocks', function () {
150146 . expect ( await blockIsPresent ( this . browser , 'logic_boolean_1' ) )
151147 . equal ( true ) ;
152148
153- await this . browser . keys ( [ Key . Ctrl , 'x' ] ) ;
154- await this . browser . pause ( PAUSE_TIME ) ;
149+ await sendKeyAndWait ( this . browser , [ Key . Ctrl , 'x' ] ) ;
155150
156151 chai
157152 . expect ( await blockIsPresent ( this . browser , 'logic_boolean_1' ) )
@@ -177,16 +172,13 @@ suite('Deleting Blocks', function () {
177172 // Move to flyout.
178173 await keyRight ( this . browser ) ;
179174 // Select number block.
180- await this . browser . keys ( Key . Enter ) ;
181- await this . browser . pause ( PAUSE_TIME ) ;
175+ await sendKeyAndWait ( this . browser , Key . Enter ) ;
182176 // Confirm move.
183- await this . browser . keys ( Key . Enter ) ;
184- await this . browser . pause ( PAUSE_TIME ) ;
177+ await sendKeyAndWait ( this . browser , Key . Enter ) ;
185178
186179 chai . assert . equal ( 'math_number' , await getFocusedBlockType ( this . browser ) ) ;
187180
188- await this . browser . keys ( Key . Backspace ) ;
189- await this . browser . pause ( PAUSE_TIME ) ;
181+ await sendKeyAndWait ( this . browser , Key . Backspace ) ;
190182
191183 chai . assert . equal (
192184 await getCurrentFocusedBlockId ( this . browser ) ,
@@ -204,16 +196,13 @@ suite('Deleting Blocks', function () {
204196 // Move to flyout.
205197 await keyRight ( this . browser ) ;
206198 // Select number block.
207- await this . browser . keys ( Key . Enter ) ;
208- await this . browser . pause ( PAUSE_TIME ) ;
199+ await sendKeyAndWait ( this . browser , Key . Enter ) ;
209200 // Confirm move.
210- await this . browser . keys ( Key . Enter ) ;
211- await this . browser . pause ( PAUSE_TIME ) ;
201+ await sendKeyAndWait ( this . browser , Key . Enter ) ;
212202
213203 chai . assert . equal ( 'math_number' , await getFocusedBlockType ( this . browser ) ) ;
214204
215- await this . browser . keys ( [ Key . Ctrl , 'x' ] ) ;
216- await this . browser . pause ( PAUSE_TIME ) ;
205+ await sendKeyAndWait ( this . browser , [ Key . Ctrl , 'x' ] ) ;
217206
218207 chai . assert . equal (
219208 await getCurrentFocusedBlockId ( this . browser ) ,
@@ -225,11 +214,10 @@ suite('Deleting Blocks', function () {
225214 // Open a field editor
226215 await focusOnBlockField ( this . browser , 'colour_picker_1' , 'COLOUR' ) ;
227216 await this . browser . pause ( PAUSE_TIME ) ;
228- await this . browser . keys ( Key . Enter ) ;
229- await this . browser . pause ( PAUSE_TIME ) ;
217+ await sendKeyAndWait ( this . browser , Key . Enter ) ;
230218
231219 // Try to delete block while field editor is open
232- await this . browser . keys ( Key . Backspace ) ;
220+ await sendKeyAndWait ( this . browser , Key . Backspace ) ;
233221
234222 // Block is not deleted
235223 chai . assert . isTrue ( await blockIsPresent ( this . browser , 'colour_picker_1' ) ) ;
0 commit comments