Make e2e test `can discard industry changes when navigating back to "Store Details"` independent from previous tests (#38715)

* e2e test update

* handle modal on test

* Update deprecated method

---------

Co-authored-by: Rodel Calasagsag <rodel.calasagsag@automattic.com>
This commit is contained in:
nigeljamesstevenson 2023-06-26 07:13:02 +01:00 committed by GitHub
parent b91c37fe32
commit 3b075731a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 0 deletions

View File

@ -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

View File

@ -65,6 +65,29 @@ testRunner( 'Store owner can complete onboarding wizard', () => {
test( 'can discard industry changes when navigating back to "Store Details"', async ( { test( 'can discard industry changes when navigating back to "Store Details"', async ( {
page, 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( await onboarding.completeIndustrySection(
page, page,
storeDetails.us.industries, storeDetails.us.industries,