@wordpress/e2e-test-utils
Version:
End-To-End (E2E) test utils for WordPress.
46 lines (45 loc) • 1.89 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var click_block_toolbar_button_exports = {};
__export(click_block_toolbar_button_exports, {
clickBlockToolbarButton: () => clickBlockToolbarButton
});
module.exports = __toCommonJS(click_block_toolbar_button_exports);
var import_show_block_toolbar = require("./show-block-toolbar");
async function clickBlockToolbarButton(label, type = "ariaLabel") {
await (0, import_show_block_toolbar.showBlockToolbar)();
const BLOCK_TOOLBAR_SELECTOR = "block-editor-block-toolbar";
let button;
if (type === "ariaLabel") {
button = await page.waitForSelector(
`.${BLOCK_TOOLBAR_SELECTOR} button[aria-label="${label}"]`
);
}
if (type === "content") {
button = await page.waitForXPath(
`//*[contains(concat(' ', normalize-space(@class), ' '), ' ${BLOCK_TOOLBAR_SELECTOR} ')]//button[contains(text(), '${label}')]`
);
}
await button.evaluate((element) => element.scrollIntoView());
await button.click();
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
clickBlockToolbarButton
});
//# sourceMappingURL=click-block-toolbar-button.js.map