UNPKG

@wordpress/e2e-test-utils

Version:
52 lines (51 loc) 2.09 kB
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 posts_exports = {}; __export(posts_exports, { trashAllPosts: () => trashAllPosts }); module.exports = __toCommonJS(posts_exports); var import_url = require("@wordpress/url"); 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"); async function trashAllPosts(postType = "post", postStatus) { await (0, import_switch_user_to_admin.switchUserToAdmin)(); const query = (0, import_url.addQueryArgs)("", { post_type: postType, post_status: postStatus }).slice(1); await (0, import_visit_admin_page.visitAdminPage)("edit.php", query); const bulkSelector = await page.$("#bulk-action-selector-top"); if (!bulkSelector) { return; } await page.waitForSelector("[id^=cb-select-all-]"); await page.click("[id^=cb-select-all-]"); await page.select("#bulk-action-selector-top", "trash"); await page.click("#doaction"); await page.waitForXPath( '//*[contains(@class, "notice")]/p[contains(text(), "moved to the Trash.")]' ); await (0, import_switch_user_to_test.switchUserToTest)(); } // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { trashAllPosts }); //# sourceMappingURL=posts.js.map