From 1f8b7d940d0b0eb30313f83d561204f48b7afbcf Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Wed, 21 Jun 2023 10:23:41 -0400 Subject: [PATCH 1/3] Tech review changes --- src/store/index.js | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index 7ad5c4457..4d959170b 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -341,14 +341,14 @@ export const mutations = { state.order.schedule.routeCode = null; state.order.schedule.jobMaxMinutes = null; - //early bird fee used on schedule page also needs reset when schedule is reset + //premium appointment fee used on schedule page also needs reset when schedule is reset const supportingItems = state.order.lineItems.supportingItems; - const removeEarlyBirdIndex = supportingItems?.findIndex( + const premiumAppointmentFeeIndex = supportingItems?.findIndex( (item) => item.partType == PREMIUM_FEE_PART_TYPE ); - if (removeEarlyBirdIndex >= 0) { - supportingItems.splice(removeEarlyBirdIndex, 1); + if (premiumAppointmentFeeIndex >= 0) { + supportingItems.splice(premiumAppointmentFeeIndex, 1); state.order.lineItems.supportingItems = supportingItems; } }, @@ -369,7 +369,6 @@ export const mutations = { state.order.serviceLocation.address2 = null; state.order.serviceLocation.city = null; state.order.serviceLocation.state = null; - state.order.serviceLocation.zipCode = null; state.order.serviceLocation.isVehicleProtected = null; }, // Misc Mutations @@ -712,15 +711,16 @@ export const actions = { // Dependency Actions resetDamageAndDependencies(context) { context.commit(storeMutations.RESET_DAMAGE_STATE); - context.commit(storeMutations.RESET_GLASS_PARTS_STATE); - context.commit(storeMutations.UPDATE_SUPPORTING_ITEMS, null); + + context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); + context.commit(storeMutations.UPDATE_VAPS, null); }, resetRegistrationAndDependencies(context) { context.commit(storeMutations.RESET_REGISTRATION_STATE); - context.commit(storeMutations.RESET_GLASS_PARTS_STATE); - context.commit(storeMutations.UPDATE_SUPPORTING_ITEMS, null); + + context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); }, resetPartsAndDependencies(context) { @@ -1606,7 +1606,6 @@ export const actions = { if (!isSelectedGlassAvailableForVehicle) { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); - context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); } //Save new values @@ -1632,7 +1631,6 @@ export const actions = { if (!isSelectedGlassAvailableForVehicle) { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); - context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); } //Save new values @@ -1658,6 +1656,8 @@ export const actions = { ); if (havePartQuestionAnswersChanged) { + context.dispatch(storeActions.RESET_SERVICE_LOCATION_STATE_AND_DEPENDENCIES); + context.commit(storeMutations.UPDATE_GLASS_PARTS, null); context.commit(storeMutations.UPDATE_SUPPORTING_ITEMS, null); context.commit(storeMutations.UPDATE_MOLDING_QUESTION_ANSWERS, null); @@ -1705,6 +1705,8 @@ export const actions = { previouslySelectedPartNumbers !== currentlySelectedPartNumbers; if (haveSelectedVehiclePartsChanged) { + context.dispatch(storeActions.RESET_SERVICE_LOCATION_STATE_AND_DEPENDENCIES); + context.commit(storeMutations.UPDATE_GLASS_PARTS, null); context.commit(storeMutations.UPDATE_SUPPORTING_ITEMS, null); context.commit(storeMutations.UPDATE_MOLDING_QUESTION_ANSWERS, null); @@ -1736,6 +1738,8 @@ export const actions = { ); if (haveMoldingQuestionAnswersChanged) { + context.dispatch(storeActions.RESET_SERVICE_LOCATION_STATE_AND_DEPENDENCIES); + context.commit(storeMutations.UPDATE_GLASS_PARTS, null); context.commit(storeMutations.UPDATE_SUPPORTING_ITEMS, null); context.commit(storeMutations.UPDATE_CAPABILITY_QUESTION_ANSWERS, null); @@ -1765,6 +1769,8 @@ export const actions = { ); if (haveCapabilityQuestionAnswersChanged) { + context.dispatch(storeActions.RESET_SERVICE_LOCATION_STATE_AND_DEPENDENCIES); + context.commit(storeMutations.UPDATE_GLASS_PARTS, null); context.commit(storeMutations.UPDATE_SUPPORTING_ITEMS, null); } @@ -1897,7 +1903,6 @@ export const actions = { if (vehicleInfo.vin !== context.state.order.vehicle.vin) { if (!isSelectedGlassAvailableForVehicle) { context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES); - context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); } //Save new values From 99ae8bcb106be84a24ae545e2eb9010fad415c20 Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Wed, 21 Jun 2023 10:31:17 -0400 Subject: [PATCH 2/3] Update unit tests. --- src/store/store.spec.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/store/store.spec.js b/src/store/store.spec.js index 847701e67..9d9cdfcf4 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -547,28 +547,32 @@ describe("Actions", () => { // Arrange const context = state; const commit = jest.fn(); + const dispatch = jest.fn(); context.commit = commit; + context.dispatch = dispatch; // Act await actions.resetDamageAndDependencies(context); expect(commit).toBeCalledWith(storeMutations.RESET_DAMAGE_STATE); - expect(commit).toBeCalledWith(storeMutations.RESET_GLASS_PARTS_STATE); + expect(dispatch).toBeCalledWith(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); }); it("resetRegistrationAndDependencies action", async () => { // Arrange const context = state; const commit = jest.fn(); + const dispatch = jest.fn(); context.commit = commit; + context.dispatch = dispatch; // Act await actions.resetRegistrationAndDependencies(context); expect(commit).toBeCalledWith(storeMutations.RESET_REGISTRATION_STATE); - expect(commit).toBeCalledWith(storeMutations.RESET_GLASS_PARTS_STATE); + expect(dispatch).toBeCalledWith(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); }); it("resetPartsAndDependencies action", async () => { From 89ba15c5384f4a2cb675491e536d3c7a0903dd95 Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Wed, 21 Jun 2023 10:35:58 -0400 Subject: [PATCH 3/3] Formatting. --- src/store/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index 4d959170b..4b3272eac 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -711,7 +711,7 @@ export const actions = { // Dependency Actions resetDamageAndDependencies(context) { context.commit(storeMutations.RESET_DAMAGE_STATE); - + context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); context.commit(storeMutations.UPDATE_VAPS, null); @@ -719,7 +719,7 @@ export const actions = { resetRegistrationAndDependencies(context) { context.commit(storeMutations.RESET_REGISTRATION_STATE); - + context.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES); },