@wordpress/e2e-test-utils
Version:
End-To-End (E2E) test utils for WordPress.
49 lines (48 loc) • 2.08 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 login_user_exports = {};
__export(login_user_exports, {
loginUser: () => loginUser
});
module.exports = __toCommonJS(login_user_exports);
var import_config = require("./shared/config");
var import_create_url = require("./create-url");
var import_is_current_url = require("./is-current-url");
var import_press_key_with_modifier = require("./press-key-with-modifier");
async function loginUser(username = import_config.WP_USERNAME, password = import_config.WP_PASSWORD) {
if (!(0, import_is_current_url.isCurrentURL)("wp-login.php")) {
const waitForLoginPageNavigation = page.waitForNavigation();
await page.goto((0, import_create_url.createURL)("wp-login.php"));
await waitForLoginPageNavigation;
}
await page.focus("#user_login");
await (0, import_press_key_with_modifier.pressKeyWithModifier)("primary", "a");
await page.type("#user_login", username);
await page.focus("#user_pass");
await (0, import_press_key_with_modifier.pressKeyWithModifier)("primary", "a");
await page.type("#user_pass", password);
await Promise.all([
page.click("#wp-submit"),
page.waitForNavigation({ waitUntil: "networkidle0" })
]);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
loginUser
});
//# sourceMappingURL=login-user.js.map