@@ -3,6 +3,7 @@ import SeleniumHelper from '../helpers/selenium-helper';
3
3
4
4
const {
5
5
clickText,
6
+ clickBlocksCategory,
6
7
clickButton,
7
8
clickXpath,
8
9
findByText,
@@ -31,8 +32,7 @@ describe('Working with the blocks', () => {
31
32
test ( 'Blocks report when clicked in the toolbox' , async ( ) => {
32
33
await loadUri ( uri ) ;
33
34
await clickText ( 'Code' ) ;
34
- await clickText ( 'Operators' , scope . blocksTab ) ;
35
- await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ; // Wait for scroll animation
35
+ await clickBlocksCategory ( 'Operators' ) ;
36
36
await clickText ( 'join' , scope . blocksTab ) ; // Click "join <hello> <world>" block
37
37
await findByText ( 'apple banana' , scope . reportedValue ) ; // Tooltip with result
38
38
const logs = await getLogs ( ) ;
@@ -41,14 +41,13 @@ describe('Working with the blocks', () => {
41
41
42
42
test ( 'Switching sprites updates the block menus' , async ( ) => {
43
43
await loadUri ( uri ) ;
44
- await clickText ( 'Sound' , scope . blocksTab ) ;
45
- await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ; // Wait for scroll animation
44
+ await clickBlocksCategory ( 'Sound' ) ;
46
45
// "Meow" sound block should be visible
47
46
await findByText ( 'Meow' , scope . blocksTab ) ;
48
47
await clickText ( 'Backdrops' ) ; // Switch to the backdrop
49
48
// Now "pop" sound block should be visible and motion blocks hidden
50
49
await findByText ( 'pop' , scope . blocksTab ) ;
51
- await clickText ( 'Motion' , scope . blocksTab ) ;
50
+ await clickBlocksCategory ( 'Motion' ) ;
52
51
await findByText ( 'Stage selected: no motion blocks' ) ;
53
52
54
53
const logs = await getLogs ( ) ;
@@ -58,8 +57,7 @@ describe('Working with the blocks', () => {
58
57
test ( 'Creating variables' , async ( ) => {
59
58
await loadUri ( uri ) ;
60
59
await clickText ( 'Code' ) ;
61
- await clickText ( 'Variables' , scope . blocksTab ) ;
62
- await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ; // Wait for scroll animation
60
+ await clickBlocksCategory ( 'Variables' ) ;
63
61
64
62
// Expect a default variable "my variable" to be visible
65
63
await clickText ( 'my\u00A0variable' , scope . blocksTab ) ;
@@ -75,8 +73,7 @@ describe('Working with the blocks', () => {
75
73
await clickButton ( 'OK' ) ;
76
74
77
75
// Make sure reporting works on a new variable
78
- await clickText ( 'Variables' , scope . blocksTab ) ;
79
- await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ; // Wait for scroll animation
76
+ await clickBlocksCategory ( 'Variables' ) ;
80
77
await clickText ( 'score' , scope . blocksTab ) ;
81
78
await findByText ( '0' , scope . reportedValue ) ; // Tooltip with result
82
79
@@ -100,8 +97,7 @@ describe('Working with the blocks', () => {
100
97
test ( 'Creating a list' , async ( ) => {
101
98
await loadUri ( uri ) ;
102
99
await clickText ( 'Code' ) ;
103
- await clickText ( 'Variables' , scope . blocksTab ) ;
104
- await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ; // Wait for scroll animation
100
+ await clickBlocksCategory ( 'Variables' ) ;
105
101
106
102
await clickText ( 'Make a List' ) ;
107
103
let el = await findByXpath ( "//input[@name='New list name:']" ) ;
@@ -133,8 +129,7 @@ describe('Working with the blocks', () => {
133
129
134
130
test ( 'Custom procedures' , async ( ) => {
135
131
await loadUri ( uri ) ;
136
- await clickText ( 'My Blocks' ) ;
137
- await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ; // Wait for scroll animation
132
+ await clickBlocksCategory ( 'My Blocks' ) ;
138
133
await clickText ( 'Make a Block' ) ;
139
134
// Click on the "add an input" buttons
140
135
await clickText ( 'number or text' , scope . modal ) ;
@@ -165,8 +160,7 @@ describe('Working with the blocks', () => {
165
160
test ( 'Record option from sound block menu opens sound recorder' , async ( ) => {
166
161
await loadUri ( uri ) ;
167
162
await clickText ( 'Code' ) ;
168
- await clickText ( 'Sound' , scope . blocksTab ) ;
169
- await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ; // Wait for scroll animation
163
+ await clickBlocksCategory ( 'Sound' ) ;
170
164
await clickText ( 'Meow' , scope . blocksTab ) ; // Click "play sound <Meow> until done" block
171
165
await clickText ( 'record' ) ; // Click "record..." option in the block's sound menu
172
166
// Access has been force denied, so close the alert that comes up
@@ -193,8 +187,7 @@ describe('Working with the blocks', () => {
193
187
194
188
// Make sure it is updated in the block menu
195
189
await clickText ( 'Code' ) ;
196
- await clickText ( 'Looks' , scope . blocksTab ) ;
197
- await driver . sleep ( 500 ) ; // Wait for scroll to finish
190
+ await clickBlocksCategory ( 'Looks' ) ;
198
191
await clickText ( 'newname' , scope . blocksTab ) ;
199
192
} ) ;
200
193
@@ -213,19 +206,17 @@ describe('Working with the blocks', () => {
213
206
214
207
// Make sure it is updated in the block menu
215
208
await clickText ( 'Code' ) ;
216
- await clickText ( 'Looks' , scope . blocksTab ) ;
217
- await driver . sleep ( 500 ) ; // Wait for scroll to finish
209
+ await clickBlocksCategory ( 'Looks' ) ;
218
210
await clickText ( '<NewCostume>' , scope . blocksTab ) ;
219
211
220
- await clickText ( 'Sound' , scope . blocksTab ) ;
212
+ await clickBlocksCategory ( 'Sound' ) ;
221
213
} ) ;
222
214
223
215
test ( 'Adding costumes DOES update the default costume name in the toolbox' , async ( ) => {
224
216
await loadUri ( uri ) ;
225
217
226
218
// By default, costume2 is in the costume tab
227
- await clickText ( 'Looks' , scope . blocksTab ) ;
228
- await driver . sleep ( 500 ) ; // Wait for scroll to finish
219
+ await clickBlocksCategory ( 'Looks' ) ;
229
220
await clickText ( 'costume2' , scope . blocksTab ) ;
230
221
231
222
// Also check that adding a new costume does update the list
@@ -254,8 +245,7 @@ describe('Working with the blocks', () => {
254
245
await findByXpath ( "//div[contains(@class,'sprite-selector-item_is-selected_')]" +
255
246
"//div[contains(text(), 'A Bass')]" ) ;
256
247
await clickText ( 'Code' ) ;
257
- await clickText ( 'Sound' , scope . blocksTab ) ;
258
- await driver . sleep ( 500 ) ; // Wait for scroll to finish
248
+ await clickBlocksCategory ( 'Sound' ) ;
259
249
await clickText ( 'A\u00A0Bass' , scope . blocksTab ) ; // Need for block text
260
250
} ) ;
261
251
@@ -264,15 +254,13 @@ describe('Working with the blocks', () => {
264
254
const playerUri = path . resolve ( __dirname , '../../build/player.html' ) ;
265
255
await loadUri ( playerUri ) ;
266
256
await clickText ( 'See inside' ) ;
267
- await clickText ( 'Variables' ) ;
268
- await driver . sleep ( 500 ) ; // Wait for scroll to finish
257
+ await clickBlocksCategory ( 'Variables' ) ;
269
258
await clickText ( 'my\u00A0variable' ) ;
270
259
271
260
await clickText ( 'See Project Page' ) ;
272
261
await clickText ( 'See inside' ) ;
273
262
274
- await clickText ( 'Variables' ) ;
275
- await driver . sleep ( 500 ) ; // Wait for scroll to finish
263
+ await clickBlocksCategory ( 'Variables' ) ;
276
264
await clickText ( 'my\u00A0variable' ) ;
277
265
} ) ;
278
266
@@ -281,8 +269,7 @@ describe('Working with the blocks', () => {
281
269
await loadUri ( uri ) ;
282
270
await clickText ( 'Costumes' ) ;
283
271
await clickText ( 'Code' ) ;
284
- await clickText ( 'Variables' , scope . blocksTab ) ;
285
- await driver . sleep ( 500 ) ; // Wait for scroll
272
+ await clickBlocksCategory ( 'Variables' ) ;
286
273
await clickText ( 'Make a List' ) ;
287
274
const el = await findByXpath ( "//input[@name='New list name:']" ) ;
288
275
await el . sendKeys ( 'list1' ) ;
0 commit comments