Skip to content

Commit 6daa162

Browse files
committed
fix: Fix the browser tests. (#8735)
(cherry picked from commit a86ba15)
1 parent d95039d commit 6daa162

6 files changed

Lines changed: 19 additions & 12 deletions

File tree

core/menu.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,10 @@ export class Menu {
264264
if (el) {
265265
aria.setState(el, aria.State.ACTIVEDESCENDANT, item.getId());
266266
}
267-
item.getElement()?.scrollIntoView();
267+
item.getElement()?.scrollIntoView({
268+
block: 'nearest',
269+
inline: 'start',
270+
});
268271
}
269272
}
270273

tests/browser/test/basic_playground_test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ suite('Disabling', function () {
137137
110,
138138
);
139139
await connect(this.browser, child, 'OUTPUT', parent, 'IF0');
140-
140+
await this.browser.pause(PAUSE_TIME);
141141
await contextMenuSelect(this.browser, parent, 'Disable Block');
142142

143143
chai.assert.isTrue(await getIsDisabled(this.browser, child.id));

tests/browser/test/delete_blocks_test.mjs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,14 @@ suite('Delete blocks', function (done) {
123123
)
124124
.waitForExist({timeout: 2000, reverse: true});
125125

126-
// Load the start blocks
127-
await this.browser.execute((blocks) => {
128-
Blockly.serialization.workspaces.load(blocks, Blockly.getMainWorkspace());
129-
}, startBlocks);
126+
// Load the start blocks. This hangs indefinitely if `startBlocks` is
127+
// passed without being stringified.
128+
this.browser.execute((blocks) => {
129+
Blockly.serialization.workspaces.load(
130+
JSON.parse(blocks),
131+
Blockly.getMainWorkspace(),
132+
);
133+
}, JSON.stringify(startBlocks));
130134
// Wait for there to be a block on the main workspace before continuing
131135
(await getBlockElementById(this.browser, firstBlockId)).waitForExist({
132136
timeout: 2000,

tests/browser/test/procedure_test.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ suite('Testing Connecting Blocks', function (done) {
2626
// Setup Selenium for all of the tests
2727
suiteSetup(async function () {
2828
this.browser = await testSetup(testFileLocations.CODE_DEMO);
29+
// Prevent WebDriver from suppressing alerts
30+
// https://github.com/webdriverio/webdriverio/issues/13610#issuecomment-2357768103
31+
this.browser.on('dialog', (dialog) => {});
2932
});
3033

3134
test('Testing Procedure', async function () {

tests/browser/test/test_setup.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,9 @@ export async function getCategory(browser, categoryName) {
254254
export async function getNthBlockOfCategory(browser, categoryName, n) {
255255
const category = await getCategory(browser, categoryName);
256256
await category.click();
257-
const block = await browser.$(
258-
`.blocklyFlyout .blocklyBlockCanvas > g:nth-child(${3 + n * 2})`,
259-
);
257+
const block = (
258+
await browser.$$(`.blocklyFlyout .blocklyBlockCanvas > .blocklyDraggable`)
259+
)[n];
260260
return block;
261261
}
262262

tests/browser/test/workspace_comment_test.mjs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66

77
import * as chai from 'chai';
8-
import * as sinon from 'sinon';
98
import {testFileLocations, testSetup} from './test_setup.mjs';
109

1110
suite('Workspace comments', function () {
@@ -20,8 +19,6 @@ suite('Workspace comments', function () {
2019
});
2120

2221
teardown(async function () {
23-
sinon.restore();
24-
2522
await this.browser.execute(() => {
2623
Blockly.getMainWorkspace().clear();
2724
});

0 commit comments

Comments
 (0)