chore(tests): Update RTL tests and misc improvements to helpers (#7293)

* chore(tests): make switch to rtl wait before continuing

* chore: use browser.pause

* chore: fix documentation

* chore: format

* fix: missing await
This commit is contained in:
Maribeth Bottorff
2023-07-26 18:03:42 -07:00
committed by GitHub
parent c8be2f2538
commit 734b687f40
5 changed files with 11 additions and 19 deletions

View File

@@ -784,7 +784,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
}
block = blocks.appendInternal(
blockInfo as blocks.State,
this.workspace_
this.workspace_,
);
}
}

View File

@@ -566,7 +566,7 @@ export function domToBlock(xmlBlock: Element, workspace: Workspace): Block {
*/
export function domToBlockInternal(
xmlBlock: Element,
workspace: Workspace
workspace: Workspace,
): Block {
// Create top-level block.
eventUtils.disable();

View File

@@ -53,7 +53,7 @@ suite('Testing Connecting Blocks', function () {
'#blocklyDiv > div > svg:nth-child(7) > g > g.blocklyBlockCanvas > g:nth-child(3)',
);
await ifDoBlock.dragAndDrop({x: 20, y: 20});
await new Promise((resolve) => setTimeout(resolve, 200));
await this.browser.pause(200);
const blockOnWorkspace = await this.browser.execute(() => {
const newBlock = Blockly.getMainWorkspace().getAllBlocks(false)[0];
if (newBlock.id) {

View File

@@ -33,7 +33,7 @@ suite('Testing Field Edits', function (done) {
});
test('Testing Field Edits RTL', async function () {
switchRTL(this.browser);
await switchRTL(this.browser);
await testFieldEdits(this.browser, screenDirection.RTL);
});
});

View File

@@ -148,18 +148,10 @@ async function getBlockElementById(browser, id) {
* @throws If the category cannot be found.
*/
async function getCategory(browser, categoryName) {
const categories = await browser.$$('.blocklyTreeLabel');
const category = browser.$(`.blocklyToolboxCategory*=${categoryName}`);
category.waitForExist();
let category;
for (const c of categories) {
const text = await c.getText();
if (text === categoryName) {
category = c;
}
}
if (!category) throw Error();
return category;
return await category;
}
/**
@@ -171,7 +163,7 @@ async function getCategory(browser, categoryName) {
*/
async function getNthBlockOfCategory(browser, categoryName, n) {
const category = await getCategory(browser, categoryName);
category.click();
await category.click();
await browser.pause(100);
const block = await browser.$(
`.blocklyFlyout .blocklyBlockCanvas > g:nth-child(${3 + n * 2})`,
@@ -190,8 +182,7 @@ async function getNthBlockOfCategory(browser, categoryName, n) {
async function getBlockTypeFromCategory(browser, categoryName, blockType) {
if (categoryName) {
const category = await getCategory(browser, categoryName);
category.click();
await browser.pause(100);
await category.click();
}
const id = await browser.execute((blockType) => {
@@ -312,6 +303,7 @@ async function connect(
async function switchRTL(browser) {
const ltrForm = await browser.$('#options > select:nth-child(1)');
await ltrForm.selectByIndex(1);
await browser.pause(500);
}
/**
@@ -379,9 +371,9 @@ async function contextMenuSelect(browser, block, itemText) {
const yOffset = -Math.round(blockHeight * 0.5) + 10;
await block.click({button: 2, x: xOffset, y: yOffset});
await browser.pause(100);
const item = await browser.$(`div=${itemText}`);
await item.waitForExist();
await item.click();
await browser.pause(100);