UNPKG

@wordpress/e2e-test-utils

Version:
37 lines (36 loc) 1.08 kB
import { switchUserToAdmin } from "./switch-user-to-admin"; import { switchUserToTest } from "./switch-user-to-test"; import { visitAdminPage } from "./visit-admin-page"; async function deleteUser(username) { await switchUserToAdmin(); await visitAdminPage("users.php"); const [userLink] = await page.$x( `//td[@data-colname="Username"]//a[contains(text(), "${username}")]` ); if (!userLink) { await switchUserToTest(); return; } await userLink.focus(); await page.keyboard.press("Tab"); await page.keyboard.press("Tab"); await Promise.all([ page.keyboard.press("Enter"), page.waitForNavigation({ waitUntil: "networkidle0" }) ]); const deleteContentRadioButton = await page.$( 'input[type="radio"][name="delete_option"][value="delete"]' ); if (deleteContentRadioButton) { await deleteContentRadioButton.click(); } await Promise.all([ page.click("input#submit"), page.waitForNavigation({ waitUntil: "networkidle0" }) ]); await switchUserToTest(); } export { deleteUser }; //# sourceMappingURL=delete-user.js.map