Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
32 changes: 16 additions & 16 deletions test/webdriverio/test/actions_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,31 @@ import {
tabNavigateToWorkspace,
testFileLocations,
testSetup,
sendKeyAndWait,
keyRight,
contextMenuItems,
} from './test_setup.js';

suite('Menus test', function () {
// Setting timeout to unlimited as these tests take longer time to run
this.timeout(0);
// Disable timeouts when non-zero PAUSE_TIME is used to watch tests run.
if (PAUSE_TIME) this.timeout(0);

// Clear the workspace and load start blocks
// Clear the workspace and load start blocks.
setup(async function () {
// This is the first test suite, which must wait for Chrome +
// chromedriver to start up, which can be slow—perhaps a few
// seconds. Allow 30s just in case.
this.timeout(30000);

this.browser = await testSetup(testFileLocations.BASE);
await this.browser.pause(PAUSE_TIME);
});

test('Menu on block', async function () {
// Navigate to draw_circle_1.
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 sendKeyAndWait(this.browser, [Key.Ctrl, Key.Return]);

chai.assert.deepEqual(
process.platform === 'darwin'
Expand Down Expand Up @@ -70,14 +74,12 @@ suite('Menus test', function () {

test('Menu on block 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.
await keyRight(this.browser);
await this.browser.keys([Key.Ctrl, Key.Return]);
await this.browser.pause(PAUSE_TIME);
await sendKeyAndWait(this.browser, [Key.Ctrl, Key.Return]);

chai.assert.deepEqual(
process.platform === 'darwin'
Expand All @@ -100,9 +102,8 @@ suite('Menus test', function () {
test('Menu on workspace', async function () {
// Navigate to draw_circle_1.
await tabNavigateToWorkspace(this.browser);
await this.browser.keys('w');
await this.browser.keys([Key.Ctrl, Key.Return]);
await this.browser.pause(PAUSE_TIME);
await sendKeyAndWait(this.browser, 'w');
await sendKeyAndWait(this.browser, [Key.Ctrl, Key.Return]);

chai.assert.deepEqual(
process.platform === 'darwin'
Expand Down Expand Up @@ -132,12 +133,11 @@ suite('Menus test', function () {

test('Menu on block during drag is not shown', async function () {
// Navigate to draw_circle_1.
await tabNavigateToWorkspace(this.browser);
await focusOnBlock(this.browser, 'draw_circle_1');
// Start moving the block
await this.browser.keys('m');
await this.browser.keys([Key.Ctrl, Key.Return]);
await this.browser.pause(PAUSE_TIME);
await sendKeyAndWait(this.browser, 'm');
await sendKeyAndWait(this.browser, [Key.Ctrl, Key.Return]);

chai.assert.isTrue(
await contextMenuExists(this.browser, 'Collapse Block', true),
'The menu should not be openable during a move',
Expand Down
71 changes: 12 additions & 59 deletions test/webdriverio/test/basic_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
testSetup,
testFileLocations,
PAUSE_TIME,
sendKeyAndWait,
tabNavigateToWorkspace,
keyLeft,
keyRight,
Expand All @@ -25,10 +26,10 @@ import {
import {Key} from 'webdriverio';

suite('Keyboard navigation on Blocks', function () {
// Setting timeout to unlimited as these tests take a longer time to run than most mocha test
this.timeout(0);
// Disable timeouts when non-zero PAUSE_TIME is used to watch tests run.
if (PAUSE_TIME) this.timeout(0);

// Setup Selenium for all of the tests
// Clear the workspace and load start blocks.
suiteSetup(async function () {
this.browser = await testSetup(testFileLocations.NAVIGATION_TEST_BLOCKS);
});
Expand All @@ -53,8 +54,6 @@ suite('Keyboard navigation on Blocks', function () {
});

test('Down from statement block selects next block across stacks', async function () {
await tabNavigateToWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);
await focusOnBlock(this.browser, 'p5_canvas_1');
await this.browser.pause(PAUSE_TIME);
await keyDown(this.browser);
Expand All @@ -65,8 +64,6 @@ suite('Keyboard navigation on Blocks', function () {
});

test('Up from statement block selects previous block', async function () {
await tabNavigateToWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);
await focusOnBlock(this.browser, 'simple_circle_1');
await this.browser.pause(PAUSE_TIME);
await keyUp(this.browser);
Expand All @@ -77,8 +74,6 @@ suite('Keyboard navigation on Blocks', function () {
});

test('Down from parent block selects first child block', async function () {
await tabNavigateToWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);
await focusOnBlock(this.browser, 'p5_setup_1');
await this.browser.pause(PAUSE_TIME);
await keyDown(this.browser);
Expand All @@ -88,8 +83,6 @@ suite('Keyboard navigation on Blocks', function () {
});

test('Up from child block selects parent block', async function () {
await tabNavigateToWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);
await focusOnBlock(this.browser, 'p5_canvas_1');
await this.browser.pause(PAUSE_TIME);
await keyUp(this.browser);
Expand All @@ -99,8 +92,6 @@ suite('Keyboard navigation on Blocks', function () {
});

test('Right from block selects first field', async function () {
await tabNavigateToWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);
await focusOnBlock(this.browser, 'p5_canvas_1');
await this.browser.pause(PAUSE_TIME);
await keyRight(this.browser);
Expand All @@ -113,8 +104,6 @@ suite('Keyboard navigation on Blocks', function () {
});

test('Right from block selects first inline input', async function () {
await tabNavigateToWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);
await focusOnBlock(this.browser, 'simple_circle_1');
await this.browser.pause(PAUSE_TIME);
await keyRight(this.browser);
Expand All @@ -126,8 +115,6 @@ suite('Keyboard navigation on Blocks', function () {
});

test('Up from inline input selects statement block', async function () {
await tabNavigateToWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);
await focusOnBlock(this.browser, 'math_number_2');
await this.browser.pause(PAUSE_TIME);
await keyUp(this.browser);
Expand All @@ -139,8 +126,6 @@ suite('Keyboard navigation on Blocks', function () {
});

test('Left from first inline input selects block', async function () {
await tabNavigateToWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);
await focusOnBlock(this.browser, 'math_number_2');
await this.browser.pause(PAUSE_TIME);
await keyLeft(this.browser);
Expand All @@ -152,8 +137,6 @@ suite('Keyboard navigation on Blocks', function () {
});

test('Right from first inline input selects second inline input', async function () {
await tabNavigateToWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);
await focusOnBlock(this.browser, 'math_number_2');
await this.browser.pause(PAUSE_TIME);
await keyRight(this.browser);
Expand All @@ -165,8 +148,6 @@ suite('Keyboard navigation on Blocks', function () {
});

test('Left from second inline input selects first inline input', async function () {
await tabNavigateToWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);
await focusOnBlock(this.browser, 'math_number_3');
await this.browser.pause(PAUSE_TIME);
await keyLeft(this.browser);
Expand All @@ -178,8 +159,6 @@ suite('Keyboard navigation on Blocks', function () {
});

test('Right from last inline input selects next block', async function () {
await tabNavigateToWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);
await focusOnBlock(this.browser, 'colour_picker_1');
await this.browser.pause(PAUSE_TIME);
await keyRight(this.browser);
Expand All @@ -190,8 +169,6 @@ suite('Keyboard navigation on Blocks', function () {
});

test('Down from inline input selects next block', async function () {
await tabNavigateToWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);
await focusOnBlock(this.browser, 'colour_picker_1');
await this.browser.pause(PAUSE_TIME);
await keyDown(this.browser);
Expand All @@ -202,8 +179,6 @@ suite('Keyboard navigation on Blocks', function () {
});

test("Down from inline input selects block's child block", async function () {
await tabNavigateToWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);
await focusOnBlock(this.browser, 'logic_boolean_1');
await this.browser.pause(PAUSE_TIME);
await keyDown(this.browser);
Expand All @@ -214,8 +189,6 @@ suite('Keyboard navigation on Blocks', function () {
});

test('Right from text block selects shadow block then field', async function () {
await tabNavigateToWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);
await focusOnBlock(this.browser, 'text_print_1');
await this.browser.pause(PAUSE_TIME);
await keyRight(this.browser);
Expand All @@ -236,33 +209,27 @@ suite('Keyboard navigation on Blocks', function () {
});

test('Losing focus cancels move', async function () {
await tabNavigateToWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);
await focusOnBlock(this.browser, 'text_print_1');
await this.browser.keys('m');
await this.browser.pause(PAUSE_TIME);
await sendKeyAndWait(this.browser, 'm');

chai.assert.isTrue(await isDragging(this.browser));

await this.browser.keys(Key.Tab);
await this.browser.pause(PAUSE_TIME);
await sendKeyAndWait(this.browser, Key.Tab);

chai.assert.isFalse(await isDragging(this.browser));
});
});

suite('Keyboard navigation on Fields', function () {
// Setting timeout to unlimited as these tests take a longer time to run than most mocha test
this.timeout(0);
// Disable timeouts when non-zero PAUSE_TIME is used to watch tests run.
if (PAUSE_TIME) this.timeout(0);

// Setup Selenium for all of the tests
// Clear the workspace and load start blocks.
suiteSetup(async function () {
this.browser = await testSetup(testFileLocations.NAVIGATION_TEST_BLOCKS);
});

test('Up from first field selects block', async function () {
await tabNavigateToWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);
await focusOnBlockField(this.browser, 'p5_canvas_1', 'WIDTH');
await this.browser.pause(PAUSE_TIME);
await keyUp(this.browser);
Expand All @@ -274,8 +241,6 @@ suite('Keyboard navigation on Fields', function () {
});

test('Left from first field selects block', async function () {
await tabNavigateToWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);
await focusOnBlockField(this.browser, 'p5_canvas_1', 'WIDTH');
await this.browser.pause(PAUSE_TIME);
await keyLeft(this.browser);
Expand All @@ -287,8 +252,6 @@ suite('Keyboard navigation on Fields', function () {
});

test('Right from first field selects second field', async function () {
await tabNavigateToWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);
await focusOnBlockField(this.browser, 'p5_canvas_1', 'WIDTH');
await this.browser.pause(PAUSE_TIME);
await keyRight(this.browser);
Expand All @@ -301,8 +264,6 @@ suite('Keyboard navigation on Fields', function () {
});

test('Left from second field selects first field', async function () {
await tabNavigateToWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);
await focusOnBlockField(this.browser, 'p5_canvas_1', 'HEIGHT');
await this.browser.pause(PAUSE_TIME);
await keyLeft(this.browser);
Expand All @@ -315,8 +276,6 @@ suite('Keyboard navigation on Fields', function () {
});

test('Right from second field selects next block', async function () {
await tabNavigateToWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);
await focusOnBlockField(this.browser, 'p5_canvas_1', 'HEIGHT');
await this.browser.pause(PAUSE_TIME);
await keyRight(this.browser);
Expand All @@ -327,8 +286,6 @@ suite('Keyboard navigation on Fields', function () {
});

test('Down from field selects next block', async function () {
await tabNavigateToWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);
await focusOnBlockField(this.browser, 'p5_canvas_1', 'WIDTH');
await this.browser.pause(PAUSE_TIME);
await keyDown(this.browser);
Expand All @@ -339,8 +296,6 @@ suite('Keyboard navigation on Fields', function () {
});

test("Down from field selects block's child block", async function () {
await tabNavigateToWorkspace(this.browser);
await this.browser.pause(PAUSE_TIME);
await focusOnBlockField(this.browser, 'controls_repeat_1', 'TIMES');
await this.browser.pause(PAUSE_TIME);
await keyDown(this.browser);
Expand All @@ -354,8 +309,7 @@ suite('Keyboard navigation on Fields', function () {
// Open a field editor dropdown
await focusOnBlockField(this.browser, 'logic_boolean_1', 'BOOL');
await this.browser.pause(PAUSE_TIME);
await this.browser.keys(Key.Enter);
await this.browser.pause(PAUSE_TIME);
await sendKeyAndWait(this.browser, Key.Enter);

// Try to navigate to a different block
await keyRight(this.browser);
Expand All @@ -368,13 +322,12 @@ suite('Keyboard navigation on Fields', function () {
// Open colour picker
await focusOnBlockField(this.browser, 'colour_picker_1', 'COLOUR');
await this.browser.pause(PAUSE_TIME);
await this.browser.keys(Key.Enter);
await this.browser.pause(PAUSE_TIME);
await sendKeyAndWait(this.browser, Key.Enter);

// Move right to pick a new colour.
await keyRight(this.browser);
// Enter to choose.
await this.browser.keys(Key.Enter);
await sendKeyAndWait(this.browser, Key.Enter);

// Focus seems to take longer than a single pause to settle.
await this.browser.waitUntil(
Expand Down
7 changes: 4 additions & 3 deletions test/webdriverio/test/block_comment_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import {
sendKeyAndWait,
testFileLocations,
keyRight,
PAUSE_TIME,
} from './test_setup.js';
import {Key} from 'webdriverio';

suite('Block comment navigation', function () {
// Setting timeout to unlimited as these tests take a longer time to run than most mocha test
this.timeout(0);
// Disable timeouts when non-zero PAUSE_TIME is used to watch tests run.
if (PAUSE_TIME) this.timeout(0);

// Setup Selenium for all of the tests
// Clear the workspace and load start blocks.
setup(async function () {
this.browser = await testSetup(testFileLocations.NAVIGATION_TEST_BLOCKS);
await this.browser.execute(() => {
Expand Down
Loading
Loading