Skip to content

Commit db03a10

Browse files
committed
chore: Speed up test & force rendering.
Before the code was only forcing queueing not actual rendering.
1 parent e0a0594 commit db03a10

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

test/webdriverio/test/scroll_test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ suite('Scrolling into view', function () {
6161
// Increase timeout to 10s for this longer test.
6262
this.timeout(PAUSE_TIME ? 0 : 10000);
6363

64-
setPauseTime(0);
64+
// setPauseTime(0);
6565
await tabNavigateToWorkspace(this.browser);
6666

6767
// Separate the two top-level blocks by moving p5_draw_1 further down.
6868
await keyDown(this.browser, 3);
6969
await sendKeyAndWait(this.browser, 'm');
7070
await sendKeyAndWait(this.browser, [Key.Alt, Key.ArrowDown], 25);
7171
await sendKeyAndWait(this.browser, Key.Enter);
72-
setPauseTime(1000);
72+
// setPauseTime(1000);
7373
const movedBlockBounds = await this.browser.execute(() => {
7474
const block = Blockly.getFocusManager().getFocusedNode() as Blockly.BlockSvg;
7575
const blockBounds = block.getBoundingRectangleWithoutChildren();

test/webdriverio/test/test_setup.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ let driver: webdriverio.Browser | null = null;
4242
* the browser.wait* functions if you need your test to wait for
4343
* something to happen after sending input.
4444
*/
45-
export var PAUSE_TIME = 1000;
45+
export var PAUSE_TIME = 0;
4646

4747
export function setPauseTime(time: number) { PAUSE_TIME = time; }
4848

@@ -208,7 +208,15 @@ export async function getSelectedBlockId(browser: WebdriverIO.Browser) {
208208

209209
export async function idle(browser: WebdriverIO.Browser) {
210210
await browser.execute(() => {
211-
(Blockly.getMainWorkspace() as Blockly.WorkspaceSvg).render();
211+
const workspace = Blockly.getMainWorkspace() as Blockly.WorkspaceSvg;
212+
// Queue re-rendering all blocks.
213+
workspace.render();
214+
// Flush the rendering queue (this is a slight hack to leverage
215+
// BlockSvg.render() directly blocking on rendering finishing).
216+
const blocks = workspace.getTopBlocks();
217+
if (blocks.length > 0) {
218+
blocks[0].render();
219+
}
212220
});
213221
await browser.pause(PAUSE_TIME);
214222
}

0 commit comments

Comments
 (0)