Skip to content

Commit 11080fd

Browse files
committed
chore: Use idle() more broadly.
1 parent 3542de5 commit 11080fd

14 files changed

+95
-82
lines changed

test/webdriverio/test/actions_test.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
keyRight,
2222
contextMenuItems,
2323
checkForFailures,
24+
idle,
2425
} from './test_setup.js';
2526

2627
const isDarwin = process.platform === 'darwin';
@@ -97,7 +98,7 @@ suite('Menus test', function () {
9798
testFileLocations.MORE_BLOCKS,
9899
this.timeout(),
99100
);
100-
await this.browser.pause(PAUSE_TIME);
101+
await idle(this.browser);
101102
});
102103

103104
teardown(async function() {
@@ -107,7 +108,7 @@ suite('Menus test', function () {
107108
test('Menu action via keyboard on block opens menu', async function () {
108109
// Navigate to draw_circle_1.
109110
await focusOnBlock(this.browser, 'draw_circle_1');
110-
await this.browser.pause(PAUSE_TIME);
111+
await idle(this.browser);
111112
await sendKeyAndWait(this.browser, [Key.Ctrl, Key.Return]);
112113

113114
chai.assert.deepEqual(
@@ -131,7 +132,7 @@ suite('Menus test', function () {
131132
await focusOnBlock(this.browser, 'text_print_1');
132133
await this.browser.keys(Key.ArrowRight);
133134
await this.browser.keys([Key.Ctrl, Key.Return]);
134-
await this.browser.pause(PAUSE_TIME);
135+
await idle(this.browser);
135136

136137
chai.assert.deepEqual(
137138
await contextMenuItems(this.browser),
@@ -159,9 +160,9 @@ suite('Menus test', function () {
159160
await moveToToolboxCategory(this.browser, 'Math');
160161
// Move to flyout.
161162
await keyRight(this.browser);
162-
await this.browser.pause(PAUSE_TIME);
163+
await idle(this.browser);
163164
await rightClickOnFlyoutBlockType(this.browser, 'math_number');
164-
await this.browser.pause(PAUSE_TIME);
165+
await idle(this.browser);
165166

166167
chai.assert.deepEqual(
167168
await contextMenuItems(this.browser),
@@ -197,11 +198,11 @@ suite('Menus test', function () {
197198
test('Escape key dismisses menu', async function () {
198199
await tabNavigateToWorkspace(this.browser);
199200
await focusOnBlock(this.browser, 'draw_circle_1');
200-
await this.browser.pause(PAUSE_TIME);
201+
await idle(this.browser);
201202
await this.browser.keys([Key.Ctrl, Key.Return]);
202-
await this.browser.pause(PAUSE_TIME);
203+
await idle(this.browser);
203204
await this.browser.keys(Key.Escape);
204-
await this.browser.pause(PAUSE_TIME);
205+
await idle(this.browser);
205206

206207
chai.assert.isTrue(
207208
await contextMenuExists(this.browser, 'Duplicate', /* reverse= */ true),
@@ -212,9 +213,9 @@ suite('Menus test', function () {
212213
test('Clicking workspace dismisses menu', async function () {
213214
await tabNavigateToWorkspace(this.browser);
214215
await clickBlock(this.browser, 'draw_circle_1', {button: 'right'});
215-
await this.browser.pause(PAUSE_TIME);
216+
await idle(this.browser);
216217
await focusWorkspace(this.browser);
217-
await this.browser.pause(PAUSE_TIME);
218+
await idle(this.browser);
218219

219220
chai.assert.isTrue(
220221
await contextMenuExists(this.browser, 'Duplicate', /* reverse= */ true),

test/webdriverio/test/basic_test.ts

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
keyUp,
2424
keyDown,
2525
checkForFailures,
26+
idle,
2627
} from './test_setup.js';
2728
import {Key} from 'webdriverio';
2829

@@ -52,7 +53,7 @@ suite('Keyboard navigation on Blocks', function () {
5253

5354
test('Selected block', async function () {
5455
await tabNavigateToWorkspace(this.browser);
55-
await this.browser.pause(PAUSE_TIME);
56+
await idle(this.browser);
5657

5758
await keyDown(this.browser, 14);
5859

@@ -63,7 +64,7 @@ suite('Keyboard navigation on Blocks', function () {
6364

6465
test('Down from statement block selects next block across stacks', async function () {
6566
await focusOnBlock(this.browser, 'p5_canvas_1');
66-
await this.browser.pause(PAUSE_TIME);
67+
await idle(this.browser);
6768
await keyDown(this.browser);
6869

6970
chai
@@ -73,7 +74,7 @@ suite('Keyboard navigation on Blocks', function () {
7374

7475
test('Up from statement block selects previous block', async function () {
7576
await focusOnBlock(this.browser, 'simple_circle_1');
76-
await this.browser.pause(PAUSE_TIME);
77+
await idle(this.browser);
7778
await keyUp(this.browser);
7879

7980
chai
@@ -83,7 +84,7 @@ suite('Keyboard navigation on Blocks', function () {
8384

8485
test('Down from parent block selects first child block', async function () {
8586
await focusOnBlock(this.browser, 'p5_setup_1');
86-
await this.browser.pause(PAUSE_TIME);
87+
await idle(this.browser);
8788
await keyDown(this.browser);
8889
chai
8990
.expect(await getCurrentFocusedBlockId(this.browser))
@@ -92,7 +93,7 @@ suite('Keyboard navigation on Blocks', function () {
9293

9394
test('Up from child block selects parent block', async function () {
9495
await focusOnBlock(this.browser, 'p5_canvas_1');
95-
await this.browser.pause(PAUSE_TIME);
96+
await idle(this.browser);
9697
await keyUp(this.browser);
9798
chai
9899
.expect(await getCurrentFocusedBlockId(this.browser))
@@ -101,7 +102,7 @@ suite('Keyboard navigation on Blocks', function () {
101102

102103
test('Right from block selects first field', async function () {
103104
await focusOnBlock(this.browser, 'p5_canvas_1');
104-
await this.browser.pause(PAUSE_TIME);
105+
await idle(this.browser);
105106
await keyRight(this.browser);
106107

107108
chai
@@ -113,7 +114,7 @@ suite('Keyboard navigation on Blocks', function () {
113114

114115
test('Right from block selects first inline input', async function () {
115116
await focusOnBlock(this.browser, 'simple_circle_1');
116-
await this.browser.pause(PAUSE_TIME);
117+
await idle(this.browser);
117118
await keyRight(this.browser);
118119

119120
chai.assert.equal(
@@ -124,7 +125,7 @@ suite('Keyboard navigation on Blocks', function () {
124125

125126
test('Up from inline input selects statement block', async function () {
126127
await focusOnBlock(this.browser, 'math_number_2');
127-
await this.browser.pause(PAUSE_TIME);
128+
await idle(this.browser);
128129
await keyUp(this.browser);
129130

130131
chai.assert.equal(
@@ -135,7 +136,7 @@ suite('Keyboard navigation on Blocks', function () {
135136

136137
test('Left from first inline input selects block', async function () {
137138
await focusOnBlock(this.browser, 'math_number_2');
138-
await this.browser.pause(PAUSE_TIME);
139+
await idle(this.browser);
139140
await keyLeft(this.browser);
140141

141142
chai.assert.equal(
@@ -146,7 +147,7 @@ suite('Keyboard navigation on Blocks', function () {
146147

147148
test('Right from first inline input selects second inline input', async function () {
148149
await focusOnBlock(this.browser, 'math_number_2');
149-
await this.browser.pause(PAUSE_TIME);
150+
await idle(this.browser);
150151
await keyRight(this.browser);
151152

152153
chai.assert.equal(
@@ -157,7 +158,7 @@ suite('Keyboard navigation on Blocks', function () {
157158

158159
test('Left from second inline input selects first inline input', async function () {
159160
await focusOnBlock(this.browser, 'math_number_3');
160-
await this.browser.pause(PAUSE_TIME);
161+
await idle(this.browser);
161162
await keyLeft(this.browser);
162163

163164
chai.assert.equal(
@@ -168,7 +169,7 @@ suite('Keyboard navigation on Blocks', function () {
168169

169170
test('Right from last inline input selects next block', async function () {
170171
await focusOnBlock(this.browser, 'colour_picker_1');
171-
await this.browser.pause(PAUSE_TIME);
172+
await idle(this.browser);
172173
await keyRight(this.browser);
173174

174175
chai
@@ -178,7 +179,7 @@ suite('Keyboard navigation on Blocks', function () {
178179

179180
test('Down from inline input selects next block', async function () {
180181
await focusOnBlock(this.browser, 'colour_picker_1');
181-
await this.browser.pause(PAUSE_TIME);
182+
await idle(this.browser);
182183
await keyDown(this.browser);
183184

184185
chai
@@ -188,7 +189,7 @@ suite('Keyboard navigation on Blocks', function () {
188189

189190
test("Down from inline input selects block's child block", async function () {
190191
await focusOnBlock(this.browser, 'logic_boolean_1');
191-
await this.browser.pause(PAUSE_TIME);
192+
await idle(this.browser);
192193
await keyDown(this.browser);
193194

194195
chai
@@ -198,7 +199,7 @@ suite('Keyboard navigation on Blocks', function () {
198199

199200
test('Right from text block selects shadow block then field', async function () {
200201
await focusOnBlock(this.browser, 'text_print_1');
201-
await this.browser.pause(PAUSE_TIME);
202+
await idle(this.browser);
202203
await keyRight(this.browser);
203204

204205
chai.assert.equal(await getCurrentFocusedBlockId(this.browser), 'text_1');
@@ -246,7 +247,7 @@ suite('Keyboard navigation on Fields', function () {
246247

247248
test('Up from first field selects block', async function () {
248249
await focusOnBlockField(this.browser, 'p5_canvas_1', 'WIDTH');
249-
await this.browser.pause(PAUSE_TIME);
250+
await idle(this.browser);
250251
await keyUp(this.browser);
251252

252253
chai.assert.equal(
@@ -257,7 +258,7 @@ suite('Keyboard navigation on Fields', function () {
257258

258259
test('Left from first field selects block', async function () {
259260
await focusOnBlockField(this.browser, 'p5_canvas_1', 'WIDTH');
260-
await this.browser.pause(PAUSE_TIME);
261+
await idle(this.browser);
261262
await keyLeft(this.browser);
262263

263264
chai.assert.equal(
@@ -268,7 +269,7 @@ suite('Keyboard navigation on Fields', function () {
268269

269270
test('Right from first field selects second field', async function () {
270271
await focusOnBlockField(this.browser, 'p5_canvas_1', 'WIDTH');
271-
await this.browser.pause(PAUSE_TIME);
272+
await idle(this.browser);
272273
await keyRight(this.browser);
273274

274275
chai
@@ -280,7 +281,7 @@ suite('Keyboard navigation on Fields', function () {
280281

281282
test('Left from second field selects first field', async function () {
282283
await focusOnBlockField(this.browser, 'p5_canvas_1', 'HEIGHT');
283-
await this.browser.pause(PAUSE_TIME);
284+
await idle(this.browser);
284285
await keyLeft(this.browser);
285286

286287
chai
@@ -292,7 +293,7 @@ suite('Keyboard navigation on Fields', function () {
292293

293294
test('Right from second field selects next block', async function () {
294295
await focusOnBlockField(this.browser, 'p5_canvas_1', 'HEIGHT');
295-
await this.browser.pause(PAUSE_TIME);
296+
await idle(this.browser);
296297
await keyRight(this.browser);
297298

298299
chai
@@ -302,7 +303,7 @@ suite('Keyboard navigation on Fields', function () {
302303

303304
test('Down from field selects next block', async function () {
304305
await focusOnBlockField(this.browser, 'p5_canvas_1', 'WIDTH');
305-
await this.browser.pause(PAUSE_TIME);
306+
await idle(this.browser);
306307
await keyDown(this.browser);
307308

308309
chai
@@ -312,7 +313,7 @@ suite('Keyboard navigation on Fields', function () {
312313

313314
test("Down from field selects block's child block", async function () {
314315
await focusOnBlockField(this.browser, 'controls_repeat_1', 'TIMES');
315-
await this.browser.pause(PAUSE_TIME);
316+
await idle(this.browser);
316317
await keyDown(this.browser);
317318

318319
chai
@@ -323,7 +324,7 @@ suite('Keyboard navigation on Fields', function () {
323324
test('Do not navigate while field editor is open', async function () {
324325
// Open a field editor dropdown
325326
await focusOnBlockField(this.browser, 'logic_boolean_1', 'BOOL');
326-
await this.browser.pause(PAUSE_TIME);
327+
await idle(this.browser);
327328
await sendKeyAndWait(this.browser, Key.Enter);
328329

329330
// Try to navigate to a different block
@@ -336,7 +337,7 @@ suite('Keyboard navigation on Fields', function () {
336337
test('Do not reopen field editor when handling enter to make a choice inside the editor', async function () {
337338
// Open colour picker
338339
await focusOnBlockField(this.browser, 'colour_picker_1', 'COLOUR');
339-
await this.browser.pause(PAUSE_TIME);
340+
await idle(this.browser);
340341
await sendKeyAndWait(this.browser, Key.Enter);
341342

342343
// Move right to pick a new colour.

test/webdriverio/test/clipboard_test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
getFocusedBlockType,
2020
sendKeyAndWait,
2121
checkForFailures,
22+
idle,
2223
} from './test_setup.js';
2324
import {Key, KeyAction, PointerAction, WheelAction} from 'webdriverio';
2425

@@ -29,7 +30,7 @@ suite('Clipboard test', function () {
2930
// Clear the workspace and load start blocks.
3031
setup(async function () {
3132
this.browser = await testSetup(testFileLocations.BASE, this.timeout());
32-
await this.browser.pause(PAUSE_TIME);
33+
await idle(this.browser);
3334
});
3435

3536
teardown(async function() {
@@ -117,7 +118,7 @@ suite('Clipboard test', function () {
117118
test('Do not cut block while field editor is open', async function () {
118119
// Open a field editor
119120
await focusOnBlockField(this.browser, 'draw_circle_1_color', 'COLOUR');
120-
await this.browser.pause(PAUSE_TIME);
121+
await idle(this.browser);
121122
await sendKeyAndWait(this.browser, Key.Enter);
122123

123124
// Try to cut block while field editor is open
@@ -171,7 +172,7 @@ async function performActionWhileDraggingBlock(
171172
.move(blockX, blockY),
172173
action,
173174
]);
174-
await browser.pause(PAUSE_TIME);
175+
await idle(browser);
175176
}
176177

177178
/**

0 commit comments

Comments
 (0)