Improve reset password check using or locator (#50823)

* Update to use or locator

* Changelog
This commit is contained in:
Ilyas Foo 2024-08-22 08:57:46 +08:00 committed by GitHub
parent 35cdc6dc20
commit 8b62cf87e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 15 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: tweak
Update reset password e2e to use or locator to check reset status

View File

@ -19,20 +19,16 @@ test.describe( 'Can go to lost password page and submit the form', () => {
.fill( admin.username );
await page.getByRole( 'button', { name: 'Get New Password' } ).click();
try {
// For local testing, the email might not be sent, so we can ignore this error.
await expect(
page.getByText(
/The email could not be sent. Your site may not be correctly configured to send emails/i
)
).toBeVisible();
} catch ( e ) {
// eslint-disable-next-line jest/no-try-expect
await page.waitForURL( '**/wp-login.php?checkemail=confirm' );
// eslint-disable-next-line jest/no-try-expect
await expect(
page.getByText( /Check your email for the confirmation link/i )
).toBeVisible();
}
const emailSentMessage = page.getByText(
'check your email for the confirmation link'
);
const emailNotSentMessage = page.getByText(
'the email could not be sent'
);
// We don't have to care if the email was sent, we just want to know the button click attempts a reset.
await expect(
emailSentMessage.or( emailNotSentMessage )
).toBeVisible();
} );
} );