Skip to content

Commit

Permalink
fix: Fix the browser tests. (#8735)
Browse files Browse the repository at this point in the history
  • Loading branch information
gonfunko authored Jan 16, 2025
1 parent 6404107 commit a86ba15
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
5 changes: 4 additions & 1 deletion core/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ export class Menu {
if (el) {
aria.setState(el, aria.State.ACTIVEDESCENDANT, item.getId());
}
item.getElement()?.scrollIntoView();
item.getElement()?.scrollIntoView({
block: 'nearest',
inline: 'start',
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/browser/test/basic_playground_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ suite('Disabling', function () {
110,
);
await connect(this.browser, child, 'OUTPUT', parent, 'IF0');

await this.browser.pause(PAUSE_TIME);
await contextMenuSelect(this.browser, parent, 'Disable Block');

chai.assert.isTrue(await getIsDisabled(this.browser, child.id));
Expand Down
12 changes: 8 additions & 4 deletions tests/browser/test/delete_blocks_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,14 @@ suite('Delete blocks', function (done) {
)
.waitForExist({timeout: 2000, reverse: true});

// Load the start blocks
await this.browser.execute((blocks) => {
Blockly.serialization.workspaces.load(blocks, Blockly.getMainWorkspace());
}, startBlocks);
// Load the start blocks. This hangs indefinitely if `startBlocks` is
// passed without being stringified.
this.browser.execute((blocks) => {
Blockly.serialization.workspaces.load(
JSON.parse(blocks),
Blockly.getMainWorkspace(),
);
}, JSON.stringify(startBlocks));
// Wait for there to be a block on the main workspace before continuing
(await getBlockElementById(this.browser, firstBlockId)).waitForExist({
timeout: 2000,
Expand Down
3 changes: 3 additions & 0 deletions tests/browser/test/procedure_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ suite('Testing Connecting Blocks', function (done) {
// Setup Selenium for all of the tests
suiteSetup(async function () {
this.browser = await testSetup(testFileLocations.CODE_DEMO);
// Prevent WebDriver from suppressing alerts
// https://github.com/webdriverio/webdriverio/issues/13610#issuecomment-2357768103
this.browser.on('dialog', (dialog) => {});
});

test('Testing Procedure', async function () {
Expand Down
6 changes: 3 additions & 3 deletions tests/browser/test/test_setup.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,9 @@ export async function getCategory(browser, categoryName) {
export async function getNthBlockOfCategory(browser, categoryName, n) {
const category = await getCategory(browser, categoryName);
await category.click();
const block = await browser.$(
`.blocklyFlyout .blocklyBlockCanvas > g:nth-child(${3 + n * 2})`,
);
const block = (
await browser.$$(`.blocklyFlyout .blocklyBlockCanvas > .blocklyDraggable`)
)[n];
return block;
}

Expand Down
3 changes: 0 additions & 3 deletions tests/browser/test/workspace_comment_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import * as chai from 'chai';
import * as sinon from 'sinon';
import {testFileLocations, testSetup} from './test_setup.mjs';

suite('Workspace comments', function () {
Expand All @@ -20,8 +19,6 @@ suite('Workspace comments', function () {
});

teardown(async function () {
sinon.restore();

await this.browser.execute(() => {
Blockly.getMainWorkspace().clear();
});
Expand Down

0 comments on commit a86ba15

Please sign in to comment.