Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix the browser tests. #8735

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
gonfunko marked this conversation as resolved.
Show resolved Hide resolved
// 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
Loading