From 1fe82b23545b9a344d5365f15b01dd7bbea2bcbc Mon Sep 17 00:00:00 2001 From: Maribeth Bottorff Date: Fri, 28 Jul 2023 09:42:28 -0700 Subject: [PATCH] chore(tests): fix disable block tests (#7330) * chore(tests): fix disable block tests * chore: add comment --- tests/browser/test/basic_playground_test.js | 2 ++ tests/browser/test/test_setup.js | 16 +++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/browser/test/basic_playground_test.js b/tests/browser/test/basic_playground_test.js index 9f0e320ac..0c0bb221a 100644 --- a/tests/browser/test/basic_playground_test.js +++ b/tests/browser/test/basic_playground_test.js @@ -125,6 +125,8 @@ suite('Disabling', function () { setup(async function () { await this.browser.refresh(); + // Pause to allow refresh time to work. + await this.browser.pause(200); }); test( diff --git a/tests/browser/test/test_setup.js b/tests/browser/test/test_setup.js index 9376db984..634286a33 100644 --- a/tests/browser/test/test_setup.js +++ b/tests/browser/test/test_setup.js @@ -396,7 +396,8 @@ async function dragBlockTypeFromFlyout(browser, categoryName, type, x, y) { * context menu item. * * @param browser The active WebdriverIO Browser object. - * @param block The block to click, as an interactable element. + * @param block The block to click, as an interactable element. This block must + * 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. */ @@ -404,13 +405,14 @@ async function contextMenuSelect(browser, block, itemText) { // Clicking will always happen in the middle of the block's bounds // (including children) by default, which causes problems if it has holes // (e.g. statement inputs). - // Instead we want to click 10px from the left and 10px from the top. - const blockWidth = await block.getSize('width'); - const blockHeight = await block.getSize('height'); - const xOffset = -Math.round(blockWidth * 0.5) + 10; - const yOffset = -Math.round(blockHeight * 0.5) + 10; + // Instead, we'll click directly on the first bit of text on the block. + const clickEl = block.$('.blocklyText'); - await block.click({button: 2, x: xOffset, y: yOffset}); + // Even though the element should definitely already exist, + // one specific test breaks if you remove this... + await clickEl.waitForExist(); + + await clickEl.click({button: 2}); const item = await browser.$(`div=${itemText}`); await item.waitForExist();