From ef488e363c1f649cf4d8400d51cc8d9335a472bb Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Tue, 18 Jul 2023 16:40:30 +0200 Subject: [PATCH] feat: Allow dragging from simple toolbox fix: Add delay after block connection. Otherwise it can randomly and silently fail. --- tests/browser/test/test_setup.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/browser/test/test_setup.js b/tests/browser/test/test_setup.js index 6797b47ac69..2eb8f8a1fbb 100644 --- a/tests/browser/test/test_setup.js +++ b/tests/browser/test/test_setup.js @@ -155,14 +155,17 @@ async function getNthBlockOfCategory(browser, categoryName, n) { /** * @param browser The active WebdriverIO Browser object. * @param categoryName The name of the toolbox category to search. + * Null if the toolbox has no categories (simple). * @param blockType The type of the block to search for. * @return A Promise that resolves to the root element of the first * block with the given type in the given category. */ async function getBlockTypeFromCategory(browser, categoryName, blockType) { - const category = await getCategory(browser, categoryName); - category.click(); - await browser.pause(100); + if (categoryName) { + const category = await getCategory(browser, categoryName); + category.click(); + await browser.pause(100); + } const id = await browser.execute((blockType) => { return Blockly.getMainWorkspace() @@ -271,6 +274,7 @@ async function connect( y: targetLocation.y - draggedLocation.y, }; await draggedBlock.dragAndDrop(delta); + await browser.pause(200); } /** @@ -310,6 +314,7 @@ async function dragNthBlockFromFlyout(browser, categoryName, n, x, y) { * * @param browser The active WebdriverIO Browser object. * @param categoryName The name of the toolbox category to search. + * Null if the toolbox has no categories (simple). * @param type The type of the block to search for. * @param x The x-distance to drag, as a delta from the block's * initial location on screen.