fix(tests): fix broken browser tests (#7324)

* fix(tests):broken browser tests

* chore: format

* chore(tests): flip assertion order
This commit is contained in:
Rachel Fenichel
2023-07-24 15:10:00 -07:00
committed by GitHub
parent 36ba408b79
commit c61da55566
4 changed files with 8 additions and 18 deletions

View File

@@ -2,5 +2,4 @@
module.exports = {
ui: 'tdd',
reporter: 'landing',
};

View File

@@ -14,10 +14,7 @@ const {
testSetup,
testFileLocations,
getAllBlocks,
getSelectedBlockElement,
switchRTL,
dragBlockTypeFromFlyout,
screenDirection,
dragNthBlockFromFlyout,
} = require('./test_setup');
const {Key} = require('webdriverio');
@@ -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);
chai.assert.equal((await getAllBlocks(browser)).length, i);
}
});

View File

@@ -182,7 +182,7 @@ suite('Disabling', function () {
110,
110
);
await connect(browser, child, 'PREVIOUS', parent, 'IF0');
await connect(browser, child, 'PREVIOUS', parent, 'DO0');
await contextMenuSelect(browser, parent, 'Disable Block');

View File

@@ -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
@@ -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);
@@ -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) => ({