Skip to content

Commit d586a45

Browse files
committed
refactor: Use sendKeyAndWait instead of pauses.
1 parent 82d7b69 commit d586a45

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

test/webdriverio/test/workspace_comment_test.ts

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import {
1313
getFocusedBlockType,
1414
testSetup,
1515
focusOnWorkspaceComment,
16+
sendKeyAndWait,
1617
testFileLocations,
17-
PAUSE_TIME,
1818
keyLeft,
1919
keyRight,
2020
keyDown,
@@ -142,8 +142,7 @@ suite('Workspace comment navigation', function () {
142142
test('Activate workspace comment button', async function () {
143143
await focusOnWorkspaceComment(this.browser, this.commentId1);
144144
await keyRight(this.browser);
145-
await this.browser.keys(Key.Enter);
146-
await this.browser.pause(PAUSE_TIME);
145+
await sendKeyAndWait(this.browser, Key.Enter);
147146
const collapsed = await this.browser.execute((commentId) => {
148147
return Blockly.getMainWorkspace()
149148
.getCommentById(commentId)
@@ -154,19 +153,16 @@ suite('Workspace comment navigation', function () {
154153

155154
test('Activating workspace comment focuses its editor', async function () {
156155
await focusOnWorkspaceComment(this.browser, this.commentId1);
157-
await this.browser.keys(Key.Enter);
158-
await this.browser.pause(PAUSE_TIME);
156+
await sendKeyAndWait(this.browser, Key.Enter);
159157
const focusedNodeId = await getCurrentFocusNodeId(this.browser);
160158
chai.assert.equal(focusedNodeId, `${this.commentId1}_comment_textarea_`);
161159
});
162160

163161
test('Terminating editing commits edits and focuses root workspace comment', async function () {
164162
await focusOnWorkspaceComment(this.browser, this.commentId1);
165-
await this.browser.keys(Key.Enter);
166-
await this.browser.pause(PAUSE_TIME);
167-
await this.browser.keys('Hello world');
168-
await this.browser.pause(PAUSE_TIME);
169-
await this.browser.keys(Key.Escape);
163+
await sendKeyAndWait(this.browser, Key.Enter);
164+
await sendKeyAndWait(this.browser, 'Hello world');
165+
await sendKeyAndWait(this.browser, Key.Escape);
170166
const focusedNodeId = await getCurrentFocusNodeId(this.browser);
171167
chai.assert.equal(focusedNodeId, `${this.commentId1}`);
172168

@@ -178,8 +174,7 @@ suite('Workspace comment navigation', function () {
178174

179175
test('Action menu can be displayed for a workspace comment', async function () {
180176
await focusOnWorkspaceComment(this.browser, this.commentId1);
181-
await this.browser.keys([Key.Ctrl, Key.Return]);
182-
await this.browser.pause(PAUSE_TIME);
177+
await sendKeyAndWait(this.browser, [Key.Ctrl, Key.Return]);
183178
chai.assert.isTrue(
184179
await contextMenuExists(this.browser, 'Duplicate Comment'),
185180
'The menu should be openable on a workspace comment',
@@ -200,15 +195,10 @@ suite('Workspace comment navigation', function () {
200195
const initialPosition = await this.getCommentLocation(this.commentId1);
201196
chai.assert.deepEqual(initialPosition, [200, 200]);
202197

203-
await this.browser.keys('m');
204-
await this.browser.pause(PAUSE_TIME);
205-
await this.browser.keys([Key.Alt, Key.ArrowDown]);
206-
await this.browser.pause(PAUSE_TIME);
207-
await this.browser.keys([Key.Alt, Key.ArrowDown]);
208-
await this.browser.pause(PAUSE_TIME);
209-
await this.browser.keys([Key.Alt, Key.ArrowRight]);
210-
await this.browser.pause(PAUSE_TIME);
211-
await this.browser.keys(Key.Enter);
198+
await sendKeyAndWait(this.browser, 'm');
199+
await sendKeyAndWait(this.browser, [Key.Alt, Key.ArrowDown], 2);
200+
await sendKeyAndWait(this.browser, [Key.Alt, Key.ArrowRight]);
201+
await sendKeyAndWait(this.browser, Key.Enter);
212202

213203
const newPosition = await this.getCommentLocation(this.commentId1);
214204
chai.assert.deepEqual(newPosition, [220, 240]);

0 commit comments

Comments
 (0)