mirror of
https://github.com/google/blockly.git
synced 2026-01-04 15:40:08 +01:00
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:
committed by
GitHub
parent
c8be2f2538
commit
734b687f40
@@ -784,7 +784,7 @@ export abstract class Flyout extends DeleteArea implements IFlyout {
|
||||
}
|
||||
block = blocks.appendInternal(
|
||||
blockInfo as blocks.State,
|
||||
this.workspace_
|
||||
this.workspace_,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user