@wordpress/e2e-test-utils
Version:
End-To-End (E2E) test utils for WordPress.
57 lines (56 loc) • 2.25 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 install_theme_exports = {};
__export(install_theme_exports, {
installTheme: () => installTheme
});
module.exports = __toCommonJS(install_theme_exports);
var import_switch_user_to_admin = require("./switch-user-to-admin");
var import_switch_user_to_test = require("./switch-user-to-test");
var import_visit_admin_page = require("./visit-admin-page");
var import_theme_installed = require("./theme-installed");
async function installTheme(slug, { searchTerm } = {}) {
await (0, import_switch_user_to_admin.switchUserToAdmin)();
const installed = await (0, import_theme_installed.isThemeInstalled)(slug);
if (installed) {
return;
}
await (0, import_visit_admin_page.visitAdminPage)(
"theme-install.php",
`search=${encodeURIComponent(searchTerm || slug)}`
);
await page.waitForSelector(`div[data-slug="${slug}"]`);
const activateLink = await page.$(
`div[data-slug="${slug}"] .button.activate`
);
if (activateLink) {
await (0, import_switch_user_to_test.switchUserToTest)();
return;
}
await page.waitForSelector(`.theme-install[data-slug="${slug}"]`);
await page.click(`.theme-install[data-slug="${slug}"]`);
await page.waitForSelector(`.theme[data-slug="${slug}"] .activate`, {
timeout: 6e4
});
await (0, import_switch_user_to_test.switchUserToTest)();
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
installTheme
});
//# sourceMappingURL=install-theme.js.map