Commit 039c355e7f for woocommerce
commit 039c355e7ffdacc5993409cdaf834d003f0829aa
Author: Adrian Moldovan <3854374+adimoldovan@users.noreply.github.com>
Date: Tue Jul 1 16:30:48 2025 +0300
[e2e tests] Merge global setup steps (#59310)
diff --git a/plugins/woocommerce/changelog/wooplug-4851-e2e-tests-merge-setup-projects-by-using-steps-instead-of b/plugins/woocommerce/changelog/wooplug-4851-e2e-tests-merge-setup-projects-by-using-steps-instead-of
new file mode 100644
index 0000000000..cfba94d7bb
--- /dev/null
+++ b/plugins/woocommerce/changelog/wooplug-4851-e2e-tests-merge-setup-projects-by-using-steps-instead-of
@@ -0,0 +1,4 @@
+Significance: patch
+Type: dev
+
+E2E tests: merge global setup steps
diff --git a/plugins/woocommerce/tests/e2e-pw/fixtures/auth.setup.js b/plugins/woocommerce/tests/e2e-pw/fixtures/auth.setup.js
index 4f73beb62c..f5a2240b7a 100644
--- a/plugins/woocommerce/tests/e2e-pw/fixtures/auth.setup.js
+++ b/plugins/woocommerce/tests/e2e-pw/fixtures/auth.setup.js
@@ -32,10 +32,11 @@ setup.beforeAll( 'clear existing state', async () => {
} );
} );
-setup( 'authenticate admin', async ( { request } ) => {
- await authenticate( request, admin, ADMIN_STATE_PATH );
-} );
-
-setup( 'authenticate customer', async ( { request } ) => {
- await authenticate( request, customer, CUSTOMER_STATE_PATH );
+setup( 'authenticate users', async ( { request } ) => {
+ await setup.step( 'authenticate admin', async () => {
+ await authenticate( request, admin, ADMIN_STATE_PATH );
+ } );
+ await setup.step( 'authenticate customer', async () => {
+ await authenticate( request, customer, CUSTOMER_STATE_PATH );
+ } );
} );
diff --git a/plugins/woocommerce/tests/e2e-pw/fixtures/site.setup.js b/plugins/woocommerce/tests/e2e-pw/fixtures/site.setup.js
index 9586deddcc..322262827e 100644
--- a/plugins/woocommerce/tests/e2e-pw/fixtures/site.setup.js
+++ b/plugins/woocommerce/tests/e2e-pw/fixtures/site.setup.js
@@ -6,93 +6,95 @@ import { setComingSoon } from '../utils/coming-soon';
import { skipOnboardingWizard } from '../utils/onboarding';
import { WC_API_PATH } from '../utils/api-client';
-setup( 'configure HPOS', async ( { restApi } ) => {
- const { DISABLE_HPOS } = process.env;
- console.log( `DISABLE_HPOS: ${ DISABLE_HPOS }` );
+setup( 'setup site', async ( { baseURL, restApi } ) => {
+ await setup.step( 'configure HPOS', async () => {
+ const { DISABLE_HPOS } = process.env;
+ console.log( `DISABLE_HPOS: ${ DISABLE_HPOS }` );
- if ( DISABLE_HPOS ) {
- const hposSettingRetries = 5;
- const value = DISABLE_HPOS === '1' ? 'no' : 'yes';
- let hposConfigured = false;
+ if ( DISABLE_HPOS ) {
+ const hposSettingRetries = 5;
+ const value = DISABLE_HPOS === '1' ? 'no' : 'yes';
+ let hposConfigured = false;
- for ( let i = 0; i < hposSettingRetries; i++ ) {
- try {
- console.log(
- `Trying to switch ${
- value === 'yes' ? 'on' : 'off'
- } HPOS...`
- );
- const response = await restApi.post(
- `${ WC_API_PATH }/settings/advanced/woocommerce_custom_orders_table_enabled`,
- { value }
- );
- if ( response.data.value === value ) {
+ for ( let i = 0; i < hposSettingRetries; i++ ) {
+ try {
console.log(
- `HPOS Switched ${
+ `Trying to switch ${
value === 'yes' ? 'on' : 'off'
- } successfully`
+ } HPOS...`
+ );
+ const response = await restApi.post(
+ `${ WC_API_PATH }/settings/advanced/woocommerce_custom_orders_table_enabled`,
+ { value }
+ );
+ if ( response.data.value === value ) {
+ console.log(
+ `HPOS Switched ${
+ value === 'yes' ? 'on' : 'off'
+ } successfully`
+ );
+ hposConfigured = true;
+ break;
+ }
+ } catch ( e ) {
+ console.log(
+ `HPOS setup failed. Retrying... ${ i }/${ hposSettingRetries }`
);
- hposConfigured = true;
- break;
+ console.log( e );
}
- } catch ( e ) {
- console.log(
- `HPOS setup failed. Retrying... ${ i }/${ hposSettingRetries }`
- );
- console.log( e );
}
- }
- if ( ! hposConfigured ) {
- console.error(
- 'Cannot proceed e2e test, HPOS configuration failed. Please check if the correct DISABLE_HPOS value was used and the test site has been setup correctly.'
- );
- process.exit( 1 );
+ if ( ! hposConfigured ) {
+ console.error(
+ 'Cannot proceed e2e test, HPOS configuration failed. Please check if the correct DISABLE_HPOS value was used and the test site has been setup correctly.'
+ );
+ process.exit( 1 );
+ }
}
- }
- const response = await restApi.get(
- `${ WC_API_PATH }/settings/advanced/woocommerce_custom_orders_table_enabled`
- );
- const dataValue = response.data.value;
- const enabledOption = response.data.options[ dataValue ];
- console.log(
- `HPOS configuration (woocommerce_custom_orders_table_enabled): ${ dataValue } - ${ enabledOption }`
- );
-} );
+ const response = await restApi.get(
+ `${ WC_API_PATH }/settings/advanced/woocommerce_custom_orders_table_enabled`
+ );
+ const dataValue = response.data.value;
+ const enabledOption = response.data.options[ dataValue ];
+ console.log(
+ `HPOS configuration (woocommerce_custom_orders_table_enabled): ${ dataValue } - ${ enabledOption }`
+ );
+ } );
-setup( 'disable coming soon', async ( { baseURL } ) => {
- await setComingSoon( { baseURL, enabled: 'no' } );
-} );
+ await setup.step( 'disable coming soon', async () => {
+ await setComingSoon( { baseURL, enabled: 'no' } );
+ } );
-setup( 'disable onboarding wizard', async () => {
- await skipOnboardingWizard();
-} );
+ await setup.step( 'disable onboarding wizard', async () => {
+ await skipOnboardingWizard();
+ } );
-setup( 'determine if multisite', async ( { restApi } ) => {
- const response = await restApi.get( `${ WC_API_PATH }/system_status` );
- const { environment } = response.data;
+ await setup.step( 'determine if multisite', async () => {
+ const response = await restApi.get( `${ WC_API_PATH }/system_status` );
+ const { environment } = response.data;
- if ( environment.wp_multisite === false ) {
- delete process.env.IS_MULTISITE;
- } else {
- process.env.IS_MULTISITE = environment.wp_multisite;
- console.log( `IS_MULTISITE: ${ process.env.IS_MULTISITE }` );
- }
-} );
+ if ( environment.wp_multisite === false ) {
+ delete process.env.IS_MULTISITE;
+ } else {
+ process.env.IS_MULTISITE = environment.wp_multisite;
+ console.log( `IS_MULTISITE: ${ process.env.IS_MULTISITE }` );
+ }
+ } );
-setup( 'general settings', async ( { restApi } ) => {
- await restApi.post( `${ WC_API_PATH }/settings/general/batch`, {
- update: [
- { id: 'woocommerce_allowed_countries', value: 'all' },
- { id: 'woocommerce_currency', value: 'USD' },
- { id: 'woocommerce_price_thousand_sep', value: ',' },
- { id: 'woocommerce_price_decimal_sep', value: '.' },
- { id: 'woocommerce_price_num_decimals', value: '2' },
- { id: 'woocommerce_store_address', value: 'addr 1' },
- { id: 'woocommerce_store_city', value: 'San Francisco' },
- { id: 'woocommerce_default_country', value: 'US:CA' },
- { id: 'woocommerce_store_postcode', value: '94107' },
- ],
+ await setup.step( 'general settings', async () => {
+ await restApi.post( `${ WC_API_PATH }/settings/general/batch`, {
+ update: [
+ { id: 'woocommerce_allowed_countries', value: 'all' },
+ { id: 'woocommerce_currency', value: 'USD' },
+ { id: 'woocommerce_price_thousand_sep', value: ',' },
+ { id: 'woocommerce_price_decimal_sep', value: '.' },
+ { id: 'woocommerce_price_num_decimals', value: '2' },
+ { id: 'woocommerce_store_address', value: 'addr 1' },
+ { id: 'woocommerce_store_city', value: 'San Francisco' },
+ { id: 'woocommerce_default_country', value: 'US:CA' },
+ { id: 'woocommerce_store_postcode', value: '94107' },
+ ],
+ } );
} );
} );