From dc8b602e4161c126c871f657c879746154e4d32f Mon Sep 17 00:00:00 2001 From: CarlNation Date: Wed, 23 Nov 2022 09:30:54 -0500 Subject: [PATCH] CSR-944 optional vin vehicles --- src/constants/store-actions.js | 1 + .../heritage-integration/navigation-helper.js | 15 ++++++++++- src/layouts/estimate/estimate.spec.js | 19 +++++++++++++- src/layouts/estimate/estimate.vue | 23 +++++++++++++---- src/store/index.js | 19 ++++++++++++++ src/store/store.spec.js | 25 +++++++++++++++++++ 6 files changed, 95 insertions(+), 7 deletions(-) diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index b77b1456f..8f67cc048 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -12,6 +12,7 @@ const storeActions = { SET_VEHICLE: "setVehicle", GET_DAMAGE_OPTIONS: "getDamageOptions", GET_EVOX_IMAGE: "getEvoxImage", + IS_VIN_OPTIONAL_VEHICLE: "isVinOptionalVehicle", // Lookup Actions LOOKUP_VEHICLE_BY_YMMS: "lookupVehicleByYmms", diff --git a/src/helpers/heritage-integration/navigation-helper.js b/src/helpers/heritage-integration/navigation-helper.js index 9720598eb..5ac7a902e 100644 --- a/src/helpers/heritage-integration/navigation-helper.js +++ b/src/helpers/heritage-integration/navigation-helper.js @@ -3,6 +3,8 @@ import { externalUrls } from "@/router/router-constants/externalUrl-values"; import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js"; import { saveOrder } from "@/helpers/heritage-integration/order-helper.js"; 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 router from "@/router"; @@ -73,6 +75,17 @@ async function getLatestPageForRedirection() { const moldingQuestionsComponent = await getLazyLoadedComponent(fmgPageValues.MOLDING_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()) { return fmgPageValues.VEHICLE_YEAR; } else if (!vehicleModelComponent.methods.arePagePrerequisitesValid()) { @@ -96,7 +109,7 @@ async function getLatestPageForRedirection() { else if (partQuestionsComponent.methods.arePagePrerequisitesValid()) { 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; } else { diff --git a/src/layouts/estimate/estimate.spec.js b/src/layouts/estimate/estimate.spec.js index 476b8cdff..12e03c3df 100644 --- a/src/layouts/estimate/estimate.spec.js +++ b/src/layouts/estimate/estimate.spec.js @@ -87,6 +87,9 @@ describe("estimate.vue", () => { selectedVinLookupMethod: vinLookupMethodSelections.HOMEADDRESS }) + store.commit( storeMutations.UPDATE_IS_REPAIR, false ); + store.commit( storeMutations.UPDATE_MAKE, "acura" ); + //Act 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({ groupName = "estimate", + isVinOptionalVehicle = false, 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" }], funnelFooterWidget = { ForwardButtonText: "test txt" }, @@ -187,12 +204,12 @@ function setupMocks({ const apiPromise = Promise.resolve({ cmsContent }); settleAllPromises.mockImplementation(() => apiPromise); fetchCmsContentForPage.mockImplementation(() => Promise.resolve()); - const mountOptions = getMountOptions({ ...mountOptionsMockData, mixins: [baseMixin] }); mountOptions['attachTo'] = document.body; const wrapper = shallowMount(estimate, mountOptions); + wrapper.vm.isVinOptionalVehicle = isVinOptionalVehicle; return { wrapper, apiPromise }; diff --git a/src/layouts/estimate/estimate.vue b/src/layouts/estimate/estimate.vue index faf2c8ed6..8097585e6 100644 --- a/src/layouts/estimate/estimate.vue +++ b/src/layouts/estimate/estimate.vue @@ -11,7 +11,7 @@
-
+
-
+
{ + vm.isVinOptionalVehicle = resultMap.vinOptionalOptions; if (resultMap.cmsContent.FunnelFooterWidget.ForwardButtonText.includes("|")) { 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] } else @@ -184,9 +194,9 @@ export default { ); }, async forwardButtonAction() { - if (this.isRepair){ + if (this.skipVinLookup){ const zipCodeData = await this.getZipCodeData(this.serviceZipCode); - //todo: validation + await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.emailAddress, false); await this.dispatchStoreAction(storeActions.SAVE_SERVICE_LOCATION, { zipCode: this.serviceZipCode, @@ -246,6 +256,9 @@ export default { isRepair() { return store.getters.damage.isRepair; }, + skipVinLookup() { + return this.isRepair || this.isVinOptionalVehicle; + }, }, watch: { serviceZipCode() { diff --git a/src/store/index.js b/src/store/index.js index 233a57d37..4628841a4 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1100,6 +1100,25 @@ export const actions = { }, clearVin(context) { 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; } } diff --git a/src/store/store.spec.js b/src/store/store.spec.js index 8a710fe99..ca611a062 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -1611,4 +1611,29 @@ 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); + }); }); \ No newline at end of file