CSR-944 refactoring
This commit is contained in:
parent
f227aa57c2
commit
e061105bac
3 changed files with 95 additions and 55 deletions
|
|
@ -56,6 +56,33 @@ export async function navigateToHeritageFunnel(shouldSaveSession = true) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function skipVinLookup() {
|
||||||
|
const isVinOptionalVehicle = store.getters.order.vehicle.make
|
||||||
|
? await store.dispatch(storeActions.IS_VIN_OPTIONAL_VEHICLE)
|
||||||
|
: false;
|
||||||
|
|
||||||
|
return (
|
||||||
|
store.getters.damage.isRepair ||
|
||||||
|
isVinOptionalVehicle ||
|
||||||
|
experimentMixin.methods.hasSettingEqualTo(experimentSettings.SUPPRESS_VIN_CAPTURE, true)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function skipVinLookupNotRepair() {
|
||||||
|
const isVinOptionalVehicle = store.getters.order.vehicle.make
|
||||||
|
? await store.dispatch(storeActions.IS_VIN_OPTIONAL_VEHICLE)
|
||||||
|
: false;
|
||||||
|
|
||||||
|
return (
|
||||||
|
!store.getters.damage.isRepair &&
|
||||||
|
(isVinOptionalVehicle ||
|
||||||
|
experimentMixin.methods.hasSettingEqualTo(
|
||||||
|
experimentSettings.SUPPRESS_VIN_CAPTURE,
|
||||||
|
true
|
||||||
|
))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Logic for getting the last "valid" page a user visited.
|
Logic for getting the last "valid" page a user visited.
|
||||||
*/
|
*/
|
||||||
|
|
@ -76,9 +103,7 @@ async function getLatestPageForRedirection() {
|
||||||
fmgPageValues.CAPABILITY_QUESTIONS
|
fmgPageValues.CAPABILITY_QUESTIONS
|
||||||
);
|
);
|
||||||
|
|
||||||
const isVinOptionalVehicle = store.getters.order.vehicle.make
|
const skipVin = await skipVinLookup();
|
||||||
? await store.dispatch(storeActions.IS_VIN_OPTIONAL_VEHICLE)
|
|
||||||
: false;
|
|
||||||
|
|
||||||
if (!vehicleMakeComponent.methods.arePagePrerequisitesValid()) {
|
if (!vehicleMakeComponent.methods.arePagePrerequisitesValid()) {
|
||||||
return fmgPageValues.VEHICLE_YEAR;
|
return fmgPageValues.VEHICLE_YEAR;
|
||||||
|
|
@ -102,12 +127,7 @@ async function getLatestPageForRedirection() {
|
||||||
} else if (
|
} else if (
|
||||||
// capture vin
|
// capture vin
|
||||||
vinLookupComponent.methods.arePagePrerequisitesValid() &&
|
vinLookupComponent.methods.arePagePrerequisitesValid() &&
|
||||||
!store.getters.damage.isRepair &&
|
!skipVin
|
||||||
!isVinOptionalVehicle &&
|
|
||||||
experimentMixin.methods.hasSettingEqualTo(
|
|
||||||
experimentSettings.SUPPRESS_VIN_CAPTURE,
|
|
||||||
false
|
|
||||||
)
|
|
||||||
) {
|
) {
|
||||||
return fmgPageValues.VIN_LOOKUP;
|
return fmgPageValues.VIN_LOOKUP;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -219,40 +219,69 @@ describe("estimate.vue", () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("skipVinLookup", () => {
|
describe("test alertInfo and isRepair", () => {
|
||||||
const skipOptions = [
|
const skipOptions = [
|
||||||
[true, true, true, true],
|
[true, false, "AlertQuoteReady"],
|
||||||
[true, false, false, true],
|
[false, true, "AlertQuoteVinOptional"],
|
||||||
[false, true, true, true],
|
[false, false, "AlertQuoteReady"],
|
||||||
[false, false, false, false],
|
[true, true, "AlertQuoteVinOptional"],
|
||||||
];
|
];
|
||||||
test.each(skipOptions)(
|
test.each(skipOptions)(
|
||||||
"isRepair %s, isVinOptional %s and suppressVinCapture %s should return %s",
|
"isRepair %s, skipVinNotRepair %s alertInfo should return %s",
|
||||||
async (isRepair, isVinOptionalVehicle, suppressVinCapture, expectedVinSkip) => {
|
async (isRepair, skipVinNotRepair, expectedAlertInfo) => {
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
await wrapper.setData({
|
await wrapper.setData({
|
||||||
isVinOptionalVehicle: isVinOptionalVehicle,
|
skipVinNotRepair: skipVinNotRepair,
|
||||||
});
|
});
|
||||||
|
|
||||||
store.commit(storeMutations.UPDATE_IS_REPAIR, isRepair);
|
store.commit(storeMutations.UPDATE_IS_REPAIR, isRepair);
|
||||||
const mockExperimentsList = [
|
|
||||||
{
|
|
||||||
universeName: "ConceptFunnel",
|
|
||||||
settings: {
|
|
||||||
SuppressVinCapture: suppressVinCapture,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
store.commit(storeMutations.UPDATE_EXPERIMENTS, mockExperimentsList);
|
|
||||||
|
|
||||||
expect(wrapper.vm.skipVinLookup).toEqual(expectedVinSkip);
|
expect(wrapper.vm.alertInfo).toEqual(expectedAlertInfo);
|
||||||
|
expect(wrapper.vm.isRepair).toEqual(isRepair);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("test skipVin Navigation", () => {
|
||||||
|
test("skipVin for repair ForwardButtonAction triggers a router.navigateWithSaving", async () => {
|
||||||
|
//Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
await wrapper.setData({
|
||||||
|
skipVin: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
store.commit(storeMutations.UPDATE_IS_REPAIR, true);
|
||||||
|
store.commit(storeMutations.UPDATE_MAKE, "acura");
|
||||||
|
|
||||||
|
//Act
|
||||||
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test("skipVin for non-repair ForwardButtonAction triggers navigateForwardWithSingleCarMatch", async () => {
|
||||||
|
//Arrange
|
||||||
|
const { wrapper } = setupMocks({});
|
||||||
|
await wrapper.setData({
|
||||||
|
skipVin: true,
|
||||||
|
});
|
||||||
|
wrapper.vm.navigateForwardWithSingleCarMatch = jest.fn();
|
||||||
|
|
||||||
|
store.commit(storeMutations.UPDATE_IS_REPAIR, false);
|
||||||
|
store.commit(storeMutations.UPDATE_MAKE, "acura");
|
||||||
|
|
||||||
|
//Act
|
||||||
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
||||||
|
//Assert
|
||||||
|
expect(wrapper.vm.navigateForwardWithSingleCarMatch).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
function setupMocks({
|
function setupMocks({
|
||||||
groupName = "estimate",
|
groupName = "estimate",
|
||||||
isVinOptionalVehicle = false,
|
skipVin = false,
|
||||||
cmsQuestionText = "Let's get your VIN. Or we can look it up for you!",
|
cmsQuestionText = "Let's get your VIN. Or we can look it up for you!",
|
||||||
cmsAnswers = [
|
cmsAnswers = [
|
||||||
{ Name: "Provide my VIN manually Most specific to your vehicle" },
|
{ Name: "Provide my VIN manually Most specific to your vehicle" },
|
||||||
|
|
@ -284,7 +313,10 @@ function setupMocks({
|
||||||
mountOptions["attachTo"] = document.body;
|
mountOptions["attachTo"] = document.body;
|
||||||
|
|
||||||
const wrapper = shallowMount(estimate, mountOptions);
|
const wrapper = shallowMount(estimate, mountOptions);
|
||||||
wrapper.vm.isVinOptionalVehicle = isVinOptionalVehicle;
|
wrapper.vm.skipVin = skipVin;
|
||||||
|
wrapper.vm.getZipCodeData = jest
|
||||||
|
.fn()
|
||||||
|
.mockReturnValue({ isValid: true, isServiceable: true, state: "OH" });
|
||||||
|
|
||||||
return { wrapper, apiPromise };
|
return { wrapper, apiPromise };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<vehicleBanner cmsWidgetName="VehicleBannerWidget" />
|
<vehicleBanner cmsWidgetName="VehicleBannerWidget" />
|
||||||
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" />
|
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" />
|
||||||
<div class="fade-on-route-transition sub-container make-tall">
|
<div class="fade-on-route-transition sub-container make-tall">
|
||||||
<div v-if="!skipVinLookup">
|
<div v-if="!skipVin">
|
||||||
<alert
|
<alert
|
||||||
class="vinLookupMethodHeading"
|
class="vinLookupMethodHeading"
|
||||||
cmsWidgetName="AlertVinLookupQuestion"
|
cmsWidgetName="AlertVinLookupQuestion"
|
||||||
|
|
@ -101,7 +101,10 @@ import { Form, defineRule } from "vee-validate";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import { storeActions } from "@/constants/store-actions";
|
import { storeActions } from "@/constants/store-actions";
|
||||||
import { vinLookupMethodSelections } from "@/constants/vin-lookup-method-selections.js";
|
import { vinLookupMethodSelections } from "@/constants/vin-lookup-method-selections.js";
|
||||||
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
import {
|
||||||
|
skipVinLookup,
|
||||||
|
skipVinLookupNotRepair,
|
||||||
|
} from "@/helpers/heritage-integration/navigation-helper";
|
||||||
import experimentMixin from "@/mixins/experiment-mixin";
|
import experimentMixin from "@/mixins/experiment-mixin";
|
||||||
import { experimentSettings } from "@/constants/experiments";
|
import { experimentSettings } from "@/constants/experiments";
|
||||||
import vinPagesMixin from "@/mixins/vin-pages-mixin";
|
import vinPagesMixin from "@/mixins/vin-pages-mixin";
|
||||||
|
|
@ -129,7 +132,8 @@ export default {
|
||||||
emailAddress: this.getEmailFromStore(),
|
emailAddress: this.getEmailFromStore(),
|
||||||
displayInvalidZipAlert: false,
|
displayInvalidZipAlert: false,
|
||||||
displayNonServiceableZipAlert: false,
|
displayNonServiceableZipAlert: false,
|
||||||
isVinOptionalVehicle: false,
|
skipVin: false,
|
||||||
|
skipVinNotRepair: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -146,14 +150,16 @@ export default {
|
||||||
];
|
];
|
||||||
|
|
||||||
const resultMap = await settleAllPromises(promiseResultMap);
|
const resultMap = await settleAllPromises(promiseResultMap);
|
||||||
const isVinOptionalVehicle = await store.dispatch(storeActions.IS_VIN_OPTIONAL_VEHICLE);
|
const skipVin = await skipVinLookup();
|
||||||
|
const skipVinNotRepair = await skipVinLookupNotRepair();
|
||||||
|
|
||||||
next((vm) => {
|
next((vm) => {
|
||||||
vm.isVinOptionalVehicle = isVinOptionalVehicle;
|
vm.skipVin = skipVin;
|
||||||
|
vm.skipVinNotRepair = skipVinNotRepair;
|
||||||
if (resultMap.cmsContent.FunnelFooterWidget.ForwardButtonText.includes("|")) {
|
if (resultMap.cmsContent.FunnelFooterWidget.ForwardButtonText.includes("|")) {
|
||||||
const forwardTextOption =
|
const forwardTextOption =
|
||||||
resultMap.cmsContent.FunnelFooterWidget.ForwardButtonText.split("|");
|
resultMap.cmsContent.FunnelFooterWidget.ForwardButtonText.split("|");
|
||||||
if (store.getters.damage.isRepair || vm.isVinOptionalVehicle) {
|
if (skipVin) {
|
||||||
resultMap.cmsContent.FunnelFooterWidget.ForwardButtonText =
|
resultMap.cmsContent.FunnelFooterWidget.ForwardButtonText =
|
||||||
forwardTextOption[1];
|
forwardTextOption[1];
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -180,9 +186,8 @@ export default {
|
||||||
this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route);
|
this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route);
|
||||||
},
|
},
|
||||||
async forwardButtonAction() {
|
async forwardButtonAction() {
|
||||||
if (this.skipVinLookup) {
|
if (this.skipVin) {
|
||||||
const zipCodeData = await this.getZipCodeData(this.serviceZipCode);
|
const zipCodeData = await this.getZipCodeData(this.serviceZipCode);
|
||||||
|
|
||||||
await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.emailAddress, false);
|
await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.emailAddress, false);
|
||||||
await this.dispatchStoreAction(
|
await this.dispatchStoreAction(
|
||||||
storeActions.SAVE_SERVICE_LOCATION,
|
storeActions.SAVE_SERVICE_LOCATION,
|
||||||
|
|
@ -256,25 +261,8 @@ export default {
|
||||||
isRepair() {
|
isRepair() {
|
||||||
return store.getters.damage.isRepair;
|
return store.getters.damage.isRepair;
|
||||||
},
|
},
|
||||||
skipVinLookup() {
|
|
||||||
return (
|
|
||||||
this.isRepair ||
|
|
||||||
this.isVinOptionalVehicle ||
|
|
||||||
experimentMixin.methods.hasSettingEqualTo(
|
|
||||||
experimentSettings.SUPPRESS_VIN_CAPTURE,
|
|
||||||
true
|
|
||||||
)
|
|
||||||
);
|
|
||||||
},
|
|
||||||
alertInfo() {
|
alertInfo() {
|
||||||
return (this.isVinOptionalVehicle ||
|
return this.skipVinNotRepair ? "AlertQuoteVinOptional" : "AlertQuoteReady";
|
||||||
experimentMixin.methods.hasSettingEqualTo(
|
|
||||||
experimentSettings.SUPPRESS_VIN_CAPTURE,
|
|
||||||
true
|
|
||||||
)) &&
|
|
||||||
!this.isRepair
|
|
||||||
? "AlertQuoteVinOptional"
|
|
||||||
: "AlertQuoteReady";
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue