Skip to content

Commit 3542de5

Browse files
committed
chore: Restore headless, and add force rendering.
This is a sledgehammer solution but it seems potentially viable. More changes to follow.
1 parent c7a5087 commit 3542de5

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

test/webdriverio/test/test_setup.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export async function driverSetup(
7979
// Run in headless mode on Github Actions.
8080
if (process.env.CI) {
8181
options.capabilities['goog:chromeOptions'].args.push(
82-
'--headless=new',
82+
'--headless',
8383
'--no-sandbox',
8484
'--disable-dev-shm-usage',
8585
);
@@ -204,6 +204,13 @@ export async function getSelectedBlockId(browser: WebdriverIO.Browser) {
204204
});
205205
}
206206

207+
export async function idle(browser: WebdriverIO.Browser) {
208+
await browser.execute(() => {
209+
(Blockly.getMainWorkspace() as Blockly.WorkspaceSvg).render();
210+
});
211+
await browser.pause(PAUSE_TIME);
212+
}
213+
207214
/**
208215
* Clicks in the workspace to focus it.
209216
*
@@ -214,7 +221,7 @@ export async function focusWorkspace(browser: WebdriverIO.Browser) {
214221
'#blocklyDiv > div > svg.blocklySvg > g',
215222
);
216223
await workspaceElement.click({x: 100});
217-
await browser.pause(PAUSE_TIME);
224+
await idle(browser);
218225
}
219226

220227
/**
@@ -303,7 +310,7 @@ export async function focusOnBlock(
303310
if (!block) throw new Error(`No block found with ID: ${blockId}.`);
304311
Blockly.getFocusManager().focusNode(block);
305312
}, blockId);
306-
await browser.pause(PAUSE_TIME);
313+
await idle(browser);
307314
}
308315

309316
/**
@@ -326,7 +333,7 @@ export async function focusOnWorkspaceComment(
326333
}
327334
Blockly.getFocusManager().focusNode(comment);
328335
}, commentId);
329-
await browser.pause(PAUSE_TIME);
336+
await idle(browser);
330337
}
331338

332339
/**
@@ -358,7 +365,7 @@ export async function focusOnBlockField(
358365
blockId,
359366
fieldName,
360367
);
361-
await browser.pause(PAUSE_TIME);
368+
await idle(browser);
362369
}
363370

364371
/**
@@ -491,7 +498,7 @@ export async function tabNavigateToWorkspace(
491498
// there's no straightforward way to do that; see
492499
// https://stackoverflow.com/q/51518855/4969945
493500
await browser.execute(() => document.getElementById('focusableDiv')?.focus());
494-
await browser.pause(PAUSE_TIME);
501+
await idle(browser);
495502
// Navigate to workspace.
496503
if (hasToolbox) await tabNavigateForward(browser);
497504
if (hasFlyout) await tabNavigateForward(browser);
@@ -591,7 +598,7 @@ export async function sendKeyAndWait(
591598
} else {
592599
for (let i = 0; i < times; i++) {
593600
await browser.keys(keys);
594-
await browser.pause(PAUSE_TIME);
601+
await idle(browser);
595602
}
596603
}
597604
}
@@ -737,13 +744,13 @@ export async function clickBlock(
737744
blockId,
738745
findableId,
739746
);
740-
await browser.pause(PAUSE_TIME);
747+
await idle(browser);
741748

742749
// In the test context, get the WebdriverIO Element that we've identified.
743750
const elem = await browser.$(`#${findableId}`);
744751

745752
await elem.click(clickOptions);
746-
await browser.pause(PAUSE_TIME);
753+
await idle(browser);
747754

748755
// In the browser context, remove the ID.
749756
await browser.execute((elemId) => {
@@ -763,5 +770,5 @@ export async function rightClickOnFlyoutBlockType(
763770
) {
764771
const elem = await browser.$(`.blocklyFlyout .${blockType}`);
765772
await elem.click({button: 'right'});
766-
await browser.pause(PAUSE_TIME);
773+
await idle(browser);
767774
}

0 commit comments

Comments
 (0)