Add lost password e2e tests (#50611)

* Add lost password e2e tests

* Add changefile(s) from automation for the following project(s): woocommerce

* Update lost password e2e test

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Chi-Hsuan Huang 2024-08-14 12:28:16 +08:00 committed by GitHub
parent 175ebe2a5e
commit 6290e8e0f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: dev
Add lost password e2e tests

View File

@ -0,0 +1,38 @@
const { test, expect } = require( '@playwright/test' );
const { admin } = require( '../../test-data/data' );
test.describe( 'Can go to lost password page and submit the form', () => {
test( 'can visit the lost password page from the login page', async ( {
page,
} ) => {
await page.goto( '/wp-login.php' );
await page.getByRole( 'link', { name: 'Lost your password?' } ).click();
expect( page.url() ).toContain( '/wp-login.php?action=lostpassword' );
await expect( page.getByText( 'Get New Password' ) ).toBeVisible();
} );
test( 'can submit the lost password form', async ( { page } ) => {
await page.goto( '/wp-login.php?action=lostpassword' );
await page.getByLabel( 'Username or Email Address' ).click();
await page
.getByLabel( 'Username or Email Address' )
.fill( admin.username );
await page.getByRole( 'button', { name: 'Get New Password' } ).click();
try {
await page.waitForURL( '**/wp-login.php?checkemail=confirm' );
await expect(
page.getByText( /Check your email for the confirmation link/i )
).toBeVisible();
} catch ( e ) {
// For local testing, the email might not be sent, so we can ignore this error.
// eslint-disable-next-line jest/no-try-expect
await expect(
page.getByText(
/The email could not be sent. Your site may not be correctly configured to send emails/i
)
).toBeVisible();
}
} );
} );