Skip to content

Commit 59d5f5a

Browse files
committed
How about this?
1 parent 0a3d31e commit 59d5f5a

1 file changed

Lines changed: 18 additions & 11 deletions

File tree

tests/e2e/specs/collaboration/fixtures/collaboration-utils.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,19 +100,26 @@ export default class CollaborationUtils {
100100
* @param {Object} userInfo User credentials.
101101
*/
102102
async loginUser( page, userInfo ) {
103-
await page.goto( '/wp-login.php' );
103+
// Login to admin using request context.
104+
let response = await page.request.post( 'wp-login.php', {
105+
failOnStatusCode: true,
106+
form: {
107+
log: userInfo.username,
108+
pwd: userInfo.password,
109+
},
110+
} );
111+
await response.dispose();
104112

105-
// Retry filling if the page resets during a cold Docker start.
106-
await expect( async () => {
107-
await page.locator( '#user_login' ).fill( userInfo.username );
108-
await page.locator( '#user_pass' ).fill( userInfo.password, { force: true } );
109-
await expect( page.locator( '#user_pass' ) ).toHaveValue(
110-
userInfo.password
111-
);
112-
} ).toPass( { timeout: 15_000 } );
113+
// Get the nonce.
114+
response = await page.request.get(
115+
'wp-admin/admin-ajax.php?action=rest-nonce',
116+
{
117+
failOnStatusCode: true,
118+
}
119+
);
120+
const nonce = await response.text();
113121

114-
await page.getByRole( 'button', { name: 'Log In' } ).click();
115-
await page.waitForURL( '**/wp-admin/**' );
122+
return nonce;
116123
}
117124

118125
/**

0 commit comments

Comments
 (0)