From c2d92379023af50cd563e568dcfa7887888e01f4 Mon Sep 17 00:00:00 2001 From: Chloe Herd Date: Thu, 21 Sep 2023 15:30:59 -0400 Subject: [PATCH] Schedule --- .../schedule/helpers/schedule-helper.js | 5 +- src/layouts/schedule/schedule.spec.js | 64 ++++++++++++++++++- src/layouts/schedule/schedule.vue | 12 ++-- src/store/index.js | 12 +++- 4 files changed, 82 insertions(+), 11 deletions(-) diff --git a/src/layouts/schedule/helpers/schedule-helper.js b/src/layouts/schedule/helpers/schedule-helper.js index 0f595b435..b85572e88 100644 --- a/src/layouts/schedule/helpers/schedule-helper.js +++ b/src/layouts/schedule/helpers/schedule-helper.js @@ -2,11 +2,12 @@ import { storeActions } from "@/constants/store-actions"; import baseMixin from "@/mixins/base-mixin.js"; export async function getAlertReasons(ctu) { - const alertReasons = await baseMixin.methods.dispatchStoreAction( + const alertReasons = await baseMixin.methods.dispatchStoreActionWithLogging( storeActions.GET_ALERT_REASONS_BY_CTU, { ctu: ctu, - } + }, + "schedule" ); return Promise.resolve(alertReasons); diff --git a/src/layouts/schedule/schedule.spec.js b/src/layouts/schedule/schedule.spec.js index 5ce90638c..270da75f0 100644 --- a/src/layouts/schedule/schedule.spec.js +++ b/src/layouts/schedule/schedule.spec.js @@ -70,6 +70,65 @@ jest.mock("@/mixins/base-mixin.js", () => ({ ]); } }), + dispatchStoreActionWithLogging: jest.fn().mockImplementation((storeAction) => { + if (storeAction === "getShopTimeSlots") { + return { + data: { + estimatedServiceMinutesMinimum: 90, + estimatedServiceMinutesMaximum: 120, + days: [ + { + date: "2023-12-01", + timeSlots: [ + { + id: "06747-01820-S-B*20424*7 AM", + startTime: "07:00", + endTime: "08:00", + offerPremium: false, + }, + ], + }, + ], + }, + }; + } + if (storeAction === "getMobilePremiumFee") { + return Promise.resolve({ + data: { + partNumber: "EARLY BIRD", + description: null, + partType: "EARLY BIRD", + laborAmount: 0, + sellingPrice: 14.99, + kitPrice: 0, + }, + }); + } + if (storeAction === "priceOrderItemsAndSaveServerData") { + return Promise.resolve([ + { + partNumber: "EARLY BIRD", + description: null, + partType: "EARLY BIRD", + laborAmount: 0, + sellingPrice: 14.99, + kitPrice: 0, + }, + ]); + } + if (storeAction === "saveSupportingItemsSuppressingStateResetting") { + return Promise.resolve([ + { + partNumber: "EARLY BIRD", + description: null, + partType: "EARLY BIRD", + laborAmount: 0, + sellingPrice: 14.99, + kitPrice: 0, + }, + ]); + } + }), }, })); @@ -226,10 +285,11 @@ describe("schedule.vue...", () => { ); // Assert - expect(baseMixin.methods.dispatchStoreAction).toHaveBeenCalledTimes(3); - expect(baseMixin.methods.dispatchStoreAction).toHaveBeenCalledWith( + expect(baseMixin.methods.dispatchStoreActionWithLogging).toHaveBeenCalledTimes(3); + expect(baseMixin.methods.dispatchStoreActionWithLogging).toHaveBeenCalledWith( "getShopTimeSlots", expect.anything(), + expect.anything(), expect.anything() ); }); diff --git a/src/layouts/schedule/schedule.vue b/src/layouts/schedule/schedule.vue index f276ea1cd..562077d17 100644 --- a/src/layouts/schedule/schedule.vue +++ b/src/layouts/schedule/schedule.vue @@ -168,9 +168,10 @@ const getAvailableDates = async ( const makeParallelCalls = async () => { await Promise.all( storeActionConfigs.map(async (storeAction) => { - const timeSlotsResponse = await baseMixin.methods.dispatchStoreAction( + const timeSlotsResponse = await baseMixin.methods.dispatchStoreActionWithLogging( storeAction.storeAction, storeAction.payload, + "schedule", false ); timeSlotsResponsesData.estimatedServiceMinutesMinimum = @@ -218,17 +219,20 @@ export default { preSelectedDate: preSelectedDate, }); - const premiumFeePromise = baseMixin.methods.dispatchStoreAction( - storeActions.GET_MOBILE_PREMIUM_FEE + const premiumFeePromise = baseMixin.methods.dispatchStoreActionWithLogging( + storeActions.GET_MOBILE_PREMIUM_FEE, + null, + "schedule" ); const premiumFeeWithPricePromise = premiumFeePromise.then((result) => { if (result.data) { - return baseMixin.methods.dispatchStoreAction( + return baseMixin.methods.dispatchStoreActionWithLogging( storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA, { availableLineItems: [result.data], }, + "schedule", false ); } else { diff --git a/src/store/index.js b/src/store/index.js index acdbea86d..b1aa7c790 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -930,11 +930,13 @@ export const actions = { }, // Location API Actions - getAlertReasonsByCtu(context, { ctu }) { + getAlertReasonsByCtu(context, { payload: { ctu }, pageNameToLog }) { return globalMethods.callHttpClient({ method: endpoints.GetAlertReasons.method, endpoint: `${endpoints.GetAlertReasons.url}/${ctu}`, payload: {}, + logApiCall: true, + pageNameToLog: pageNameToLog, }); }, @@ -1412,7 +1414,7 @@ export const actions = { }); }, - getMobileTimeSlots(context, { startDate, endDate }) { + getMobileTimeSlots(context, { payload: { startDate, endDate }, pageNameToLog }) { const order = context.state.order; const vehicle = context.state.order.vehicle; let lineItems = [ @@ -1464,6 +1466,8 @@ export const actions = { method: endpoints.GetMobileTimeSlots.method, endpoint: endpoints.GetMobileTimeSlots.url, payload: payload, + logApiCall: true, + pageNameToLog: pageNameToLog, additionalSuccessEventDataHandler: (response) => getTimeSlotsAdditionalEventData( response.data.provisionalTriggers, @@ -1473,13 +1477,15 @@ export const actions = { }); }, - getMobilePremiumFee(context) { + getMobilePremiumFee(context, { pageNameToLog }) { const damageType = context.getters.damage.isRepair ? "Repair" : "Replace"; const paymentType = context.getters.order.payment.isInsurance ? "Insurance" : "Cash"; return globalMethods.callHttpClient({ method: endpoints.GetMobilePremiumFee.method, endpoint: `${endpoints.GetMobilePremiumFee.url}/${paymentType}/${damageType}`, + logApiCall: true, + pageNameToLog: pageNameToLog, }); },