diff --git a/src/store/index.js b/src/store/index.js index fe05a4a53..41ca166c1 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1620,6 +1620,10 @@ export const actions = { }, saveVehicle(context, { year, make, model, style }) { + context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); + context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES); + context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); + if (context.state.order.vehicle.year !== year) { context.commit(storeMutations.UPDATE_YEAR, year); } diff --git a/src/store/store.spec.js b/src/store/store.spec.js index 1081d383c..08aa406c9 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -1718,8 +1718,10 @@ describe("Actions", () => { }; const commit = jest.fn(); + const dispatch = jest.fn(); context.commit = commit; + context.dispatch = dispatch; //Act const payload = { @@ -1731,6 +1733,14 @@ describe("Actions", () => { actions.saveVehicle(context, payload); //Assert + expect(dispatch).toHaveBeenNthCalledWith( + 1, + storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES + ); + expect(dispatch).toHaveBeenNthCalledWith( + 2, + storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES + ); if (context.state.order.vehicle.year !== payload.year) { expect(commit).toBeCalledWith(storeMutations.UPDATE_YEAR, payload.year); }