UNPKG

@wordpress/e2e-test-utils

Version:
50 lines (44 loc) 1.48 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.deleteUser = deleteUser; var _switchUserToAdmin = require("./switch-user-to-admin"); var _switchUserToTest = require("./switch-user-to-test"); var _visitAdminPage = require("./visit-admin-page"); /** * Internal dependencies */ /** * Delete a user account. * * @param {string} username User name. */ async function deleteUser(username) { await (0, _switchUserToAdmin.switchUserToAdmin)(); await (0, _visitAdminPage.visitAdminPage)('users.php'); const [userLink] = await page.$x(`//td[@data-colname="Username"]//a[contains(text(), "${username}")]`); if (!userLink) { await (0, _switchUserToTest.switchUserToTest)(); return; } // Focus to unveil actions. await userLink.focus(); // Tab twice to focus 'Delete' await page.keyboard.press('Tab'); await page.keyboard.press('Tab'); await Promise.all([page.keyboard.press('Enter'), page.waitForNavigation({ waitUntil: 'networkidle0' })]); // If there's content owned by this user, delete it. const deleteContentRadioButton = await page.$('input[type="radio"][name="delete_option"][value="delete"]'); if (deleteContentRadioButton) { await deleteContentRadioButton.click(); } // Confirm. await Promise.all([page.click('input#submit'), page.waitForNavigation({ waitUntil: 'networkidle0' })]); await (0, _switchUserToTest.switchUserToTest)(); } //# sourceMappingURL=delete-user.js.map