Merge pull request #839 from Safelite/feature/CSR-746
CSR-746 & CSR-889 | State management for quote page selections
This commit is contained in:
commit
e5087a4f35
8 changed files with 128 additions and 41 deletions
|
|
@ -42,7 +42,6 @@ const storeActions = {
|
|||
RESET_SAVE_SESSION_PROMISE: "resetSaveSessionPromise",
|
||||
|
||||
// DEPENDENCY MUTATIONS
|
||||
RESET_VEHICLE_STATE_AND_DEPENDENCIES: "resetVehicleAndDependencies",
|
||||
RESET_DAMAGE_STATE_AND_DEPENDENCIES: "resetDamageAndDependencies",
|
||||
RESET_REGISTRATION_STATE_AND_DEPENDENCIES: "resetRegistrationAndDependencies",
|
||||
RESET_PARTS_STATE_AND_DEPENDENCIES: "resetPartsAndDependencies",
|
||||
|
|
@ -66,6 +65,7 @@ const storeActions = {
|
|||
"resetMoldingAndCapabilityQuestionAnswersIfNeeded",
|
||||
SAVE_MOLDING_QUESTION_ANSWERS: "saveMoldingQuestionAnswers",
|
||||
SAVE_CAPABILITY_QUESTION_ANSWERS: "saveCapabilityQuestionAnswers",
|
||||
SAVE_QUOTE_PAGE_SELECTIONS: "saveQuotePageSelections",
|
||||
};
|
||||
|
||||
export { storeActions };
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ const storeMutations = {
|
|||
UPDATE_MOLDING_QUESTION_ANSWERS: "updateMoldingQuestionAnswers",
|
||||
UPDATE_CAPABILITY_QUESTION_ANSWERS: "updateCapabilityQuestionAnswers",
|
||||
UPDATE_GLASS_PARTS: "updateGlassParts",
|
||||
UPDATE_OTHER_PARTS: "updateOtherParts",
|
||||
UPDATE_VAPS: "updateVaps",
|
||||
UPDATE_SUPPORTING_ITEMS: "updateSupportingItems",
|
||||
|
||||
UPDATE_REGISTRATION_LICENSE_PLATE: "updateRegistrationLicensePlate",
|
||||
UPDATE_REGISTRATION_ADDRESS: "updateRegistrationAddress",
|
||||
|
|
@ -42,6 +43,7 @@ const storeMutations = {
|
|||
UPDATE_REFERRAL_CORRELATION_ID: "updateReferralCorrelationId",
|
||||
UPDATE_PARENT_ACCT_NUMBER: "updateParentAcctNumber",
|
||||
UPDATE_EON: "updateEON",
|
||||
UPDATE_IS_INSURANCE: "updateIsInsurance",
|
||||
UPDATE_SAVED_SESSION_ID: "updateSavedSessionId",
|
||||
UPDATE_CRM_CUSTOMER_ID: "updateCrmCustomerId",
|
||||
|
||||
|
|
@ -54,6 +56,8 @@ const storeMutations = {
|
|||
RESET_DAMAGE_STATE: "resetDamageState",
|
||||
RESET_REGISTRATION_STATE: "resetRegistrationState",
|
||||
RESET_GLASS_PARTS_STATE: "resetGlassPartsState",
|
||||
RESET_SUPPORTING_ITEMS_STATE: "resetSupportingItemsState",
|
||||
RESET_VAPS_STATE: "resetVapsState",
|
||||
RESET_STATE: "resetState",
|
||||
RESET_SAVE_SESSION_PROMISE: "resetSaveSessionPromise",
|
||||
|
||||
|
|
|
|||
|
|
@ -109,16 +109,17 @@ export default {
|
|||
// Call the "next" function to complete the transition to this page.
|
||||
next((vm) => {
|
||||
vm.setCmsContent(cmsContent);
|
||||
vm.supportingItems = resultMap.supportingItems;
|
||||
vm.availableLineItems = pricingResults;
|
||||
vm.isInsuranceSelected = vm.getDefaultIsInsuranceSelectedValue();
|
||||
});
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
pricingRequestResult: null,
|
||||
isInsuranceSelected: null,
|
||||
selectedPackage: null,
|
||||
availableLineItems: null,
|
||||
supportingItems: null,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
|
|
@ -139,6 +140,19 @@ export default {
|
|||
backButtonAction() {
|
||||
vehicleQuestionsMixin.methods.navigateBack(this);
|
||||
},
|
||||
async forwardButtonAction() {
|
||||
await this.dispatchStoreAction(
|
||||
this.storeActions.SAVE_QUOTE_PAGE_SELECTIONS,
|
||||
{
|
||||
isInsuranceSelected: this.isInsuranceSelected,
|
||||
vapsItemsToAdd: this.selectedPackage,
|
||||
supportingItemsToAdd: this.supportingItems,
|
||||
},
|
||||
false
|
||||
);
|
||||
|
||||
//return this.navigateForward();
|
||||
},
|
||||
},
|
||||
components: {
|
||||
funnelHeader,
|
||||
|
|
|
|||
|
|
@ -49,14 +49,21 @@ describe("service-package-question.vue", () => {
|
|||
const packageNameKey = "05_01_CSR_Quote_Standard_Repair";
|
||||
Object.assign(processedCmsContent, mockProcessedCmsContent[packageNameKey]);
|
||||
});
|
||||
it("should emit captured value", () => {
|
||||
it("should emit relevant VAPS items in an array", () => {
|
||||
// Arrange
|
||||
const wrapper = setupMocks({});
|
||||
// Act
|
||||
wrapper.componentVM.selectedValues = "newValue";
|
||||
wrapper.componentVM.selectedValues = "TierThree";
|
||||
|
||||
// Assert
|
||||
expect(wrapper.emitted()["update:modelValue"][0][0]).toEqual("newValue");
|
||||
expect(wrapper.emitted()["update:modelValue"][0][0]).toEqual([
|
||||
{
|
||||
description: null,
|
||||
partNumber: "RAIN DEFENSE",
|
||||
partType: "RAIN DEFENSE",
|
||||
price: 35.5,
|
||||
},
|
||||
]);
|
||||
});
|
||||
it("should have the correct insurance pricing text when insurance is selected", () => {
|
||||
// Arrange
|
||||
|
|
|
|||
|
|
@ -43,7 +43,9 @@ export default {
|
|||
return this.modelValue;
|
||||
},
|
||||
set: function (newValue) {
|
||||
this.$emit("update:modelValue", newValue);
|
||||
const VapsProductsInSelectedPackage =
|
||||
this.getVapsLineItemsForSelectedPackage(newValue);
|
||||
this.$emit("update:modelValue", VapsProductsInSelectedPackage);
|
||||
},
|
||||
},
|
||||
nullSafeAvailableLineItems() {
|
||||
|
|
@ -206,6 +208,38 @@ export default {
|
|||
});
|
||||
return vapsPrice;
|
||||
},
|
||||
getVapsLineItemsForSelectedPackage(packageName) {
|
||||
const vapsLineItemsForSelectedPackage = [];
|
||||
if (packageName === packageNames.TIER_TWO) {
|
||||
if (this.frontWipersApplicableForTierTwo) {
|
||||
vapsLineItemsForSelectedPackage.push(
|
||||
...this.getLineItemsContainingPartType(partTypeStrings.FRONT_WIPER)
|
||||
);
|
||||
}
|
||||
if (this.rearWiperApplicableForTierTwo) {
|
||||
vapsLineItemsForSelectedPackage.push(
|
||||
...this.getLineItemsContainingPartType(partTypeStrings.REAR_WIPER)
|
||||
);
|
||||
}
|
||||
} else if (packageName === packageNames.TIER_THREE) {
|
||||
if (this.frontWipersApplicableForTierThree) {
|
||||
vapsLineItemsForSelectedPackage.push(
|
||||
...this.getLineItemsContainingPartType(partTypeStrings.FRONT_WIPER)
|
||||
);
|
||||
}
|
||||
if (this.rearWiperApplicableForTierThree) {
|
||||
vapsLineItemsForSelectedPackage.push(
|
||||
...this.getLineItemsContainingPartType(partTypeStrings.REAR_WIPER)
|
||||
);
|
||||
}
|
||||
if (this.rainDefenseApplicableForTierThree) {
|
||||
vapsLineItemsForSelectedPackage.push(
|
||||
...this.getLineItemsContainingPartType(partTypeStrings.RAIN_DEFENSE)
|
||||
);
|
||||
}
|
||||
}
|
||||
return vapsLineItemsForSelectedPackage;
|
||||
},
|
||||
getCustomValueFromString(str) {
|
||||
switch (str) {
|
||||
case "isRecalibrationOnOrder":
|
||||
|
|
@ -224,10 +258,14 @@ export default {
|
|||
return null;
|
||||
}
|
||||
},
|
||||
lineItemsContainsPartType(partType) {
|
||||
getLineItemsContainingPartType(partType) {
|
||||
const partTypeMatches = this.nullSafeAvailableLineItems.filter(
|
||||
(lineItem) => lineItem.partType.toUpperCase() === partType
|
||||
);
|
||||
return partTypeMatches;
|
||||
},
|
||||
lineItemsContainsPartType(partType) {
|
||||
const partTypeMatches = this.getLineItemsContainingPartType(partType);
|
||||
return !!partTypeMatches.length;
|
||||
},
|
||||
glassToReplaceContainsGlassLocation(glassLocation) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<baseInputButton v-bind="$props" @buttonClicked="handleAnswerChange">
|
||||
<baseInputButton v-bind="$props" @buttonClicked="handleAnswerChange" v-model="selectedValue">
|
||||
<div class="package-label" for="testradio">
|
||||
<div class="package-specs">
|
||||
<p :class="[this.buttonLabelSubCopy ? 'mb-2' : 'm-0']">
|
||||
|
|
|
|||
|
|
@ -54,6 +54,9 @@ const getDefaultState = () => {
|
|||
},
|
||||
lineItems: {
|
||||
glassParts: null,
|
||||
supportingItems: null,
|
||||
vaps: null,
|
||||
serverData: null,
|
||||
},
|
||||
payment: {
|
||||
isInsurance: null,
|
||||
|
|
@ -143,8 +146,11 @@ export const mutations = {
|
|||
updateGlassParts(state, partsData) {
|
||||
state.order.lineItems.glassParts = partsData;
|
||||
},
|
||||
updateOtherParts(state, partsData) {
|
||||
state.order.lineItems.otherParts = partsData;
|
||||
updateVaps(state, partsData) {
|
||||
state.order.lineItems.vaps = partsData;
|
||||
},
|
||||
updateSupportingItems(state, partsData) {
|
||||
state.order.lineItems.supportingItems = partsData;
|
||||
},
|
||||
updatePageData(state, pageData) {
|
||||
state.applicationUser.pageData[pageData.page] = pageData.data;
|
||||
|
|
@ -296,6 +302,12 @@ export const mutations = {
|
|||
state.applicationUser.pageData[fmgPageValues.MOLDING_QUESTIONS] = null;
|
||||
state.applicationUser.pageData[fmgPageValues.CAPABILITY_QUESTIONS] = null;
|
||||
},
|
||||
resetSupportingItemsState(state) {
|
||||
state.order.lineItems.supportingItems = null;
|
||||
},
|
||||
resetVapsState(state) {
|
||||
state.order.lineItems.vaps = null;
|
||||
},
|
||||
resetState(state) {
|
||||
Object.assign(state, getDefaultState());
|
||||
},
|
||||
|
|
@ -343,6 +355,9 @@ export const mutations = {
|
|||
state.order.damage.numberOfChips = sessionInformation.order.damage.numberOfChips;
|
||||
|
||||
state.order.lineItems.glassParts = sessionInformation.order.lineItems.glassParts;
|
||||
state.order.lineItems.supportingItems = sessionInformation.order.lineItems.supportingItems;
|
||||
state.order.lineItems.vapsItems = sessionInformation.order.lineItems.vapsItems;
|
||||
state.order.lineItems.serverData = sessionInformation.order.lineItems.serverData;
|
||||
state.order.accountNumber = sessionInformation.order.accountNumber;
|
||||
state.order.providerNumber = sessionInformation.order.providerNumber;
|
||||
(state.order.serviceLocation.address =
|
||||
|
|
@ -436,7 +451,11 @@ export const getters = {
|
|||
"partNumber"
|
||||
),
|
||||
...getNonFalseValuesOfPropertyInArrayOfObjects(
|
||||
state.order.lineItems.otherParts,
|
||||
state.order.lineItems.supportingItems,
|
||||
"partNumber"
|
||||
),
|
||||
...getNonFalseValuesOfPropertyInArrayOfObjects(
|
||||
state.order.lineItems.vaps,
|
||||
"partNumber"
|
||||
),
|
||||
],
|
||||
|
|
@ -446,10 +465,6 @@ export const getters = {
|
|||
state.order.lineItems.glassParts,
|
||||
"recalibrationType"
|
||||
),
|
||||
...getNonFalseValuesOfPropertyInArrayOfObjects(
|
||||
state.order.lineItems.otherParts,
|
||||
"recalibrationType"
|
||||
),
|
||||
],
|
||||
};
|
||||
},
|
||||
|
|
@ -572,21 +587,22 @@ export const actions = {
|
|||
},
|
||||
|
||||
// Dependency Actions
|
||||
resetVehicleAndDependencies(context) {
|
||||
context.commit(storeMutations.RESET_VEHICLE_STATE);
|
||||
context.commit(storeMutations.RESET_DAMAGE_STATE);
|
||||
context.commit(storeMutations.RESET_REGISTRATION_STATE);
|
||||
},
|
||||
resetDamageAndDependencies(context) {
|
||||
context.commit(storeMutations.RESET_DAMAGE_STATE);
|
||||
context.commit(storeMutations.RESET_GLASS_PARTS_STATE);
|
||||
context.commit(storeMutations.RESET_SUPPORTING_ITEMS_STATE);
|
||||
context.commit(storeMutations.RESET_VAPS_STATE);
|
||||
},
|
||||
resetRegistrationAndDependencies(context) {
|
||||
context.commit(storeMutations.RESET_REGISTRATION_STATE);
|
||||
context.commit(storeMutations.RESET_GLASS_PARTS_STATE);
|
||||
context.commit(storeMutations.RESET_SUPPORTING_ITEMS_STATE);
|
||||
context.commit(storeMutations.RESET_VAPS_STATE);
|
||||
},
|
||||
resetPartsAndDependencies(context) {
|
||||
context.commit(storeMutations.RESET_GLASS_PARTS_STATE);
|
||||
context.commit(storeMutations.RESET_SUPPORTING_ITEMS_STATE);
|
||||
context.commit(storeMutations.RESET_VAPS_STATE);
|
||||
},
|
||||
resetState(context) {
|
||||
context.commit(storeMutations.RESET_STATE);
|
||||
|
|
@ -994,6 +1010,9 @@ export const actions = {
|
|||
},
|
||||
lineItems: {
|
||||
glassParts: lineItems.glassParts,
|
||||
supportingItems: lineItems.supportingItems,
|
||||
vapsItems: lineItems.vapsItems,
|
||||
serverData: lineItems.serverData,
|
||||
},
|
||||
payment: {
|
||||
InsuranceCoverage: {
|
||||
|
|
@ -1245,6 +1264,7 @@ export const actions = {
|
|||
|
||||
if (havePartQuestionAnswersChanged) {
|
||||
context.commit(storeMutations.UPDATE_GLASS_PARTS, null);
|
||||
context.commit(storeMutations.RESET_SUPPORTING_ITEMS_STATE);
|
||||
context.commit(storeMutations.UPDATE_MOLDING_QUESTION_ANSWERS, null);
|
||||
context.commit(storeMutations.UPDATE_CAPABILITY_QUESTION_ANSWERS, null);
|
||||
context.commit(storeMutations.UPDATE_PAGE_DATA, {
|
||||
|
|
@ -1290,6 +1310,7 @@ export const actions = {
|
|||
|
||||
if (haveSelectedVehiclePartsChanged) {
|
||||
context.commit(storeMutations.UPDATE_GLASS_PARTS, null);
|
||||
context.commit(storeMutations.RESET_SUPPORTING_ITEMS_STATE);
|
||||
context.commit(storeMutations.UPDATE_MOLDING_QUESTION_ANSWERS, null);
|
||||
context.commit(storeMutations.UPDATE_CAPABILITY_QUESTION_ANSWERS, null);
|
||||
context.commit(storeMutations.UPDATE_PAGE_DATA, {
|
||||
|
|
@ -1319,6 +1340,7 @@ export const actions = {
|
|||
|
||||
if (haveMoldingQuestionAnswersChanged) {
|
||||
context.commit(storeMutations.UPDATE_GLASS_PARTS, null);
|
||||
context.commit(storeMutations.RESET_SUPPORTING_ITEMS_STATE);
|
||||
context.commit(storeMutations.UPDATE_CAPABILITY_QUESTION_ANSWERS, null);
|
||||
context.commit(storeMutations.UPDATE_PAGE_DATA, {
|
||||
page: fmgPageValues.CAPABILITY_QUESTIONS,
|
||||
|
|
@ -1346,6 +1368,7 @@ export const actions = {
|
|||
|
||||
if (haveCapabilityQuestionAnswersChanged) {
|
||||
context.commit(storeMutations.UPDATE_GLASS_PARTS, null);
|
||||
context.commit(storeMutations.RESET_SUPPORTING_ITEMS_STATE);
|
||||
}
|
||||
|
||||
//Save new values
|
||||
|
|
@ -1354,6 +1377,17 @@ export const actions = {
|
|||
capabilityQuestionAnswers
|
||||
);
|
||||
},
|
||||
// Quote Page
|
||||
saveQuotePageSelections(
|
||||
context,
|
||||
{ isInsuranceSelected, vapsItemsToAdd, supportingItemsToAdd }
|
||||
) {
|
||||
context.commit(storeMutations.RESET_SUPPORTING_ITEMS_STATE);
|
||||
context.commit(storeMutations.RESET_VAPS_STATE);
|
||||
context.commit(storeMutations.UPDATE_IS_INSURANCE, isInsuranceSelected);
|
||||
context.commit(storeMutations.UPDATE_VAPS, vapsItemsToAdd);
|
||||
context.commit(storeMutations.UPDATE_SUPPORTING_ITEMS, supportingItemsToAdd);
|
||||
},
|
||||
// Price order actions
|
||||
// PLACEHOLDER, WILL CHANGE WHEN PRICING END POINT IS IMPLEMENTED
|
||||
priceOrderItems(context, availableLineItems) {
|
||||
|
|
|
|||
|
|
@ -476,21 +476,6 @@ describe("Actions", () => {
|
|||
expect(response.data).toEqual("43201");
|
||||
});
|
||||
|
||||
it("resetVehicleAndDependencies action", async () => {
|
||||
// Arrange
|
||||
const context = state;
|
||||
const commit = jest.fn();
|
||||
|
||||
context.commit = commit;
|
||||
|
||||
// Act
|
||||
await actions.resetVehicleAndDependencies(context);
|
||||
|
||||
expect(commit).toBeCalledWith(storeMutations.RESET_VEHICLE_STATE);
|
||||
expect(commit).toBeCalledWith(storeMutations.RESET_DAMAGE_STATE);
|
||||
expect(commit).toBeCalledWith(storeMutations.RESET_REGISTRATION_STATE);
|
||||
});
|
||||
|
||||
it("resetDamageAndDependencies action", async () => {
|
||||
// Arrange
|
||||
const context = state;
|
||||
|
|
@ -2409,7 +2394,8 @@ describe("Getters", () => {
|
|||
funnelParentAccountNumber: "999999",
|
||||
funnelIsCoverageVerified: true,
|
||||
funnelGlassParts: null,
|
||||
funnelOtherParts: null,
|
||||
funnelSupportingItems: null,
|
||||
funnelVaps: null,
|
||||
funnelGlassToReplace: null,
|
||||
};
|
||||
|
||||
|
|
@ -2432,7 +2418,8 @@ describe("Getters", () => {
|
|||
mockStateValues.funnelIsCoverageVerified
|
||||
);
|
||||
mutations.updateGlassParts(storeState, mockStateValues.funnelGlassParts);
|
||||
mutations.updateOtherParts(storeState, mockStateValues.funnelOtherParts);
|
||||
mutations.updateSupportingItems(storeState, mockStateValues.funnelSupportingItems);
|
||||
mutations.updateVaps(storeState, mockStateValues.funnelVaps);
|
||||
mutations.updateGlassToReplace(storeState, mockStateValues.funnelGlassToReplace);
|
||||
|
||||
//Assert
|
||||
|
|
@ -2500,7 +2487,8 @@ describe("Getters", () => {
|
|||
mockStateValues.funnelIsCoverageVerified
|
||||
);
|
||||
mutations.updateGlassParts(storeState, mockStateValues.funnelGlassParts);
|
||||
mutations.updateOtherParts(storeState, mockStateValues.funnelOtherParts);
|
||||
mutations.updateSupportingItems(storeState, mockStateValues.funnelSupportingItems);
|
||||
mutations.updateVaps(storeState, mockStateValues.funnelVaps);
|
||||
mutations.updateGlassToReplace(storeState, mockStateValues.funnelGlassToReplace);
|
||||
|
||||
//Assert
|
||||
|
|
@ -2578,7 +2566,8 @@ describe("Getters", () => {
|
|||
mutations.updateParentAcctNumber(storeState, mockStateValues.parentAccountNumber);
|
||||
mutations.updateInsuranceVerifiedStatus(storeState, mockStateValues.isCoverageVerified);
|
||||
mutations.updateGlassParts(storeState, mockStateValues.glassParts);
|
||||
mutations.updateOtherParts(storeState, mockStateValues.otherParts);
|
||||
mutations.updateSupportingItems(storeState, mockStateValues.funnelSupportingItems);
|
||||
mutations.updateVaps(storeState, mockStateValues.funnelVaps);
|
||||
mutations.updateGlassToReplace(storeState, mockStateValues.glassToReplace);
|
||||
|
||||
//Assert
|
||||
|
|
@ -2682,7 +2671,8 @@ describe("Getters", () => {
|
|||
mutations.updateParentAcctNumber(storeState, mockStateValues.parentAccountNumber);
|
||||
mutations.updateInsuranceVerifiedStatus(storeState, mockStateValues.isCoverageVerified);
|
||||
mutations.updateGlassParts(storeState, mockStateValues.glassParts);
|
||||
mutations.updateOtherParts(storeState, mockStateValues.otherParts);
|
||||
mutations.updateSupportingItems(storeState, mockStateValues.funnelSupportingItems);
|
||||
mutations.updateVaps(storeState, mockStateValues.funnelVaps);
|
||||
mutations.updateGlassToReplace(storeState, mockStateValues.glassToReplace);
|
||||
|
||||
//Assert
|
||||
|
|
|
|||
Loading…
Reference in a new issue