From 7a8c685cecd9b15ac0e224734b68de6073b154ae Mon Sep 17 00:00:00 2001 From: Michaela Brydon Date: Mon, 4 Mar 2024 13:42:37 -0500 Subject: [PATCH 01/12] Adding comment --- src/store/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/store/index.js b/src/store/index.js index 114b9989..8c32d3e9 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -144,6 +144,7 @@ const getDefaultState = () => ({ lineItems: { glassParts: null, otherParts: null, + // TODO figure out when this needs set and reset, then just reference supportingItems: null, vaps: null }, From 881a79c7eb9e3920400258038d88eda971beffce Mon Sep 17 00:00:00 2001 From: Michaela Brydon Date: Mon, 4 Mar 2024 15:08:51 -0500 Subject: [PATCH 02/12] Cleaning up supportingItems setting --- .../coverage-statement/coverage-statement.vue | 5 +- src/layouts/schedule-page/schedule-page.vue | 43 ++------------ .../service-packages/service-packages.vue | 24 ++++++-- src/layouts/vehicle-damage/vehicle-damage.vue | 3 +- src/store/index.js | 56 +++++++------------ 5 files changed, 49 insertions(+), 82 deletions(-) diff --git a/src/layouts/coverage-statement/coverage-statement.vue b/src/layouts/coverage-statement/coverage-statement.vue index f5ab548d..b9877b44 100644 --- a/src/layouts/coverage-statement/coverage-statement.vue +++ b/src/layouts/coverage-statement/coverage-statement.vue @@ -369,7 +369,7 @@ export default { }, async navigateForward() { if (this.unverified || this.verifiedDeductible) { - this.mainStore.saveSupportingItems(this.supportingItems); + this.mainStore.updateSupportingItems(this.supportingItems); this.$router.navigate( navigationScenarios.CLICKED_FORWARD, this.$route, @@ -379,7 +379,8 @@ export default { } else if (this.verifiedITAC || this.verifiedNoComp) { useMainStore().updateIsSafeliteProvider(this.selectedProvider === 'Safelite'); if (this.selectedProvider === 'Safelite') { - this.mainStore.saveSupportingItems(this.supportingItems); + // TODO maybe don't save supporting items on this page + this.mainStore.updateSupportingItems(this.supportingItems); this.$router.navigate( navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE, this.$route, diff --git a/src/layouts/schedule-page/schedule-page.vue b/src/layouts/schedule-page/schedule-page.vue index 5a3fb0d4..13a8315e 100644 --- a/src/layouts/schedule-page/schedule-page.vue +++ b/src/layouts/schedule-page/schedule-page.vue @@ -268,7 +268,9 @@ export default { return { mainStore }; }, data() { + const { supportingItems } = useMainStore().lineItems; return { + supportingItems, selectedDate: this.getSelectedDate(), selectedTimeSlotInfo: this.getSelectedTimeSlotInfo(), selectableDatesData: [], @@ -324,7 +326,7 @@ export default { && ((serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE || serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE_NOT_ITAC_AND_NOT_NOCOMP) || serviceLocation.provider.providerNumber); - const supportingItems = useMainStore().lineItems.supportingItems !== null; + const supportingItems = this.supportingItems !== null; const damageInfo = useMainStore().order.damage.isRepair || (useMainStore().order.lineItems?.glassParts != null @@ -360,9 +362,8 @@ export default { return this.mainStore.order.schedule.date; }, getSelectedTimeSlotInfo() { - const supportingItems = this.getSupportingItems(); const isPremiumAppointment = - !!supportingItems.filter((lineItem) => lineItem.partType === PREMIUM_FEE_PART_TYPE) + !!this.supportingItems.filter((lineItem) => lineItem.partType === PREMIUM_FEE_PART_TYPE) .length > 0; const selectedTimeSlotInfo = { @@ -372,9 +373,6 @@ export default { return selectedTimeSlotInfo; }, - getSupportingItems() { - return this.mainStore.lineItems.supportingItems; - }, timeSlotModalClosed() { // Clear the selectedDate if no timeSlot has been selected if (this.selectedTimeSlotInfo.timeSlot.routeCode == null) { @@ -424,40 +422,7 @@ export default { } return `${hours}:${minutes} ${meridianNotation}`; }, - updateSupportingItems() { - const supportingItems = this.getSupportingItems(); - - // if we have a premium fee(early bird), then save/update supporting items - if ( - this.appointmentType === AppointmentTypeStrings.MOBILE - && this.selectedTimeSlotInfo?.isPremiumAppointment - ) { - const premiumFeeIndex = supportingItems.findIndex((item) => item.partType === PREMIUM_FEE_PART_TYPE); - - if (premiumFeeIndex >= 0) { - supportingItems[premiumFeeIndex].laborAmount = - this.mobilePremiumAppointmentFee.laborAmount; - supportingItems[premiumFeeIndex].sellingPrice = - this.mobilePremiumAppointmentFee.sellingPrice; - supportingItems[premiumFeeIndex].kitPrice = - this.mobilePremiumAppointmentFee.kitPrice; - } else { - supportingItems.push(this.mobilePremiumAppointmentFee); - } - - this.mainStore.saveSupportingItemsSuppressingStateResetting(supportingItems); - } else { - // if it's not a mobile and/or premium early bird, then make sure we remove any that may have been added - const removePremiumFeeIndex = supportingItems.findIndex((item) => item.partType === PREMIUM_FEE_PART_TYPE); - - if (removePremiumFeeIndex >= 0) { - supportingItems.splice(removePremiumFeeIndex, 1); - this.mainStore.saveSupportingItemsSuppressingStateResetting(supportingItems); - } - } - }, forwardButtonAction() { - this.updateSupportingItems(); this.mainStore.saveSchedule(this.selectedTimeSlotInfo.timeSlot); this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD, this.$route); diff --git a/src/layouts/service-packages/service-packages.vue b/src/layouts/service-packages/service-packages.vue index 8644ad85..8226c8a4 100644 --- a/src/layouts/service-packages/service-packages.vue +++ b/src/layouts/service-packages/service-packages.vue @@ -90,6 +90,7 @@ export default { const wipersPromise = await store.getWipers(); const rainDefensePromise = await store.getRainDefense(); + // TODO does this call need to happen here? const supportingItemsPromise = await store.getSupportingItems(); const promiseResultMap = [ { @@ -124,7 +125,13 @@ export default { let hasBailedOut = false; const pricingResults = await store.getPriceOrderItems(availableLineItems) .catch((err) => { - useMainStore().setBailout(to, bailoutMessage.pricingResponseError(availableLineItems.map((li) => li.partNumber), { code: err.code, message: err.message, data: err.data })); + useMainStore().setBailout( + to, + bailoutMessage.pricingResponseError( + availableLineItems.map((li) => li.partNumber), + { code: err.code, message: err.message, data: err.data } + ) + ); hasBailedOut = true; next(`/?issPage=${issPageValues.BAILOUT_PAGE}`); }); @@ -179,15 +186,22 @@ export default { this.selectedVaps = vapsItemsSelected; }, forwardButtonAction() { - const parts = { glassParts: this.pricedGlassParts, supportingItems: this.supportingItems, vaps: this.selectedVaps }; + const parts = { + glassParts: this.pricedGlassParts, + supportingItems: this.supportingItems, + vaps: this.selectedVaps + }; if (!allGlassPartsAndItemsHavePrices(parts)) { window.console.error('One or more items have no price assigned!'); } if (this.pricedGlassParts.length > 0) { - store.saveGlassParts(this.pricedGlassParts); + // TODO saving glass parts here + store.updateGlassParts(this.pricedGlassParts); } - store.saveSupportingItems(this.supportingItems); - store.saveVaps(this.selectedVaps); + // TODO saving supporting items on service packages page + // TODO does the glass parts array change? + store.updateSupportingItems(this.supportingItems); + store.updateVaps(this.selectedVaps); this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD, this.$route); } diff --git a/src/layouts/vehicle-damage/vehicle-damage.vue b/src/layouts/vehicle-damage/vehicle-damage.vue index dd78afc0..892ec962 100644 --- a/src/layouts/vehicle-damage/vehicle-damage.vue +++ b/src/layouts/vehicle-damage/vehicle-damage.vue @@ -360,8 +360,9 @@ export default { ); if (this.isWindshieldRepair) { + // TODO only save supporting items on vehicle damage page if windshield repair const supportingItems = await useMainStore().getSupportingItems(); - this.mainStore.saveSupportingItems(supportingItems.data); + useMainStore().updateSupportingItems(supportingItems.data); } if (this.mainStore.damage.isRepair) { diff --git a/src/store/index.js b/src/store/index.js index 8c32d3e9..3954b24b 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -947,11 +947,12 @@ export const useMainStore = defineStore({ }); }, + // TODO this needs called when vehicle, damage, or glass parts changes async getSupportingItems() { - const glassPartsArray = this.order.lineItems.glassParts ?? []; - const { carId } = this.order.vehicle; - const { isRepair } = this.order.damage; - const { numberOfChips } = this.order.damage; + const { glassParts } = this.lineItems; + const { carId } = this.vehicle; + const { isRepair, numberOfChips } = this.damage; + const { parentAccountNumber } = this.issConfig; return globalMethods .callHttpClient({ @@ -960,8 +961,8 @@ export const useMainStore = defineStore({ payload: { carId, damageType: isRepair ? 'Repair' : 'Replace', - parentAccountNumber: applicationConfig.CASH_PARENT_ACCOUNT_NUMBER, - parts: glassPartsArray, + parentAccountNumber, + parts: glassParts ?? [], numberOfRepairChips: isRepair ? numberOfChips : 0 } }); @@ -1434,8 +1435,9 @@ export const useMainStore = defineStore({ this.order.payment.insuranceCoverage.isVerified = false; }, + // Note that this is only used in the store updateSupportingItems(partsData) { - this.order.lineItems.supportingItems = partsData; + this.lineItems.supportingItems = partsData; }, updateVaps(partsData) { @@ -1473,8 +1475,8 @@ export const useMainStore = defineStore({ this.order.originalDeductible = vehicle.deductible; this.order.currentDeductible = vehicle.deductible; - this.resetSupportingItemsState(); - this.resetVapsState(); + this.updateSupportingItems(null); + this.updateVaps(null); }, updateVehicleVin(vin) { @@ -1497,6 +1499,7 @@ export const useMainStore = defineStore({ resetGlassPartsState() { this.order.lineItems.glassParts = null; + this.order.lineItems.supportingItems = null; this.order.damage.partQuestionAnswers = null; this.order.damage.moldingQuestionAnswers = null; this.order.damage.capabilityQuestionAnswers = null; @@ -1505,6 +1508,7 @@ export const useMainStore = defineStore({ this.applicationUser.pageData[issPageValues.MOLDING_QUESTIONS] = null; this.applicationUser.pageData[issPageValues.CAPABILITY_QUESTIONS] = null; }, + // TODO when schedule reset, supporting items modified resetSchedule() { this.order.schedule.date = null; this.order.schedule.startTime = null; @@ -1522,12 +1526,6 @@ export const useMainStore = defineStore({ state.order.lineItems.supportingItems = supportingItems; } }, - resetSupportingItemsState() { - this.order.lineItems.supportingItems = null; - }, - resetVapsState() { - this.order.lineItems.vaps = null; - }, resetDamageState() { this.order.damage.isRepair = null; this.order.damage.numberOfChips = null; @@ -1686,8 +1684,8 @@ export const useMainStore = defineStore({ this.updateGlassParts(null); this.updateMoldingQuestionAnswers(null); this.updateCapabilityQuestionAnswers(null); - this.resetSupportingItemsState(); - this.resetVapsState(); + this.updateSupportingItems(null); + this.updateVaps(null); this.updatePageData({ page: issPageValues.VEHICLE_PARTS, data: null }); this.updatePageData({ page: issPageValues.MOLDING_QUESTIONS, data: null }); @@ -1731,18 +1729,6 @@ export const useMainStore = defineStore({ // Save new values this.updateCapabilityQuestionAnswers(capabilityQuestionAnswersArray); }, - saveGlassParts(glassParts) { - this.order.lineItems.glassParts = glassParts; - }, - saveSupportingItems(supportingItems) { - this.order.lineItems.supportingItems = supportingItems; - }, - saveSupportingItemsSuppressingStateResetting(supportingItems) { - this.order.lineItems.supportingItems = supportingItems; - }, - saveVaps(vaps) { - this.order.lineItems.vaps = vaps; - }, // Price order actions async priceOrderItemsAndSaveServerData(availableLineItems, serviceZipCode, serviceZipCodeCtu) { @@ -2044,6 +2030,7 @@ export const useMainStore = defineStore({ if (!isSelectedGlassAvailableForVehicle) { this.resetDamageState(); this.resetGlassPartsState(); + // TODO probably reset supporting items } // Save new values @@ -2062,6 +2049,7 @@ export const useMainStore = defineStore({ if (!isSelectedGlassAvailableForVehicle) { this.resetDamageState(); this.resetGlassPartsState(); + // TODO probably reset supporting items } // Save new values @@ -2078,6 +2066,7 @@ export const useMainStore = defineStore({ // Dependencies already cleared in above statement this.resetDamageState(); this.resetGlassPartsState(); + // TODO reset supporting items state } // Save new values @@ -2111,21 +2100,18 @@ export const useMainStore = defineStore({ resetRegistrationAndDependencies() { this.resetRegistrationState(); this.resetGlassPartsState(); - this.resetSupportingItemsState(); - this.resetVapsState(); + this.updateVaps(null); }, resetDamageAndDependencies() { this.resetDamageState(); this.resetGlassPartsState(); - this.resetSupportingItemsState(); - this.resetVapsState(); + this.updateVaps(null); }, resetPartsAndDependencies() { this.resetGlassPartsState(); - this.resetSupportingItemsState(); - this.resetVapsState(); + this.updateVaps(null); this.resetServiceLocationAndDependencies(); }, From c8b491cbbd3eb808e448aea9fa28dae4c9ae31f7 Mon Sep 17 00:00:00 2001 From: Michaela Brydon Date: Mon, 4 Mar 2024 15:10:23 -0500 Subject: [PATCH 03/12] Removing comment --- src/layouts/coverage-statement/coverage-statement.vue | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/layouts/coverage-statement/coverage-statement.vue b/src/layouts/coverage-statement/coverage-statement.vue index b9877b44..7338f1ad 100644 --- a/src/layouts/coverage-statement/coverage-statement.vue +++ b/src/layouts/coverage-statement/coverage-statement.vue @@ -369,7 +369,7 @@ export default { }, async navigateForward() { if (this.unverified || this.verifiedDeductible) { - this.mainStore.updateSupportingItems(this.supportingItems); + useMainStore().updateSupportingItems(this.supportingItems); this.$router.navigate( navigationScenarios.CLICKED_FORWARD, this.$route, @@ -379,8 +379,7 @@ export default { } else if (this.verifiedITAC || this.verifiedNoComp) { useMainStore().updateIsSafeliteProvider(this.selectedProvider === 'Safelite'); if (this.selectedProvider === 'Safelite') { - // TODO maybe don't save supporting items on this page - this.mainStore.updateSupportingItems(this.supportingItems); + useMainStore().updateSupportingItems(this.supportingItems); this.$router.navigate( navigationScenarios.CLICKED_FORWARD_WITH_SAFELITE, this.$route, From de406b6fbbb688fc5a3ad4372199b6f15a5d702d Mon Sep 17 00:00:00 2001 From: Michaela Brydon Date: Mon, 4 Mar 2024 15:12:22 -0500 Subject: [PATCH 04/12] Removing comment --- src/layouts/service-packages/service-packages.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/layouts/service-packages/service-packages.vue b/src/layouts/service-packages/service-packages.vue index 8226c8a4..52fc9ba1 100644 --- a/src/layouts/service-packages/service-packages.vue +++ b/src/layouts/service-packages/service-packages.vue @@ -90,7 +90,6 @@ export default { const wipersPromise = await store.getWipers(); const rainDefensePromise = await store.getRainDefense(); - // TODO does this call need to happen here? const supportingItemsPromise = await store.getSupportingItems(); const promiseResultMap = [ { From e359126d3dd02f536eace2b355262300d48f6c74 Mon Sep 17 00:00:00 2001 From: Michaela Brydon Date: Mon, 4 Mar 2024 15:14:17 -0500 Subject: [PATCH 05/12] Removing comment --- src/layouts/service-packages/service-packages.vue | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/layouts/service-packages/service-packages.vue b/src/layouts/service-packages/service-packages.vue index 52fc9ba1..ea1cb229 100644 --- a/src/layouts/service-packages/service-packages.vue +++ b/src/layouts/service-packages/service-packages.vue @@ -194,11 +194,8 @@ export default { window.console.error('One or more items have no price assigned!'); } if (this.pricedGlassParts.length > 0) { - // TODO saving glass parts here store.updateGlassParts(this.pricedGlassParts); } - // TODO saving supporting items on service packages page - // TODO does the glass parts array change? store.updateSupportingItems(this.supportingItems); store.updateVaps(this.selectedVaps); From 63872cd9000c187ef1b67c71ac081f293c2d88ec Mon Sep 17 00:00:00 2001 From: Michaela Brydon Date: Mon, 4 Mar 2024 15:15:15 -0500 Subject: [PATCH 06/12] Removing comment --- src/layouts/vehicle-damage/vehicle-damage.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/src/layouts/vehicle-damage/vehicle-damage.vue b/src/layouts/vehicle-damage/vehicle-damage.vue index 892ec962..2771b30e 100644 --- a/src/layouts/vehicle-damage/vehicle-damage.vue +++ b/src/layouts/vehicle-damage/vehicle-damage.vue @@ -360,7 +360,6 @@ export default { ); if (this.isWindshieldRepair) { - // TODO only save supporting items on vehicle damage page if windshield repair const supportingItems = await useMainStore().getSupportingItems(); useMainStore().updateSupportingItems(supportingItems.data); } From 3a75fe9658a7537fd3b1c5dddd6f21a61e7cb74d Mon Sep 17 00:00:00 2001 From: Michaela Brydon Date: Mon, 4 Mar 2024 15:16:07 -0500 Subject: [PATCH 07/12] Removing comment --- src/store/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/store/index.js b/src/store/index.js index 3954b24b..be6c7343 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -144,7 +144,6 @@ const getDefaultState = () => ({ lineItems: { glassParts: null, otherParts: null, - // TODO figure out when this needs set and reset, then just reference supportingItems: null, vaps: null }, From 60012cb033681ab4f410115f19211af9eccb4392 Mon Sep 17 00:00:00 2001 From: Michaela Brydon Date: Mon, 4 Mar 2024 15:16:45 -0500 Subject: [PATCH 08/12] Removing comment --- src/store/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/store/index.js b/src/store/index.js index be6c7343..49027c3c 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -946,7 +946,6 @@ export const useMainStore = defineStore({ }); }, - // TODO this needs called when vehicle, damage, or glass parts changes async getSupportingItems() { const { glassParts } = this.lineItems; const { carId } = this.vehicle; From c7ffb35e4c672ea7bfac62ae6a07ab6b2f687164 Mon Sep 17 00:00:00 2001 From: Michaela Brydon Date: Mon, 4 Mar 2024 15:17:24 -0500 Subject: [PATCH 09/12] Removing comment --- src/store/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index 49027c3c..098b7f84 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1433,9 +1433,8 @@ export const useMainStore = defineStore({ this.order.payment.insuranceCoverage.isVerified = false; }, - // Note that this is only used in the store updateSupportingItems(partsData) { - this.lineItems.supportingItems = partsData; + this.order.lineItems.supportingItems = partsData; }, updateVaps(partsData) { From e5709444f9c5745b03334dac9c20371141b67fd9 Mon Sep 17 00:00:00 2001 From: Michaela Brydon Date: Mon, 4 Mar 2024 15:19:36 -0500 Subject: [PATCH 10/12] Removing comment --- src/store/index.js | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index 098b7f84..3aad08dc 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1505,7 +1505,6 @@ export const useMainStore = defineStore({ this.applicationUser.pageData[issPageValues.MOLDING_QUESTIONS] = null; this.applicationUser.pageData[issPageValues.CAPABILITY_QUESTIONS] = null; }, - // TODO when schedule reset, supporting items modified resetSchedule() { this.order.schedule.date = null; this.order.schedule.startTime = null; @@ -1513,15 +1512,6 @@ export const useMainStore = defineStore({ this.order.schedule.routeCode = null; this.order.schedule.jobMaxMinutes = null; this.order.schedule.jobMinMinutes = null; - - // premium appointment fee used on schedule page also needs reset when schedule is reset - const { supportingItems } = this.order.lineItems; - const premiumAppointmentFeeIndex = supportingItems?.findIndex((item) => item.partType === PREMIUM_FEE_PART_TYPE); - - if (premiumAppointmentFeeIndex >= 0) { - supportingItems.splice(premiumAppointmentFeeIndex, 1); - state.order.lineItems.supportingItems = supportingItems; - } }, resetDamageState() { this.order.damage.isRepair = null; @@ -2027,7 +2017,6 @@ export const useMainStore = defineStore({ if (!isSelectedGlassAvailableForVehicle) { this.resetDamageState(); this.resetGlassPartsState(); - // TODO probably reset supporting items } // Save new values @@ -2046,7 +2035,6 @@ export const useMainStore = defineStore({ if (!isSelectedGlassAvailableForVehicle) { this.resetDamageState(); this.resetGlassPartsState(); - // TODO probably reset supporting items } // Save new values From 21d811c815343761f10cba1405ba59d32aa03c92 Mon Sep 17 00:00:00 2001 From: Michaela Brydon Date: Mon, 4 Mar 2024 15:20:12 -0500 Subject: [PATCH 11/12] Removing comment --- src/store/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/store/index.js b/src/store/index.js index 3aad08dc..3ba028ec 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -2051,7 +2051,6 @@ export const useMainStore = defineStore({ // Dependencies already cleared in above statement this.resetDamageState(); this.resetGlassPartsState(); - // TODO reset supporting items state } // Save new values From 24103335eec282fad8ded09087cf8502b0150ad6 Mon Sep 17 00:00:00 2001 From: Michaela Brydon Date: Mon, 4 Mar 2024 15:46:31 -0500 Subject: [PATCH 12/12] Fixing tests --- .../schedule-page/schedule-page.spec.js | 79 ------------------- src/layouts/schedule-page/schedule-page.vue | 7 +- 2 files changed, 4 insertions(+), 82 deletions(-) diff --git a/src/layouts/schedule-page/schedule-page.spec.js b/src/layouts/schedule-page/schedule-page.spec.js index bc0d80df..c025ece6 100644 --- a/src/layouts/schedule-page/schedule-page.spec.js +++ b/src/layouts/schedule-page/schedule-page.spec.js @@ -75,8 +75,6 @@ function getShallowMountedComponent(initialData = {}, methodToRun = () => {}) { } }); - // mountOptions.global.mocks["$store"] = store; - mountOptions.global.stubs = { siteFooter: footerStub, loadingModal: loadingModalStub @@ -337,81 +335,4 @@ describe('schedule-page.vue', () => { // Assert expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); }); - test('for mobile appts, updateSupportingItems should call store action to save supporting items', async () => { - // Arrange - const { wrapper } = getShallowMountedComponent(); - wrapper.vm.mainStore.order.serviceLocation.appointmentType = AppointmentTypeStrings.MOBILE; - wrapper.vm.mobilePremiumAppointmentFee = 14.99; - wrapper.vm.selectedTimeSlotInfo.isPremiumAppointment = true; - wrapper.vm.mainStore.lineItems.supportingItems = [ - { - partNumber: 'EARLY BIRD', - description: null, - partType: 'EARLY BIRD', - laborAmount: 0, - sellingPrice: 0, - kitPrice: 0 - } - ]; - const store = useMainStore(); - - // Act - await wrapper.vm.updateSupportingItems(); - - // Assert - expect(store.saveSupportingItemsSuppressingStateResetting).toHaveBeenCalledTimes(1); - expect(wrapper.vm.mainStore.lineItems.supportingItems) - .toEqual(expect.arrayContaining([ - expect.objectContaining({ - partType: 'EARLY BIRD' - }) - ])); - }); - test( - 'for Inshop appts, updateSupportingItems should call store action to save supporting items WITHOUT the EARLY BIRD supporting item', - async () => { - // Arrange - const { wrapper } = getShallowMountedComponent(); - wrapper.vm.mainStore.order.serviceLocation.appointmentType = AppointmentTypeStrings.IN_SHOP; - wrapper.vm.mobilePremiumAppointmentFee = 14.99; - wrapper.vm.selectedTimeSlotInfo.isPremiumAppointment = true; - wrapper.vm.mainStore.lineItems.supportingItems = [ - { - partNumber: 'EARLY BIRD', - description: null, - partType: 'EARLY BIRD', - laborAmount: 0, - sellingPrice: 0, - kitPrice: 0 - } - ]; - const store = useMainStore(); - - // Act - await wrapper.vm.updateSupportingItems(); - - // Assert - expect(store.saveSupportingItemsSuppressingStateResetting).toHaveBeenCalledTimes(1); - expect(wrapper.vm.mainStore.lineItems.supportingItems) - .not.toEqual(expect.arrayContaining([ - expect.objectContaining({ - partType: 'EARLY BIRD' - }) - ])); - } - ); - test('if no EARLY BIRD supporting item, then updateSupportingItems should NOT call store action', async () => { - // Arrange - const { wrapper } = getShallowMountedComponent(); - wrapper.vm.mainStore.order.serviceLocation.appointmentType = AppointmentTypeStrings.MOBILE; - wrapper.vm.mobilePremiumAppointmentFee = 14.99; - wrapper.vm.selectedTimeSlotInfo.isPremiumAppointment = false; - wrapper.vm.mainStore.lineItems.supportingItems = []; - const store = useMainStore(); - // Act - await wrapper.vm.updateSupportingItems(); - - // Assert - expect(store.saveSupportingItemsSuppressingStateResetting).toHaveBeenCalledTimes(0); - }); }); diff --git a/src/layouts/schedule-page/schedule-page.vue b/src/layouts/schedule-page/schedule-page.vue index 13a8315e..4636b834 100644 --- a/src/layouts/schedule-page/schedule-page.vue +++ b/src/layouts/schedule-page/schedule-page.vue @@ -268,9 +268,7 @@ export default { return { mainStore }; }, data() { - const { supportingItems } = useMainStore().lineItems; return { - supportingItems, selectedDate: this.getSelectedDate(), selectedTimeSlotInfo: this.getSelectedTimeSlotInfo(), selectableDatesData: [], @@ -293,6 +291,9 @@ export default { } return this.selectableDatesData.days?.find((selectableDate) => selectableDate.date === this.selectedDate); + }, + supportingItems() { + return useMainStore().lineItems.supportingItems; } }, watch: { @@ -363,7 +364,7 @@ export default { }, getSelectedTimeSlotInfo() { const isPremiumAppointment = - !!this.supportingItems.filter((lineItem) => lineItem.partType === PREMIUM_FEE_PART_TYPE) + !!(this.supportingItems?.filter((lineItem) => lineItem.partType === PREMIUM_FEE_PART_TYPE) ?? []) .length > 0; const selectedTimeSlotInfo = {