mirror of
https://github.com/google/blockly.git
synced 2026-01-07 00:50:27 +01:00
chore: remove extra waits and shorten necessary ones (#7259)
This commit is contained in:
@@ -37,7 +37,6 @@ suite('Testing Connecting Blocks', function (done) {
|
||||
'procedures_defreturn'
|
||||
);
|
||||
await proceduresDefReturn.dragAndDrop({x: 50, y: 20});
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000)); // 2 sec
|
||||
const doSomething = await getSelectedBlockElement(browser);
|
||||
|
||||
// Drag out second function.
|
||||
@@ -47,7 +46,6 @@ suite('Testing Connecting Blocks', function (done) {
|
||||
'procedures_defreturn'
|
||||
);
|
||||
await proceduresDefReturn.dragAndDrop({x: 300, y: 200});
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000)); // 2 sec
|
||||
const doSomething2 = await getSelectedBlockElement(browser);
|
||||
|
||||
// Drag out numeric
|
||||
@@ -57,7 +55,6 @@ suite('Testing Connecting Blocks', function (done) {
|
||||
'math_number'
|
||||
);
|
||||
await mathNumeric.dragAndDrop({x: 50, y: 20});
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000)); // 2 sec
|
||||
const numeric = await getSelectedBlockElement(browser);
|
||||
|
||||
// Connect numeric to first procedure
|
||||
@@ -70,7 +67,6 @@ suite('Testing Connecting Blocks', function (done) {
|
||||
3
|
||||
);
|
||||
await doSomethingFlyout.dragAndDrop({x: 50, y: 20});
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000)); // 2 sec
|
||||
const doSomethingCaller = await getSelectedBlockElement(browser);
|
||||
|
||||
// Connect the doSomething caller to doSomething2
|
||||
@@ -82,8 +78,7 @@ suite('Testing Connecting Blocks', function (done) {
|
||||
'Text',
|
||||
'text_print'
|
||||
);
|
||||
await printFlyout.dragAndDrop({x: 50, y: 0});
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000)); // 2 sec
|
||||
await printFlyout.dragAndDrop({x: 50, y: 20});
|
||||
const print = await getSelectedBlockElement(browser);
|
||||
|
||||
// Drag out doSomething2 caller from flyout.
|
||||
@@ -92,19 +87,16 @@ suite('Testing Connecting Blocks', function (done) {
|
||||
'Functions',
|
||||
4
|
||||
);
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000)); // 2 sec
|
||||
await doSomething2Flyout.dragAndDrop({x: 130, y: 20});
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000)); // 2 sec
|
||||
const doSomething2Caller = await getSelectedBlockElement(browser);
|
||||
|
||||
// Connect doSomething2 caller with print.
|
||||
await connect(browser, doSomething2Caller, 'OUTPUT', print, 'TEXT');
|
||||
|
||||
// Click run button and verify the number is 123
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000)); // 2 sec
|
||||
const runButton = await browser.$('#runButton');
|
||||
runButton.click();
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000)); // 2 sec
|
||||
await browser.pause(200);
|
||||
const alertText = await browser.getAlertText(); // get the alert text
|
||||
chai.assert.equal(alertText, '123');
|
||||
});
|
||||
|
||||
@@ -119,7 +119,7 @@ async function getCategory(browser, categoryName) {
|
||||
async function getNthBlockOfCategory(browser, categoryName, n) {
|
||||
const category = await getCategory(browser, categoryName);
|
||||
category.click();
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000)); // 2 sec
|
||||
await browser.pause(100);
|
||||
const block = await browser.$(
|
||||
`.blocklyFlyout .blocklyBlockCanvas > g:nth-child(${3 + n * 2})`
|
||||
);
|
||||
@@ -129,7 +129,7 @@ async function getNthBlockOfCategory(browser, categoryName, n) {
|
||||
async function getBlockTypeFromCategory(browser, categoryName, blockType) {
|
||||
const category = await getCategory(browser, categoryName);
|
||||
category.click();
|
||||
await new Promise((resolve) => setTimeout(resolve, 2000)); // 2 sec
|
||||
await browser.pause(100);
|
||||
|
||||
const id = await browser.execute((blockType) => {
|
||||
return Blockly.getMainWorkspace()
|
||||
@@ -202,9 +202,7 @@ async function connect(
|
||||
|
||||
async function dragNthBlockFromFlyout(browser, categoryName, n, x, y) {
|
||||
const flyoutBlock = await getNthBlockOfCategory(browser, categoryName, n);
|
||||
await browser.pause(2000);
|
||||
await flyoutBlock.dragAndDrop({x: x, y: y});
|
||||
await browser.pause(2000);
|
||||
return await getSelectedBlockElement(browser);
|
||||
}
|
||||
|
||||
@@ -214,18 +212,16 @@ async function dragBlockTypeFromFlyout(browser, categoryName, type, x, y) {
|
||||
categoryName,
|
||||
type
|
||||
);
|
||||
await browser.pause(2000);
|
||||
await flyoutBlock.dragAndDrop({x: x, y: y});
|
||||
await browser.pause(2000);
|
||||
return await getSelectedBlockElement(browser);
|
||||
}
|
||||
|
||||
async function contextMenuSelect(browser, block, itemText) {
|
||||
await block.click({button: 2});
|
||||
await browser.pause(2000);
|
||||
await browser.pause(200);
|
||||
const item = await browser.$(`div=${itemText}`);
|
||||
await item.click();
|
||||
await browser.pause(2000);
|
||||
await browser.pause(200);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
||||
Reference in New Issue
Block a user