From 1f5dc25b3cc1d361584abfd6e8e006e6ddd2a977 Mon Sep 17 00:00:00 2001 From: Rachel Fenichel Date: Tue, 12 Sep 2023 14:43:31 -0700 Subject: [PATCH] fix(tests): use new helper function for right-clicks --- tests/browser/test/basic_playground_test.js | 25 ++++++++++----------- tests/browser/test/delete_blocks_test.js | 2 +- tests/browser/test/test_setup.js | 6 ++--- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/tests/browser/test/basic_playground_test.js b/tests/browser/test/basic_playground_test.js index 965de4445..ef8bc4abb 100644 --- a/tests/browser/test/basic_playground_test.js +++ b/tests/browser/test/basic_playground_test.js @@ -69,37 +69,36 @@ suite('Right Clicking on Blocks', function () { suiteSetup(async function () { this.browser = await testSetup(testFileLocations.PLAYGROUND); this.block = await dragNthBlockFromFlyout(this.browser, 'Loops', 0, 20, 20); - this.blockId = this.block.id; }); test('clicking the collapse option collapses the block', async function () { - await contextMenuSelect(this.browser, this.block, 'Collapse Block'); - chai.assert.isTrue(await getIsCollapsed(this.browser, this.blockId)); + await contextMenuSelect(this.browser, this.block.id, 'Collapse Block'); + chai.assert.isTrue(await getIsCollapsed(this.browser, this.block.id)); }); // Assumes that test('clicking the expand option expands the block', async function () { - await contextMenuSelect(this.browser, this.block, 'Expand Block'); - chai.assert.isFalse(await getIsCollapsed(this.browser, this.blockId)); + await contextMenuSelect(this.browser, this.block.id, 'Expand Block'); + chai.assert.isFalse(await getIsCollapsed(this.browser, this.block.id)); }); test('clicking the disable option disables the block', async function () { - await contextMenuSelect(this.browser, this.block, 'Disable Block'); - chai.assert.isTrue(await getIsDisabled(this.browser, this.blockId)); + await contextMenuSelect(this.browser, this.block.id, 'Disable Block'); + chai.assert.isTrue(await getIsDisabled(this.browser, this.block.id)); }); test('clicking the enable option enables the block', async function () { - await contextMenuSelect(this.browser, this.block, 'Enable Block'); + await contextMenuSelect(this.browser, this.block.id, 'Enable Block'); chai.assert.isFalse(await getIsDisabled(this.browser, this.block.id)); }); test('clicking the add comment option adds a comment to the block', async function () { - await contextMenuSelect(this.browser, this.block, 'Add Comment'); + await contextMenuSelect(this.browser, this.block.id, 'Add Comment'); chai.assert.equal(await getCommentText(this.browser, this.block.id), ''); }); test('clicking the remove comment option removes a comment from the block', async function () { - await contextMenuSelect(this.browser, this.block, 'Remove Comment'); + await contextMenuSelect(this.browser, this.block.id, 'Remove Comment'); chai.assert.isNull(await getCommentText(this.browser, this.block.id)); }); }); @@ -139,7 +138,7 @@ suite('Disabling', function () { ); await connect(this.browser, child, 'OUTPUT', parent, 'IF0'); - await contextMenuSelect(this.browser, parent, 'Disable Block'); + await contextMenuSelect(this.browser, parent.id, 'Disable Block'); chai.assert.isTrue(await getIsDisabled(this.browser, child.id)); }, @@ -165,7 +164,7 @@ suite('Disabling', function () { ); await connect(this.browser, child, 'PREVIOUS', parent, 'DO0'); - await contextMenuSelect(this.browser, parent, 'Disable Block'); + await contextMenuSelect(this.browser, parent.id, 'Disable Block'); chai.assert.isTrue(await getIsDisabled(this.browser, child.id)); }, @@ -191,7 +190,7 @@ suite('Disabling', function () { ); await connect(this.browser, child, 'PREVIOUS', parent, 'NEXT'); - await contextMenuSelect(this.browser, parent, 'Disable Block'); + await contextMenuSelect(this.browser, parent.id, 'Disable Block'); chai.assert.isFalse(await getIsDisabled(this.browser, child.id)); }, diff --git a/tests/browser/test/delete_blocks_test.js b/tests/browser/test/delete_blocks_test.js index 261074a91..e493b840b 100644 --- a/tests/browser/test/delete_blocks_test.js +++ b/tests/browser/test/delete_blocks_test.js @@ -168,7 +168,7 @@ suite('Delete blocks', function (done) { const before = (await getAllBlocks(this.browser)).length; // Get first print block, click to select it, and delete it using context menu. const block = await getBlockElementById(this.browser, firstBlockId); - await contextMenuSelect(this.browser, block, 'Delete 2 Blocks'); + await contextMenuSelect(this.browser, block.id, 'Delete 2 Blocks'); const after = (await getAllBlocks(this.browser)).length; chai.assert.equal( before - 2, diff --git a/tests/browser/test/test_setup.js b/tests/browser/test/test_setup.js index 9b8919acb..055ac2249 100644 --- a/tests/browser/test/test_setup.js +++ b/tests/browser/test/test_setup.js @@ -460,13 +460,13 @@ async function dragBlockFromMutatorFlyout(browser, mutatorBlock, type, x, y) { * context menu item. * * @param browser The active WebdriverIO Browser object. - * @param block The block to click, as an interactable element. This block must + * @param blockId The ID of the block to click. This block should * have text on it, because we use the text element as the click target. * @param itemText The display text of the context menu item to click. * @return A Promise that resolves when the actions are completed. */ -async function contextMenuSelect(browser, block, itemText) { - const clickEl = await getClickableBlockElementById(browser, block.id); +async function contextMenuSelect(browser, blockId, itemText) { + const clickEl = await getClickableBlockElementById(browser, blockId); // Even though the element should definitely already exist, // one specific test breaks if you remove this... await clickEl.waitForExist();