diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index 416c6394..ca2c297f 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -121,7 +121,11 @@ const endpoints = { IsVinbyAddressPermissible:{ url:'/vehicle/api/v1/vehicle/is-vin-by-address-permissible', method:'Get' - } + }, + CoveragePolicyInfo: { + url: '/coverage/api/v1/coverage/get-policy-information', + method: 'POST' +} }; export { endpoints }; diff --git a/src/iss-components/site-header/site-header.vue b/src/iss-components/site-header/site-header.vue index 75a82bef..4c9e4938 100644 --- a/src/iss-components/site-header/site-header.vue +++ b/src/iss-components/site-header/site-header.vue @@ -53,12 +53,19 @@ export default({ }; } }, + methods: { + setupHeader(){ + const answers = this.getCmsContent(this.cmsWidgetName, "Answers"); + if(Array.isArray(answers)) + { + this.headerAnswers = answers.filter(x => x.AccountNumber == this.mainStore.issConfig.accountNumber)[0] + this.headerAnswers = !this.headerAnswers ? answers.filter(x => x.AccountNumber === '0')[0] : this.headerAnswers; + } + } + }, mounted() { - const answers = this.getCmsContent(this.cmsWidgetName, "Answers"); - this.headerAnswers = Array.isArray(answers) - ? answers.filter(x => x.AccountNumber == this.mainStore.issConfig.accountNumber)[0] - : null; - + this.$nextTick(this.setupHeader); + // Check if alert event is on the bus const alertEvent = eventBus.readAndPopEventFromBus( globalEvents.Categories.GLOBAL_ALERT, @@ -78,11 +85,11 @@ export default({ { document.getElementsByTagName("body")[0].className += " " + clientOverrideClass; } - }, - components: { - menuModal, - alert - }, + }, + components: { + menuModal, + alert + }, }) diff --git a/src/layouts/entry-page/entry-page.vue b/src/layouts/entry-page/entry-page.vue index db24c722..8fa467d5 100644 --- a/src/layouts/entry-page/entry-page.vue +++ b/src/layouts/entry-page/entry-page.vue @@ -144,6 +144,7 @@ { case "policynumber": this.mainStore.order.policy.policyNumber = value; + this.mainStore.issConfig.disabledFields.policyNumber = true; break; case "lossdate": diff --git a/src/layouts/policy-holder-details/policy-holder-details.spec.js b/src/layouts/policy-holder-details/policy-holder-details.spec.js index c6b84096..38fd58ea 100644 --- a/src/layouts/policy-holder-details/policy-holder-details.spec.js +++ b/src/layouts/policy-holder-details/policy-holder-details.spec.js @@ -6,7 +6,8 @@ import { shallowMount } from '@vue/test-utils'; import { settleAllPromises } from "@/helpers/layout-helper.js"; import { fetchCmsContentForPage } from "@/helpers/cms-content-helper"; import { getMountOptions } from "@/helpers/unit-test-helper.js"; - +import { useMainStore } from "@/store"; +import { navigationScenarios } from "@/router/router-constants/navigation-scenarios"; // Mock our module for promises. jest.mock("@/helpers/layout-helper.js", () => ({ @@ -65,8 +66,9 @@ describe("navigation", () => { customerQuestions: { addressQuestions: mockRegistrationAddress, }, + isCoverageEnabled:false }); - + wrapper.vm.navigateForward = jest.fn(); // Act @@ -76,6 +78,53 @@ describe("navigation", () => { expect(wrapper.vm.navigateForward).toHaveBeenCalled(); }); + + test("if the coverage policy verified navigate forward to policy-vehicle page", async () => { + // Arrange + const mockRegistrationAddress = { + streetAddress: "1234 Main St", + city: "Columbus", + state: "OH", + zipCode: "43215", + }; + + const { wrapper } = setupMocks(); + + await wrapper.setData({ + firstName: "KK", + lastName:"KK", + customerQuestions: { + addressQuestions: mockRegistrationAddress, + }, + isCoverageEnabled : true, + }); + const vehiclesFound = [{ + vehicles:[ + { + vin: "TEST_VIN", + }, + { + vin: "TEST_VIN2", + } + ]}]; + + useMainStore().order.policy.policyNumber = "p_0001"; + useMainStore().order.policy.dateOfLoss = "2022-01-28"; + useMainStore().order.accountNumber = "00000"; + + // Act + await wrapper.vm.forwardButtonAction(); + + // Assert + expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith( + navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED, + undefined, + {}, + {}, + vehiclesFound + ); + + }); }); @@ -97,8 +146,29 @@ function setupMocks() }) ); + const policies = [{ + vehicles:[ + { + vin: "TEST_VIN", + }, + { + vin: "TEST_VIN2", + } + ] + }, +]; + useMainStore().getCoveragePolicyInfo = jest.fn().mockImplementation(() => { + return Promise.resolve({ + data: { + policies:policies, + }, + }) + }) const apiResponses = { + policyLookupResponse:{ + policies:policies + } }; settleAllPromises.mockImplementation(() => apiResponses); diff --git a/src/layouts/policy-holder-details/policy-holder-details.vue b/src/layouts/policy-holder-details/policy-holder-details.vue index 1de675b1..6a75e5b7 100644 --- a/src/layouts/policy-holder-details/policy-holder-details.vue +++ b/src/layouts/policy-holder-details/policy-holder-details.vue @@ -97,17 +97,44 @@ export default { this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route); }, - forwardButtonAction() - { - this.mainStore.updatePolicyHolderDetails(this.customerQuestions); - return this.navigateForward(); + async forwardButtonAction() + { + this.mainStore.updatePolicyHolderDetails(this.customerQuestions); + //call coverage policy lookup if isCoverageEnabled flag enabled + var vehiclesFound = {}; + if(this.isCoverageEnabled){ + const policyLookupResponse = this.mainStore.getCoveragePolicyInfo({ + accountNumber:this.mainStore.order.accountNumber.toString(), + policyNumber:this.mainStore.order.policy.policyNumber, + dateOfLoss:this.mainStore.order.policy.dateOfLoss}); + + // Settle promises and get results + const promisePolicyLookupResultMap = [ + { + resultKey: "policyLookupResponse", + promise: policyLookupResponse, + } + ]; + const policyLookupResultMap = await settleAllPromises(promisePolicyLookupResultMap); + vehiclesFound = policyLookupResultMap.policyLookupResponse?.policies; + } + return this.navigateForward(vehiclesFound); }, - navigateForward() { - this.$router.navigate( - this.navigationScenarios.CLICKED_FORWARD_POLICY_HOLDER_DETAILS, - this.$route - ); + navigateForward(vehiclesFound) { + if(vehiclesFound?.length > 0) + this.$router.navigate( + this.navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED, + this.$route, + {}, + {}, + vehiclesFound + ); + else + this.$router.navigate( + this.navigationScenarios.CLICKED_FORWARD_POLICY_UNVERIFIED, + this.$route + ); }, getPolicyHolderDetailsFromStore() { return { @@ -124,6 +151,11 @@ export default { } }, }, + computed:{ + isCoverageEnabled(){ + return this.mainStore.issConfig.isCoverageEnabled; + } + }, components: { siteHeader, siteSubHeader, 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 a69fb31c..8e862b6b 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 @@ -3,24 +3,28 @@ :questionText="questionText" ref="policyVehiclesQuestion" buttonTypeString="listButton" - isOverflowScrollable + isOverflowScrollable :answers="answers" isRequired />