diff --git a/packages/e2e-tests/config/setup-test-framework.js b/packages/e2e-tests/config/setup-test-framework.js index a3129c4d82c48a..4800da23a860fd 100644 --- a/packages/e2e-tests/config/setup-test-framework.js +++ b/packages/e2e-tests/config/setup-test-framework.js @@ -13,6 +13,8 @@ import { setBrowserViewport, visitAdminPage, activatePlugin, + switchUserToAdmin, + switchUserToTest, } from '@wordpress/e2e-test-utils'; /** @@ -54,6 +56,7 @@ async function setupBrowser() { * @return {Promise} Promise resolving once posts have been trashed. */ async function trashExistingPosts() { + await switchUserToAdmin(); // Visit `/wp-admin/edit.php` so we can see a list of posts and delete them. await visitAdminPage( 'edit.php' ); @@ -70,9 +73,10 @@ async function trashExistingPosts() { await page.select( '#bulk-action-selector-top', 'trash' ); // Submit the form to send all draft/scheduled/published posts to the trash. await page.click( '#doaction' ); - return page.waitForXPath( + await page.waitForXPath( '//*[contains(@class, "updated notice")]/p[contains(text(), "moved to the Trash.")]' ); + await switchUserToTest(); } /**