Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
147 changes: 145 additions & 2 deletions test/webdriverio/test/actions_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ import * as chai from 'chai';
import {Key} from 'webdriverio';
import {
contextMenuExists,
getContextMenuItemNames,
moveToToolboxCategory,
PAUSE_TIME,
focusOnBlock,
focusWorkspace,
rightClickOnBlock,
rightClickOnFlyoutBlockType,
tabNavigateToWorkspace,
testFileLocations,
testSetup,
Expand All @@ -27,6 +31,18 @@ suite('Menus test', function () {
await this.browser.pause(PAUSE_TIME);
});

test('Menu keyboard shortcut on workspace does not open menu', async function () {
await tabNavigateToWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);
await this.browser.keys([Key.Ctrl, Key.Return]);
await this.browser.pause(PAUSE_TIME);

chai.assert.isTrue(
await contextMenuExists(this.browser, 'Undo', /* reverse= */ true),
'The menu should not be openable on the workspace',
);
});

test('Menu action opens menu', async function () {
// Navigate to draw_circle_1.
await tabNavigateToWorkspace(this.browser);
Expand All @@ -41,9 +57,7 @@ suite('Menus test', function () {
});

test('Menu action returns true in the toolbox', async function () {
// Navigate to draw_circle_1.
await tabNavigateToWorkspace(this.browser);
await focusOnBlock(this.browser, 'draw_circle_1');
// Navigate to a toolbox category
await moveToToolboxCategory(this.browser, 'Functions');
// Move to flyout.
Expand All @@ -70,4 +84,133 @@ suite('Menus test', function () {
'The menu should not be openable during a move',
);
});

test('Block menu via keyboard displays expected items', async function () {
await tabNavigateToWorkspace(this.browser);
await focusOnBlock(this.browser, 'draw_circle_1');
await this.browser.keys([Key.Ctrl, Key.Return]);
await this.browser.pause(PAUSE_TIME);

chai.assert.deepEqual(
await getContextMenuItemNames(this.browser),
[
'Duplicate',
'Add Comment',
'External Inputs',
'Collapse Block',
'Disable Block',
'Delete 2 Blocks',
'Move Block',
'Edit Block contents',
'Cut',
'Copy',
'Paste',
],
'A block context menu should display certain items',
);
});

test('Block menu via mouse displays expected items', async function () {
await tabNavigateToWorkspace(this.browser);
await rightClickOnBlock(this.browser, 'draw_circle_1');

chai.assert.deepEqual(
await getContextMenuItemNames(this.browser),
[
'Duplicate',
'Add Comment',
'External Inputs',
'Collapse Block',
'Disable Block',
'Delete 2 Blocks',
'Cut',
'Copy',
'Paste',
],
'A block context menu should display certain items',
);
});

test('Shadow block menu via keyboard displays expected items', async function () {
await tabNavigateToWorkspace(this.browser);
await focusOnBlock(this.browser, 'draw_circle_1_color');
await this.browser.keys([Key.Ctrl, Key.Return]);
await this.browser.pause(PAUSE_TIME);

chai.assert.deepEqual(
await getContextMenuItemNames(this.browser),
[
'Add Comment',
'Collapse Block',
'Disable Block',
'Help',
'Move Block',
'Cut',
'Copy',
'Paste',
],
'A shadow block context menu should display certain items',
);
});

test('Flyout block menu via keyboard displays expected items', async function () {
await tabNavigateToWorkspace(this.browser);
// Navigate to a toolbox category
await moveToToolboxCategory(this.browser, 'Functions');
// Move to flyout.
await keyRight(this.browser);
await this.browser.keys([Key.Ctrl, Key.Return]);
await this.browser.pause(PAUSE_TIME);

chai.assert.deepEqual(
await getContextMenuItemNames(this.browser),
['Help', 'Move Block', 'Cut', 'Copy', 'Paste'],
'A flyout block context menu should display certain items',
);
});

test('Flyout block menu via mouse displays expected items', async function () {
await tabNavigateToWorkspace(this.browser);
// Navigate to a toolbox category
await moveToToolboxCategory(this.browser, 'Math');
// Move to flyout.
await keyRight(this.browser);
await this.browser.pause(PAUSE_TIME);
await rightClickOnFlyoutBlockType(this.browser, 'math_number');
await this.browser.pause(PAUSE_TIME);

chai.assert.deepEqual(
await getContextMenuItemNames(this.browser),
['Help', 'Cut', 'Copy', 'Paste'],
'A flyout block context menu should display certain items',
);
});

test('Escape key dismisses menu', async function () {
await tabNavigateToWorkspace(this.browser);
await focusOnBlock(this.browser, 'draw_circle_1');
await this.browser.pause(PAUSE_TIME);
await this.browser.keys([Key.Ctrl, Key.Return]);
await this.browser.pause(PAUSE_TIME);
await this.browser.keys(Key.Escape);
await this.browser.pause(PAUSE_TIME);

chai.assert.isTrue(
await contextMenuExists(this.browser, 'Duplicate', /* reverse= */ true),
'The menu should be closed',
);
});

test('Clicking workspace dismisses menu', async function () {
await tabNavigateToWorkspace(this.browser);
await rightClickOnBlock(this.browser, 'create_canvas_1');
await this.browser.pause(PAUSE_TIME);
await focusWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);

chai.assert.isTrue(
await contextMenuExists(this.browser, 'Duplicate', /* reverse= */ true),
'The menu should be closed',
);
});
});
Loading
Loading