diff --git a/plugins/woocommerce-admin/client/profile-wizard/steps/store-details/index.js b/plugins/woocommerce-admin/client/profile-wizard/steps/store-details/index.js index ac539026fdd..899249b948c 100644 --- a/plugins/woocommerce-admin/client/profile-wizard/steps/store-details/index.js +++ b/plugins/woocommerce-admin/client/profile-wizard/steps/store-details/index.js @@ -109,9 +109,9 @@ export class StoreDetails extends Component { ); } - onSubmit() { + onSubmit( values ) { if ( this.props.allowTracking ) { - this.props.goToNextStep(); + this.onContinue( values ).then( () => this.props.goToNextStep() ); } else { this.setState( { showUsageModal: true, diff --git a/plugins/woocommerce-admin/client/profile-wizard/steps/store-details/test/index.js b/plugins/woocommerce-admin/client/profile-wizard/steps/store-details/test/index.js index dbb9dafa027..33f8257a455 100644 --- a/plugins/woocommerce-admin/client/profile-wizard/steps/store-details/test/index.js +++ b/plugins/woocommerce-admin/client/profile-wizard/steps/store-details/test/index.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { render } from '@testing-library/react'; +import { render, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; /** @@ -30,6 +30,13 @@ const testProps = { }, getLocale: jest.fn(), isLoading: false, + createNotice: jest.fn(), + profileItems: {}, + updateAndPersistSettingsForGroup: jest.fn(), + goToNextStep: jest.fn(), + errorsRef: { + current: {}, + }, }; jest.mock( '@wordpress/data', () => { @@ -84,6 +91,28 @@ describe( 'StoreDetails', () => { ).not.toBeDisabled(); } ); + test( 'should call updateProfileItems when continue button is clicked given the allowTracking is true', async () => { + const updateProfileItems = jest.fn(); + const { getByText } = render( + + ); + const continueButton = getByText( 'Continue' ); + userEvent.click( continueButton ); + await waitFor( () => { + expect( updateProfileItems ).toHaveBeenCalled(); + } ); + } ); + describe( 'Email validation test cases', () => { test( 'should fail email validation and disable continue button when isAgreeMarketing is true and email is empty', async () => { const container = render(