Skip to content

Commit 7df913d

Browse files
authored
test(MoveActions): Test starting a move using the context menu (#700)
* test(MoveActions): Test starting move using keyboard shortcuts Fixes #695. * refactor(tests): Make sendKeyAndWait faster if PAUSE_TIME === 0 Making a single webdriverio call is much faster when sending repeating keypresses; do that if we don't need to pause.
1 parent ec703af commit 7df913d

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

test/webdriverio/test/move_test.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
testSetup,
1515
sendKeyAndWait,
1616
keyDown,
17+
contextMenuItems,
1718
} from './test_setup.js';
1819

1920
suite('Move tests', function () {
@@ -32,6 +33,8 @@ suite('Move tests', function () {
3233
// moved, with subsequent statement blocks below it in the stack
3334
// reattached to where the moving block was - i.e., that a stack
3435
// heal will occur.
36+
//
37+
// Also tests initating a move using the shortcut key.
3538
test('Start moving statement blocks', async function () {
3639
for (let i = 1; i < 7; i++) {
3740
// Navigate to statement_<i>.
@@ -48,7 +51,7 @@ suite('Move tests', function () {
4851
);
4952
chai.assert(info.nextId, 'selected block has no next block');
5053

51-
// Start move.
54+
// Start move using keyboard shortcut.
5255
await sendKeyAndWait(this.browser, 'm');
5356

5457
// Check that the moving block has nothing connected it its
@@ -91,6 +94,8 @@ suite('Move tests', function () {
9194
// When a move of a value block begins, it is expected that block
9295
// and all blocks connected to its inputs will be moved - i.e., that
9396
// a stack heal (really: unary operator chain heal) will NOT occur.
97+
//
98+
// Also tests initiating a move via the context menu.
9499
test('Start moving value blocks', async function () {
95100
for (let i = 1; i < 7; i++) {
96101
// Navigate to statement_<i>.
@@ -107,8 +112,16 @@ suite('Move tests', function () {
107112
);
108113
chai.assert(info.valueId, 'selected block has no child value block');
109114

110-
// Start move.
115+
// Start move using context menu (using keyboard nav).
116+
await sendKeyAndWait(this.browser, [Key.Ctrl, Key.Return]);
111117
await sendKeyAndWait(this.browser, 'm');
118+
await keyDown(
119+
this.browser,
120+
(await contextMenuItems(this.browser)).findIndex(({text}) =>
121+
text.includes('Move'),
122+
),
123+
);
124+
await sendKeyAndWait(this.browser, Key.Return);
112125

113126
// Check that the moving block has nothing connected it its
114127
// next/previous connections, and same thing connected to value

test/webdriverio/test/test_setup.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,9 +554,15 @@ export async function sendKeyAndWait(
554554
keys: string | string[],
555555
times = 1,
556556
) {
557-
for (let i = 0; i < times; i++) {
557+
if (PAUSE_TIME === 0) {
558+
// Send all keys in one call if no pauses needed.
559+
keys = Array(times).fill(keys).flat();
558560
await browser.keys(keys);
559-
await browser.pause(PAUSE_TIME);
561+
} else {
562+
for (let i = 0; i < times; i++) {
563+
await browser.keys(keys);
564+
await browser.pause(PAUSE_TIME);
565+
}
560566
}
561567
}
562568

0 commit comments

Comments
 (0)