Merge branch 'develop' into feature/CSR-1410

This commit is contained in:
Leah Schumann 2023-06-23 08:22:08 -04:00
commit 75390dbfd4
11 changed files with 587 additions and 62 deletions

View file

@ -8,4 +8,9 @@ const PREMIUM_TIME_SLOT_ID_FLAG = "-premium";
const PREMIUM_FEE_PART_TYPE = "EARLY BIRD";
export { AppointmentTypeStrings, PREMIUM_TIME_SLOT_ID_FLAG, PREMIUM_FEE_PART_TYPE };
const RouteCodeFlags = {
ALL_DAY_DROP_OFF: "ALL DAY DROP OFF",
OVERNIGHT_DROP_OFF: "OVERNIGHT DROP OFF",
};
export { AppointmentTypeStrings, PREMIUM_TIME_SLOT_ID_FLAG, PREMIUM_FEE_PART_TYPE, RouteCodeFlags };

View file

@ -54,6 +54,7 @@ const storeActions = {
RESET_DAMAGE_STATE_AND_DEPENDENCIES: "resetDamageAndDependencies",
RESET_REGISTRATION_STATE_AND_DEPENDENCIES: "resetRegistrationAndDependencies",
RESET_PARTS_STATE_AND_DEPENDENCIES: "resetPartsAndDependencies",
RESET_SERVICE_LOCATION_STATE_AND_DEPENDENCIES: "resetServiceLocationAndDependencies",
RESET_STATE: "resetState",
// SAVE COMPONENT STATE

View file

@ -21,6 +21,19 @@
aria-hidden="true"
v-on="{ 'show.bs.modal': show, 'hide.bs.modal': hide }"
:style="`height: calc(100% - ${currentFooterAndHeaderHeight}px);`">
<div class="menu-modal-container">
<button
class="menu-button"
type="button"
:class="[isActive ? 'active' : '']"
data-bs-toggle="modal"
data-bs-target="#footerModal"
aria-label="Hamburger Menu (modal window)">
<div class="bar1"></div>
<div class="bar2"></div>
<div class="bar3"></div>
</button>
</div>
<div class="modal-dialog modal-fullscreen">
<div class="modal-content">
<div class="modal-header visually-hidden">

View file

@ -13,19 +13,19 @@
<div class="col">
<div class="text-container slide">
<p>
Finding shops near you
Tidying up the shop
<span class="dot-1">.</span>
<span class="dot-2">.</span>
<span class="dot-3">.</span>
</p>
<p>
Looking for dates
Getting all the glass shined up
<span class="dot-1">.</span>
<span class="dot-2">.</span>
<span class="dot-3">.</span>
</p>
<p>
Searching for times
Planning your new view of the road
<span class="dot-1">.</span>
<span class="dot-2">.</span>
<span class="dot-3">.</span>
@ -164,19 +164,19 @@ export default {
transform: translateX(-600px);
}
55% {
transform: translateX(-1110px);
transform: translateX(-1195px);
}
66% {
transform: translateX(-1110px);
transform: translateX(-1195px);
}
77% {
transform: translateX(-1600px);
transform: translateX(-1750px);
}
88% {
transform: translateX(-1600px);
transform: translateX(-1750px);
}
100% {
transform: translateX(-2050px);
transform: translateX(-2200px);
}
}

View file

