updates to welcome-page navigation
This commit is contained in:
parent
c5e051874d
commit
3561d85fd9
2 changed files with 74 additions and 29 deletions
|
|
@ -62,13 +62,21 @@ describe("navigation", () => {
|
||||||
];
|
];
|
||||||
|
|
||||||
const { wrapper } = setupMocks({
|
const { wrapper } = setupMocks({
|
||||||
policies: [{}]
|
policies: [{
|
||||||
|
vehicles: [
|
||||||
|
{
|
||||||
|
vin: "TEST_VIN"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
vin: "TEST_VIN2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}]
|
||||||
});
|
});
|
||||||
|
|
||||||
await wrapper.setData({
|
await wrapper.setData({
|
||||||
isCoverageEnabled: true,
|
isCoverageEnabled: true,
|
||||||
vehiclesCount: 2,
|
zipCodeMatch: true,
|
||||||
vehiclesFound: mockvehicles,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
useMainStore().order.policy.policyNumber = "p_0001";
|
useMainStore().order.policy.policyNumber = "p_0001";
|
||||||
|
|
@ -97,6 +105,7 @@ describe("navigation", () => {
|
||||||
isCoverageEnabled: true,
|
isCoverageEnabled: true,
|
||||||
vehiclesCount: 0,
|
vehiclesCount: 0,
|
||||||
vehiclesFound: null,
|
vehiclesFound: null,
|
||||||
|
zipCodeMatch: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
useMainStore().order.policy.policyNumber = "p_0001";
|
useMainStore().order.policy.policyNumber = "p_0001";
|
||||||
|
|
@ -116,11 +125,11 @@ describe("navigation", () => {
|
||||||
test("if policy is not found, navigate to policy-holder-details page", async () => {
|
test("if policy is not found, navigate to policy-holder-details page", async () => {
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({
|
const { wrapper } = setupMocks({
|
||||||
policies: undefined
|
policies: null
|
||||||
});
|
});
|
||||||
|
|
||||||
await wrapper.setData({
|
await wrapper.setData({
|
||||||
isCoverageEnabled : true,
|
isCoverageEnabled: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
useMainStore().order.policy.policyNumber = "p_0001";
|
useMainStore().order.policy.policyNumber = "p_0001";
|
||||||
|
|
@ -128,7 +137,7 @@ describe("navigation", () => {
|
||||||
useMainStore().order.accountNumber = "00000";
|
useMainStore().order.accountNumber = "00000";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.navigateForward();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
|
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
|
||||||
|
|
@ -136,6 +145,31 @@ describe("navigation", () => {
|
||||||
undefined
|
undefined
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
test("if zip code entered does not match zip on policy, navigate to policy-holder-details page", async () => {
|
||||||
|
// Arrange
|
||||||
|
const { wrapper } = setupMocks({
|
||||||
|
policies: [{}]
|
||||||
|
});
|
||||||
|
|
||||||
|
await wrapper.setData({
|
||||||
|
isCoverageEnabled: true,
|
||||||
|
zipCodeMatch: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
useMainStore().order.policy.policyNumber = "p_0001";
|
||||||
|
useMainStore().order.policy.dateOfLoss = "2022-01-28";
|
||||||
|
useMainStore().order.accountNumber = "00000";
|
||||||
|
|
||||||
|
// Act
|
||||||
|
await wrapper.vm.navigateForward();
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
expect(wrapper.vm.$router.navigate).toHaveBeenCalledWith(
|
||||||
|
navigationScenarios.CLICKED_FORWARD_WITH_NO_POLICY,
|
||||||
|
undefined
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function setupMocks({
|
function setupMocks({
|
||||||
|
|
@ -143,15 +177,20 @@ function setupMocks({
|
||||||
pageFooterWidgetCmsContent = {},
|
pageFooterWidgetCmsContent = {},
|
||||||
mountOptionsMockData = {},
|
mountOptionsMockData = {},
|
||||||
policies = [],
|
policies = [],
|
||||||
lookupPolicyResponse
|
getCoveragePolicyInfoResponse
|
||||||
}) {
|
}) {
|
||||||
useMainStore().getCoveragePolicyInfo = jest.fn().mockImplementation(() => {
|
useMainStore().getCoveragePolicyInfo = jest.fn().mockImplementation(() => {
|
||||||
return Promise.resolve({
|
return Promise.resolve({
|
||||||
data: lookupPolicyResponse
|
data: getCoveragePolicyInfoResponse
|
||||||
? lookupPolicyResponse
|
? getCoveragePolicyInfoResponse
|
||||||
: {
|
: {
|
||||||
policies: [
|
policies: [
|
||||||
{
|
{
|
||||||
|
insureds: [
|
||||||
|
{
|
||||||
|
customerId: "TEST_ID"
|
||||||
|
},
|
||||||
|
],
|
||||||
vehicles: [
|
vehicles: [
|
||||||
{
|
{
|
||||||
vin: "TEST_VIN"
|
vin: "TEST_VIN"
|
||||||
|
|
|
||||||
|
|
@ -205,6 +205,7 @@ export default {
|
||||||
return {
|
return {
|
||||||
welcomePageModel: this.getWelcomePageModelFromStore(),
|
welcomePageModel: this.getWelcomePageModelFromStore(),
|
||||||
vehiclesFound: [],
|
vehiclesFound: [],
|
||||||
|
zipCodeMatch: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
|
|
@ -259,13 +260,18 @@ export default {
|
||||||
const policyLookupResultMap = await settleAllPromises(promisePolicyLookupResultMap);
|
const policyLookupResultMap = await settleAllPromises(promisePolicyLookupResultMap);
|
||||||
const policyInfo = policyLookupResultMap.policyLookupResponse;
|
const policyInfo = policyLookupResultMap.policyLookupResponse;
|
||||||
|
|
||||||
// if policy lookup fails, move the user forward
|
// if policy lookup fails, navigate to policy-holder-details page
|
||||||
if (!policyInfo) {
|
if (!policyInfo) {
|
||||||
this.navigateForward();
|
this.navigateForward();
|
||||||
}
|
}
|
||||||
|
|
||||||
const policy = policyInfo.policies?.[0];
|
const policy = policyInfo.policies?.[0];
|
||||||
if (policy) {
|
// get the first 5 digits of the policy zip code
|
||||||
|
const policyZip = (policy.insureds?.[0]?.zipCode).slice(0, 5);
|
||||||
|
// check if policy zip enters matches zip on policy
|
||||||
|
this.zipCodeMatch = policyZip == this.welcomePageModel.policyZipCode;
|
||||||
|
|
||||||
|
if (policy && this.zipCodeMatch) {
|
||||||
//populate policy holder details from policy lookup
|
//populate policy holder details from policy lookup
|
||||||
this.mainStore.order.customer.address.streetAddress = policy.insureds?.[0]?.address;
|
this.mainStore.order.customer.address.streetAddress = policy.insureds?.[0]?.address;
|
||||||
this.mainStore.order.customer.address.city = policy.insureds?.[0]?.city;
|
this.mainStore.order.customer.address.city = policy.insureds?.[0]?.city;
|
||||||
|
|
@ -277,14 +283,29 @@ export default {
|
||||||
//populate vehicles
|
//populate vehicles
|
||||||
this.vehiclesFound = policy.vehicles;
|
this.vehiclesFound = policy.vehicles;
|
||||||
}
|
}
|
||||||
return this.navigateForward(policy);
|
return this.navigateForward(policy, this.zipCodeMatch);
|
||||||
}
|
}
|
||||||
return this.navigateForward();
|
return this.navigateForward();
|
||||||
},
|
},
|
||||||
|
|
||||||
navigateForward(policy) {
|
navigateForward(policy, zipCodeMatch) {
|
||||||
|
// if policy lookup is unsuccessful, navigate to policy-holder-details page
|
||||||
|
if (!policy || !zipCodeMatch) {
|
||||||
|
this.$router.navigate(
|
||||||
|
this.navigationScenarios.CLICKED_FORWARD_WITH_NO_POLICY,
|
||||||
|
this.$route
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// if policy lookup is successful, but no vehicles are associated with the policy
|
||||||
|
// navigate to vehicle-selection page (manual entry)
|
||||||
|
else if (policy && zipCodeMatch && !this.vehiclesFound) {
|
||||||
|
this.$router.navigate(
|
||||||
|
this.navigationScenarios.CLICKED_FORWARD_WITH_POLICY_AND_NO_VEHICLES,
|
||||||
|
this.$route
|
||||||
|
);
|
||||||
|
}
|
||||||
// if policy lookup is successful and vehicles are found, navigate to policy-vehicles page
|
// if policy lookup is successful and vehicles are found, navigate to policy-vehicles page
|
||||||
if (policy && this.vehiclesFound) {
|
else if (policy && zipCodeMatch && this.vehiclesFound) {
|
||||||
this.$router.navigate(
|
this.$router.navigate(
|
||||||
this.navigationScenarios.CLICKED_FORWARD_WITH_POLICY_AND_VEHICLES,
|
this.navigationScenarios.CLICKED_FORWARD_WITH_POLICY_AND_VEHICLES,
|
||||||
this.$route,
|
this.$route,
|
||||||
|
|
@ -293,21 +314,6 @@ export default {
|
||||||
this.vehiclesFound
|
this.vehiclesFound
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// if policy lookup is successful, but no vehicles are associated with the policy
|
|
||||||
// navigate to vehicle-selection page (manual entry)
|
|
||||||
else if (policy && !this.vehiclesFound) {
|
|
||||||
this.$router.navigate(
|
|
||||||
this.navigationScenarios.CLICKED_FORWARD_WITH_POLICY_AND_NO_VEHICLES,
|
|
||||||
this.$route
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// if policy lookup is unsuccessful, navigate to policy-holder-details page
|
|
||||||
else {
|
|
||||||
this.$router.navigate(
|
|
||||||
this.navigationScenarios.CLICKED_FORWARD_WITH_NO_POLICY,
|
|
||||||
this.$route
|
|
||||||
);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getWelcomePageModelFromStore() {
|
getWelcomePageModelFromStore() {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue