From 426f1e74456673a0f85968cc463270770e2eae31 Mon Sep 17 00:00:00 2001 From: Bryan Mauger Date: Thu, 9 Jun 2022 10:07:39 -0400 Subject: [PATCH 1/6] Update modal z-index so hamburger button doesn't show over top of modal. --- src/common-components/loading-modal/loading-modal.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common-components/loading-modal/loading-modal.vue b/src/common-components/loading-modal/loading-modal.vue index d06392755..2bcdc9c31 100644 --- a/src/common-components/loading-modal/loading-modal.vue +++ b/src/common-components/loading-modal/loading-modal.vue @@ -77,7 +77,7 @@ export default { left: 0; right: 0; bottom: 0; - z-index: 1055; + z-index: 1057; width: 100%; height: 100%; overflow-x: hidden; From 53b925b67883cec4e4296ba83a0ddf29b082bd2b Mon Sep 17 00:00:00 2001 From: Donielle Austin Date: Thu, 9 Jun 2022 10:59:38 -0400 Subject: [PATCH 2/6] unit test estimate --- src/helpers/unit-test-helper.js | 1 + src/layouts/estimate/estimate.spec.js | 187 ++++++++++++++++++++++++++ src/mixins/analytics-mixin.spec.js | 26 ++++ 3 files changed, 214 insertions(+) create mode 100644 src/layouts/estimate/estimate.spec.js diff --git a/src/helpers/unit-test-helper.js b/src/helpers/unit-test-helper.js index 4f4214120..df697a022 100644 --- a/src/helpers/unit-test-helper.js +++ b/src/helpers/unit-test-helper.js @@ -59,6 +59,7 @@ export function getMountOptions(mockData) { const global = { mocks: mocks, + mixins: mockData.mixins, stubs: { Form } }; diff --git a/src/layouts/estimate/estimate.spec.js b/src/layouts/estimate/estimate.spec.js new file mode 100644 index 000000000..5f82fa508 --- /dev/null +++ b/src/layouts/estimate/estimate.spec.js @@ -0,0 +1,187 @@ +//Components +import estimate from "@/layouts/estimate/estimate.vue"; +import { shallowMount } from "@vue/test-utils"; +import { getMountOptions } from "@/helpers/unit-test-helper.js"; + +//Supporting files +import { storeKey } from "vuex"; +import store from "@/store"; +import { storeMutations } from "@/constants/store-mutations"; +import { settleAllPromises } from "@/helpers/layout-helper.js"; +import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; +import baseMixin from "../../mixins/base-mixin"; +import { vinLookupMethodSelections } from "@/constants/vin-lookup-method-selections.js"; + + +// Mock our module for promises. +jest.mock("@/helpers/layout-helper.js", () => ({ + settleAllPromises: jest.fn(), +})); + +// Mock fetchCmsContentForPage +jest.mock("@/helpers/cms-content-helper", () => ({ + fetchCmsContentForPage: jest.fn(), +})); + +describe("estimate.vue", () => { + test("Selected vin option is emitted upon selection.", async () => { + + //Arrange + const { wrapper } = setupMocks({ modelValueProp: ["Provide my VIN manually most specific to your vehicle"] }); + + //Act + wrapper.setValue({ modelValue: ["Provide my license plate # Most accurate VIN match"] }); + await wrapper.vm.$nextTick(); + + //Assesrt + expect(wrapper.emitted()["update:modelValue"][0]).toEqual([{ modelValue: ["Provide my license plate # Most accurate VIN match"] }]); + }); + test("isRepair is set to true, arePagePrerequisitesValid should return true", async () => { + + //Arrange + const { wrapper } = setupMocks({}); + + //Act + store.commit( storeMutations.UPDATE_IS_REPAIR, true ); + + let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); + + //Assert + expect(arePagePrerequisitesValid).toBe(true); + }); + test("isRepair is set to false, arePagePrerequisitesValid should return true", async () => { + + //Arrange + const { wrapper } = setupMocks({}); + + //Act + store.commit( storeMutations.UPDATE_IS_REPAIR, false ); + + let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); + + //Assert + expect(arePagePrerequisitesValid).toBe(true); + }); + test("isRepair is set to null, arePagePrerequisitesValid should return false", async () => { + + //Arrange + const { wrapper } = setupMocks({}); + + //Act + store.commit( storeMutations.UPDATE_IS_REPAIR, null ); + + let arePagePrerequisitesValid = wrapper.vm.arePagePrerequisitesValid(); + + //Assert + expect(arePagePrerequisitesValid).toBe(false); + }); + + test("After selecting provide my home address on ForwardButtonAction triggers a router.navigate", async () => { + + //Arrange + const { wrapper } = setupMocks({}); + await wrapper.setData({ + selectedValues: [vinLookupMethodSelections.HOMEADDRESS] + }) + + //Act + wrapper.vm.forwardButtonAction(); + + //Assert + expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); + + }); + + test("After selecting provide my manual vin on ForwardButtonAction triggers a router.navigate", async () => { + + //Arrange + const { wrapper } = setupMocks({}); + await wrapper.setData({ + selectedValues: [vinLookupMethodSelections.MANUALVIN] + }) + + //Act + wrapper.vm.forwardButtonAction(); + + //Assert + expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); + + }); + + test("BackButtonAction triggers a router.navigate change", async () => { + + //Arrange + const { wrapper } = setupMocks({}); + + //Act + estimate.beforeRouteEnter.call( + wrapper.vm, + { query: { fmgPage: "estimate" } }, + undefined, + (c) => c(wrapper.vm) + ); + + wrapper.vm.backButtonAction(); + + //Assert + expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); + }); + + test("Provide my license plate on ForwardButtonAction triggers a router.navigate", async () => { + + //Arrange + const { wrapper } = setupMocks({}); + await wrapper.setData({ + selectedValues: [vinLookupMethodSelections.LICENSEPLATE] + }) + + //Act + wrapper.vm.forwardButtonAction(); + + //Assert + expect(wrapper.vm.$router.navigate).toHaveBeenCalled(); + + }); + +}); + +function setupMocks({ + modelValueProp = ["Provide my VIN manually most specific to your vehicle"], + isMultiSelect = false, + groupName = "estimate", + 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" }], + dataFromApi = [], + mountOptionsMockData = { + router: { + navigate: jest.fn(), + }, + }, +}) { + + //Mock CMS Content + const cmsContent = { + groupName: groupName, + QuestionText: cmsQuestionText, + Answers: cmsAnswers + }; + + //Mock props + const mockMixin = { + methods: { + getCmsContent: jest.fn() + } + } + + 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); + + return { wrapper, apiPromise }; + +} \ No newline at end of file diff --git a/src/mixins/analytics-mixin.spec.js b/src/mixins/analytics-mixin.spec.js index db773da56..32bd3c397 100644 --- a/src/mixins/analytics-mixin.spec.js +++ b/src/mixins/analytics-mixin.spec.js @@ -126,4 +126,30 @@ describe("analyticsMixin.js", () => { //Assert expect(obj!=null); }); + test("Obj method name does not include bound", () => { + //Arrange + const obj = {baseMethodName:"testMethodName", data:"testData"}; + const method = {name:"testMethodName", data:"testData" } + const action = "testAction"; + + //Act + analyticsMixin.methods.prependActionToMethod(obj, method, action); + + + //Assert + expect(method.name.startsWith("bound ")).toBe(false); + }); + test("Prepended action does not include bound", () => { + //Arrange + const obj = {baseMethodName:"testMethodName", data:"testData"}; + const method = {name:"testMethodName", data:"testData" } + const action = "testAction"; + + //Act + analyticsMixin.methods.prependActionToMethod(obj, method, action); + + + //Assert + expect(action.startsWith("bound ")).toBe(false); + }); }); \ No newline at end of file From 27dae3e8896b3771dd692952afc3afb82602ba78 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Thu, 9 Jun 2022 15:05:58 -0400 Subject: [PATCH 3/6] vin-lookup-tests | added some tests --- src/layouts/vin-lookup/vin-lookup.spec.js | 140 ++++++++++++++++++---- 1 file changed, 116 insertions(+), 24 deletions(-) diff --git a/src/layouts/vin-lookup/vin-lookup.spec.js b/src/layouts/vin-lookup/vin-lookup.spec.js index ce2ac71af..8574b2505 100644 --- a/src/layouts/vin-lookup/vin-lookup.spec.js +++ b/src/layouts/vin-lookup/vin-lookup.spec.js @@ -46,7 +46,6 @@ describe("vin-lookup.vue", () => { it("Should update the funnel-footer forward button when VIN is changed", (done) => { //Arrange const { wrapper } = setupMocks({ }); - wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn(); //Act wrapper.setData({vin: "newValue"}); //Assert @@ -60,25 +59,6 @@ describe("vin-lookup.vue", () => { it("Should call navigateForward() if the store carId matches the vin response carId and forward button is clicked", async () => { // Arrange const { wrapper } = setupMocks({ }); - const zipValidationApiResponse = { - data: { - isServiceable: true - } - }; - const vehicleLookupApiResponse = { - data: { - carId: 'initial carId' - } - }; - - const zipPromise = Promise.resolve(zipValidationApiResponse); - const vinPromise = Promise.resolve(vehicleLookupApiResponse); - - wrapper.vm.validateZip = jest.fn().mockImplementation(() => zipPromise); - wrapper.vm.lookupVehicle = jest.fn().mockImplementation(() => vinPromise); - - wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn(); - wrapper.vm.$refs.funnelFooter.removeLoader = jest.fn(); wrapper.vm.navigateForward = jest.fn(); // Act @@ -87,12 +67,98 @@ describe("vin-lookup.vue", () => { //Assert expect(wrapper.vm.navigateForward).toHaveBeenCalled(); }); + + it("Should not call navigateForward() if the store carId does not match the vin response carId and forward button is clicked", async () => { + // Arrange + const { wrapper } = setupMocks({ }); + const vehicleLookupApiResponse = { + data: { + carId: 'new carId' // does not match the store value + } + }; + const vinPromise = Promise.resolve(vehicleLookupApiResponse); + + wrapper.vm.lookupVehicle = jest.fn().mockImplementation(() => vinPromise); + + wrapper.vm.navigateForward = jest.fn(); + + // Act + await wrapper.vm.forwardButtonAction(); + + //Assert + expect(wrapper.vm.navigateForward).not.toHaveBeenCalled(); + }); + + it("Should call navigateForward() if the store carId does not match the vin response carId but does match previously enterted carId and forward button is clicked", async () => { + // Arrange + const { wrapper } = setupMocks({ }); + const vehicleLookupApiResponse = { + data: { + carId: 'new carId' // does not match the store value + } + }; + const vinPromise = Promise.resolve(vehicleLookupApiResponse); + + wrapper.vm.lookupVehicle = jest.fn().mockImplementation(() => vinPromise); + wrapper.vm.navigateForward = jest.fn(); + + wrapper.vm.previouslyEnteredCarId = 'new carId'; + + // Act + await wrapper.vm.forwardButtonAction(); + + //Assert + expect(wrapper.vm.navigateForward).toHaveBeenCalled(); + }); + + it("Should not call navigateForward() if zip service returns a non-serviceable flag", async () => { + // Arrange + const { wrapper } = setupMocks({ }); + const zipValidationApiResponse = { + data: { + isServiceable: false + } + }; + + const zipPromise = Promise.resolve(zipValidationApiResponse); + + wrapper.vm.validateZip = jest.fn().mockImplementation(() => zipPromise); + wrapper.vm.navigateForward = jest.fn(); + + wrapper.vm.previouslyEnteredCarId = 'new carId'; + + // Act + await wrapper.vm.forwardButtonAction(); + + //Assert + expect(wrapper.vm.navigateForward).not.toHaveBeenCalled(); + }); + + it("Should not call navigateForward() when forward button is clicked but lookupVehicle errors out.", async () => { + // Arrange + const { wrapper } = setupMocks({ }); + const vehicleLookupApiResponse = { + data: { + carId: 'new carId' // does not match the store value + } + }; + const vinPromise = Promise.reject(vehicleLookupApiResponse); + + wrapper.vm.lookupVehicle = jest.fn().mockImplementation(() => vinPromise); + wrapper.vm.navigateForward = jest.fn(); + + wrapper.vm.previouslyEnteredCarId = 'new carId'; + + // Act + await wrapper.vm.forwardButtonAction(); + + //Assert + expect(wrapper.vm.navigateForward).not.toHaveBeenCalled(); + }); }); function setupMocks({ customMountOptions }) { - - const mountOptions = getMountOptions({}); const finalMountOptions = Object.assign(mountOptions, customMountOptions); @@ -100,10 +166,36 @@ function setupMocks({ customMountOptions }) { finalMountOptions.global.mocks["$store"] = store; finalMountOptions.global.mixins = [mockMixin]; finalMountOptions['attachTo'] = document.body; // append wrapper to document.body to test DOM methods - + const wrapper = shallowMount(vinLookup, finalMountOptions); + mockOutPromises(wrapper); + mockOutStubFunctions(wrapper); return { wrapper }; - } +} + +function mockOutPromises(wrapper) { + const zipValidationApiResponse = { + data: { + isServiceable: true + } + }; + const vehicleLookupApiResponse = { + data: { + carId: 'initial carId' + } + }; + + const zipPromise = Promise.resolve(zipValidationApiResponse); + const vinPromise = Promise.resolve(vehicleLookupApiResponse); + + wrapper.vm.validateZip = jest.fn().mockImplementation(() => zipPromise); + wrapper.vm.lookupVehicle = jest.fn().mockImplementation(() => vinPromise); +} + +function mockOutStubFunctions(wrapper) { + wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn(); + wrapper.vm.$refs.funnelFooter.removeLoader = jest.fn(); +} const mockMixin = { methods: { From 06ca68cff365660d73e5bb46de9ba90a04ca644f Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Thu, 9 Jun 2022 15:07:30 -0400 Subject: [PATCH 4/6] vin-lookup-tests | fixed error in vin-lookup --- src/layouts/vin-lookup/vin-lookup.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index 6c0f305b5..9dc81f719 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -292,8 +292,11 @@ export default { this.vinNotFound = true; this.$refs.funnelFooter.removeLoader(); this.noServiceZip = false; - return; + return false; }); + if (!vehicleLookupResponse) { + return; + } if (!zipValidationResponse.data.isServiceable) { this.customAlertData.zip = this.zip; this.$refs.funnelFooter.removeLoader(); From ece57def136c0c18dd507daf6ff32268f28dfa5e Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Thu, 9 Jun 2022 16:45:36 -0400 Subject: [PATCH 5/6] Halfway through - highly notated fields --- src/layouts/vin-lookup/vin-lookup.vue | 56 +++++++++++++-------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index 9dc81f719..74eb2352e 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -209,9 +209,11 @@ export default { return text; }, MatchedDifferentVehicleAlertBody(){ - const text = this.getCmsContent("MatchedDifferentVehicle", - "BodyText").replaceAll("{custom:damage}", getDamageString()).replaceAll("{custom:vinlookupYear}", this.customAlertData?.vehicleInfo?.year).replaceAll("{custom:vinlookupMake}", this.customAlertData?.vehicleInfo?.make).replaceAll("{custom:vinlookupModel}", - this.customAlertData?.vehicleInfo?.model); + const text = this.getCmsContent("MatchedDifferentVehicle", "BodyText") + .replaceAll("{custom:damage}", getDamageString()) + .replaceAll("{custom:vinlookupYear}", this.customAlertData?.vehicleInfo?.year) + .replaceAll("{custom:vinlookupMake}", this.customAlertData?.vehicleInfo?.make) + .replaceAll("{custom:vinlookupModel}", this.customAlertData?.vehicleInfo?.model); return text; }, @@ -287,47 +289,43 @@ export default { async forwardButtonAction() { const zipValidation = this.validateZip(this.zip); const vehicleLookup = this.lookupVehicle(this.vin); + // await responses below to let above service calls run asynchronously const zipValidationResponse = await zipValidation; const vehicleLookupResponse = await vehicleLookup.catch(() => { - this.vinNotFound = true; - this.$refs.funnelFooter.removeLoader(); - this.noServiceZip = false; return false; }); - if (!vehicleLookupResponse) { - return; - } - if (!zipValidationResponse.data.isServiceable) { - this.customAlertData.zip = this.zip; + // validations + if (!vehicleLookupResponse) { // vehicle response is null or false (it fails) + this.vinNotFound = true; // used to determine alerts that show this.$refs.funnelFooter.removeLoader(); - this.noServiceZip = true; - this.invalidZip = this.zip; - return; - } - this.isCarIdDifferent = vehicleLookupResponse.data.carId !== store.getters.vehicle.carId; - - if (this.isCarIdDifferent && (vehicleLookupResponse.data.carId !== this.previouslyEnteredCarId)) { - this.previouslyEnteredCarId = vehicleLookupResponse.data.carId; - this.noServiceZip = false; - this.customAlertData.vehicleInfo = vehicleLookupResponse.data; + this.noServiceZip = false; // used to determine alerts that show + } else if (!zipValidationResponse.data.isServiceable) { // zip response shows zip is not serviceable + this.$refs.funnelFooter.removeLoader(); + this.noServiceZip = true; // used to determine alerts that show + this.invalidZip = this.zip; // used to populate the alert + } else if (vehicleLookupResponse.data.carId !== store.getters.vehicle.carId && // response does not match what was selected previously in the flow && + (vehicleLookupResponse.data.carId !== this.previouslyEnteredCarId)) // response does not match what was returned from a previous response + { + this.isCarIdDifferent = true; // because vehicleLookupResponse.data.carId !== store.getters.vehicle.carId + this.previouslyEnteredCarId = vehicleLookupResponse.data.carId; // tracks if car ID is different since last time we got a vehicle lookup response + this.noServiceZip = false; // used to determine alerts that show + this.customAlertData.vehicleInfo = vehicleLookupResponse.data; // populate the vehicle info alert info this.$refs.funnelFooter.updateButtonText(`Continue with ${vehicleLookupResponse.data.year} ${vehicleLookupResponse.data.make} ${vehicleLookupResponse.data.model}`); - this.isVinValid = true; + this.isVinValid = true; //I don't think this line is needed this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(vehicleLookupResponse.data.carId); this.$refs.funnelFooter.removeLoader(); - this.isCarIdDifferent = true; - return; + } else { + this.isCarIdDifferent = vehicleLookupResponse.data.carId !== store.getters.vehicle.carId; // do I need this line? -- I do + this.updateStore(vehicleLookupResponse.data, zipValidationResponse.data); + this.navigateForward(); } - this.updateStore(vehicleLookupResponse.data, zipValidationResponse.data); - this.navigateForward(); }, navigateForward(){ - if(this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle){ + if(this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle){ // does it matter if the carId is different here? would we ever go forward if we didn't have glass match? -- it does this.$router.navigateAfterSave(this.navigationScenarios.CLICKED_FORWARD, this.$route, {}, { displayVehicleChangeAlert: true }, {}); - return; } else { this.$refs.loadingModal.showModal(); navigateAfterSaveToHeritageFunnel(this.$route); - return; } }, validateZip(zip) { From 9e79accb3aa666b110cf8a9104c37ba4e78d2186 Mon Sep 17 00:00:00 2001 From: Scott Kiener Date: Thu, 9 Jun 2022 16:45:36 -0400 Subject: [PATCH 6/6] Revert "Halfway through - highly notated fields" This reverts commit ece57def136c0c18dd507daf6ff32268f28dfa5e. --- src/layouts/vin-lookup/vin-lookup.vue | 56 ++++++++++++++------------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index 74eb2352e..9dc81f719 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -209,11 +209,9 @@ export default { return text; }, MatchedDifferentVehicleAlertBody(){ - const text = this.getCmsContent("MatchedDifferentVehicle", "BodyText") - .replaceAll("{custom:damage}", getDamageString()) - .replaceAll("{custom:vinlookupYear}", this.customAlertData?.vehicleInfo?.year) - .replaceAll("{custom:vinlookupMake}", this.customAlertData?.vehicleInfo?.make) - .replaceAll("{custom:vinlookupModel}", this.customAlertData?.vehicleInfo?.model); + const text = this.getCmsContent("MatchedDifferentVehicle", + "BodyText").replaceAll("{custom:damage}", getDamageString()).replaceAll("{custom:vinlookupYear}", this.customAlertData?.vehicleInfo?.year).replaceAll("{custom:vinlookupMake}", this.customAlertData?.vehicleInfo?.make).replaceAll("{custom:vinlookupModel}", + this.customAlertData?.vehicleInfo?.model); return text; }, @@ -289,43 +287,47 @@ export default { async forwardButtonAction() { const zipValidation = this.validateZip(this.zip); const vehicleLookup = this.lookupVehicle(this.vin); - // await responses below to let above service calls run asynchronously const zipValidationResponse = await zipValidation; const vehicleLookupResponse = await vehicleLookup.catch(() => { + this.vinNotFound = true; + this.$refs.funnelFooter.removeLoader(); + this.noServiceZip = false; return false; }); - // validations - if (!vehicleLookupResponse) { // vehicle response is null or false (it fails) - this.vinNotFound = true; // used to determine alerts that show + if (!vehicleLookupResponse) { + return; + } + if (!zipValidationResponse.data.isServiceable) { + this.customAlertData.zip = this.zip; this.$refs.funnelFooter.removeLoader(); - this.noServiceZip = false; // used to determine alerts that show - } else if (!zipValidationResponse.data.isServiceable) { // zip response shows zip is not serviceable - this.$refs.funnelFooter.removeLoader(); - this.noServiceZip = true; // used to determine alerts that show - this.invalidZip = this.zip; // used to populate the alert - } else if (vehicleLookupResponse.data.carId !== store.getters.vehicle.carId && // response does not match what was selected previously in the flow && - (vehicleLookupResponse.data.carId !== this.previouslyEnteredCarId)) // response does not match what was returned from a previous response - { - this.isCarIdDifferent = true; // because vehicleLookupResponse.data.carId !== store.getters.vehicle.carId - this.previouslyEnteredCarId = vehicleLookupResponse.data.carId; // tracks if car ID is different since last time we got a vehicle lookup response - this.noServiceZip = false; // used to determine alerts that show - this.customAlertData.vehicleInfo = vehicleLookupResponse.data; // populate the vehicle info alert info + this.noServiceZip = true; + this.invalidZip = this.zip; + return; + } + this.isCarIdDifferent = vehicleLookupResponse.data.carId !== store.getters.vehicle.carId; + + if (this.isCarIdDifferent && (vehicleLookupResponse.data.carId !== this.previouslyEnteredCarId)) { + this.previouslyEnteredCarId = vehicleLookupResponse.data.carId; + this.noServiceZip = false; + this.customAlertData.vehicleInfo = vehicleLookupResponse.data; this.$refs.funnelFooter.updateButtonText(`Continue with ${vehicleLookupResponse.data.year} ${vehicleLookupResponse.data.make} ${vehicleLookupResponse.data.model}`); - this.isVinValid = true; //I don't think this line is needed + this.isVinValid = true; this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(vehicleLookupResponse.data.carId); this.$refs.funnelFooter.removeLoader(); - } else { - this.isCarIdDifferent = vehicleLookupResponse.data.carId !== store.getters.vehicle.carId; // do I need this line? -- I do - this.updateStore(vehicleLookupResponse.data, zipValidationResponse.data); - this.navigateForward(); + this.isCarIdDifferent = true; + return; } + this.updateStore(vehicleLookupResponse.data, zipValidationResponse.data); + this.navigateForward(); }, navigateForward(){ - if(this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle){ // does it matter if the carId is different here? would we ever go forward if we didn't have glass match? -- it does + if(this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle){ this.$router.navigateAfterSave(this.navigationScenarios.CLICKED_FORWARD, this.$route, {}, { displayVehicleChangeAlert: true }, {}); + return; } else { this.$refs.loadingModal.showModal(); navigateAfterSaveToHeritageFunnel(this.$route); + return; } }, validateZip(zip) {