mirror of
https://github.com/google/blockly.git
synced 2026-01-08 17:40:09 +01:00
feat(test): add helper functions for getting selected block and block… (#7254)
* feat(test): add helper functions for getting selected block and block by ID * chore: format test files * chore: fix lint
This commit is contained in:
@@ -73,4 +73,32 @@ const testFileLocations = {
|
||||
playground: 2,
|
||||
};
|
||||
|
||||
module.exports = {testSetup, testFileLocations};
|
||||
/**
|
||||
* @param {Browser} browser The active WebdriverIO Browser object.
|
||||
* @return {WebElement} The selected block's root SVG element, as an interactable
|
||||
* browser element.
|
||||
*/
|
||||
async function getSelectedBlockElement(browser) {
|
||||
const result = await browser.execute(() => {
|
||||
// Note: selected is an ICopyable and I am assuming that it is a BlockSvg.
|
||||
return Blockly.common.getSelected()?.id;
|
||||
});
|
||||
return await browser.$(`[data-id="${result}"]`);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Browser} browser The active WebdriverIO Browser object.
|
||||
* @param {string} id The ID of the Blockly block to search for.
|
||||
* @return {WebElement} The root SVG element of the block with the given ID, as an
|
||||
* interactable browser element.
|
||||
*/
|
||||
async function getBlockElementById(browser, id) {
|
||||
return await browser.$(`[data-id="${id}"]`);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
testSetup,
|
||||
testFileLocations,
|
||||
getSelectedBlockElement,
|
||||
getBlockElementById,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user