@ -1,13 +1,21 @@
import axios from "axios";
import analyticsMixIn from "@/mixins/analytics-mixin.js";
import store from "@/store";
import router from "@/router";
import { applicationConfig } from "@/constants/application-config.js";
import { GaCategories, GaActions, GaLabels } from "@/constants/analytics";
import { headerKeys } from "@/constants/header-keys";
export default {
callHttpClient({ method, endpoint, payload, logApiCall = true, isFormData = false }) {
callHttpClient({
method,
endpoint,
payload,
logApiCall = true,
isFormData = false,
additionalSuccessEventDataHandler,
}) {
return new Promise((resolve, reject) => {
const cfDistroUrl = applicationConfig.CONSUMER_CF_DISTRO;
let payloadAndAnalyticsData = {};
@ -31,10 +39,16 @@ export default {
}).then(
(response) => {
if (logApiCall) {
let additionalEventData = "";
if (additionalSuccessEventDataHandler) {
additionalEventData = "_" + additionalSuccessEventDataHandler(response);
}
const pageName = analyticsMixIn.methods.getPageName();
const nextPageName = router.getNextPage() || pageName;
analyticsMixIn.methods.pushEventToGA(
GaCategories.API_RESPONSE,
GaActions.RESULT,
`${GaLabels.SUCCESS}_${endpoint}`,
`${nextPageName}_${endpoint}`,
`${GaLabels.SUCCESS}${additionalEventData}`,
true
);
}

View file

@ -25,6 +25,7 @@
mobileCmsWidgetName="MobileTimeSlotModal"
dropoffCmsWidgetName="DropOffTimeSlotModal"
sameDayDropOffCmsWidgetName="SameDayDropOffTimeSlotModal"
overnightDropOffCmsWidgetName="OvernightDropOffTimeSlotModal"
v-model="selectedTimeSlotData"
@time-slot-modal-closed="timeSlotModalClosed"
:appointmentType="appointmentType"
@ -50,7 +51,6 @@ import funnelFooter from "@/fmg-components/funnel-footer/funnel-footer";
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 { processIfStatements } from "@/helpers/cms-content-helper";
import datePicker from "@/digital-components/date-picker/date-picker";
import locationAlerts from "@/layouts/schedule/location-alerts/location-alerts";
import timeSlotModalQuestion from "./time-slot-modal-question/time-slot-modal-question";
@ -62,12 +62,7 @@ import baseMixin from "@/mixins/base-mixin.js";
import { storeActions } from "@/constants/store-actions";
import { settleAllPromises } from "@/helpers/layout-helper";
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
import {
doesCopyContainRouterLink,
splitCopyOnCMSPlaceHolder,
getRouterLinkRouteFromCopy,
getRouterLinkDisplayTextFromCopy,
} from "@/helpers/cms-content-helper";
import { splitCopyOnCMSPlaceHolder } from "@/helpers/cms-content-helper";
import { AppointmentTypeStrings, PREMIUM_FEE_PART_TYPE } from "@/constants/schedule-constants";
import { errorMessages } from "@/constants/error-messages";
import { required } from "@/helpers/validation-rules";
@ -225,11 +220,7 @@ export default {
},
},
methods: {
doesCopyContainRouterLink,
splitCopyOnCMSPlaceHolder,
getRouterLinkRouteFromCopy,
getRouterLinkDisplayTextFromCopy,
processIfStatements,
arePagePrerequisitesValid() {
const serviceLocation = store.getters.order.serviceLocation;
const serviceLocationPreReqs =
@ -268,8 +259,8 @@ export default {
getTimeSlotObjectFromTimeSlotId(timeSlotId) {
const timeSlots = this.selectableDatesData.days.find(
(selectableDate) => selectableDate.date === this.selectedDate
).timeSlots;
return timeSlots.find((timeSlot) => timeSlot.id === timeSlotId);
)?.timeSlots;
if (timeSlots) return timeSlots.find((timeSlot) => timeSlot.id === timeSlotId);
},
getSelectedDate() {
return store.getters.order.schedule.date;
@ -285,7 +276,7 @@ export default {
},
updateFooterButtonText(timeSlotData) {
let funnelFooterButtonText;
if (!timeSlotData.id) {
if (!timeSlotData.id || !this.appointmentDateAndTime) {
funnelFooterButtonText = "Continue";
} else {
funnelFooterButtonText =

View file

@ -28,11 +28,11 @@
v-if="supplementalInformationBlock"
v-html="supplementalInformationBlock"></div>
<textBlock
v-show="shouldShowDropoffDisclaimerText"
:customText="dropoffDisclaimerText"
v-show="disclaimerTextBlockCopy"
:customText="disclaimerTextBlockCopy"
justifyText="left"
typeStyle="caption"
class="mb-2 mt-4" />
class="mb-2" />
</modal>
</template>
@ -53,6 +53,7 @@ import {
AppointmentTypeStrings,
PREMIUM_TIME_SLOT_ID_FLAG,
PREMIUM_FEE_PART_TYPE,
RouteCodeFlags,
} from "@/constants/schedule-constants";
// Validation for the modal button
@ -69,6 +70,7 @@ export default {
mobilePremiumCmsWidgetName: String,
dropoffCmsWidgetName: String,
sameDayDropOffCmsWidgetName: String,
overnightDropOffCmsWidgetName: String,
appointmentType: String,
dateAndTimeSlotData: Object,
premiumAppointmentFee: Object,
@ -116,9 +118,15 @@ export default {
? this.mobilePremiumCmsWidgetName
: this.mobileCmsWidgetName;
} else {
appointmentTypeCmsWidgetName = this.isSameDay
? this.sameDayDropOffCmsWidgetName
: this.dropoffCmsWidgetName;
if (!this.selectedTimeSlotId) {
return null;
} else {
appointmentTypeCmsWidgetName =
this.getRelevantDropOffCmsWidgetNameForSelectedTimeSlot(
this.selectedTimeSlotId,
true
);
}
}
return this.getCmsContent(appointmentTypeCmsWidgetName, "BodyText");
},
@ -131,12 +139,36 @@ export default {
dropoffButtonText() {
return this.getCmsContent(this.dropoffCmsWidgetName, "HeaderText");
},
overnightDropoffButtonText() {
return this.getCmsContent(this.overnightDropOffCmsWidgetName, "HeaderText");
},
dropoffDisclaimerText() {
return this.getCmsContent(this.dropoffCmsWidgetName, "FooterText");
},
overnightDropOffDisclaimerText() {
return this.getCmsContent(this.overnightDropOffCmsWidgetName, "FooterText");
},
disclaimerTextBlockCopy() {
if (this.appointmentType === AppointmentTypeStrings.DROP_OFF) {
if (this.isSameDay) {
return null;
} else if (this.selectedTimeSlotId?.includes(RouteCodeFlags.ALL_DAY_DROP_OFF)) {
return this.dropoffDisclaimerText;
} else if (this.selectedTimeSlotId?.includes(RouteCodeFlags.OVERNIGHT_DROP_OFF)) {
return this.overnightDropOffDisclaimerText;
} else {
return null;
}
} else {
return null;
}
},
dropOffDurationText() {
return this.getCmsContent(this.dropoffCmsWidgetName, "SubheaderText");
},
overnightDropoffDurationText() {
return this.getCmsContent(this.overnightDropOffCmsWidgetName, "SubheaderText");
},
inshopDurationText() {
const inshopDurationTextWithoutTime = this.getCmsContent(
this.cmsWidgetName,
@ -154,15 +186,27 @@ export default {
} else if (this.appointmentType === AppointmentTypeStrings.IN_SHOP) {
return this.inshopDurationText;
} else {
return this.dropOffDurationText;
if (this.selectedTimeSlotId?.includes(RouteCodeFlags.OVERNIGHT_DROP_OFF)) {
return this.overnightDropoffDurationText;
} else if (this.selectedTimeSlotId?.includes(RouteCodeFlags.ALL_DAY_DROP_OFF)) {
return this.dropOffDurationText;
} else {
return null;
}
}
},
shouldShowDropoffDisclaimerText() {
return this.appointmentType === AppointmentTypeStrings.DROP_OFF && !this.isSameDay;
},
isSameDay() {
return false;
if (!this.dateAndTimeSlotData) {
return false;
}
const selectedDate = this.dateAndTimeSlotData.date;
const todaysDate = new Date().toISOString().split("T")[0];
return selectedDate === todaysDate;
},
dateSelectedReadableDate() {
if (!this.dateAndTimeSlotData) {
return null;
@ -233,6 +277,18 @@ export default {
}
return displayTextForDurationLength;
},
getRelevantDropOffCmsWidgetNameForSelectedTimeSlot(
selectedTimeSlotId,
isSameDayRelevant = false
) {
if (selectedTimeSlotId.includes(RouteCodeFlags.OVERNIGHT_DROP_OFF)) {
return this.overnightDropOffCmsWidgetName;
} else if (selectedTimeSlotId.includes(RouteCodeFlags.ALL_DAY_DROP_OFF)) {
return this.isSameDay && isSameDayRelevant
? this.sameDayDropOffCmsWidgetName
: this.dropoffCmsWidgetName;
}
},
getAvailableTimeSlotsForInshop(timeSlotsForSelectedDate) {
return timeSlotsForSelectedDate.map((timeSlot) => {
const readableTime = this.getDisplayTextForMilitaryTime(timeSlot.startTime);
@ -243,12 +299,16 @@ export default {
});
},
getAvailableTimeSlotsForDropOff(timeSlotsForSelectedDate) {
return [
{
value: timeSlotsForSelectedDate[0].id,
buttonLabel: this.dropoffButtonText,
},
];
const availableTimeSlots = timeSlotsForSelectedDate.map((timeSlot) => {
const buttonLabelValue = timeSlot.id.includes(RouteCodeFlags.OVERNIGHT_DROP_OFF)
? this.overnightDropoffButtonText
: this.dropoffButtonText;
return {
value: timeSlot.id,
buttonLabel: buttonLabelValue,
};
});
return availableTimeSlots;
},
getAvailableTimeSlotsForMobile(timeSlotsForSelectedDate) {
const availableTimeSlots = timeSlotsForSelectedDate.map((timeSlot) => {
@ -316,7 +376,7 @@ export default {
margin-bottom: 0 !important;
}
.text-block.duration-text-block {
margin-top: 0 !important;
margin-top: 4px !important;
}
.supplemental-information {
line-height: 1.5rem;
@ -325,7 +385,7 @@ export default {
font-weight: $font-weight-bold;
}
li:not(:last-child) {
margin-bottom: 16px;
margin-bottom: 8px;
}
}
}

View file

@ -23,6 +23,10 @@ import { applicationConfig } from "../constants/application-config";
export default {
methods: {
getPageName() {
return getPageNameByQueryString();
},
logPageView(pageEvent) {
const currentPageName = getPageNameByQueryString();
var payload = {

View file

@ -222,6 +222,12 @@ router.overrideNavigation = (
next();
};
router.getNextPage = () => nextPageName;
// PRIVATE VARIABLES
var nextPageName;
// PRIVATE FUNCTIONS
// Navigate to the next route, depending on the scenario.
@ -245,6 +251,8 @@ async function navigate(
if (destinationFmgPageValue !== undefined) {
// We're always pushing the same path, just changing query strings. Make sure our optional query strings get combined with our fmgPage one.
nextPageName = destinationFmgPageValue;
// Update page data to the store for next page if provided. Otherwise, keep existing page data or set to empty object
const existingPageDataForPage = store.getters.pageData(destinationFmgPageValue);
baseMixin.methods.savePageDataToStore(

View file

@ -348,14 +348,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;
}
},
@ -384,7 +384,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
@ -727,20 +726,30 @@ 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) {
context.commit(storeMutations.RESET_GLASS_PARTS_STATE);
context.commit(storeMutations.UPDATE_SUPPORTING_ITEMS, null);
context.dispatch(storeActions.RESET_SERVICE_LOCATION_STATE_AND_DEPENDENCIES);
},
resetServiceLocationAndDependencies(context) {
context.commit(storeMutations.RESET_SERVICE_LOCATION_APPOINTMENT_TYPE);
context.commit(storeMutations.RESET_SERVICE_LOCATION_PROVIDER);
context.commit(storeMutations.RESET_SCHEDULE);
},
resetState(context) {
@ -1397,6 +1406,8 @@ export const actions = {
eon: order.eon,
},
},
additionalSuccessEventDataHandler: (response) =>
"Email provided: " + (order.customer.emailAddress ? "true" : "false"),
});
},
@ -1612,7 +1623,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
@ -1638,7 +1648,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
@ -1664,6 +1673,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);
@ -1711,6 +1722,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);
@ -1742,6 +1755,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);
@ -1771,6 +1786,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);
}
@ -1792,8 +1809,7 @@ export const actions = {
saveSupportingItems(context, supportingItems) {
if (!deepEqual(supportingItems, context.state.order.lineItems.supportingItems)) {
context.commit(storeMutations.RESET_SERVICE_LOCATION_APPOINTMENT_TYPE);
context.commit(storeMutations.RESET_SERVICE_LOCATION_PROVIDER);
context.dispatch(storeActions.RESET_SERVICE_LOCATION_STATE_AND_DEPENDENCIES);
}
context.commit(storeMutations.UPDATE_SUPPORTING_ITEMS, supportingItems);
@ -1869,8 +1885,8 @@ export const actions = {
context.state.order.serviceLocation &&
serviceZipCodeInfo.zipCode !== context.state.order.serviceLocation.zipCode
) {
context.commit(storeMutations.RESET_SERVICE_LOCATION_APPOINTMENT_TYPE);
context.commit(storeMutations.RESET_SERVICE_LOCATION_PROVIDER);
context.dispatch(storeActions.RESET_SERVICE_LOCATION_STATE_AND_DEPENDENCIES);
context.commit(storeMutations.RESET_SERVICE_LOCATION_MOBILE_ADDRESS);
}
@ -1878,6 +1894,20 @@ export const actions = {
},
saveServiceLocation(context, serviceLocationInfo) {
if (context.state.order.serviceLocation) {
if (
serviceLocationInfo.zipCode !== context.state.order.serviceLocation.zipCode ||
!deepEqual(
serviceLocationInfo.provider,
context.state.order.serviceLocation.provider
) ||
serviceLocationInfo.appointmentType !==
context.state.order.serviceLocation.appointmentType
) {
context.commit(storeMutations.RESET_SCHEDULE);
}
}
context.commit(storeMutations.UPDATE_SERVICE_LOCATION, serviceLocationInfo);
},
@ -1890,7 +1920,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
@ -1900,8 +1929,7 @@ export const actions = {
saveGlassParts(context, parts) {
if (!deepEqual(parts, context.state.order.lineItems.glassParts)) {
context.commit(storeMutations.RESET_SERVICE_LOCATION_APPOINTMENT_TYPE);
context.commit(storeMutations.RESET_SERVICE_LOCATION_PROVIDER);
context.dispatch(storeActions.RESET_SERVICE_LOCATION_STATE_AND_DEPENDENCIES);
}
context.commit(storeMutations.UPDATE_GLASS_PARTS, parts);

View file

@ -547,41 +547,48 @@ 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 () => {
// Arrange
const context = state;
const commit = jest.fn();
const dispatch = jest.fn();
context.commit = commit;
context.dispatch = dispatch;
// Act
await actions.resetPartsAndDependencies(context);
expect(commit).toBeCalledWith(storeMutations.RESET_GLASS_PARTS_STATE);
expect(dispatch).toBeCalledWith(storeActions.RESET_SERVICE_LOCATION_STATE_AND_DEPENDENCIES);
});
it("resetState action", async () => {
@ -933,6 +940,90 @@ describe("Actions", () => {
);
});
it("saveServiceZipCodeInfo, should call mutation and save zip code to state", () => {
// Arrange
const context = state;
const commit = jest.fn();
context.commit = commit;
const serviceZipCodeInfo = {
zipCode: "43212",
};
// Act
actions.saveServiceLocation(context, serviceZipCodeInfo);
// Assert
expect(commit).toBeCalledWith(storeMutations.UPDATE_SERVICE_LOCATION, serviceZipCodeInfo);
expect(state.order.serviceLocation.zipCode).toEqual("43212");
});
it("saveServiceZipCodeInfo, should reset if zip code is different", () => {
// Arrange
const context = {
state: {
order: {
serviceLocation: {
zipCode: "43212",
},
},
},
};
const commit = jest.fn();
const dispatch = jest.fn();
context.commit = commit;
context.dispatch = dispatch;
const serviceZipCodeInfo = {
zipCode: "43202",
};
// Act
actions.saveServiceZipCodeInfo(context, serviceZipCodeInfo);
// Assert
expect(dispatch).toHaveBeenCalledWith(
storeActions.RESET_SERVICE_LOCATION_STATE_AND_DEPENDENCIES
);
expect(commit).toHaveBeenCalledWith(storeMutations.RESET_SERVICE_LOCATION_MOBILE_ADDRESS);
});
it("saveServiceZipCodeInfo, should not reset if zip code is the same", () => {
// Arrange
const context = {
state: {
order: {
serviceLocation: {
zipCode: "43212",
},
},
},
};
const commit = jest.fn();
const dispatch = jest.fn();
context.commit = commit;
context.dispatch = dispatch;
const serviceZipCodeInfo = {
zipCode: "43212",
};
// Act
actions.saveServiceZipCodeInfo(context, serviceZipCodeInfo);
// Assert
expect(dispatch).not.toHaveBeenCalledWith(
storeActions.RESET_SERVICE_LOCATION_STATE_AND_DEPENDENCIES
);
expect(commit).not.toHaveBeenCalledWith(
storeMutations.RESET_SERVICE_LOCATION_MOBILE_ADDRESS
);
});
it("saveServiceLocation, should call mutation and save service address to state", () => {
// Arrange
const context = state;
@ -959,6 +1050,242 @@ describe("Actions", () => {
expect(state.order.serviceLocation.zipCodeCtu).toEqual("01820");
});
it("saveServiceLocation, should reset if zipcode is different", () => {
// Arrange
const context = {
state: {
order: {
serviceLocation: {
address: "123 Test Lane",
city: "Columbus",
zipCode: "43212",
state: "OH",
zipCodeCtu: "01820",
appointmentType: "Mobile",
isVehicleProtected: true,
provider: {
providerNumber: "11111",
address: {
streetAddress: "123 Test Lane",
city: "Columbus",
state: "OH",
zip: "43212",
},
},
},
},
},
};
const commit = jest.fn();
const dispatch = jest.fn();
context.commit = commit;
context.dispatch = dispatch;
const serviceLocation = {
address: "123 Test Lane",
city: "Columbus",
zipCode: "43202",
state: "OH",
zipCodeCtu: "01820",
appointmentType: "Mobile",
isVehicleProtected: true,
provider: {
providerNumber: "11111",
address: {
streetAddress: "123 Test Lane",
city: "Columbus",
state: "OH",
zip: "43212",
},
},
};
// Act
actions.saveServiceLocation(context, serviceLocation);
// Assert
expect(commit).toHaveBeenCalledWith(storeMutations.RESET_SCHEDULE);
});
it("saveServiceLocation, should reset if provider is different", () => {
// Arrange
const context = {
state: {
order: {
serviceLocation: {
address: "123 Test Lane",
city: "Columbus",
zipCode: "43212",
state: "OH",
zipCodeCtu: "01820",
appointmentType: "Mobile",
isVehicleProtected: true,
provider: {
providerNumber: "11111",
address: {
streetAddress: "123 Test Lane",
city: "Columbus",
state: "OH",
zip: "43212",
},
},
},
},
},
};
const commit = jest.fn();
const dispatch = jest.fn();
context.commit = commit;
context.dispatch = dispatch;
const serviceLocation = {
address: "123 Test Lane",
city: "Columbus",
zipCode: "43212",
state: "OH",
zipCodeCtu: "01820",
appointmentType: "Mobile",
isVehicleProtected: true,
provider: {
providerNumber: "22222",
address: {
streetAddress: "321 Test Lane",
city: "Columbus",
state: "OH",
zip: "43212",
},
},
};
// Act
actions.saveServiceLocation(context, serviceLocation);
// Assert
expect(commit).toHaveBeenCalledWith(storeMutations.RESET_SCHEDULE);
});
it("saveServiceLocation, should reset if appointment type is different", () => {
// Arrange
const context = {
state: {
order: {
serviceLocation: {
address: "123 Test Lane",
city: "Columbus",
zipCode: "43212",
state: "OH",
zipCodeCtu: "01820",
appointmentType: "Mobile",
isVehicleProtected: true,
provider: {
providerNumber: "11111",
address: {
streetAddress: "123 Test Lane",
city: "Columbus",
state: "OH",
zip: "43212",
},
},
},
},
},
};
const commit = jest.fn();
const dispatch = jest.fn();
context.commit = commit;
context.dispatch = dispatch;
const serviceLocation = {
address: "123 Test Lane",
city: "Columbus",
zipCode: "43212",
state: "OH",
zipCodeCtu: "01820",
appointmentType: "Inshop",
isVehicleProtected: true,
provider: {
providerNumber: "11111",
address: {
streetAddress: "123 Test Lane",
city: "Columbus",
state: "OH",
zip: "43212",
},
},
};
// Act
actions.saveServiceLocation(context, serviceLocation);
// Assert
expect(commit).toHaveBeenCalledWith(storeMutations.RESET_SCHEDULE);
});
it("saveServiceLocation, should not reset if parameters are the same", () => {
// Arrange
const context = {
state: {
order: {
serviceLocation: {
address: "123 Test Lane",
city: "Columbus",
zipCode: "43212",
state: "OH",
zipCodeCtu: "01820",
appointmentType: "Mobile",
isVehicleProtected: true,
provider: {
providerNumber: "11111",
address: {
streetAddress: "123 Test Lane",
city: "Columbus",
state: "OH",
zip: "43212",
},
},
},
},
},
};
const commit = jest.fn();
const dispatch = jest.fn();
context.commit = commit;
context.dispatch = dispatch;
const serviceLocation = {
address: "123 Test Lane",
city: "Columbus",
zipCode: "43212",
state: "OH",
zipCodeCtu: "01820",
appointmentType: "Mobile",
isVehicleProtected: true,
provider: {
providerNumber: "11111",
address: {
streetAddress: "123 Test Lane",
city: "Columbus",
state: "OH",
zip: "43212",
},
},
};
// Act
actions.saveServiceLocation(context, serviceLocation);
// Assert
expect(commit).not.toHaveBeenCalledWith(storeMutations.RESET_SCHEDULE);
});
it("saveGlassParts, should call mutation", () => {
// Arrange
const context = {
@ -966,14 +1293,88 @@ describe("Actions", () => {
};
const commit = jest.fn();
const dispatch = jest.fn();
context.commit = commit;
context.dispatch = dispatch;
// Act
actions.saveGlassParts(context, { glassParts: {} });
// Assert
expect(commit).toBeCalledWith(storeMutations.UPDATE_GLASS_PARTS, { glassParts: {} });
expect(dispatch).toBeCalledWith(storeActions.RESET_SERVICE_LOCATION_STATE_AND_DEPENDENCIES);
});
it("saveSupportingItems, should call mutations", () => {
// Arrange
const context = {
state: state,
};
const commit = jest.fn();
const dispatch = jest.fn();
context.commit = commit;
context.dispatch = dispatch;
// Act
actions.saveSupportingItems(context, []);
// Assert
expect(commit).toBeCalledWith(storeMutations.UPDATE_SUPPORTING_ITEMS, []);
});
it("saveSupportingItems, should call reset logic when value is new", () => {
// Arrange
const context = {
state: {
order: {
lineItems: {
supportingItems: ["TestValue1", "TestValue2"],
},
},
},
};
const commit = jest.fn();
const dispatch = jest.fn();
context.commit = commit;
context.dispatch = dispatch;
// Act
actions.saveSupportingItems(context, ["TestValue3", "TestValue4", "TestValue5"]);
// Assert
expect(dispatch).toBeCalledWith(storeActions.RESET_SERVICE_LOCATION_STATE_AND_DEPENDENCIES);
});
it("saveSupportingItems, should not call reset logic when value is the same", () => {
// Arrange
const context = {
state: {
order: {
lineItems: {
supportingItems: ["TestValue1", "TestValue2"],
},
},
},
};
const commit = jest.fn();
const dispatch = jest.fn();
context.commit = commit;
context.dispatch = dispatch;
// Act
actions.saveSupportingItems(context, ["TestValue1", "TestValue2"]);
// Assert
expect(dispatch).not.toBeCalledWith(
storeActions.RESET_SERVICE_LOCATION_STATE_AND_DEPENDENCIES
);
});
it("clearVin, should call mutation", () => {