From f7bbd024a6e2a2b59242bd9d2359f58c856e017e Mon Sep 17 00:00:00 2001 From: Jason Wheeler Date: Mon, 8 May 2023 16:48:00 -0400 Subject: [PATCH 1/8] fixed bug --- src/store/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index c6eef029..b545d32c 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1205,8 +1205,8 @@ export const useMainStore = defineStore({ }, resetDamagePartsAndDependencies() { - this.resetDamageState(); - this.resetGlassPartsState(); + //this.resetDamageState(); + //this.resetGlassPartsState(); this.resetSupportingItemsState(); this.resetVapsState(); }, From ff0d87717036ad0cc08b63d43a4fcd90e0093272 Mon Sep 17 00:00:00 2001 From: DavidAtSafelite Date: Wed, 10 May 2023 08:52:10 -0400 Subject: [PATCH 2/8] Changes for SSR-442, Defect SSR-463 and a little bit of cleanup for SSR-290 --- src/layouts/entry-page/entry-page.vue | 7 +- src/layouts/vehicle-damage/vehicle-damage.vue | 5 +- src/layouts/vehicle-parts/vehicle-parts.vue | 4 +- src/layouts/welcome-page/welcome-page.vue | 94 ++++++++++--------- src/store/index.js | 78 +++++++++------ 5 files changed, 107 insertions(+), 81 deletions(-) diff --git a/src/layouts/entry-page/entry-page.vue b/src/layouts/entry-page/entry-page.vue index 8fa467d5..4f06bb03 100644 --- a/src/layouts/entry-page/entry-page.vue +++ b/src/layouts/entry-page/entry-page.vue @@ -147,6 +147,11 @@ this.mainStore.issConfig.disabledFields.policyNumber = true; break; + case "policyzipcode": + this.mainStore.order.policy.policyZipCode = value; + this.mainStore.issConfig.disabledFields.policyZipCode = true; + break; + case "lossdate": // NOTE: May need some date parsing logic in here depending on client. this.mainStore.order.policy.dateOfLoss = value; @@ -167,7 +172,7 @@ break; } } - }, + } }, computed:{ }, diff --git a/src/layouts/vehicle-damage/vehicle-damage.vue b/src/layouts/vehicle-damage/vehicle-damage.vue index f01ff4a4..5106203c 100644 --- a/src/layouts/vehicle-damage/vehicle-damage.vue +++ b/src/layouts/vehicle-damage/vehicle-damage.vue @@ -95,9 +95,12 @@ export default { name: "vehicle-damage", mixins: [BaseFormMixin], async beforeRouteEnter(to, from, next) { + + const store = useMainStore(); + // Call APIs const cmsContentPromise = fetchCmsContentForPage(to.query.issPage); - const damageOptionsPromise = useMainStore().getDamageOptions(useMainStore().order.vehicle.carId); + const damageOptionsPromise = store.getDamageOptions(store.order.vehicle.carId); // Settle promises and get results const promiseResultMap = [ diff --git a/src/layouts/vehicle-parts/vehicle-parts.vue b/src/layouts/vehicle-parts/vehicle-parts.vue index 08caf800..83d4077f 100644 --- a/src/layouts/vehicle-parts/vehicle-parts.vue +++ b/src/layouts/vehicle-parts/vehicle-parts.vue @@ -108,7 +108,7 @@ data() { }, computed: { isForwardActionDisabled() { - return this.selectedGlassPartNumbers.length !== this.PartsFromApi.partsOrQuestions.length + return this.selectedGlassPartNumbers?.length !== this.PartsFromApi.partsOrQuestions?.length }, selectedGlassPartNumbers() { // Compile all selected parts from the page. @@ -124,7 +124,7 @@ computed: { const partsData = this.PartsFromApi; // Map API result data, to vehicle-parts data structure - const mappedData = partsData.partsOrQuestions.map((g) => { + const mappedData = partsData.partsOrQuestions?.map((g) => { return { glassName: g.glassName, glassLocation: g.glassLocation, diff --git a/src/layouts/welcome-page/welcome-page.vue b/src/layouts/welcome-page/welcome-page.vue index b70a24eb..b2e53f00 100644 --- a/src/layouts/welcome-page/welcome-page.vue +++ b/src/layouts/welcome-page/welcome-page.vue @@ -18,13 +18,15 @@ validationRules="policy-number-required" /> -
+
+ ref="policyZip" + validationRules="policy-zip-required|policy-zip-format" />
@@ -152,51 +154,49 @@ diff --git a/src/layouts/vehicle-selection/model-question/model-question.vue b/src/layouts/vehicle-selection/model-question/model-question.vue new file mode 100644 index 00000000..e1cb2a75 --- /dev/null +++ b/src/layouts/vehicle-selection/model-question/model-question.vue @@ -0,0 +1,77 @@ + + + diff --git a/src/layouts/vehicle-selection/style-question/style-question.vue b/src/layouts/vehicle-selection/style-question/style-question.vue new file mode 100644 index 00000000..b957d923 --- /dev/null +++ b/src/layouts/vehicle-selection/style-question/style-question.vue @@ -0,0 +1,76 @@ + + + diff --git a/src/layouts/vehicle-selection/vehicle-selection.vue b/src/layouts/vehicle-selection/vehicle-selection.vue new file mode 100644 index 00000000..cb53c2ea --- /dev/null +++ b/src/layouts/vehicle-selection/vehicle-selection.vue @@ -0,0 +1,183 @@ + + + diff --git a/src/layouts/vehicle-selection/year-question/year-question.vue b/src/layouts/vehicle-selection/year-question/year-question.vue new file mode 100644 index 00000000..97ba0090 --- /dev/null +++ b/src/layouts/vehicle-selection/year-question/year-question.vue @@ -0,0 +1,63 @@ + + + \ No newline at end of file diff --git a/src/router/router-constants/issPage-values.js b/src/router/router-constants/issPage-values.js index 9cbbdfbc..763994ac 100644 --- a/src/router/router-constants/issPage-values.js +++ b/src/router/router-constants/issPage-values.js @@ -29,6 +29,7 @@ export const issPageValues = { VEHICLE_PARTS: 'vehicle-parts', VEHICLE_STYLE: 'vehicle-style', VEHICLE_YEAR: 'vehicle-year', + VEHICLE_SELECTION: 'vehicle-selection', VIN_LOOKUP: 'vin-lookup', TPA_SUBMIT: 'tpa-submit', BAILOUT_PAGE: 'bailout-page', diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index e6c25ae6..d9df9162 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -4,6 +4,19 @@ import { navigationScenarios } from '@/router/router-constants/navigation-scenar // Get store from router/index.js instead of importing it here to get updated values const routingTable = function(store) { return [ + { + issPageValue: issPageValues.VEHICLE_SELECTION, + maps: [ + { + scenario: navigationScenarios.CLICKED_BACK, + destinationIssPageValue: issPageValues.POLICY_HOLDER_DETAILS + }, + { + scenario: navigationScenarios.CLICKED_FORWARD, + destinationIssPageValue: issPageValues.VEHICLE_DAMAGE + } + ] + }, { issPageValue: issPageValues.VEHICLE_YEAR, maps: [ @@ -61,7 +74,7 @@ const routingTable = function(store) { maps: [ { scenario: navigationScenarios.CLICKED_BACK, - destinationIssPageValue: issPageValues.VEHICLE_STYLE + destinationIssPageValue: issPageValues.VEHICLE_SELECTION }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_REPAIR, @@ -389,7 +402,7 @@ const routingTable = function(store) { }, { scenario: navigationScenarios.CLICKED_FORWARD_POLICY_UNVERIFIED, - destinationIssPageValue: issPageValues.VEHICLE_YEAR + destinationIssPageValue: issPageValues.VEHICLE_SELECTION }, { scenario: navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED, From ca2181c2da036a56eaacf45d13bc006c61c39056 Mon Sep 17 00:00:00 2001 From: Sneha Date: Wed, 10 May 2023 20:02:18 +0530 Subject: [PATCH 4/8] Update routing-table.js --- src/router/router-constants/routing-table.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index d9df9162..65dcf571 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -74,7 +74,7 @@ const routingTable = function(store) { maps: [ { scenario: navigationScenarios.CLICKED_BACK, - destinationIssPageValue: issPageValues.VEHICLE_SELECTION + destinationIssPageValue: issPageValues.VEHICLE_STYLE }, { scenario: navigationScenarios.CLICKED_FORWARD_WITH_REPAIR, @@ -402,7 +402,7 @@ const routingTable = function(store) { }, { scenario: navigationScenarios.CLICKED_FORWARD_POLICY_UNVERIFIED, - destinationIssPageValue: issPageValues.VEHICLE_SELECTION + destinationIssPageValue: issPageValues.VEHICLE_YEAR }, { scenario: navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED, From 0e5f0504c6fe2becac06c047095d36d4c01e449e Mon Sep 17 00:00:00 2001 From: Kroell Date: Wed, 10 May 2023 10:53:19 -0400 Subject: [PATCH 5/8] fixes to spacing around header --- src/layouts/service-location/service-location.vue | 2 +- src/layouts/welcome-page/welcome-page.vue | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/layouts/service-location/service-location.vue b/src/layouts/service-location/service-location.vue index eac6e7ec..5b42579c 100644 --- a/src/layouts/service-location/service-location.vue +++ b/src/layouts/service-location/service-location.vue @@ -3,7 +3,7 @@
- +
diff --git a/src/layouts/welcome-page/welcome-page.vue b/src/layouts/welcome-page/welcome-page.vue index b70a24eb..353d2e11 100644 --- a/src/layouts/welcome-page/welcome-page.vue +++ b/src/layouts/welcome-page/welcome-page.vue @@ -3,9 +3,9 @@
- +
-
+
Date: Wed, 10 May 2023 11:03:03 -0400 Subject: [PATCH 6/8] Nulls for the win! --- src/store/index.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index 9fba1222..90b04423 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -699,10 +699,10 @@ export const useMainStore = defineStore({ this.order.damage.partQuestionAnswers = null; this.order.damage.moldingQuestionAnswers = null; this.order.damage.capabilityQuestionAnswers = null; - this.applicationUser.pageData[issPageValues.PART_QUESTIONS] = {}; - this.applicationUser.pageData[issPageValues.VEHICLE_PARTS] = {}; - this.applicationUser.pageData[issPageValues.MOLDING_QUESTIONS] = {}; - this.applicationUser.pageData[issPageValues.CAPABILITY_QUESTIONS] = {}; + this.applicationUser.pageData[issPageValues.PART_QUESTIONS] = null; + this.applicationUser.pageData[issPageValues.VEHICLE_PARTS] = null; + this.applicationUser.pageData[issPageValues.MOLDING_QUESTIONS] = null; + this.applicationUser.pageData[issPageValues.CAPABILITY_QUESTIONS] = null; }, resetSupportingItemsState() { @@ -734,8 +734,8 @@ export const useMainStore = defineStore({ this.resetPartsAndDependencies(); this.updateMoldingQuestionAnswers(null); this.updateCapabilityQuestionAnswers(null); - this.updatePageData({ page: issPageValues.MOLDING_QUESTIONS, data: {} }); - this.updatePageData({ page: issPageValues.CAPABILITY_QUESTIONS, data: {} }); + this.updatePageData({ page: issPageValues.MOLDING_QUESTIONS, data: null }); + this.updatePageData({ page: issPageValues.CAPABILITY_QUESTIONS, data: null }); } }, @@ -842,7 +842,7 @@ export const useMainStore = defineStore({ }, updatePageData(pageData) { - this.applicationUser.pageData[pageData.page] = (!!pageData.data) ? pageData.data : {}; + this.applicationUser.pageData[pageData.page] = pageData.data; }, updatePolicyData(welcomePageModel) { @@ -890,9 +890,9 @@ export const useMainStore = defineStore({ this.resetSupportingItemsState(); this.resetVapsState(); - this.updatePageData({ page: issPageValues.VEHICLE_PARTS, data: {} }); - this.updatePageData({ page: issPageValues.MOLDING_QUESTIONS, data: {} }); - this.updatePageData({ page: issPageValues.CAPABILITY_QUESTIONS, data: {} }); + this.updatePageData({ page: issPageValues.VEHICLE_PARTS, data: null }); + this.updatePageData({ page: issPageValues.MOLDING_QUESTIONS, data: null }); + this.updatePageData({ page: issPageValues.CAPABILITY_QUESTIONS, data: null }); } //Save new values @@ -918,7 +918,7 @@ export const useMainStore = defineStore({ // was updateGlassParts(null), added dependencies for SSR-290 this.resetPartsAndDependencies(); this.updateCapabilityQuestionAnswers(null); - this.updatePageData({ page: issPageValues.CAPABILITY_QUESTIONS, data: {} }); + this.updatePageData({ page: issPageValues.CAPABILITY_QUESTIONS, data: null }); } // Save new values From 311d19cb30a6401d30fbfbb8903bf6346c0e7fcb Mon Sep 17 00:00:00 2001 From: DavidAtSafelite Date: Wed, 10 May 2023 11:19:15 -0400 Subject: [PATCH 7/8] Removed unwanted comments --- src/store/index.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index 90b04423..25463efb 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -671,7 +671,6 @@ export const useMainStore = defineStore({ this.order.vehicle.imageVifNumber = vehicle.imageVifNumber; this.order.vehicle.imageColor = vehicle.imageVifColor; - // added for SSR-290 this.resetSupportingItemsState(); this.resetVapsState(); }, @@ -757,7 +756,6 @@ export const useMainStore = defineStore({ if(this.order.vehicle.year !== year) { this.resetVehicleState(); - // was resetDamageState, added dependencies for SSR-290 this.resetDamageAndDependencies(); this.order.vehicle.year = year; @@ -770,7 +768,6 @@ export const useMainStore = defineStore({ const year = this.order.vehicle.year; this.resetVehicleState(); - // was resetDamageState, added dependencies for SSR-290 this.resetDamageAndDependencies(); this.order.vehicle.year = year; @@ -785,7 +782,6 @@ export const useMainStore = defineStore({ const make = this.order.vehicle.make; this.resetVehicleState(); - // was resetDamageState, added dependencies for SSR-290 this.resetDamageAndDependencies(); this.order.vehicle.year = year; @@ -803,7 +799,6 @@ export const useMainStore = defineStore({ const model = this.order.vehicle.model; this.resetVehicleState(); - // was resetDamageState, added dependencies for SSR-290 this.resetDamageAndDependencies(); this.order.vehicle.year = year; @@ -886,7 +881,6 @@ export const useMainStore = defineStore({ this.updateGlassParts(null); this.updateMoldingQuestionAnswers(null); this.updateCapabilityQuestionAnswers(null); - // Added for SSR-290 this.resetSupportingItemsState(); this.resetVapsState(); @@ -915,7 +909,6 @@ export const useMainStore = defineStore({ ); if (haveMoldingQuestionAnswersChanged) { - // was updateGlassParts(null), added dependencies for SSR-290 this.resetPartsAndDependencies(); this.updateCapabilityQuestionAnswers(null); this.updatePageData({ page: issPageValues.CAPABILITY_QUESTIONS, data: null }); @@ -941,7 +934,6 @@ export const useMainStore = defineStore({ ); if (haveCapabilityQuestionAnswersChanged) { - // was updateGlassPars(null), added dependencies for SSR-290 this.resetPartsAndDependencies(); } From 0652dd743c457852c15d902abee1508daa4497a3 Mon Sep 17 00:00:00 2001 From: hiteshkumar87 Date: Thu, 11 May 2023 16:56:07 +0530 Subject: [PATCH 8/8] SSR-386 UI functionality policy vehicle page --- src/constants/vehicle-selection-options.js | 6 + .../policy-vehicles-question.spec.js | 33 ++++ .../policy-vehicles-question.vue | 14 +- .../policy-vehicles/policy-vehicles.spec.js | 185 ++++++++++++++++++ .../policy-vehicles/policy-vehicles.vue | 71 ++++++- .../router-constants/navigation-scenarios.js | 11 +- src/router/router-constants/routing-table.js | 21 ++ 7 files changed, 331 insertions(+), 10 deletions(-) create mode 100644 src/constants/vehicle-selection-options.js create mode 100644 src/layouts/policy-vehicles/policy-vehicles-question/policy-vehicles-question.spec.js create mode 100644 src/layouts/policy-vehicles/policy-vehicles.spec.js diff --git a/src/constants/vehicle-selection-options.js b/src/constants/vehicle-selection-options.js new file mode 100644 index 00000000..01897ea9 --- /dev/null +++ b/src/constants/vehicle-selection-options.js @@ -0,0 +1,6 @@ +const vehicleSelectionOptions = Object.freeze({ + VEHICLE_NOT_LISTED: 'Vehicle not listed', + }); + + export {vehicleSelectionOptions}; + \ No newline at end of file diff --git a/src/layouts/policy-vehicles/policy-vehicles-question/policy-vehicles-question.spec.js b/src/layouts/policy-vehicles/policy-vehicles-question/policy-vehicles-question.spec.js new file mode 100644 index 00000000..c9efabf3 --- /dev/null +++ b/src/layouts/policy-vehicles/policy-vehicles-question/policy-vehicles-question.spec.js @@ -0,0 +1,33 @@ +import policyVehiclesQuestion from "@/layouts/policy-vehicles/policy-vehicles-question/policy-vehicles-question.vue"; +import { shallowMount } from "@vue/test-utils"; + + +describe("policy-vehicles-question.vue", () => { + test("Selected vehicle is emitted upon selection", async () => { + //Arrange + const vehicleToSelect = "Test1"; + const wrapper = shallowMount(policyVehiclesQuestion, { + mixins: [mockMixin], + propsData: { + vehicles: ["Test1", "Test2"] + }, + }); + + //Act + wrapper.setValue({ modelValue: vehicleToSelect }); + await wrapper.vm.$nextTick(); + + //Assert + expect(wrapper.emitted()["update:modelValue"][0]).toEqual([ + { modelValue: "Test1" }, + ]); + }); +}); + +const mockMixin = { + methods: { + getCmsContent: jest.fn(()=>{ + return [ "vehicle not listed" ]; + }) + }, +}; \ No newline at end of file diff --git a/src/layouts/policy-vehicles/policy-vehicles-question/policy-vehicles-question.vue b/src/layouts/policy-vehicles/policy-vehicles-question/policy-vehicles-question.vue index 62f2522e..6d19b5da 100644 --- a/src/layouts/policy-vehicles/policy-vehicles-question/policy-vehicles-question.vue +++ b/src/layouts/policy-vehicles/policy-vehicles-question/policy-vehicles-question.vue @@ -5,7 +5,9 @@ buttonTypeString="listButton" isOverflowScrollable :answers="answers" - isRequired /> + v-model="selectedVehicleVin" + isRequired + :validation-rules="validationRules" /> diff --git a/src/layouts/policy-vehicles/policy-vehicles.spec.js b/src/layouts/policy-vehicles/policy-vehicles.spec.js new file mode 100644 index 00000000..1d2f6875 --- /dev/null +++ b/src/layouts/policy-vehicles/policy-vehicles.spec.js @@ -0,0 +1,185 @@ +import policyVehicles from "@/layouts/policy-vehicles/policy-vehicles"; +import { settleAllPromises } from "@/helpers/layout-helper.js"; +import { shallowMount } from "@vue/test-utils"; +import { getMountOptions } from "@/helpers/unit-test-helper.js"; +import { useMainStore } from "@/store"; +import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; +import {vehicleSelectionOptions} from "@/constants/vehicle-selection-options"; +import { navigationScenarios } from "@/router/router-constants/navigation-scenarios"; + +// Mock fetchCmsContentForPage +jest.mock("@/helpers/cms-content-helper", () => ({ + fetchCmsContentForPage: jest.fn(), + doesCopyContainRouterLink: jest.fn(), + splitCopyOnCMSPlaceHolder: jest.fn().mockImplementation(() => "test"), + getRouterLinkRouteFromCopy: jest.fn(), + getRouterLinkDisplayTextFromCopy: jest.fn(), + splitCMSCopyOnParagraphTag: jest.fn(), +})); + +// Mock our module for promises. +jest.mock("@/helpers/layout-helper.js", () => ({ + settleAllPromises: jest.fn(), +})); + +describe("policy-vehicles.vue", () => { + test("Should navigate to CLICKED_BACK if backButtonAction is run", async () => { + // Arrange + const { wrapper } = setupMocks({}); + + // Act + await wrapper.vm.backButtonAction(); + + //Assert + expect(wrapper.vm.$router.navigate).toBeCalled(); + }); + test("Should navigate to CLICKED_BACK if backButtonAction is run", async () => { + // Arrange + const { wrapper } = setupMocks({}); + + // Act + await wrapper.vm.backButtonAction(); + + //Assert + expect(wrapper.vm.$router.navigate).toBeCalled(); + }); + + test("Selected vehicle VIN do match vehicles listed in our system (CarIDs) found then navigate forward to vehicle-damage page.", async () => { + //Arrange + const { wrapper } = setupMocks({}); + + // Act + await wrapper.setData({ + selectedVehicleVin: "5NMS3CADXLH233004" + }); + await wrapper.vm.forwardButtonAction(); + + // Assert + expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith( + navigationScenarios.CLICKED_FORWARD_LISTED_VEHICLE, + undefined, + {}, + {} + ); + }); + test("Selected vehicle VIN do not match vehicles listed in our system (CarIDs) found then navigate forward to bailout page.", async () => { + //Arrange + const { wrapper } = setupMocks({}); + + // Act + await wrapper.setData({ + selectedVehicleVin: "5NMS3CADXLH233004", + bailout: true + }); + await wrapper.vm.forwardButtonAction(); + + // Assert + expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith( + navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT, + undefined, + {}, + {} + ); + }); + test("if user select vehicle not listed option then navigate forward to vehicle-selection page.", async () => { + //Arrange + const { wrapper } = setupMocks({}); + + // Act + await wrapper.setData({ + selectedVehicleVin: vehicleSelectionOptions.VEHICLE_NOT_LISTED, + }); + await wrapper.vm.forwardButtonAction(); + + // Assert + expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith( + navigationScenarios.CLICKED_FORWARD_NON_LISTED_VEHICLE, + undefined, + {}, + {} + ); + }); +}); + +function setupMocks({ + route = null, + lookupVehicleByVinResponse +}) +{ + useMainStore().applicationUser = { + pageData: { + "policy-vehicles": + [ + { + vehicleMake: "Hyundai", + vehicleModel: "Santa Fe", + vehicleStyle: "4 door utility", + vehicleYear: 2020, + vin: "5NMS3CADXLH233004", + }, + ], + } + }; + useMainStore().lookupVehicleByVin = jest.fn().mockImplementation(() => { + return Promise.resolve({ + data: lookupVehicleByVinResponse + ? lookupVehicleByVinResponse : { + vehicle: { + carId: "CARID" + }, + }, + }) + }); + const mountOptions = getMountOptions({ + route: route ? route : undefined, + router: { + navigate: jest.fn(), + }, + mainStore: { + order: { + vehicle: { + carId: "CR00069309", + category: "SUV", + imageUrl: + "https://dbhdyzvm8lm25.cloudfront.net/color_0320_032/MY2020/13769/13769_cc0320_032_WW8.jpg", + imageVifColor: "white", + imageVifNumber: "13769", + make: "Hyundai", + model: "Santa Fe", + style: "4 door utility", + year: 2020, + }, + vin: "5NMS3CADXLH233004", + }, + }, + }, + ); + + const apiResponses = { + cmsContent: {}, + }; + + settleAllPromises.mockImplementation(() => apiResponses); + fetchCmsContentForPage.mockImplementation(() => Promise.resolve()); + + + //Mock props + const mockMixin = { + methods: { + getCmsContent: jest.fn(), + }, + computed: { + dynamicStrings() { + return { ROUTER_LINK: "routerLink:" }; + }, + }, + }; + + mountOptions.mixins = [mockMixin]; + const wrapper = shallowMount(policyVehicles,mountOptions); + wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => ""); + wrapper.vm.setCmsContent = jest.fn(); + wrapper.vm.$refs.siteFooter.updateButtonText = jest.fn(); + wrapper.vm.$refs.siteFooter.removeLoader = jest.fn(); + return { wrapper }; +} \ No newline at end of file diff --git a/src/layouts/policy-vehicles/policy-vehicles.vue b/src/layouts/policy-vehicles/policy-vehicles.vue index 73c0bcb8..a85cc583 100644 --- a/src/layouts/policy-vehicles/policy-vehicles.vue +++ b/src/layouts/policy-vehicles/policy-vehicles.vue @@ -9,7 +9,13 @@
- +
@@ -29,18 +35,25 @@ import policyVehiclesQuestion from "@/layouts/policy-vehicles/policy-vehicles-qu // Supporting files import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; import { settleAllPromises } from "@/helpers/layout-helper"; -import { Form,defineRule } from "vee-validate"; +import { required } from "@/helpers/validation-rules"; +import { Form, defineRule } from "vee-validate"; import BaseFormMixin from '@/mixins/base-form-mixin.js'; import { issPageValues } from "@/router/router-constants/issPage-values"; import { useMainStore } from '@/store'; import { errorMessages } from "@/constants/error-messages"; -import { required } from "@/helpers/validation-rules"; +import {vehicleSelectionOptions} from "@/constants/vehicle-selection-options"; // DEFINE VALIDATION RULES defineRule("option-required", required(errorMessages.OPTION_REQUIRED)); export default { name: "policy-vehicles", mixins: [BaseFormMixin], + data() { + return { + selectedVehicleVin: "", + bailout: false + } + }, async beforeRouteEnter(to, from, next) { // Call APIs @@ -59,13 +72,57 @@ export default { }, methods: { - backButtonAction() { + backButtonAction() { + this.mainStore.issConfig.disabledFields.policyNumber = true; + this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route); }, - forwardButtonAction() { + async forwardButtonAction() { + if(this.selectedVehicleVin != vehicleSelectionOptions.VEHICLE_NOT_LISTED){ + const vehicleLookupResponse = await this.lookupVehicleByVin(this.selectedVehicleVin); + if (vehicleLookupResponse.error) { + this.bailout = true; + return this.navigateForward(); + } + this.vehicleFromLookup = Object.assign(vehicleLookupResponse.data, { vin: this.selectedVehicleVin }); + this.mainStore.updateVehicle(this.vehicleFromLookup); + } return this.navigateForward(); }, navigateForward() { + if(this.bailout) + this.$router.navigate( + this.navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT, + this.$route, + {}, + {} + ); + else if(this.selectedVehicleVin == vehicleSelectionOptions.VEHICLE_NOT_LISTED) + this.$router.navigate( + this.navigationScenarios.CLICKED_FORWARD_NON_LISTED_VEHICLE, + this.$route, + {}, + {} + ); + else + this.$router.navigate( + this.navigationScenarios.CLICKED_FORWARD_LISTED_VEHICLE, + this.$route, + {}, + {} + ); }, + async lookupVehicleByVin(vin) { + try { + return await this.mainStore.lookupVehicleByVin(vin); + } + catch (responseError) { + return { + error: { + status: responseError.status, + }, + }; + } + }, }, computed:{ @@ -88,8 +145,8 @@ export default { }, VehiclesFromApi() { return useMainStore().pageData(issPageValues.POLICY_VEHICLES); - }, - }, + }, + }, components: { siteHeader, siteFooter, diff --git a/src/router/router-constants/navigation-scenarios.js b/src/router/router-constants/navigation-scenarios.js index 64fd8933..b2fb1fa4 100644 --- a/src/router/router-constants/navigation-scenarios.js +++ b/src/router/router-constants/navigation-scenarios.js @@ -16,6 +16,10 @@ const navigationScenarios = { CLICKED_FORWARD_POLICY_UNVERIFIED: "CLICKED_FORWARD_POLICY_UNVERIFIED", CLICKED_FORWARD_POLICY_VERIFIED: "CLICKED_FORWARD_POLICY_VERIFIED", + //Policy Vehicle + CLICKED_FORWARD_LISTED_VEHICLE: "CLICKED_FORWARD_LISTED_VEHICLE", + CLICKED_FORWARD_NON_LISTED_VEHICLE: "CLICKED_FORWARD_NON_LISTED_VEHICLE", + // Vehicle Damage CLICKED_FORWARD_WITH_REPAIR: 'CLICKED_FORWARD_WITH_REPAIR', @@ -46,8 +50,11 @@ const navigationScenarios = { //Provider Preference CLICKED_FORWARD_WITH_SAFELITE: "CLICKED_FORWARD_WITH_SAFELITE", CLICKED_FORWARD_WITH_TPA_ENABLED: "CLICKED_FORWARD_WITH_TPA_ENABLED", - CLICKED_FORWARD_WITH_TPA_DISABLED: "CLICKED_FORWARD_WITH_TPA_DISABLED" - + CLICKED_FORWARD_WITH_TPA_DISABLED: "CLICKED_FORWARD_WITH_TPA_DISABLED", + + //Bailout + CLICKED_FORWARD_WITH_BAILOUT: "CLICKED_FORWARD_WITH_BAILOUT", + }; diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index 65dcf571..f57b253b 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -410,6 +410,27 @@ const routingTable = function(store) { } ] }, + { + issPageValue: issPageValues.POLICY_VEHICLES, + maps: [ + { + scenario: navigationScenarios.CLICKED_BACK, + destinationIssPageValue: issPageValues.WELCOME_PAGE + }, + { + scenario: navigationScenarios.CLICKED_FORWARD_LISTED_VEHICLE, + destinationIssPageValue: issPageValues.VEHICLE_DAMAGE + }, + { + scenario: navigationScenarios.CLICKED_FORWARD_NON_LISTED_VEHICLE, + destinationIssPageValue: issPageValues.VEHICLE_SELECTION + }, + { + scenario:navigationScenarios.CLICKED_FORWARD_WITH_BAILOUT, + destinationIssPageValue: issPageValues.BAILOUT_PAGE + } + ] + }, { issPageValue: issPageValues.COVERAGE_STATEMENT, maps: [