diff --git a/plugins/woocommerce/changelog/e2e-make-tests-independant-from-previous-tests b/plugins/woocommerce/changelog/e2e-make-tests-independant-from-previous-tests new file mode 100644 index 00000000000..c56e0819f52 --- /dev/null +++ b/plugins/woocommerce/changelog/e2e-make-tests-independant-from-previous-tests @@ -0,0 +1,4 @@ +Significance: patch +Type: dev + +Ensure `can discard industry changes when navigating back to "Store Details"'` can run independent from previous tests diff --git a/plugins/woocommerce/tests/e2e-pw/tests/activate-and-setup/complete-onboarding-wizard.spec.js b/plugins/woocommerce/tests/e2e-pw/tests/activate-and-setup/complete-onboarding-wizard.spec.js index 1061fb7e1f9..5dccaaef9eb 100644 --- a/plugins/woocommerce/tests/e2e-pw/tests/activate-and-setup/complete-onboarding-wizard.spec.js +++ b/plugins/woocommerce/tests/e2e-pw/tests/activate-and-setup/complete-onboarding-wizard.spec.js @@ -65,6 +65,29 @@ testRunner( 'Store owner can complete onboarding wizard', () => { test( 'can discard industry changes when navigating back to "Store Details"', async ( { page, } ) => { + + // set up pre-condition to ensure Industries stored in + // storeDetails.us.industries2 have been set + await onboarding.completeIndustrySection( + page, + storeDetails.us.industries2, + storeDetails.us.expectedNumberOfIndustries + ); + + // Navigate to "Store Details" section to show Save Changes modal prompt + await page.locator( 'button >> text=Store Details' ).click(); + + // handle save changes modal if displayed + const saveChangesModalVisible = await page + .locator( '.components-modal__header-heading' ) + .isVisible(); + if ( saveChangesModalVisible ) { + // Save the changes to ensure the test is now in the correct state + // independent of the previous test results + await onboarding.handleSaveChangesModal( page, { saveChanges: true } ); + } + + // test proper begins await onboarding.completeIndustrySection( page, storeDetails.us.industries,