@wordpress/e2e-test-utils
Version:
End-To-End (E2E) test utils for WordPress.
56 lines (55 loc) • 2.39 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 delete_theme_exports = {};
__export(delete_theme_exports, {
deleteTheme: () => deleteTheme
});
module.exports = __toCommonJS(delete_theme_exports);
var import_activate_theme = require("./activate-theme");
var import_install_theme = require("./install-theme");
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 deleteTheme(slug, { newThemeSlug, newThemeSearchTerm } = {}) {
await (0, import_switch_user_to_admin.switchUserToAdmin)();
if (newThemeSlug) {
await (0, import_install_theme.installTheme)(newThemeSlug, newThemeSearchTerm);
await (0, import_activate_theme.activateTheme)(newThemeSlug);
} else {
await (0, import_visit_admin_page.visitAdminPage)("themes.php");
}
if (!await (0, import_theme_installed.isThemeInstalled)(slug)) {
await (0, import_switch_user_to_test.switchUserToTest)();
return;
}
await page.click(`[data-slug="${slug}"]`);
await page.waitForSelector(".theme-actions .delete-theme");
await page.click(".theme-actions .delete-theme");
await page.waitForSelector("body:not(.modal-open)");
await page.waitForFunction(
(themeSlug) => !document.querySelector(`[data-slug="${themeSlug}"]`),
slug
);
await (0, import_switch_user_to_test.switchUserToTest)();
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
deleteTheme
});
//# sourceMappingURL=delete-theme.js.map