Skip to content

Commit 1fe82b2

Browse files
authored
chore(tests): fix disable block tests (#7330)
* chore(tests): fix disable block tests * chore: add comment
1 parent 9c24848 commit 1fe82b2

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

tests/browser/test/basic_playground_test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ suite('Disabling', function () {
125125

126126
setup(async function () {
127127
await this.browser.refresh();
128+
// Pause to allow refresh time to work.
129+
await this.browser.pause(200);
128130
});
129131

130132
test(

tests/browser/test/test_setup.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -396,21 +396,23 @@ async function dragBlockTypeFromFlyout(browser, categoryName, type, x, y) {
396396
* context menu item.
397397
*
398398
* @param browser The active WebdriverIO Browser object.
399-
* @param block The block to click, as an interactable element.
399+
* @param block The block to click, as an interactable element. This block must
400+
* have text on it, because we use the text element as the click target.
400401
* @param itemText The display text of the context menu item to click.
401402
* @return A Promise that resolves when the actions are completed.
402403
*/
403404
async function contextMenuSelect(browser, block, itemText) {
404405
// Clicking will always happen in the middle of the block's bounds
405406
// (including children) by default, which causes problems if it has holes
406407
// (e.g. statement inputs).
407-
// Instead we want to click 10px from the left and 10px from the top.
408-
const blockWidth = await block.getSize('width');
409-
const blockHeight = await block.getSize('height');
410-
const xOffset = -Math.round(blockWidth * 0.5) + 10;
411-
const yOffset = -Math.round(blockHeight * 0.5) + 10;
408+
// Instead, we'll click directly on the first bit of text on the block.
409+
const clickEl = block.$('.blocklyText');
412410

413-
await block.click({button: 2, x: xOffset, y: yOffset});
411+
// Even though the element should definitely already exist,
412+
// one specific test breaks if you remove this...
413+
await clickEl.waitForExist();
414+
415+
await clickEl.click({button: 2});
414416

415417
const item = await browser.$(`div=${itemText}`);
416418
await item.waitForExist();

0 commit comments

Comments
 (0)