SSR-394
Implement policy lookup call and populate the vehicles
This commit is contained in:
parent
af384c40df
commit
379a8c7cec
9 changed files with 180 additions and 19 deletions
|
|
@ -121,7 +121,11 @@ const endpoints = {
|
||||||
IsVinbyAddressPermissible:{
|
IsVinbyAddressPermissible:{
|
||||||
url:'/vehicle/api/v1/vehicle/is-vin-by-address-permissible',
|
url:'/vehicle/api/v1/vehicle/is-vin-by-address-permissible',
|
||||||
method:'Get'
|
method:'Get'
|
||||||
}
|
},
|
||||||
|
CoveragePolicyInfo: {
|
||||||
|
url: '/coverage/api/v1/coverage/get-policy-information',
|
||||||
|
method: 'POST'
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export { endpoints };
|
export { endpoints };
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,8 @@ import { shallowMount } from '@vue/test-utils';
|
||||||
import { settleAllPromises } from "@/helpers/layout-helper.js";
|
import { settleAllPromises } from "@/helpers/layout-helper.js";
|
||||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
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.
|
// Mock our module for promises.
|
||||||
jest.mock("@/helpers/layout-helper.js", () => ({
|
jest.mock("@/helpers/layout-helper.js", () => ({
|
||||||
|
|
@ -65,8 +66,9 @@ describe("navigation", () => {
|
||||||
customerQuestions: {
|
customerQuestions: {
|
||||||
addressQuestions: mockRegistrationAddress,
|
addressQuestions: mockRegistrationAddress,
|
||||||
},
|
},
|
||||||
|
isCoverageEnabled:false
|
||||||
});
|
});
|
||||||
|
|
||||||
wrapper.vm.navigateForward = jest.fn();
|
wrapper.vm.navigateForward = jest.fn();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -76,6 +78,53 @@ describe("navigation", () => {
|
||||||
expect(wrapper.vm.navigateForward).toHaveBeenCalled();
|
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 = {
|
const apiResponses = {
|
||||||
|
policyLookupResponse:{
|
||||||
|
policies:policies
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
settleAllPromises.mockImplementation(() => apiResponses);
|
settleAllPromises.mockImplementation(() => apiResponses);
|
||||||
|
|
|
||||||
|
|
@ -97,17 +97,44 @@ export default {
|
||||||
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
|
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
|
||||||
},
|
},
|
||||||
|
|
||||||
forwardButtonAction()
|
async forwardButtonAction()
|
||||||
{
|
{
|
||||||
this.mainStore.updatePolicyHolderDetails(this.customerQuestions);
|
this.mainStore.updatePolicyHolderDetails(this.customerQuestions);
|
||||||
return this.navigateForward();
|
//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() {
|
navigateForward(vehiclesFound) {
|
||||||
this.$router.navigate(
|
if(vehiclesFound?.length > 0)
|
||||||
this.navigationScenarios.CLICKED_FORWARD_POLICY_HOLDER_DETAILS,
|
this.$router.navigate(
|
||||||
this.$route
|
this.navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED,
|
||||||
);
|
this.$route,
|
||||||
|
{},
|
||||||
|
{},
|
||||||
|
vehiclesFound
|
||||||
|
);
|
||||||
|
else
|
||||||
|
this.$router.navigate(
|
||||||
|
this.navigationScenarios.CLICKED_FORWARD_POLICY_HOLDER_DETAILS,
|
||||||
|
this.$route
|
||||||
|
);
|
||||||
},
|
},
|
||||||
getPolicyHolderDetailsFromStore() {
|
getPolicyHolderDetailsFromStore() {
|
||||||
return {
|
return {
|
||||||
|
|
@ -124,6 +151,11 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
computed:{
|
||||||
|
isCoverageEnabled(){
|
||||||
|
return this.mainStore.issConfig.isCoverageEnabled;
|
||||||
|
}
|
||||||
|
},
|
||||||
components: {
|
components: {
|
||||||
siteHeader,
|
siteHeader,
|
||||||
siteSubHeader,
|
siteSubHeader,
|
||||||
|
|
|
||||||
|
|
@ -3,24 +3,28 @@
|
||||||
:questionText="questionText"
|
:questionText="questionText"
|
||||||
ref="policyVehiclesQuestion"
|
ref="policyVehiclesQuestion"
|
||||||
buttonTypeString="listButton"
|
buttonTypeString="listButton"
|
||||||
isOverflowScrollable
|
isOverflowScrollable
|
||||||
:answers="answers"
|
:answers="answers"
|
||||||
isRequired />
|
isRequired />
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import buttonQuestion from "@/digital-components/button-question/button-question";
|
import buttonQuestion from "@/digital-components/button-question/button-question";
|
||||||
|
|
||||||
export default ({
|
export default ({
|
||||||
name: "policy-vehicles-question",
|
name: "policy-vehicles-question",
|
||||||
components: {
|
components: {
|
||||||
buttonQuestion,
|
buttonQuestion,
|
||||||
},
|
},
|
||||||
|
props:{
|
||||||
|
vehicles: Array,
|
||||||
|
},
|
||||||
computed: {
|
computed: {
|
||||||
questionText() {
|
questionText() {
|
||||||
return this.getCmsContent("PolicyVehiclesQuestion", "QuestionText");
|
return this.getCmsContent("PolicyVehiclesQuestion", "QuestionText");
|
||||||
},
|
},
|
||||||
answers(){
|
answers(){
|
||||||
return this.getCmsContent("PolicyVehiclesQuestion", "Answers");
|
const policyVehiclesAnswerfromCMS = this.getCmsContent("PolicyVehiclesQuestion", "Answers");
|
||||||
|
const combinedVehicles = [...this.vehicles, ...policyVehiclesAnswerfromCMS];
|
||||||
|
return combinedVehicles;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="select-car-form rounded text-center">
|
<div class="select-car-form rounded text-center">
|
||||||
<vehicleBanner cmsWidgetName="VehicleBannerWidget" :displayGenericVehicleImage="true" class="mb-3" />
|
<vehicleBanner cmsWidgetName="VehicleBannerWidget" :displayGenericVehicleImage="true" class="mb-3" />
|
||||||
<policyVehiclesQuestion class="px-4" cmsWidgetName="PolicyVehiclesQuestion"/>
|
<policyVehiclesQuestion class="px-4" cmsWidgetName="PolicyVehiclesQuestion" :vehicles="VehiclesForQuestions"/>
|
||||||
<siteFooter cmsWidgetName="SiteFooterWidget" ref="siteFooter" :isForwardActionDisabled="!meta.valid" @ForwardClicked="forwardButtonAction" @back-clicked="backButtonAction"/>
|
<siteFooter cmsWidgetName="SiteFooterWidget" ref="siteFooter" :isForwardActionDisabled="!meta.valid" @ForwardClicked="forwardButtonAction" @back-clicked="backButtonAction"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -31,6 +31,9 @@ import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||||
import { Form } from "vee-validate";
|
import { Form } from "vee-validate";
|
||||||
import BaseFormMixin from '@/mixins/base-form-mixin.js';
|
import BaseFormMixin from '@/mixins/base-form-mixin.js';
|
||||||
|
import { issPageValues } from "@/router/router-constants/issPage-values";
|
||||||
|
import { useMainStore } from '@/store';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "policy-vehicles",
|
name: "policy-vehicles",
|
||||||
mixins: [BaseFormMixin],
|
mixins: [BaseFormMixin],
|
||||||
|
|
@ -59,6 +62,29 @@ export default {
|
||||||
},
|
},
|
||||||
navigateForward() {
|
navigateForward() {
|
||||||
},
|
},
|
||||||
|
|
||||||
|
},
|
||||||
|
computed:{
|
||||||
|
VehiclesForQuestions() {
|
||||||
|
// Map API result data, to address-vehicles data structure
|
||||||
|
const vehicles = this.VehiclesFromApi?.[0].vehicles;
|
||||||
|
const mappedData = vehicles.map((v) => {
|
||||||
|
const maskSymbol = "X";
|
||||||
|
const vinStart = maskSymbol.repeat(v.vin.length - 6);
|
||||||
|
const vinEnd = v.vin.substring(v.vin.length - 6);
|
||||||
|
return {
|
||||||
|
vin: v.vin,
|
||||||
|
vehicle: v,
|
||||||
|
Text: v.vehicleYear + " " + v.vehicleMake + " " + v.vehicleModel,
|
||||||
|
Name: v.vin,
|
||||||
|
SubText: "VIN " + vinStart + vinEnd,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
return mappedData;
|
||||||
|
},
|
||||||
|
VehiclesFromApi() {
|
||||||
|
return useMainStore().pageData(issPageValues.POLICY_VEHICLES);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
siteHeader,
|
siteHeader,
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ export const issPageValues = {
|
||||||
VIN_LOOKUP: 'vin-lookup',
|
VIN_LOOKUP: 'vin-lookup',
|
||||||
TPA_SUBMIT: 'tpa-submit',
|
TPA_SUBMIT: 'tpa-submit',
|
||||||
BAILOUT_PAGE: 'bailout-page',
|
BAILOUT_PAGE: 'bailout-page',
|
||||||
TPA_SEARCH: 'tpa-search'
|
TPA_SEARCH: 'tpa-search',
|
||||||
|
POLICY_VEHICLES:'policy-vehicles'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -13,7 +13,7 @@ const navigationScenarios = {
|
||||||
SELECTED_STYLE: "SELECTED_STYLE",
|
SELECTED_STYLE: "SELECTED_STYLE",
|
||||||
CLICKED_FORWARD_WELCOME_PAGE: "CLICKED_FORWARD_WELCOME_PAGE",
|
CLICKED_FORWARD_WELCOME_PAGE: "CLICKED_FORWARD_WELCOME_PAGE",
|
||||||
CLICKED_FORWARD_POLICY_HOLDER_DETAILS: "CLICKED_FORWARD_POLICY_HOLDER_DETAILS",
|
CLICKED_FORWARD_POLICY_HOLDER_DETAILS: "CLICKED_FORWARD_POLICY_HOLDER_DETAILS",
|
||||||
|
CLICKED_FORWARD_POLICY_VERIFIED: "CLICKED_FORWARD_POLICY_VERIFIED",
|
||||||
// Vehicle Damage
|
// Vehicle Damage
|
||||||
CLICKED_FORWARD_WITH_REPAIR: 'CLICKED_FORWARD_WITH_REPAIR',
|
CLICKED_FORWARD_WITH_REPAIR: 'CLICKED_FORWARD_WITH_REPAIR',
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -377,7 +377,7 @@ const routingTable = function(store) {
|
||||||
{
|
{
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD_WELCOME_PAGE,
|
scenario: navigationScenarios.CLICKED_FORWARD_WELCOME_PAGE,
|
||||||
destinationIssPageValue: issPageValues.POLICY_HOLDER_DETAILS
|
destinationIssPageValue: issPageValues.POLICY_HOLDER_DETAILS
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -390,6 +390,10 @@ const routingTable = function(store) {
|
||||||
{
|
{
|
||||||
scenario: navigationScenarios.CLICKED_FORWARD_POLICY_HOLDER_DETAILS,
|
scenario: navigationScenarios.CLICKED_FORWARD_POLICY_HOLDER_DETAILS,
|
||||||
destinationIssPageValue: issPageValues.VEHICLE_YEAR
|
destinationIssPageValue: issPageValues.VEHICLE_YEAR
|
||||||
|
},
|
||||||
|
{
|
||||||
|
scenario: navigationScenarios.CLICKED_FORWARD_POLICY_VERIFIED,
|
||||||
|
destinationIssPageValue: issPageValues.POLICY_VEHICLES
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -322,6 +322,26 @@ export const useMainStore = defineStore({
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
getCoveragePolicyInfo({accountNumber,policyNumber,dateOfLoss}){
|
||||||
|
try{
|
||||||
|
const response = globalMethods.callHttpClient({
|
||||||
|
method:endpoints.CoveragePolicyInfo.method,
|
||||||
|
endpoint:endpoints.CoveragePolicyInfo.url,
|
||||||
|
payload: {
|
||||||
|
accountNumber: accountNumber,
|
||||||
|
policyNumber: policyNumber,
|
||||||
|
dateOfLoss: dateOfLoss
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return response;
|
||||||
|
} catch (responseError) {
|
||||||
|
return {
|
||||||
|
error: {
|
||||||
|
status: responseError.status
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
},
|
||||||
async lookupVinByPlate(licensePlate, licenseState) {
|
async lookupVinByPlate(licensePlate, licenseState) {
|
||||||
try {
|
try {
|
||||||
const response = await globalMethods.callHttpClient({
|
const response = await globalMethods.callHttpClient({
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue