@@ -10,6 +10,7 @@ const {
1010 testFileLocations,
1111 getAllBlocks,
1212 getBlockElementById,
13+ clickBlock,
1314 contextMenuSelect,
1415 PAUSE_TIME ,
1516} = require ( './test_setup' ) ;
@@ -130,15 +131,13 @@ suite('Delete blocks', function (done) {
130131 ( await getBlockElementById ( this . browser , firstBlockId ) ) . waitForExist ( {
131132 timeout : 2000 ,
132133 } ) ;
134+ this . firstBlock = await getBlockElementById ( this . browser , firstBlockId ) ;
133135 } ) ;
134136
135137 test ( 'Delete block using backspace key' , async function ( ) {
136138 const before = ( await getAllBlocks ( this . browser ) ) . length ;
137139 // Get first print block, click to select it, and delete it using backspace key.
138- const block = ( await getBlockElementById ( this . browser , firstBlockId ) ) . $ (
139- '.blocklyPath' ,
140- ) ;
141- await block . click ( ) ;
140+ await clickBlock ( this . browser , this . firstBlock , { button : 1 } ) ;
142141 await this . browser . keys ( [ Key . Backspace ] ) ;
143142 const after = ( await getAllBlocks ( this . browser ) ) . length ;
144143 chai . assert . equal (
@@ -151,10 +150,7 @@ suite('Delete blocks', function (done) {
151150 test ( 'Delete block using delete key' , async function ( ) {
152151 const before = ( await getAllBlocks ( this . browser ) ) . length ;
153152 // Get first print block, click to select it, and delete it using delete key.
154- const block = ( await getBlockElementById ( this . browser , firstBlockId ) ) . $ (
155- '.blocklyPath' ,
156- ) ;
157- await block . click ( ) ;
153+ await clickBlock ( this . browser , this . firstBlock , { button : 1 } ) ;
158154 await this . browser . keys ( [ Key . Delete ] ) ;
159155 const after = ( await getAllBlocks ( this . browser ) ) . length ;
160156 chai . assert . equal (
@@ -167,8 +163,7 @@ suite('Delete blocks', function (done) {
167163 test ( 'Delete block using context menu' , async function ( ) {
168164 const before = ( await getAllBlocks ( this . browser ) ) . length ;
169165 // Get first print block, click to select it, and delete it using context menu.
170- const block = await getBlockElementById ( this . browser , firstBlockId ) ;
171- await contextMenuSelect ( this . browser , block , 'Delete 2 Blocks' ) ;
166+ await contextMenuSelect ( this . browser , this . firstBlock , 'Delete 2 Blocks' ) ;
172167 const after = ( await getAllBlocks ( this . browser ) ) . length ;
173168 chai . assert . equal (
174169 before - 2 ,
@@ -180,10 +175,7 @@ suite('Delete blocks', function (done) {
180175 test ( 'Undo block deletion' , async function ( ) {
181176 const before = ( await getAllBlocks ( this . browser ) ) . length ;
182177 // Get first print block, click to select it, and delete it using backspace key.
183- const block = ( await getBlockElementById ( this . browser , firstBlockId ) ) . $ (
184- '.blocklyPath' ,
185- ) ;
186- await block . click ( ) ;
178+ await clickBlock ( this . browser , this . firstBlock , { button : 1 } ) ;
187179 await this . browser . keys ( [ Key . Backspace ] ) ;
188180 await this . browser . pause ( PAUSE_TIME ) ;
189181 // Undo
@@ -199,10 +191,7 @@ suite('Delete blocks', function (done) {
199191 test ( 'Redo block deletion' , async function ( ) {
200192 const before = ( await getAllBlocks ( this . browser ) ) . length ;
201193 // Get first print block, click to select it, and delete it using backspace key.
202- const block = ( await getBlockElementById ( this . browser , firstBlockId ) ) . $ (
203- '.blocklyPath' ,
204- ) ;
205- await block . click ( ) ;
194+ await clickBlock ( this . browser , this . firstBlock , { button : 1 } ) ;
206195 await this . browser . keys ( [ Key . Backspace ] ) ;
207196 await this . browser . pause ( PAUSE_TIME ) ;
208197 // Undo
0 commit comments