Commit e4f743e1108 for woocommerce
commit e4f743e11089c479cbf0e3ca9ea9e6012ca3f444
Author: Tom Cafferkey <tjcafferkey@gmail.com>
Date: Mon Oct 19 16:28:01 2026 +0100
Add E2E coverage for My Account temporary-password notice (#69762)
* E2E test
* Make My Account registration tests independent of store settings
* Restore all My Account settings even if one update fails
* Preserve customer cleanup errors when restoring account settings
diff --git a/plugins/woocommerce/changelog/wooplug-2472-my-account-password-notice-e2e b/plugins/woocommerce/changelog/wooplug-2472-my-account-password-notice-e2e
new file mode 100644
index 00000000000..10276b75634
--- /dev/null
+++ b/plugins/woocommerce/changelog/wooplug-2472-my-account-password-notice-e2e
@@ -0,0 +1,3 @@
+Significance: patch
+Type: dev
+Comment: Cover the My Account temporary-password notice with E2E tests; no production change.
diff --git a/plugins/woocommerce/tests/e2e/tests/my-account/my-account-create-account.spec.ts b/plugins/woocommerce/tests/e2e/tests/my-account/my-account-create-account.spec.ts
index e94225ddaa2..b980822af6a 100644
--- a/plugins/woocommerce/tests/e2e/tests/my-account/my-account-create-account.spec.ts
+++ b/plugins/woocommerce/tests/e2e/tests/my-account/my-account-create-account.spec.ts
@@ -9,11 +9,30 @@ import { WC_API_PATH } from '@woocommerce/e2e-utils-playwright';
import { expect, test } from '../../fixtures/fixtures';
const customerEmailAddress = `john.doe.${ Date.now() }@example.com`;
+const originalSettingValues = new Map< string, string >();
+const accountSettingsPath = `${ WC_API_PATH }/settings/account`;
+const registrationSettingIds = [
+ 'woocommerce_enable_myaccount_registration',
+ 'woocommerce_registration_generate_password',
+];
test.describe( 'Shopper My Account Create Account', () => {
test.beforeAll( async ( { restApi } ) => {
+ for ( const settingId of registrationSettingIds ) {
+ const response = await restApi.get(
+ `${ accountSettingsPath }/${ settingId }`
+ );
+ originalSettingValues.set( settingId, response.data.value );
+ }
+
+ await restApi.put(
+ `${ accountSettingsPath }/woocommerce_enable_myaccount_registration`,
+ {
+ value: 'yes',
+ }
+ );
await restApi.put(
- `${ WC_API_PATH }/settings/account/woocommerce_enable_myaccount_registration`,
+ `${ accountSettingsPath }/woocommerce_registration_generate_password`,
{
value: 'yes',
}
@@ -21,28 +40,43 @@ test.describe( 'Shopper My Account Create Account', () => {
} );
test.afterAll( async ( { restApi } ) => {
- // get a list of all customers and delete the one we created
- await restApi
- .get( `${ WC_API_PATH }/customers` )
- .then( ( response ) => {
- for ( let i = 0; i < response.data.length; i++ ) {
- if ( response.data[ i ].email === customerEmailAddress ) {
- restApi.delete(
- `${ WC_API_PATH }/customers/${ response.data[ i ].id }`,
- {
- force: true,
- }
- );
- }
+ const cleanupErrors: unknown[] = [];
+ try {
+ const response = await restApi.get(
+ `${ WC_API_PATH }/customers?email=${ encodeURIComponent(
+ customerEmailAddress
+ ) }`
+ );
+ for ( const customer of response.data ) {
+ await restApi.delete(
+ `${ WC_API_PATH }/customers/${ customer.id }`,
+ { force: true }
+ );
+ }
+ } catch ( error ) {
+ cleanupErrors.push( error );
+ } finally {
+ for ( const [ settingId, value ] of originalSettingValues ) {
+ try {
+ await restApi.put(
+ `${ accountSettingsPath }/${ settingId }`,
+ { value }
+ );
+ } catch ( error ) {
+ cleanupErrors.push(
+ new Error(
+ `Failed to restore ${ settingId }: ${ String( error ) }`
+ )
+ );
}
- } );
-
- await restApi.put(
- `${ WC_API_PATH }/settings/account/woocommerce_enable_myaccount_registration`,
- {
- value: 'no',
}
- );
+ }
+ if ( cleanupErrors.length ) {
+ throw new AggregateError(
+ cleanupErrors,
+ 'Failed to clean up My Account registration test state.'
+ );
+ }
} );
test( 'can create a new account via my account', async ( { page } ) => {
@@ -65,4 +99,40 @@ test.describe( 'Shopper My Account Create Account', () => {
customerEmailAddress
);
} );
+
+ test( 'shows the temporary password reminder on My Account after registration', async ( {
+ page,
+ restApi,
+ } ) => {
+ const email = `temporary-password-${ Date.now() }@example.com`;
+
+ try {
+ await page.goto( 'my-account/' );
+ await expect(
+ page.locator( '.woocommerce-form-register' )
+ ).toBeVisible();
+ await expect( page.locator( '#reg_password' ) ).toBeHidden();
+ await page.locator( '#reg_email' ).fill( email );
+ await page.locator( 'button[name="register"]' ).click();
+
+ await expect( page ).toHaveURL( /\/my-account\/?$/ );
+ await expect(
+ page.getByRole( 'status' ).filter( {
+ has: page.getByRole( 'link', { name: 'Resend' } ),
+ } )
+ ).toContainText(
+ 'Your account is using a temporary password. We emailed you a link to change your password.'
+ );
+ } finally {
+ const response = await restApi.get(
+ `${ WC_API_PATH }/customers?email=${ encodeURIComponent( email ) }`
+ );
+ for ( const customer of response.data ) {
+ await restApi.delete(
+ `${ WC_API_PATH }/customers/${ customer.id }`,
+ { force: true }
+ );
+ }
+ }
+ } );
} );