Fix store details fails to save store address after navigating back to the tab (#34426)
This commit is contained in:
parent
bec2336c1e
commit
c612d04819
|
@ -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,
|
||||
|
|
|
@ -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(
|
||||
<StoreDetails
|
||||
{ ...{
|
||||
...testProps,
|
||||
initialValues: {
|
||||
...testProps.initialValues,
|
||||
countryState: 'US',
|
||||
},
|
||||
} }
|
||||
updateProfileItems={ updateProfileItems }
|
||||
allowTracking={ true }
|
||||
/>
|
||||
);
|
||||
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(
|
||||
|
|
Loading…
Reference in New Issue