CSR-944 optional vin vehicles
This commit is contained in:
parent
4c9d3cacca
commit
dc8b602e41
6 changed files with 95 additions and 7 deletions
|
|
@ -12,6 +12,7 @@ const storeActions = {
|
||||||
SET_VEHICLE: "setVehicle",
|
SET_VEHICLE: "setVehicle",
|
||||||
GET_DAMAGE_OPTIONS: "getDamageOptions",
|
GET_DAMAGE_OPTIONS: "getDamageOptions",
|
||||||
GET_EVOX_IMAGE: "getEvoxImage",
|
GET_EVOX_IMAGE: "getEvoxImage",
|
||||||
|
IS_VIN_OPTIONAL_VEHICLE: "isVinOptionalVehicle",
|
||||||
|
|
||||||
// Lookup Actions
|
// Lookup Actions
|
||||||
LOOKUP_VEHICLE_BY_YMMS: "lookupVehicleByYmms",
|
LOOKUP_VEHICLE_BY_YMMS: "lookupVehicleByYmms",
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ import { externalUrls } from "@/router/router-constants/externalUrl-values";
|
||||||
import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js";
|
import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js";
|
||||||
import { saveOrder } from "@/helpers/heritage-integration/order-helper.js";
|
import { saveOrder } from "@/helpers/heritage-integration/order-helper.js";
|
||||||
import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
|
import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
|
||||||
|
import { storeActions } from "@/constants/store-actions.js";
|
||||||
|
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
|
|
||||||
|
|
@ -73,6 +75,17 @@ async function getLatestPageForRedirection() {
|
||||||
const moldingQuestionsComponent = await getLazyLoadedComponent(fmgPageValues.MOLDING_QUESTIONS);
|
const moldingQuestionsComponent = await getLazyLoadedComponent(fmgPageValues.MOLDING_QUESTIONS);
|
||||||
const capabilityQuestionsComponent = await getLazyLoadedComponent(fmgPageValues.CAPABILITY_QUESTIONS);
|
const capabilityQuestionsComponent = await getLazyLoadedComponent(fmgPageValues.CAPABILITY_QUESTIONS);
|
||||||
|
|
||||||
|
const vinOptionalVehiclePromise = store.dispatch(storeActions.IS_VIN_OPTIONAL_VEHICLE);
|
||||||
|
const promiseResultMap = [
|
||||||
|
{
|
||||||
|
resultKey: "vinOptionalOptions",
|
||||||
|
promise: vinOptionalVehiclePromise,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const resultMap = await settleAllPromises(promiseResultMap);
|
||||||
|
|
||||||
|
var isVinOptionalVehicle = resultMap.vinOptionalOptions;
|
||||||
|
|
||||||
if (!vehicleMakeComponent.methods.arePagePrerequisitesValid()) {
|
if (!vehicleMakeComponent.methods.arePagePrerequisitesValid()) {
|
||||||
return fmgPageValues.VEHICLE_YEAR;
|
return fmgPageValues.VEHICLE_YEAR;
|
||||||
} else if (!vehicleModelComponent.methods.arePagePrerequisitesValid()) {
|
} else if (!vehicleModelComponent.methods.arePagePrerequisitesValid()) {
|
||||||
|
|
@ -96,7 +109,7 @@ async function getLatestPageForRedirection() {
|
||||||
else if (partQuestionsComponent.methods.arePagePrerequisitesValid()) {
|
else if (partQuestionsComponent.methods.arePagePrerequisitesValid()) {
|
||||||
return fmgPageValues.PART_QUESTIONS;
|
return fmgPageValues.PART_QUESTIONS;
|
||||||
}
|
}
|
||||||
else if (vinLookupComponent.methods.arePagePrerequisitesValid() && !store.getters.damage.isRepair) {
|
else if (vinLookupComponent.methods.arePagePrerequisitesValid() && !store.getters.damage.isRepair && !isVinOptionalVehicle) {
|
||||||
return fmgPageValues.VIN_LOOKUP;
|
return fmgPageValues.VIN_LOOKUP;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,9 @@ describe("estimate.vue", () => {
|
||||||
selectedVinLookupMethod: vinLookupMethodSelections.HOMEADDRESS
|
selectedVinLookupMethod: vinLookupMethodSelections.HOMEADDRESS
|
||||||
})
|
})
|
||||||
|
|
||||||
|
store.commit( storeMutations.UPDATE_IS_REPAIR, false );
|
||||||
|
store.commit( storeMutations.UPDATE_MAKE, "acura" );
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
wrapper.vm.forwardButtonAction();
|
wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
|
|
@ -162,8 +165,22 @@ describe("estimate.vue", () => {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("skipVinLookup", () => {
|
||||||
|
const skipOptions = [[true, true, true],
|
||||||
|
[true, false, true],
|
||||||
|
[false, true, true],
|
||||||
|
[false, false, false]];
|
||||||
|
test.each(skipOptions)("isRepair %s and isVinOptional %s should return %s", async (isRepair, isVinOptionalVehicle, expectedVinSkip) => {
|
||||||
|
const { wrapper } = setupMocks({ isVinOptionalVehicle: isVinOptionalVehicle});
|
||||||
|
store.commit( storeMutations.UPDATE_IS_REPAIR, isRepair);
|
||||||
|
|
||||||
|
expect(wrapper.vm.skipVinLookup).toEqual(expectedVinSkip);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
function setupMocks({
|
function setupMocks({
|
||||||
groupName = "estimate",
|
groupName = "estimate",
|
||||||
|
isVinOptionalVehicle = false,
|
||||||
cmsQuestionText = "Let's get your VIN. Or we can look it up for you!",
|
cmsQuestionText = "Let's get your VIN. Or we can look it up for you!",
|
||||||
cmsAnswers = [{ Name: "Provide my VIN manually Most specific to your vehicle" }, { Name: "Provide my license plate # Most accurate VIN match" }, { Name: "Provide my home address Most convenient VIN match" }],
|
cmsAnswers = [{ Name: "Provide my VIN manually Most specific to your vehicle" }, { Name: "Provide my license plate # Most accurate VIN match" }, { Name: "Provide my home address Most convenient VIN match" }],
|
||||||
funnelFooterWidget = { ForwardButtonText: "test txt" },
|
funnelFooterWidget = { ForwardButtonText: "test txt" },
|
||||||
|
|
@ -188,11 +205,11 @@ function setupMocks({
|
||||||
settleAllPromises.mockImplementation(() => apiPromise);
|
settleAllPromises.mockImplementation(() => apiPromise);
|
||||||
fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
|
fetchCmsContentForPage.mockImplementation(() => Promise.resolve());
|
||||||
|
|
||||||
|
|
||||||
const mountOptions = getMountOptions({ ...mountOptionsMockData, mixins: [baseMixin] });
|
const mountOptions = getMountOptions({ ...mountOptionsMockData, mixins: [baseMixin] });
|
||||||
mountOptions['attachTo'] = document.body;
|
mountOptions['attachTo'] = document.body;
|
||||||
|
|
||||||
const wrapper = shallowMount(estimate, mountOptions);
|
const wrapper = shallowMount(estimate, mountOptions);
|
||||||
|
wrapper.vm.isVinOptionalVehicle = isVinOptionalVehicle;
|
||||||
|
|
||||||
return { wrapper, apiPromise };
|
return { wrapper, apiPromise };
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@
|
||||||
<vehicleBanner cmsWidgetName="VehicleBannerWidget" />
|
<vehicleBanner cmsWidgetName="VehicleBannerWidget" />
|
||||||
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" />
|
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" />
|
||||||
<div class="fade-on-route-transition sub-container make-tall">
|
<div class="fade-on-route-transition sub-container make-tall">
|
||||||
<div v-if="!isRepair">
|
<div v-if="!skipVinLookup">
|
||||||
<alert
|
<alert
|
||||||
class="vinLookupMethodHeading"
|
class="vinLookupMethodHeading"
|
||||||
cmsWidgetName="AlertVinLookupQuestion"
|
cmsWidgetName="AlertVinLookupQuestion"
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
validationRules="option-required"
|
validationRules="option-required"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="isRepair">
|
<div v-if="skipVinLookup">
|
||||||
<alert
|
<alert
|
||||||
class="my-4"
|
class="my-4"
|
||||||
cmsWidgetName="AlertQuoteReady"
|
cmsWidgetName="AlertQuoteReady"
|
||||||
|
|
@ -136,25 +136,35 @@ export default {
|
||||||
emailAddress: this.getEmailFromStore(),
|
emailAddress: this.getEmailFromStore(),
|
||||||
displayInvalidZipAlert: false,
|
displayInvalidZipAlert: false,
|
||||||
displayNonServiceableZipAlert: false,
|
displayNonServiceableZipAlert: false,
|
||||||
|
isVinOptionalVehicle: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
async beforeRouteEnter(to, from, next) {
|
async beforeRouteEnter(to, from, next) {
|
||||||
//Call APIs
|
//Call APIs
|
||||||
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
|
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
|
||||||
|
const vinOptionalVehiclePromise = store.dispatch(storeActions.IS_VIN_OPTIONAL_VEHICLE);
|
||||||
|
|
||||||
//Settle promises and get results
|
//Settle promises and get results
|
||||||
const promiseResultMap = [
|
const promiseResultMap = [
|
||||||
{
|
{
|
||||||
resultKey: "cmsContent",
|
resultKey: "cmsContent",
|
||||||
promise: cmsContentPromise,
|
promise: cmsContentPromise,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
resultKey: "vinOptionalOptions",
|
||||||
|
promise: vinOptionalVehiclePromise,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const resultMap = await settleAllPromises(promiseResultMap);
|
const resultMap = await settleAllPromises(promiseResultMap);
|
||||||
|
|
||||||
next((vm) => {
|
next((vm) => {
|
||||||
|
vm.isVinOptionalVehicle = resultMap.vinOptionalOptions;
|
||||||
if (resultMap.cmsContent.FunnelFooterWidget.ForwardButtonText.includes("|"))
|
if (resultMap.cmsContent.FunnelFooterWidget.ForwardButtonText.includes("|"))
|
||||||
{
|
{
|
||||||
const forwardTextOption = resultMap.cmsContent.FunnelFooterWidget.ForwardButtonText.split("|");
|
const forwardTextOption = resultMap.cmsContent.FunnelFooterWidget.ForwardButtonText.split("|");
|
||||||
if (store.getters.damage.isRepair){
|
if (store.getters.damage.isRepair || vm.isVinOptionalVehicle){
|
||||||
resultMap.cmsContent.FunnelFooterWidget.ForwardButtonText = forwardTextOption[1]
|
resultMap.cmsContent.FunnelFooterWidget.ForwardButtonText = forwardTextOption[1]
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -184,9 +194,9 @@ export default {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
async forwardButtonAction() {
|
async forwardButtonAction() {
|
||||||
if (this.isRepair){
|
if (this.skipVinLookup){
|
||||||
const zipCodeData = await this.getZipCodeData(this.serviceZipCode);
|
const zipCodeData = await this.getZipCodeData(this.serviceZipCode);
|
||||||
//todo: validation
|
|
||||||
await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.emailAddress, false);
|
await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.emailAddress, false);
|
||||||
await this.dispatchStoreAction(storeActions.SAVE_SERVICE_LOCATION, {
|
await this.dispatchStoreAction(storeActions.SAVE_SERVICE_LOCATION, {
|
||||||
zipCode: this.serviceZipCode,
|
zipCode: this.serviceZipCode,
|
||||||
|
|
@ -246,6 +256,9 @@ export default {
|
||||||
isRepair() {
|
isRepair() {
|
||||||
return store.getters.damage.isRepair;
|
return store.getters.damage.isRepair;
|
||||||
},
|
},
|
||||||
|
skipVinLookup() {
|
||||||
|
return this.isRepair || this.isVinOptionalVehicle;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
serviceZipCode() {
|
serviceZipCode() {
|
||||||
|
|
|
||||||
|
|
@ -1100,6 +1100,25 @@ export const actions = {
|
||||||
},
|
},
|
||||||
clearVin(context) {
|
clearVin(context) {
|
||||||
context.commit(storeMutations.UPDATE_VEHICLE_VIN, null);
|
context.commit(storeMutations.UPDATE_VEHICLE_VIN, null);
|
||||||
|
},
|
||||||
|
|
||||||
|
isVinOptionalVehicle(context){
|
||||||
|
switch((context.state.order.vehicle.make).toLowerCase()) {
|
||||||
|
case "mercedes benz":
|
||||||
|
case "volkswagen":
|
||||||
|
case "audi":
|
||||||
|
case "porsche":
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((context.state.order.vehicle.make).toLowerCase() === "ford" && context.state.order.vehicle.year >= 2018)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if ((context.state.order.vehicle.make).toLowerCase() === "bmw" && context.state.order.vehicle.year <= 2017)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1612,3 +1612,28 @@ describe("Getters", () => {
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("isVinOptionalVehicle", () => {
|
||||||
|
const testVehicles = [["2017", "acura", false],
|
||||||
|
["2017", "ford", false],
|
||||||
|
["2018", "ford", true],
|
||||||
|
["2018", "bmw", false],
|
||||||
|
["2017", "bmw", true],
|
||||||
|
["2016", "bmw", true],
|
||||||
|
["2016", "mercedes benz", true],
|
||||||
|
["2016", "volkswagen", true],
|
||||||
|
["2016", "audi", true],
|
||||||
|
["2016", "porsche", true]];
|
||||||
|
test.each(testVehicles)("%s %s should skip vin lookup is %s", async (year, make, expectedVinSkip) => {
|
||||||
|
const context = state;
|
||||||
|
|
||||||
|
context.state = {
|
||||||
|
order: {
|
||||||
|
vehicle: { year: year, make: make}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var vinOptionalResult = actions.isVinOptionalVehicle(context);
|
||||||
|
expect(vinOptionalResult).toEqual(expectedVinSkip);
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue