@wordpress/e2e-test-utils
Version:
End-To-End (E2E) test utils for WordPress.
58 lines (57 loc) • 2.03 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 plugins_exports = {};
__export(plugins_exports, {
activatePlugin: () => activatePlugin,
deactivatePlugin: () => deactivatePlugin
});
module.exports = __toCommonJS(plugins_exports);
var import_change_case = require("change-case");
var import_rest_api = require("./rest-api");
const pluginsMapPromise = (async function getPluginsMap() {
const plugins = await (0, import_rest_api.rest)({ path: "/wp/v2/plugins" });
const map = {};
for (const plugin of plugins) {
map[(0, import_change_case.paramCase)(plugin.name)] = plugin.plugin;
}
return map;
})();
async function activatePlugin(slug) {
const pluginsMap = await pluginsMapPromise;
const plugin = pluginsMap[slug];
await (0, import_rest_api.rest)({
method: "PUT",
path: `/wp/v2/plugins/${plugin}`,
data: { status: "active" }
});
}
async function deactivatePlugin(slug) {
const pluginsMap = await pluginsMapPromise;
const plugin = pluginsMap[slug];
await (0, import_rest_api.rest)({
method: "PUT",
path: `/wp/v2/plugins/${plugin}`,
data: { status: "inactive" }
});
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
activatePlugin,
deactivatePlugin
});
//# sourceMappingURL=plugins.js.map