Merge pull request #868 from Safelite/feature/CSR-944-dev
Feature/csr 944 dev
This commit is contained in:
commit
a64bf65e5a
3 changed files with 58 additions and 55 deletions
|
|
@ -61,6 +61,33 @@ export async function navigateToHeritageFunnel({ shouldSaveSession = true, loadi
|
|||
});
|
||||
}
|
||||
|
||||
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.
|
||||
*/
|
||||
|
|
@ -81,9 +108,7 @@ async function getLatestPageForRedirection() {
|
|||
fmgPageValues.CAPABILITY_QUESTIONS
|
||||
);
|
||||
|
||||
const isVinOptionalVehicle = store.getters.order.vehicle.make
|
||||
? await store.dispatch(storeActions.IS_VIN_OPTIONAL_VEHICLE)
|
||||
: false;
|
||||
const skipVin = await skipVinLookup();
|
||||
|
||||
if (!vehicleMakeComponent.methods.arePagePrerequisitesValid()) {
|
||||
return fmgPageValues.VEHICLE_YEAR;
|
||||
|
|
@ -107,12 +132,7 @@ async function getLatestPageForRedirection() {
|
|||
} else if (
|
||||
// capture vin
|
||||
vinLookupComponent.methods.arePagePrerequisitesValid() &&
|
||||
!store.getters.damage.isRepair &&
|
||||
!isVinOptionalVehicle &&
|
||||
experimentMixin.methods.hasSettingEqualTo(
|
||||
experimentSettings.SUPPRESS_VIN_CAPTURE,
|
||||
false
|
||||
)
|
||||
!skipVin
|
||||
) {
|
||||
return fmgPageValues.VIN_LOOKUP;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -219,40 +219,32 @@ describe("estimate.vue", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("skipVinLookup", () => {
|
||||
describe("test alertInfo and isRepair", () => {
|
||||
const skipOptions = [
|
||||
[true, true, true, true],
|
||||
[true, false, false, true],
|
||||
[false, true, true, true],
|
||||
[false, false, false, false],
|
||||
[true, false, "AlertQuoteReady"],
|
||||
[false, true, "AlertQuoteVinOptional"],
|
||||
[false, false, "AlertQuoteReady"],
|
||||
[true, true, "AlertQuoteVinOptional"],
|
||||
];
|
||||
test.each(skipOptions)(
|
||||
"isRepair %s, isVinOptional %s and suppressVinCapture %s should return %s",
|
||||
async (isRepair, isVinOptionalVehicle, suppressVinCapture, expectedVinSkip) => {
|
||||
"isRepair %s, skipVinNotRepair %s alertInfo should return %s",
|
||||
async (isRepair, skipVinNotRepair, expectedAlertInfo) => {
|
||||
const { wrapper } = setupMocks({});
|
||||
await wrapper.setData({
|
||||
isVinOptionalVehicle: isVinOptionalVehicle,
|
||||
skipVinNotRepair: skipVinNotRepair,
|
||||
});
|
||||
|
||||
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);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
function setupMocks({
|
||||
groupName = "estimate",
|
||||
isVinOptionalVehicle = false,
|
||||
skipVin = false,
|
||||
cmsQuestionText = "Let's get your VIN. Or we can look it up for you!",
|
||||
cmsAnswers = [
|
||||
{ Name: "Provide my VIN manually Most specific to your vehicle" },
|
||||
|
|
@ -284,7 +276,10 @@ function setupMocks({
|
|||
mountOptions["attachTo"] = document.body;
|
||||
|
||||
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 };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
<vehicleBanner cmsWidgetName="VehicleBannerWidget" />
|
||||
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" />
|
||||
<div class="fade-on-route-transition sub-container make-tall">
|
||||
<div v-if="!skipVinLookup">
|
||||
<div v-if="!skipVin">
|
||||
<alert
|
||||
class="vinLookupMethodHeading"
|
||||
cmsWidgetName="AlertVinLookupQuestion"
|
||||
|
|
@ -103,7 +103,10 @@ import { Form, defineRule } from "vee-validate";
|
|||
import store from "@/store";
|
||||
import { storeActions } from "@/constants/store-actions";
|
||||
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 { experimentSettings } from "@/constants/experiments";
|
||||
import vinPagesMixin from "@/mixins/vin-pages-mixin";
|
||||
|
|
@ -131,7 +134,8 @@ export default {
|
|||
emailAddress: this.getEmailFromStore(),
|
||||
displayInvalidZipAlert: false,
|
||||
displayNonServiceableZipAlert: false,
|
||||
isVinOptionalVehicle: false,
|
||||
skipVin: false,
|
||||
skipVinNotRepair: false,
|
||||
};
|
||||
},
|
||||
|
||||
|
|
@ -148,14 +152,16 @@ export default {
|
|||
];
|
||||
|
||||
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) => {
|
||||
vm.isVinOptionalVehicle = isVinOptionalVehicle;
|
||||
vm.skipVin = skipVin;
|
||||
vm.skipVinNotRepair = skipVinNotRepair;
|
||||
if (resultMap.cmsContent.FunnelFooterWidget.ForwardButtonText.includes("|")) {
|
||||
const forwardTextOption =
|
||||
resultMap.cmsContent.FunnelFooterWidget.ForwardButtonText.split("|");
|
||||
if (store.getters.damage.isRepair || vm.isVinOptionalVehicle) {
|
||||
if (skipVin) {
|
||||
resultMap.cmsContent.FunnelFooterWidget.ForwardButtonText =
|
||||
forwardTextOption[1];
|
||||
} else {
|
||||
|
|
@ -182,9 +188,8 @@ export default {
|
|||
this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route);
|
||||
},
|
||||
async forwardButtonAction() {
|
||||
if (this.skipVinLookup) {
|
||||
if (this.skipVin) {
|
||||
const zipCodeData = await this.getZipCodeData(this.serviceZipCode);
|
||||
|
||||
await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.emailAddress, false);
|
||||
await this.dispatchStoreAction(
|
||||
storeActions.SAVE_SERVICE_LOCATION,
|
||||
|
|
@ -264,25 +269,8 @@ export default {
|
|||
isRepair() {
|
||||
return store.getters.damage.isRepair;
|
||||
},
|
||||
skipVinLookup() {
|
||||
return (
|
||||
this.isRepair ||
|
||||
this.isVinOptionalVehicle ||
|
||||
experimentMixin.methods.hasSettingEqualTo(
|
||||
experimentSettings.SUPPRESS_VIN_CAPTURE,
|
||||
true
|
||||
)
|
||||
);
|
||||
},
|
||||
alertInfo() {
|
||||
return (this.isVinOptionalVehicle ||
|
||||
experimentMixin.methods.hasSettingEqualTo(
|
||||
experimentSettings.SUPPRESS_VIN_CAPTURE,
|
||||
true
|
||||
)) &&
|
||||
!this.isRepair
|
||||
? "AlertQuoteVinOptional"
|
||||
: "AlertQuoteReady";
|
||||
return this.skipVinNotRepair ? "AlertQuoteVinOptional" : "AlertQuoteReady";
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
|
|
|
|||
Loading…
Reference in a new issue