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(tests): fix broken browser tests #7324

Merged
merged 3 commits into from
Jul 24, 2023
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
1 change: 0 additions & 1 deletion tests/browser/test/.mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

module.exports = {
ui: 'tdd',
reporter: 'landing',
};
13 changes: 2 additions & 11 deletions tests/browser/test/basic_block_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@ const {
testSetup,
testFileLocations,
getAllBlocks,
getSelectedBlockElement,
switchRTL,
dragBlockTypeFromFlyout,
screenDirection,
dragNthBlockFromFlyout,
} = require('./test_setup');
const {Key} = require('webdriverio');

Expand All @@ -37,13 +34,7 @@ suite('Basic block tests', function (done) {

test('Drag three blocks into the workspace', async function () {
for (let i = 1; i <= 3; i++) {
await dragBlockTypeFromFlyout(
browser,
'Basic',
'test_basic_empty',
250,
50 * i
);
await dragNthBlockFromFlyout(browser, 'Align', 0, 250, 50 * i);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was there a reason this needed to be switched out?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the basic blocks was breaking (I think it's one that you fixed in dev-tools) and it was making testing difficult.

I want to have a different test to validate that every test block can be shown in the toolbox and dragged in, but this particular test doesn't actually care which block you use.

chai.assert.equal((await getAllBlocks(browser)).length, i);
}
});
Expand Down
2 changes: 1 addition & 1 deletion tests/browser/test/basic_playground_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ suite('Disabling', function () {
110,
110
);
await connect(browser, child, 'PREVIOUS', parent, 'IF0');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, I guess this was just getting it close enough that it was working? lol

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup.

await connect(browser, child, 'PREVIOUS', parent, 'DO0');

await contextMenuSelect(browser, parent, 'Disable Block');

Expand Down
10 changes: 5 additions & 5 deletions tests/browser/test/test_setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ async function getLocationOfBlockConnection(browser, id, connectionName) {
block.getRelativeToSurfaceXY(),
connection.getOffsetInBlock()
);
console.log(Blockly);
return Blockly.utils.svgMath.wsToScreenCoordinates(
Blockly.getMainWorkspace(),
loc
Expand Down Expand Up @@ -346,9 +345,11 @@ async function contextMenuSelect(browser, block, itemText) {
// Clicking will always happen in the middle of the block's bounds
// (including children) by default, which causes problems if it has holes
// (e.g. statement inputs).
// Instead we want to click 20% from the right and 5% from the top.
const xOffset = -Math.round((await block.getSize('width')) * 0.3);
const yOffset = -Math.round((await block.getSize('height')) * 0.45);
// Instead we want to click 10px from the left and 10px from the top.
const blockWidth = await block.getSize('width');
const blockHeight = await block.getSize('height');
const xOffset = -Math.round(blockWidth * 0.5) + 10;
const yOffset = -Math.round(blockHeight * 0.5) + 10;

await block.click({button: 2, x: xOffset, y: yOffset});
await browser.pause(100);
Expand All @@ -369,7 +370,6 @@ async function contextMenuSelect(browser, block, itemText) {
*/
async function getAllBlocks(browser) {
return browser.execute(() => {
// return Blockly.getMainWorkspace().getAllBlocks(false);
return Blockly.getMainWorkspace()
.getAllBlocks(false)
.map((block) => ({
Expand Down