CASH-1712: remove old obsolete files that never should've been committed
This commit is contained in:
parent
c32494309c
commit
cf0816dca3
2 changed files with 0 additions and 1398 deletions
|
|
@ -1,782 +0,0 @@
|
||||||
<!-- OLD SCHEDULE BEGINS -->
|
|
||||||
|
|
||||||
<!-- TODO: REMOVE THIS FILE ONCE CASH-803 (SERVICE-LOCATION AND SCHEDULE PAGE COMBINATION) HAS BEEN VETTED -->
|
|
||||||
|
|
||||||
<template>
|
|
||||||
<Form @submit="onSubmit" @invalid-submit="onInvalidSubmit" ref="theForm" v-slot="{ meta }">
|
|
||||||
<loadingModal ref="loadingModal" />
|
|
||||||
<div class="container-fluid page-container-grouped-styles page-schedule">
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-md-6">
|
|
||||||
<funnelHeader cmsWidgetName="FunnelHeaderWidget" ref="funnelHeader" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row justify-content-center">
|
|
||||||
<div class="col-md-6 col-xl-4">
|
|
||||||
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" class="mt-4" />
|
|
||||||
<template v-if="ChangeShopLink.length">
|
|
||||||
<textBlock
|
|
||||||
cmsWidgetName="ChangeShopLink"
|
|
||||||
justifyText="center"
|
|
||||||
class="mb-5 text-link-small change-location"
|
|
||||||
marginTopSizeOverride="1" />
|
|
||||||
</template>
|
|
||||||
<locationAlerts cmsWidgetPrefix="LocationAlert-" ref="locationAlerts" />
|
|
||||||
<datePicker
|
|
||||||
customComponentId="dateQuestion"
|
|
||||||
selectableDatesSetting="custom"
|
|
||||||
ref="datePicker"
|
|
||||||
v-model="selectedDate"
|
|
||||||
class="text-link-small"
|
|
||||||
:customSelectableDatesCallback="getAvailableDatesMethod"
|
|
||||||
validationRules="date-required"
|
|
||||||
@date-clicked="handleDateClicked"
|
|
||||||
:pricingByDayBasePrice="pricingByDayBasePrice"
|
|
||||||
:pricingByDayUpcharge="pricingByDayUpcharge"
|
|
||||||
:showPricingByDay="showPricingByDay"
|
|
||||||
:isPricingByDayExperiment="isPricingByDayExperiment"
|
|
||||||
:timeSlotsForSelectedDate="timeSlotsForSelectedDate"
|
|
||||||
:appointmentType="appointmentType"
|
|
||||||
:premiumAppointmentFee="mobilePremiumAppointmentFee"
|
|
||||||
:estimatedServiceMinutesMinimum="
|
|
||||||
selectableDatesData.estimatedServiceMinutesMinimum
|
|
||||||
"
|
|
||||||
:estimatedServiceMinutesMaximum="
|
|
||||||
selectableDatesData.estimatedServiceMinutesMaximum
|
|
||||||
"
|
|
||||||
@TimeSlotSelected="updateTimeSlot"
|
|
||||||
:displayWaitList="displayWaitList"
|
|
||||||
@waitListRequested="handleWaitListRequested" />
|
|
||||||
<navbar
|
|
||||||
cmsWidgetName="FunnelFooterWidget"
|
|
||||||
ref="navbar"
|
|
||||||
:isForwardActionDisabled="!meta.valid"
|
|
||||||
@back-clicked="backButtonAction"
|
|
||||||
@ForwardClicked="forwardButtonAction" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Form>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
// Components
|
|
||||||
import funnelHeader from "@/fmg-components/funnel-header/funnel-header";
|
|
||||||
import navbar from "@/fmg-components/nav-bar/nav-bar";
|
|
||||||
import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header";
|
|
||||||
import loadingModal from "@/fmg-components/loading-modal/loading-modal.vue";
|
|
||||||
import { Form, defineRule } from "vee-validate";
|
|
||||||
import datePicker from "@/digital-components/date-picker/date-picker";
|
|
||||||
import locationAlerts from "@/layouts/schedule/location-alerts/location-alerts";
|
|
||||||
import textBlock from "@/digital-components/text-block/text-block";
|
|
||||||
|
|
||||||
// Supporting files
|
|
||||||
import { queryStrings } from "@/constants/query-strings";
|
|
||||||
import { getQuerystringParameter } from "@/helpers/querystring-helper";
|
|
||||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
|
||||||
import baseMixin from "@/mixins/base-mixin.js";
|
|
||||||
import { storeActions } from "@/constants/store-actions";
|
|
||||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
|
||||||
import { splitCopyOnCMSPlaceHolder } from "@/helpers/cms-content-helper";
|
|
||||||
import {
|
|
||||||
calcDaysBetweenDates,
|
|
||||||
convertDateStringToDate,
|
|
||||||
sumDateString,
|
|
||||||
} from "@/layouts/schedule/helpers/schedule-helper";
|
|
||||||
import {
|
|
||||||
AppointmentTypeStrings,
|
|
||||||
PREMIUM_FEE_PART_TYPE,
|
|
||||||
PRICING_BY_DAY_PART_TYPE,
|
|
||||||
} from "@/constants/schedule-constants";
|
|
||||||
import { DAYS_OF_WEEK } from "@/digital-components/date-picker/mixins/constants";
|
|
||||||
import { errorMessages } from "@/constants/error-messages";
|
|
||||||
import { required } from "@/helpers/validation-rules";
|
|
||||||
import store from "@/store";
|
|
||||||
import experimentMixin from "@/mixins/experiment-mixin.js";
|
|
||||||
import { experimentSettings } from "@/constants/experiments";
|
|
||||||
import { getAmountDue, getPricingByDayPartWithPrice } from "@/helpers/pricing-helper.js";
|
|
||||||
import { getItemsWithoutRecalParts } from "@/helpers/recal-helper";
|
|
||||||
import { partNumberStrings } from "@/constants/part-number-strings";
|
|
||||||
import { deepClone } from "@/helpers/object-helper";
|
|
||||||
import { debugLog } from "@/helpers/debug-log-helper";
|
|
||||||
|
|
||||||
// DEFINE VALIDATION RULES
|
|
||||||
defineRule("date-required", required(errorMessages.DATE_REQUIRED));
|
|
||||||
|
|
||||||
// Define constants
|
|
||||||
const TIME_SLOTS_CALL_DAYS_LIMIT = 34; // needs to be 34 for API limits (35 does not consistently work)
|
|
||||||
|
|
||||||
const getAvailableDates = async (
|
|
||||||
startDateString,
|
|
||||||
endDateString,
|
|
||||||
appointmentType,
|
|
||||||
providerNumber
|
|
||||||
) => {
|
|
||||||
const apiEndDateLimit = sumDateString(startDateString, TIME_SLOTS_CALL_DAYS_LIMIT);
|
|
||||||
const difference = calcDaysBetweenDates(startDateString, endDateString);
|
|
||||||
const apiCallsCount = Math.ceil(difference / TIME_SLOTS_CALL_DAYS_LIMIT);
|
|
||||||
const storeActionConfigs = [];
|
|
||||||
const timeSlotsData = {};
|
|
||||||
timeSlotsData.days = [];
|
|
||||||
let apiStartDate = startDateString;
|
|
||||||
let apiEndDate = endDateString;
|
|
||||||
|
|
||||||
for (let i = 1; i <= apiCallsCount; i++) {
|
|
||||||
let storeActionConfig;
|
|
||||||
|
|
||||||
if (i > 1) {
|
|
||||||
apiStartDate = sumDateString(apiEndDate, 1);
|
|
||||||
apiEndDate = sumDateString(apiStartDate, TIME_SLOTS_CALL_DAYS_LIMIT);
|
|
||||||
|
|
||||||
if (i === apiCallsCount) {
|
|
||||||
apiEndDate = endDateString;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (apiEndDate > apiEndDateLimit) {
|
|
||||||
apiEndDate = apiEndDateLimit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (appointmentType === AppointmentTypeStrings.MOBILE) {
|
|
||||||
storeActionConfig = {
|
|
||||||
storeAction: storeActions.GET_MOBILE_TIME_SLOTS,
|
|
||||||
payload: {
|
|
||||||
startDate: apiStartDate,
|
|
||||||
endDate: apiEndDate,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
storeActionConfig = {
|
|
||||||
storeAction: storeActions.GET_SHOP_TIME_SLOTS,
|
|
||||||
payload: {
|
|
||||||
startDate: apiStartDate,
|
|
||||||
endDate: apiEndDate,
|
|
||||||
shopAppointmentType: appointmentType,
|
|
||||||
providerNumber: providerNumber,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
if (apiStartDate < apiEndDate) storeActionConfigs.push(storeActionConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
const timeSlotsResponsesData = {
|
|
||||||
days: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
function compareDayStrings(a, b) {
|
|
||||||
if (a.date < b.date) return -1;
|
|
||||||
if (a.date > b.date) return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const makeParallelCalls = async () => {
|
|
||||||
await Promise.all(
|
|
||||||
storeActionConfigs.map(async (storeAction) => {
|
|
||||||
const timeSlotsResponse = await baseMixin.methods.dispatchStoreActionWithLogging(
|
|
||||||
storeAction.storeAction,
|
|
||||||
storeAction.payload,
|
|
||||||
"schedule",
|
|
||||||
false
|
|
||||||
);
|
|
||||||
timeSlotsResponsesData.estimatedServiceMinutesMinimum =
|
|
||||||
timeSlotsResponse.data.estimatedServiceMinutesMinimum;
|
|
||||||
timeSlotsResponsesData.estimatedServiceMinutesMaximum =
|
|
||||||
timeSlotsResponse.data.estimatedServiceMinutesMaximum;
|
|
||||||
timeSlotsResponsesData.days = [
|
|
||||||
...timeSlotsResponsesData.days,
|
|
||||||
...timeSlotsResponse.data.days,
|
|
||||||
];
|
|
||||||
})
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
return makeParallelCalls().then(() => {
|
|
||||||
// sort days chronologically
|
|
||||||
timeSlotsResponsesData.days.sort(compareDayStrings);
|
|
||||||
return timeSlotsResponsesData;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: "schedule",
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
selectedDate: this.getSelectedDate(),
|
|
||||||
selectedTimeSlotInfo: this.getSelectedTimeSlotInfo(),
|
|
||||||
selectableDatesData: [],
|
|
||||||
mobilePremiumAppointmentFee: null,
|
|
||||||
waitListRequested: null,
|
|
||||||
displayWaitList: null,
|
|
||||||
pricingByDayUpchargeLineItem: null,
|
|
||||||
includePricingByDayUpcharge: null,
|
|
||||||
isPricingByDayExperiment: null,
|
|
||||||
pricingByDayBasePrice: null,
|
|
||||||
pricingByDayUpcharge: null,
|
|
||||||
showPricingByDay: null,
|
|
||||||
};
|
|
||||||
},
|
|
||||||
async beforeRouteEnter(to, from, next) {
|
|
||||||
const isPricingByDayExperiment = experimentMixin.methods.hasSettingEqualTo(
|
|
||||||
experimentSettings.PRICING_BY_DAY,
|
|
||||||
"true"
|
|
||||||
);
|
|
||||||
const showPricingByDay = !store.getters.payment.isInsurance && isPricingByDayExperiment;
|
|
||||||
|
|
||||||
// Get pricingByDayBasePrice needed for Pricing By Day
|
|
||||||
const lineItems = deepClone(store.getters.order.lineItems);
|
|
||||||
const isRecalibrationOnOrder = store.getters.isRecalibrationOnOrder;
|
|
||||||
const shouldHideRecalibration =
|
|
||||||
experimentMixin.methods.hasSettingEqualTo(
|
|
||||||
experimentSettings.RECAL_PRICE_REMOVE,
|
|
||||||
"true"
|
|
||||||
) && isRecalibrationOnOrder;
|
|
||||||
const glassParts =
|
|
||||||
isRecalibrationOnOrder && shouldHideRecalibration
|
|
||||||
? getItemsWithoutRecalParts(lineItems.glassParts)
|
|
||||||
: (lineItems.glassParts ?? []);
|
|
||||||
const supportingItemsFromStore = lineItems?.supportingItems;
|
|
||||||
const supportingItemsWithoutFees = baseMixin.methods.filterOutCertainPartTypesOrNumbers(
|
|
||||||
lineItems.supportingItems,
|
|
||||||
{
|
|
||||||
partNumbersToRemove: [
|
|
||||||
partNumberStrings.RECYCLE_FEE,
|
|
||||||
partNumberStrings.PRICING_BY_DAY_UPCHARGE,
|
|
||||||
],
|
|
||||||
}
|
|
||||||
);
|
|
||||||
const lineItemsToBePriced = {
|
|
||||||
glassParts: glassParts,
|
|
||||||
supportingItems: supportingItemsWithoutFees,
|
|
||||||
vaps: lineItems.vaps ?? [],
|
|
||||||
promos: lineItems.promos ?? [],
|
|
||||||
};
|
|
||||||
const priceString = getAmountDue(lineItemsToBePriced, false); // pass the IncludeTax param as false
|
|
||||||
const priceStringIntegerRoundedDown = priceString?.split(".")[0]; // same method used as getDisplayPrice() in service-package-radio used on /quote
|
|
||||||
const pricingByDayBasePrice = parseInt(priceStringIntegerRoundedDown);
|
|
||||||
let includePricingByDayUpcharge = false;
|
|
||||||
|
|
||||||
// Check to see if date should be pre-selected
|
|
||||||
let preSelectedSlot = await store.getters.order.schedule;
|
|
||||||
if (!preSelectedSlot.date || preSelectedSlot?.date?.length < 1) {
|
|
||||||
preSelectedSlot = null;
|
|
||||||
} else {
|
|
||||||
// Check to see if pre-selected date should have pricing by day upcharge
|
|
||||||
if (showPricingByDay) {
|
|
||||||
// is this preSelectedDate a higher priced pricingByDay day?
|
|
||||||
const dayIndex = convertDateStringToDate(preSelectedSlot?.date).getDay();
|
|
||||||
const dayObject = DAYS_OF_WEEK[dayIndex];
|
|
||||||
if (dayObject.isPricingByDayUpchargeDay) {
|
|
||||||
includePricingByDayUpcharge = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set up promises
|
|
||||||
const cmsContentPromise = fetchCmsContentForPage(to.name);
|
|
||||||
|
|
||||||
const alertReasonsPromise = locationAlerts.methods.loadInitialData(
|
|
||||||
store.getters.order.serviceLocation.zipCodeCtu,
|
|
||||||
store.getters.order.serviceLocation.provider?.address?.zipCodeCtu
|
|
||||||
);
|
|
||||||
|
|
||||||
// While Pricing By Day Experiment is active, using the updated datePicker
|
|
||||||
const datePickerInitialDataPromise = await datePicker.methods.loadInitialData({
|
|
||||||
// setup config options for date-picker
|
|
||||||
selectableDatesSetting: "custom",
|
|
||||||
initialViewRowsToShow: 2,
|
|
||||||
customSelectableDatesCallback: getAvailableDates,
|
|
||||||
preSelectedDate: preSelectedSlot ? preSelectedSlot.date : preSelectedSlot,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Get pricingByDayUpcharge needed for Pricing By Day
|
|
||||||
const pricingByDayUpchargePartPromise = showPricingByDay
|
|
||||||
? getPricingByDayPartWithPrice()
|
|
||||||
: null;
|
|
||||||
|
|
||||||
const premiumFeePromise = baseMixin.methods.dispatchStoreActionWithLogging(
|
|
||||||
storeActions.GET_MOBILE_PREMIUM_FEE,
|
|
||||||
null,
|
|
||||||
"schedule"
|
|
||||||
);
|
|
||||||
const premiumFeeWithPricePromise = premiumFeePromise.then((result) => {
|
|
||||||
if (result.data) {
|
|
||||||
return baseMixin.methods.dispatchStoreActionWithLogging(
|
|
||||||
storeActions.PRICE_ORDER_ITEMS_AND_SAVE_SERVER_DATA,
|
|
||||||
{
|
|
||||||
availableLineItems: [result.data],
|
|
||||||
},
|
|
||||||
"schedule",
|
|
||||||
false
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return result.data;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Settle promises and get results
|
|
||||||
const promiseResultMap = [
|
|
||||||
{
|
|
||||||
resultKey: "cmsContent",
|
|
||||||
promise: cmsContentPromise,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
resultKey: "alertReasons",
|
|
||||||
promise: alertReasonsPromise,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
resultKey: "datePickerInitialData",
|
|
||||||
promise: datePickerInitialDataPromise,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
resultKey: "pricingByDayUpchargePart",
|
|
||||||
promise: pricingByDayUpchargePartPromise,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
resultKey: "premiumFeeWithPrice",
|
|
||||||
promise: premiumFeeWithPricePromise,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const resultMap = await settleAllPromises(promiseResultMap);
|
|
||||||
|
|
||||||
const pricingByDayUpcharge = showPricingByDay
|
|
||||||
? await baseMixin.methods.getTotalLineItemPrice(
|
|
||||||
resultMap.pricingByDayUpchargePart,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
const datePickerInitialData = resultMap.datePickerInitialData;
|
|
||||||
datePickerInitialData.pricingByDayBasePrice = pricingByDayBasePrice;
|
|
||||||
datePickerInitialData.pricingByDayUpcharge = pricingByDayUpcharge;
|
|
||||||
|
|
||||||
// Call the "next" function to complete the transition to this page.
|
|
||||||
next((vm) => {
|
|
||||||
vm.setCmsContent(resultMap.cmsContent);
|
|
||||||
vm.$refs.datePicker.initializeComponent(datePickerInitialData);
|
|
||||||
vm.$refs.locationAlerts.initializeComponent(resultMap.alertReasons);
|
|
||||||
vm.selectableDatesData = datePickerInitialData.initialShopTimeSlotsResponse;
|
|
||||||
vm.mobilePremiumAppointmentFee = resultMap.premiumFeeWithPrice
|
|
||||||
? resultMap.premiumFeeWithPrice[0]
|
|
||||||
: null;
|
|
||||||
vm.updateFooterButtonText(vm.selectedTimeSlotInfo);
|
|
||||||
vm.setDisplayWaitList();
|
|
||||||
vm.pricingByDayUpchargeLineItem = resultMap.pricingByDayUpchargePart;
|
|
||||||
vm.includePricingByDayUpcharge = includePricingByDayUpcharge;
|
|
||||||
vm.isPricingByDayExperiment = isPricingByDayExperiment;
|
|
||||||
vm.pricingByDayBasePrice = pricingByDayBasePrice;
|
|
||||||
vm.pricingByDayUpcharge = pricingByDayUpcharge;
|
|
||||||
vm.showPricingByDay = showPricingByDay;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
const selectableDatesData = this.selectableDatesData;
|
|
||||||
// if no date selected on load
|
|
||||||
if (!this.selectedDate) {
|
|
||||||
if (selectableDatesData?.days?.length > 0) {
|
|
||||||
this.selectedDate = selectableDatesData.days[0].date;
|
|
||||||
} else {
|
|
||||||
setTimeout(() => {
|
|
||||||
this.$refs.datePicker.showAnotherMonth().then((moreSelectableDatesData) => {
|
|
||||||
this.selectableDatesData = moreSelectableDatesData;
|
|
||||||
if (selectableDatesData?.days?.length > 0) {
|
|
||||||
this.selectedDate = selectableDatesData.days[0].date;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setDisplayWaitList();
|
|
||||||
});
|
|
||||||
}, 50);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
ChangeShopLinkText() {
|
|
||||||
return this.getCmsContent("ChangeShopLink", "Text");
|
|
||||||
},
|
|
||||||
ChangeShopLink() {
|
|
||||||
// Splits content when brackets are found in text so that text can be looped through and router-link can be injected when needed
|
|
||||||
return this.splitCopyOnCMSPlaceHolder(this.ChangeShopLinkText);
|
|
||||||
},
|
|
||||||
appointmentType() {
|
|
||||||
return this.$store.getters.order.serviceLocation.appointmentType;
|
|
||||||
},
|
|
||||||
timeSlotsForSelectedDate() {
|
|
||||||
if (!this.selectedDate) return null;
|
|
||||||
|
|
||||||
return this.selectableDatesData.days?.find(
|
|
||||||
(selectableDate) => selectableDate.date === this.selectedDate
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
splitCopyOnCMSPlaceHolder,
|
|
||||||
arePagePrerequisitesValid() {
|
|
||||||
const serviceLocation = store.getters.order.serviceLocation;
|
|
||||||
|
|
||||||
const serviceLocationPreReqs =
|
|
||||||
serviceLocation.zipCode &&
|
|
||||||
serviceLocation.zipCodeCtu &&
|
|
||||||
serviceLocation.appointmentType &&
|
|
||||||
(serviceLocation.appointmentType === AppointmentTypeStrings.MOBILE ||
|
|
||||||
serviceLocation.provider.providerNumber);
|
|
||||||
|
|
||||||
const paymentInfo = store.getters.payment.isInsurance !== null;
|
|
||||||
|
|
||||||
const damageInfo =
|
|
||||||
store.getters.order.damage.isRepair ||
|
|
||||||
(store.getters.order.lineItems?.glassParts != null &&
|
|
||||||
store.getters.order.lineItems.glassParts.length > 0);
|
|
||||||
|
|
||||||
const preReqResult = serviceLocationPreReqs && paymentInfo && damageInfo;
|
|
||||||
|
|
||||||
// prettier-ignore
|
|
||||||
{
|
|
||||||
debugLog("--- schedule.vue pagePrereqs start ---", null, !preReqResult);
|
|
||||||
debugLog("store.getters.order.serviceLocation.zipCode:", serviceLocation.zipCode, !preReqResult);
|
|
||||||
debugLog("store.getters.order.serviceLocation.zipCodeCtu:", serviceLocation.zipCodeCtu, !preReqResult);
|
|
||||||
debugLog("store.getters.order.serviceLocation.appointmentType:", serviceLocation.appointmentType, !preReqResult);
|
|
||||||
debugLog("store.getters.order.serviceLocation.provider.providerNumber:", serviceLocation.provider?.providerNumber, !preReqResult);
|
|
||||||
debugLog("store.getters.payment.isInsurance:", store.getters.payment?.isInsurance, !preReqResult);
|
|
||||||
debugLog("store.getters.order.damage.isRepair:", store.getters.order.damage?.isRepair, !preReqResult);
|
|
||||||
debugLog("store.getters.order.lineItems.glassParts:", store.getters.order.lineItems?.glassParts, !preReqResult);
|
|
||||||
debugLog("--- schedule.vue pagePrereqs end ---", null, !preReqResult);
|
|
||||||
}
|
|
||||||
return preReqResult;
|
|
||||||
},
|
|
||||||
async getAvailableDatesMethod(startDate, endDate) {
|
|
||||||
const newShopTimeSlots = await getAvailableDates(
|
|
||||||
startDate,
|
|
||||||
endDate,
|
|
||||||
this.appointmentType,
|
|
||||||
this.$store.getters.order.serviceLocation.provider.providerNumber
|
|
||||||
);
|
|
||||||
|
|
||||||
// ADD API CALL RESULTS TO EXISTING DATE DATA
|
|
||||||
this.selectableDatesData.days = this.selectableDatesData.days.concat(
|
|
||||||
newShopTimeSlots.days
|
|
||||||
);
|
|
||||||
return newShopTimeSlots;
|
|
||||||
},
|
|
||||||
getAvailableDates,
|
|
||||||
getServiceZipCtuCodeFromStore() {
|
|
||||||
return store.getters.order.serviceLocation.zipCodeCtu;
|
|
||||||
},
|
|
||||||
getSelectedDate() {
|
|
||||||
return store.getters.order.schedule.date;
|
|
||||||
},
|
|
||||||
getSelectedTimeSlotInfo() {
|
|
||||||
const supportingItems = this.getSupportingItems();
|
|
||||||
|
|
||||||
var isPremiumAppointment = false;
|
|
||||||
if (supportingItems) {
|
|
||||||
isPremiumAppointment =
|
|
||||||
!!supportingItems.filter(
|
|
||||||
(lineItem) => lineItem.partType === PREMIUM_FEE_PART_TYPE
|
|
||||||
).length > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const selectedTimeSlotInfo = {
|
|
||||||
timeSlot: store.getters.order.schedule,
|
|
||||||
isPremiumAppointment: isPremiumAppointment,
|
|
||||||
};
|
|
||||||
|
|
||||||
return selectedTimeSlotInfo;
|
|
||||||
},
|
|
||||||
getSupportingItems() {
|
|
||||||
return store.getters.lineItems.supportingItems;
|
|
||||||
},
|
|
||||||
updateFooterButtonText(timeSlotInfo) {
|
|
||||||
let navbarButtonText;
|
|
||||||
if (!timeSlotInfo || !timeSlotInfo.timeSlot.date) {
|
|
||||||
navbarButtonText = "Continue";
|
|
||||||
} else {
|
|
||||||
navbarButtonText = `Select ${this.convertSelectedDateToShortMonthAndDay(
|
|
||||||
timeSlotInfo.timeSlot.date
|
|
||||||
)}`;
|
|
||||||
|
|
||||||
if (this.appointmentType === AppointmentTypeStrings.IN_SHOP) {
|
|
||||||
navbarButtonText += ` at ${this.getDisplayTextForMilitaryTime(
|
|
||||||
timeSlotInfo.timeSlot.startTime
|
|
||||||
)}`;
|
|
||||||
} else if (
|
|
||||||
this.appointmentType === AppointmentTypeStrings.MOBILE &&
|
|
||||||
!timeSlotInfo.isPremiumAppointment
|
|
||||||
) {
|
|
||||||
navbarButtonText += ` at ${this.getDisplayTextForMilitaryTime(
|
|
||||||
timeSlotInfo.timeSlot.startTime,
|
|
||||||
true
|
|
||||||
)} - ${this.getDisplayTextForMilitaryTime(
|
|
||||||
timeSlotInfo.timeSlot.endTime,
|
|
||||||
true
|
|
||||||
)}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.$refs.navbar.updateButtonText(navbarButtonText);
|
|
||||||
},
|
|
||||||
convertSelectedDateToShortMonthAndDay(selectedDate) {
|
|
||||||
// This conversion ensures we don't get get GMT induced date changes
|
|
||||||
const dateObject = convertDateStringToDate(selectedDate);
|
|
||||||
// Ex: April 25
|
|
||||||
return dateObject.toLocaleDateString("en-us", { month: "short", day: "numeric" });
|
|
||||||
},
|
|
||||||
getDisplayTextForMilitaryTime(militaryTimeInput, shouldTrimMinutesIfEmpty = false) {
|
|
||||||
// Expected input: "HH:MM"
|
|
||||||
let hours = parseInt(militaryTimeInput.split(":")[0]);
|
|
||||||
const minutes = militaryTimeInput.split(":")[1];
|
|
||||||
const meridianNotation = hours > 11 ? "PM" : "AM";
|
|
||||||
|
|
||||||
if (hours > 12) {
|
|
||||||
hours -= 12;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shouldTrimMinutesIfEmpty && minutes === "00") {
|
|
||||||
return `${hours} ${meridianNotation}`;
|
|
||||||
} else {
|
|
||||||
return `${hours}:${minutes} ${meridianNotation}`;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
backButtonAction() {
|
|
||||||
this.$router.navigateWithoutSaving(
|
|
||||||
this.navigationScenarios.CLICKED_BACK,
|
|
||||||
this.pageName
|
|
||||||
);
|
|
||||||
},
|
|
||||||
forwardButtonAction() {
|
|
||||||
this.updateSupportingItems();
|
|
||||||
|
|
||||||
if (this.displayWaitList) {
|
|
||||||
var gaLabel = "";
|
|
||||||
const status = this.waitListRequested ? "checked" : "unchecked";
|
|
||||||
const type = store.getters.isMobileAppointment ? "mobile" : "inshop";
|
|
||||||
gaLabel = `${status}_${type}`;
|
|
||||||
|
|
||||||
const currentDate = new Date();
|
|
||||||
const dateString = this.selectableDatesData.days[0].date;
|
|
||||||
const [year, month, day] = dateString.split("-").map(Number);
|
|
||||||
const appointmentDate = new Date(year, month - 1, day);
|
|
||||||
const timeDifference = appointmentDate - currentDate;
|
|
||||||
|
|
||||||
// Convert the time difference from milliseconds to days
|
|
||||||
const daysUntilAppointment = Math.ceil(timeDifference / (1000 * 60 * 60 * 24));
|
|
||||||
|
|
||||||
gaLabel +=
|
|
||||||
"_" +
|
|
||||||
daysUntilAppointment.toString() +
|
|
||||||
"_" +
|
|
||||||
store.getters.order.serviceLocation.zipCode +
|
|
||||||
"_" +
|
|
||||||
store.getters.order.serviceLocation.zipCodeCtu;
|
|
||||||
this.pushEventToGA("waitlist", "add_to_waitlist_check_box_status", gaLabel, true);
|
|
||||||
}
|
|
||||||
if (this.selectedTimeSlotInfo.timeSlot.jobMinMinutes == null) {
|
|
||||||
this.selectedTimeSlotInfo.timeSlot.jobMinMinutes =
|
|
||||||
this.selectableDatesData?.estimatedServiceMinutesMinimum?.toString();
|
|
||||||
this.selectedTimeSlotInfo.timeSlot.jobMaxMinutes =
|
|
||||||
this.selectableDatesData?.estimatedServiceMinutesMaximum?.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.dispatchStoreAction(
|
|
||||||
this.storeActions.SAVE_SCHEDULE,
|
|
||||||
this.selectedTimeSlotInfo.timeSlot,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
|
|
||||||
if (this.waitListRequested !== null && this.waitListRequested !== undefined) {
|
|
||||||
this.dispatchStoreAction(
|
|
||||||
this.storeActions.SAVE_WAITLIST_REQUESTED,
|
|
||||||
this.waitListRequested,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$router.navigateWithSaving(
|
|
||||||
this.navigationScenarios.CLICKED_FORWARD,
|
|
||||||
this.pageName
|
|
||||||
);
|
|
||||||
},
|
|
||||||
setDisplayWaitList() {
|
|
||||||
if (
|
|
||||||
experimentMixin.methods.hasSettingEqualTo(
|
|
||||||
experimentSettings.DISPLAY_WAITLIST,
|
|
||||||
"true"
|
|
||||||
) &&
|
|
||||||
this.selectableDatesData.days[0]
|
|
||||||
) {
|
|
||||||
const dateString = this.selectableDatesData.days[0].date;
|
|
||||||
const [year, month, day] = dateString.split("-").map(Number);
|
|
||||||
const targetDate = new Date(year, month - 1, day);
|
|
||||||
const currentDate = new Date();
|
|
||||||
const futureDate = new Date(currentDate);
|
|
||||||
const experimentThresholdDays = experimentMixin.methods.hasSetting(
|
|
||||||
experimentSettings.WAITLIST_THRESHOLD_DAYS
|
|
||||||
)
|
|
||||||
? parseInt(
|
|
||||||
experimentMixin.methods.getSettingValue(
|
|
||||||
experimentSettings.WAITLIST_THRESHOLD_DAYS
|
|
||||||
)
|
|
||||||
)
|
|
||||||
: 0;
|
|
||||||
futureDate.setDate(currentDate.getDate() + experimentThresholdDays);
|
|
||||||
|
|
||||||
if (targetDate >= futureDate) {
|
|
||||||
this.displayWaitList = true;
|
|
||||||
} else {
|
|
||||||
this.displayWaitList = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
updateSupportingItems() {
|
|
||||||
const supportingItems = this.getSupportingItems();
|
|
||||||
|
|
||||||
// if we have a pricing by day upcharge, then save/update supporting items with it
|
|
||||||
const pricingByDayUpchargeFeeIndex = supportingItems?.findIndex(
|
|
||||||
(item) => item.partType == PRICING_BY_DAY_PART_TYPE
|
|
||||||
);
|
|
||||||
|
|
||||||
if (this.includePricingByDayUpcharge && this.showPricingByDay) {
|
|
||||||
if (pricingByDayUpchargeFeeIndex && pricingByDayUpchargeFeeIndex > -1) {
|
|
||||||
supportingItems[pricingByDayUpchargeFeeIndex].laborAmount =
|
|
||||||
this.pricingByDayUpchargeLineItem.laborAmount;
|
|
||||||
supportingItems[pricingByDayUpchargeFeeIndex].sellingPrice =
|
|
||||||
this.pricingByDayUpchargeLineItem.sellingPrice;
|
|
||||||
supportingItems[pricingByDayUpchargeFeeIndex].kitPrice =
|
|
||||||
this.pricingByDayUpchargeLineItem.kitPrice;
|
|
||||||
} else {
|
|
||||||
supportingItems.push(this.pricingByDayUpchargeLineItem);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (pricingByDayUpchargeFeeIndex >= 0) {
|
|
||||||
// remove pricing by day upcharge if it already was in store
|
|
||||||
supportingItems.splice(pricingByDayUpchargeFeeIndex, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 > -1) {
|
|
||||||
supportingItems[premiumFeeIndex].laborAmount =
|
|
||||||
this.mobilePremiumAppointmentFee.laborAmount;
|
|
||||||
supportingItems[premiumFeeIndex].sellingPrice =
|
|
||||||
this.mobilePremiumAppointmentFee.sellingPrice;
|
|
||||||
supportingItems[premiumFeeIndex].kitPrice =
|
|
||||||
this.mobilePremiumAppointmentFee.kitPrice;
|
|
||||||
} else {
|
|
||||||
supportingItems.push(this.mobilePremiumAppointmentFee);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!supportingItems) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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.dispatchStoreAction(
|
|
||||||
this.storeActions.SAVE_SUPPORTING_ITEMS_SUPPRESSING_STATE_RESETTING,
|
|
||||||
supportingItems,
|
|
||||||
false
|
|
||||||
);
|
|
||||||
},
|
|
||||||
handleWaitListRequested(value) {
|
|
||||||
this.waitListRequested = value;
|
|
||||||
},
|
|
||||||
handleDateClicked(date) {
|
|
||||||
// do something to mark this as upcharge day or not...
|
|
||||||
if (date.isPricingByDayUpchargeDay) {
|
|
||||||
this.includePricingByDayUpcharge = true;
|
|
||||||
} else {
|
|
||||||
this.includePricingByDayUpcharge = false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
updateTimeSlot(timeSlot) {
|
|
||||||
this.selectedTimeSlotInfo = timeSlot;
|
|
||||||
},
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
selectedDate(newValue, oldValue) {
|
|
||||||
// Clear time slot selection if date selected changes
|
|
||||||
if (newValue !== oldValue) {
|
|
||||||
this.selectedTimeSlotInfo = {
|
|
||||||
timeSlot: {
|
|
||||||
date: null,
|
|
||||||
routeCode: null,
|
|
||||||
startTime: null,
|
|
||||||
endTime: null,
|
|
||||||
jobMaxMinutes: null,
|
|
||||||
jobMinMinutes: null,
|
|
||||||
},
|
|
||||||
isPremiumAppointment: null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
},
|
|
||||||
selectedTimeSlotInfo(newValue) {
|
|
||||||
this.updateFooterButtonText(newValue);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
components: {
|
|
||||||
funnelHeader,
|
|
||||||
navbar,
|
|
||||||
funnelSubHeader,
|
|
||||||
Form,
|
|
||||||
loadingModal,
|
|
||||||
datePicker,
|
|
||||||
locationAlerts,
|
|
||||||
textBlock,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
.container-fluid {
|
|
||||||
&.page-schedule {
|
|
||||||
padding: 0 1rem;
|
|
||||||
.text-link-small {
|
|
||||||
a,
|
|
||||||
.btn-link {
|
|
||||||
width: auto;
|
|
||||||
margin: 0 auto;
|
|
||||||
height: auto;
|
|
||||||
font-size: 0.875rem;
|
|
||||||
line-height: 1.75;
|
|
||||||
padding: 0;
|
|
||||||
border-radius: 0;
|
|
||||||
&:focus {
|
|
||||||
outline: 1px solid $blue;
|
|
||||||
}
|
|
||||||
@include media-breakpoint-up(md) {
|
|
||||||
font-size: 1rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.funnel-sub-header {
|
|
||||||
h5.dark-header {
|
|
||||||
margin-bottom: 0.25rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.change-location a {
|
|
||||||
font-family: AvertaSemibold;
|
|
||||||
}
|
|
||||||
.time-slots-question {
|
|
||||||
padding: 0 0.75rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<!-- OLD SCHEDULE ENDS -->
|
|
||||||
|
|
@ -1,616 +0,0 @@
|
||||||
// Components
|
|
||||||
import schedule from "@/layouts/schedule/schedule.vue";
|
|
||||||
|
|
||||||
// Supporting Files
|
|
||||||
import { shallowMount } from "@vue/test-utils";
|
|
||||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
|
||||||
import store from "@/store";
|
|
||||||
import router from "@/router";
|
|
||||||
import baseMixin from "../../mixins/base-mixin";
|
|
||||||
|
|
||||||
// Mock basemixin
|
|
||||||
jest.mock("@/mixins/base-mixin.js", () => ({
|
|
||||||
methods: {
|
|
||||||
dispatchStoreAction: jest.fn().mockImplementation((storeAction) => {
|
|
||||||
if (storeAction === "getShopTimeSlots" || storeAction === "getMobileTimeSlots") {
|
|
||||||
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,
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
dispatchStoreActionWithLogging: jest.fn().mockImplementation((storeAction) => {
|
|
||||||
if (storeAction === "getShopTimeSlots" || storeAction === "getMobileTimeSlots") {
|
|
||||||
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,
|
|
||||||
},
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
filterOutCertainPartTypesOrNumbers: jest.fn(),
|
|
||||||
hasSubmittedOrder: jest.fn(),
|
|
||||||
getTotalPriceOfAllLineItemsAndChildParts: jest.fn(),
|
|
||||||
getTotalLineItemPrice: jest.fn(),
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
// Mock fetchCmsContentForPage
|
|
||||||
jest.mock("@/helpers/cms-content-helper", () => ({
|
|
||||||
fetchCmsContentForPage: () => Promise.resolve("content"),
|
|
||||||
splitCopyOnCMSPlaceHolder: jest.fn(() => ["A", "B"]),
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
jest.restoreAllMocks();
|
|
||||||
jest.clearAllMocks();
|
|
||||||
store.getters = {
|
|
||||||
applicationUser: {
|
|
||||||
experiments: [],
|
|
||||||
},
|
|
||||||
order: {
|
|
||||||
schedule: {
|
|
||||||
date: "2019-01-01",
|
|
||||||
startTime: "09:00",
|
|
||||||
endTime: "10:00",
|
|
||||||
routeCode: "000",
|
|
||||||
},
|
|
||||||
lineItems: {
|
|
||||||
glassParts: [
|
|
||||||
{
|
|
||||||
partNumber: "ABC123",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
supportingItems: [],
|
|
||||||
},
|
|
||||||
serviceLocation: {
|
|
||||||
appointmentType: "Inshop",
|
|
||||||
zipCode: "12345",
|
|
||||||
zipCodeCtu: "01234",
|
|
||||||
provider: {
|
|
||||||
providerNumber: "123",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
damage: {
|
|
||||||
isRepair: false,
|
|
||||||
},
|
|
||||||
referralNumber: "1234567",
|
|
||||||
policy: {
|
|
||||||
policyNumber: "123",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
payment: {
|
|
||||||
isInsurance: true,
|
|
||||||
},
|
|
||||||
lineItems: {
|
|
||||||
glassParts: [],
|
|
||||||
supportingItems: [],
|
|
||||||
},
|
|
||||||
experimentSettings: {},
|
|
||||||
vehicle: {
|
|
||||||
carId: "123",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
});
|
|
||||||
afterEach(() => {
|
|
||||||
store.getters = {};
|
|
||||||
jest.restoreAllMocks();
|
|
||||||
jest.clearAllMocks();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("schedule.vue...", () => {
|
|
||||||
describe("initial load", () => {
|
|
||||||
test("should pass arePagePrerequisitesValid with a mobile CASH order and no providerNumber", () => {
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
store.getters.order.serviceLocation.appointmentType = "Mobile";
|
|
||||||
store.getters.order.serviceLocation.provider.policyNumber = null;
|
|
||||||
store.getters.payment.isInsurance = false;
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(arePagePrerequisitesValid).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should pass arePagePrerequisitesValid with an inshop order and providerNumber", () => {
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(arePagePrerequisitesValid).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should fail arePagePrerequisitesValid with a replace with no glass parts", async () => {
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
store.getters.order.lineItems.glassParts = [];
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const arePagePrerequisitesValid2 = await wrapper.vm.arePagePrerequisitesValid();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(arePagePrerequisitesValid2).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should fail arePagePrerequisitesValid without isInsurance", () => {
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
store.getters.payment.isInsurance = null;
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(arePagePrerequisitesValid).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should return timeslots when getMoreScheduleData is called", async () => {
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
wrapper.vm.selectableDatesInshop = {
|
|
||||||
days: [],
|
|
||||||
};
|
|
||||||
wrapper.vm.selectableDatesMobile = {
|
|
||||||
days: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const newShopTimeSlots = await wrapper.vm.getMoreScheduleData(
|
|
||||||
"2023-01-01",
|
|
||||||
"2023-01-31"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(newShopTimeSlots).toStrictEqual({
|
|
||||||
inshopTimeSlotsData: {
|
|
||||||
days: [
|
|
||||||
{
|
|
||||||
date: "2023-12-01",
|
|
||||||
timeSlots: [
|
|
||||||
{
|
|
||||||
endTime: "08:00",
|
|
||||||
id: "06747-01820-S-B*20424*7 AM",
|
|
||||||
offerPremium: false,
|
|
||||||
startTime: "07:00",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
estimatedServiceMinutesMinimum: 90,
|
|
||||||
estimatedServiceMinutesMaximum: 120,
|
|
||||||
},
|
|
||||||
mobileTimeSlotsData: {
|
|
||||||
days: [
|
|
||||||
{
|
|
||||||
date: "2023-12-01",
|
|
||||||
timeSlots: [
|
|
||||||
{
|
|
||||||
endTime: "08:00",
|
|
||||||
id: "06747-01820-S-B*20424*7 AM",
|
|
||||||
offerPremium: false,
|
|
||||||
startTime: "07:00",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
estimatedServiceMinutesMinimum: 90,
|
|
||||||
estimatedServiceMinutesMaximum: 120,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
test("should call API service in day ranges of 34 or less when getMoreScheduleData is called with large date ranges", async () => {
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
wrapper.vm.selectableDatesInshop = {
|
|
||||||
days: [],
|
|
||||||
};
|
|
||||||
wrapper.vm.selectableDatesMobile = {
|
|
||||||
days: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
// Act
|
|
||||||
await wrapper.vm.getMoreScheduleData.call(
|
|
||||||
wrapper.vm,
|
|
||||||
"2023-01-01",
|
|
||||||
"2023-03-31",
|
|
||||||
"Inshop",
|
|
||||||
"123"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(baseMixin.methods.dispatchStoreActionWithLogging).toHaveBeenCalledTimes(6);
|
|
||||||
expect(baseMixin.methods.dispatchStoreActionWithLogging).toHaveBeenCalledWith(
|
|
||||||
"getShopTimeSlots",
|
|
||||||
expect.anything(),
|
|
||||||
expect.anything(),
|
|
||||||
expect.anything()
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("beforeRouteEnter function... ", () => {
|
|
||||||
// TODO: restore this test (temporarily removed it until CASH-845 is in QA then looping back)
|
|
||||||
xtest("should call next() and call all functions within next", async () => {
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
wrapper.vm.selectableDatesInshop = {
|
|
||||||
days: [],
|
|
||||||
};
|
|
||||||
wrapper.vm.updateFooterButtonText = jest.fn();
|
|
||||||
wrapper.vm.setDisplayWaitList = jest.fn();
|
|
||||||
const nextFunction = jest.fn((c) => {
|
|
||||||
c(wrapper.vm);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
await schedule.beforeRouteEnter.call(
|
|
||||||
wrapper.vm,
|
|
||||||
{ query: { fmgPage: "schedule" } },
|
|
||||||
undefined,
|
|
||||||
nextFunction
|
|
||||||
);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(nextFunction).toHaveBeenCalled();
|
|
||||||
expect(wrapper.vm.setCmsContent).toHaveBeenCalledWith("content");
|
|
||||||
expect(wrapper.vm.$refs.datePicker.initializeComponent).toHaveBeenCalledWith(
|
|
||||||
expect.objectContaining({
|
|
||||||
calendarViewDirection: "future",
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expect(wrapper.vm.$refs.locationAlerts.initializeComponent).toHaveBeenCalled();
|
|
||||||
expect(wrapper.vm.selectableDatesInshop).toStrictEqual(
|
|
||||||
expect.objectContaining({
|
|
||||||
days: expect.any(Array),
|
|
||||||
estimatedServiceMinutesMaximum: expect.any(Number),
|
|
||||||
estimatedServiceMinutesMinimum: expect.any(Number),
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expect(wrapper.vm.mobilePremiumAppointmentFee).toStrictEqual(
|
|
||||||
expect.objectContaining({
|
|
||||||
partNumber: expect.any(String),
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expect(wrapper.vm.updateFooterButtonText).toHaveBeenCalled();
|
|
||||||
expect(wrapper.vm.setDisplayWaitList).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("computed properties...", () => {
|
|
||||||
test("timeSlotsForSelectedDate should return timeslots if selected date is available", () => {
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
wrapper.vm.selectableDatesInshop = {
|
|
||||||
days: [
|
|
||||||
{
|
|
||||||
date: "2022-11-11",
|
|
||||||
timeSlots: [
|
|
||||||
{
|
|
||||||
id: "1820I-01820-M-I*20425*AM",
|
|
||||||
startTime: "08:00",
|
|
||||||
endTime: "12:00",
|
|
||||||
offerPremium: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "1820I-01820-M-I*20425*PM",
|
|
||||||
startTime: "12:00",
|
|
||||||
endTime: "17:00",
|
|
||||||
offerPremium: false,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
wrapper.setData({
|
|
||||||
selectedDate: "2022-11-11",
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const testValue = wrapper.vm.timeSlotsForSelectedDate;
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(testValue).toStrictEqual(
|
|
||||||
expect.objectContaining({
|
|
||||||
date: "2022-11-11",
|
|
||||||
})
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("timeSlotsForSelectedDate should be null if no date has been selected", () => {
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
wrapper.vm.selectableDatesInshop = {
|
|
||||||
days: [
|
|
||||||
{
|
|
||||||
date: "2022-11-11",
|
|
||||||
timeSlots: [
|
|
||||||
{
|
|
||||||
id: "1820I-01820-M-I*20425*AM",
|
|
||||||
startTime: "08:00",
|
|
||||||
endTime: "12:00",
|
|
||||||
offerPremium: true,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: "1820I-01820-M-I*20425*PM",
|
|
||||||
startTime: "12:00",
|
|
||||||
endTime: "17:00",
|
|
||||||
offerPremium: false,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
wrapper.setData({
|
|
||||||
selectedDate: undefined,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const testValue = wrapper.vm.timeSlotsForSelectedDate;
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(testValue).toBe(null);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("schedule page methods...", () => {
|
|
||||||
test("getServiceZipCtuCodeFromStore should return zipCodeCtu", () => {
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
wrapper.vm.selectableDatesInshop = {
|
|
||||||
days: [],
|
|
||||||
};
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const testValue = wrapper.vm.getServiceZipCtuCodeFromStore();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(testValue).toStrictEqual("01234");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("getDisplayTextForMilitaryTime should return the correctly formatted string", () => {
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
wrapper.vm.selectableDatesInshop = {
|
|
||||||
days: [],
|
|
||||||
};
|
|
||||||
const timeInput1 = "15:00";
|
|
||||||
const timeInput2 = "15:30";
|
|
||||||
|
|
||||||
// Act
|
|
||||||
const testOutput1 = wrapper.vm.getDisplayTextForMilitaryTime(timeInput1);
|
|
||||||
const testOutput2 = wrapper.vm.getDisplayTextForMilitaryTime(timeInput2);
|
|
||||||
const testOutput3 = wrapper.vm.getDisplayTextForMilitaryTime(timeInput1, true);
|
|
||||||
const testOutput4 = wrapper.vm.getDisplayTextForMilitaryTime(timeInput2, true);
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(testOutput1).toBe("3:00 PM");
|
|
||||||
expect(testOutput2).toBe("3:30 PM");
|
|
||||||
expect(testOutput3).toBe("3 PM");
|
|
||||||
expect(testOutput4).toBe("3:30 PM");
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Clicking back should fire correct navigation", () => {
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
wrapper.vm.selectableDatesInshop = {
|
|
||||||
days: [],
|
|
||||||
};
|
|
||||||
wrapper.vm.$router.navigateWithoutSaving = jest.fn();
|
|
||||||
|
|
||||||
// Act
|
|
||||||
wrapper.vm.backButtonAction();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.$router.navigateWithoutSaving).toBeCalledWith(
|
|
||||||
"CLICKED_BACK",
|
|
||||||
"schedule"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// TODO: restore this test (temporarily removed it until CASH-845 is in QA then looping back)
|
|
||||||
xtest("forwardButtonAction should call route method navigateWithoutSaving", async () => {
|
|
||||||
// Arrange
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
wrapper.vm.dispatchStoreAction = jest.fn(() => {
|
|
||||||
return {
|
|
||||||
data: [],
|
|
||||||
};
|
|
||||||
});
|
|
||||||
wrapper.vm.$router.navigateWithSaving = jest.fn(() => {
|
|
||||||
return {};
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
await wrapper.vm.forwardButtonAction();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
|
|
||||||
test("for Inshop appts, updateSupportingItems should call store action to save supporting items WITHOUT the EARLY BIRD supporting item", async () => {
|
|
||||||
// Arrange
|
|
||||||
store.getters.order.serviceLocation.appointmentType = "Inshop";
|
|
||||||
store.getters.lineItems.supportingItems = [
|
|
||||||
{
|
|
||||||
partNumber: "EARLY BIRD",
|
|
||||||
description: null,
|
|
||||||
partType: "EARLY BIRD",
|
|
||||||
laborAmount: 0,
|
|
||||||
sellingPrice: 0,
|
|
||||||
kitPrice: 0,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
const { wrapper } = setupMocks({});
|
|
||||||
wrapper.vm.dispatchStoreAction = jest.fn(() => {
|
|
||||||
return {
|
|
||||||
data: [],
|
|
||||||
};
|
|
||||||
});
|
|
||||||
wrapper.vm.mobilePremiumAppointmentFee = 14.99;
|
|
||||||
wrapper.setData({
|
|
||||||
selectedTimeSlot: {
|
|
||||||
date: "2019-01-01",
|
|
||||||
startTime: "09:00",
|
|
||||||
endTime: "10:00",
|
|
||||||
routeCode: null,
|
|
||||||
isPremiumAppointment: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Act
|
|
||||||
await wrapper.vm.updateSupportingItems();
|
|
||||||
|
|
||||||
// Assert
|
|
||||||
expect(wrapper.vm.dispatchStoreAction).toBeCalledWith(
|
|
||||||
"saveSupportingItemsSuppressingStateResetting",
|
|
||||||
expect.not.arrayContaining([
|
|
||||||
expect.objectContaining({
|
|
||||||
partType: "EARLY BIRD",
|
|
||||||
}),
|
|
||||||
]),
|
|
||||||
expect.anything()
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const mockCmsContent = {};
|
|
||||||
|
|
||||||
function setupMocks({ customMountOptions }) {
|
|
||||||
const mountOptions = getMountOptions({
|
|
||||||
...customMountOptions,
|
|
||||||
route: { name: "schedule" },
|
|
||||||
});
|
|
||||||
|
|
||||||
mountOptions.global.mocks["$store"] = store;
|
|
||||||
mountOptions.global.mocks["$router"] = router;
|
|
||||||
mountOptions["attachTo"] = document.body;
|
|
||||||
mountOptions.mixins = [
|
|
||||||
{
|
|
||||||
methods: {
|
|
||||||
getCmsContent: jest.fn().mockImplementation((widgetName, fieldName) => {
|
|
||||||
if (mockCmsContent[widgetName] && mockCmsContent[widgetName][fieldName])
|
|
||||||
return mockCmsContent[widgetName][fieldName];
|
|
||||||
}),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
mountOptions.global.mocks.pageName = "schedule";
|
|
||||||
|
|
||||||
const wrapper = shallowMount(schedule, mountOptions);
|
|
||||||
|
|
||||||
wrapper.vm.setCmsContent = jest.fn();
|
|
||||||
wrapper.vm.$refs.datePicker.initializeComponent = jest.fn();
|
|
||||||
wrapper.vm.$refs.datePicker.loadInitialData = jest.fn();
|
|
||||||
wrapper.vm.$refs.locationAlerts.initializeComponent = jest.fn();
|
|
||||||
wrapper.vm.$refs.navbar.updateButtonText = jest.fn();
|
|
||||||
|
|
||||||
return { wrapper };
|
|
||||||
}
|
|
||||||
Loading…
Reference in a new issue