lp lookup and start of address lookup
This commit is contained in:
parent
3226ec4e6e
commit
ec05b56e51
10 changed files with 282 additions and 292 deletions
|
|
@ -3,10 +3,8 @@ import { externalUrls } from "@/router/router-constants/externalUrl-values";
|
||||||
import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js";
|
import { lazyLoadComponent } from "@/router/dynamic-routing/component-loader.js";
|
||||||
import { saveOrder } from "@/helpers/heritage-integration/order-helper.js";
|
import { saveOrder } from "@/helpers/heritage-integration/order-helper.js";
|
||||||
import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
|
import { fmgPageValues } from "@/router/router-constants/fmgPage-values";
|
||||||
import { storeActions } from "@/constants/store-actions";
|
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
import baseMixin from "@/mixins/base-mixin.js";
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
If the user has visited the funnel before this method will determine the bets place to
|
If the user has visited the funnel before this method will determine the bets place to
|
||||||
|
|
@ -54,21 +52,6 @@ export async function navigateToHeritageFunnel() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function navigateAfterSaveToHeritageFunnel(currentRoute) {
|
|
||||||
const currentComponent = currentRoute.matched[0].components;
|
|
||||||
|
|
||||||
// Create the order (or save existing order) when navigating to Heritage Funnel.
|
|
||||||
await saveOrder();
|
|
||||||
|
|
||||||
router.navigateToExternalUrl(
|
|
||||||
externalUrls.HERITAGE_FUNNEL,
|
|
||||||
{
|
|
||||||
corid: store.getters.order.referralCorrelationId,
|
|
||||||
src: "concept-funnel"
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Logic for getting the last "valid" page a user visited.
|
Logic for getting the last "valid" page a user visited.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import { storeActions } from "@/constants/store-actions";
|
||||||
import { storeMutations } from "@/constants/store-mutations";
|
import { storeMutations } from "@/constants/store-mutations";
|
||||||
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
|
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import { navigateAfterSaveToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
||||||
|
|
||||||
|
|
||||||
jest.mock("@/helpers/damage-helper", () => ({
|
jest.mock("@/helpers/damage-helper", () => ({
|
||||||
|
|
@ -17,7 +17,7 @@ jest.mock("@/helpers/damage-helper", () => ({
|
||||||
}));
|
}));
|
||||||
|
|
||||||
jest.mock("@/helpers/heritage-integration/navigation-helper", () => ({
|
jest.mock("@/helpers/heritage-integration/navigation-helper", () => ({
|
||||||
navigateAfterSaveToHeritageFunnel: jest.fn()
|
navigateToHeritageFunnel: jest.fn()
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe("address-lookup.vue", () => {
|
describe("address-lookup.vue", () => {
|
||||||
|
|
@ -262,7 +262,7 @@ describe("address-lookup.vue", () => {
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(wrapper.vm.updateVehicleInfo).toHaveBeenCalled();
|
expect(wrapper.vm.updateVehicleInfo).toHaveBeenCalled();
|
||||||
expect(navigateAfterSaveToHeritageFunnel).toHaveBeenCalled();
|
expect(navigateToHeritageFunnel).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("if the car entered does not match any of the multiple vehicles found, navigate to address-vehicles page", async () => {
|
test("if the car entered does not match any of the multiple vehicles found, navigate to address-vehicles page", async () => {
|
||||||
|
|
|
||||||
|
|
@ -132,17 +132,13 @@ export default {
|
||||||
isSelectedGlassAvailableForVehicle: false,
|
isSelectedGlassAvailableForVehicle: false,
|
||||||
customAlertData: {},
|
customAlertData: {},
|
||||||
showServiceZipField: this.getServiceZipFromStore(),
|
showServiceZipField: this.getServiceZipFromStore(),
|
||||||
isZipServicable: false,
|
isZipServiceable: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
arePagePrerequisitesValid() {
|
arePagePrerequisitesValid() {
|
||||||
return store.getters.vehicle.carId !== null;
|
return store.getters.vehicle.carId !== null;
|
||||||
},
|
},
|
||||||
resetDependentState() {
|
|
||||||
store.commit(storeMutations.UPDATE_REGISTRATION_LICENSE_PLATE, null);
|
|
||||||
store.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
|
|
||||||
},
|
|
||||||
backButtonAction() {
|
backButtonAction() {
|
||||||
// route to move backwards
|
// route to move backwards
|
||||||
this.$router.navigate(
|
this.$router.navigate(
|
||||||
|
|
@ -187,50 +183,69 @@ export default {
|
||||||
async forwardButtonAction() {
|
async forwardButtonAction() {
|
||||||
this.resetWarningsAndErrors();
|
this.resetWarningsAndErrors();
|
||||||
|
|
||||||
// Lookup VIN(s) with the provided address
|
let vehicleInfoToCommit = {};
|
||||||
const vinLookupPromise = this.lookupVin(
|
let registrationInfoToCommit = {};
|
||||||
this.customerQuestions.lastName,
|
|
||||||
this.customerQuestions.addressQuestions.streetAddress,
|
const vinLookupResponse = this.dispatchStoreAction(
|
||||||
this.customerQuestions.addressQuestions.zipCode,
|
storeActions.LOOKUP_VIN_BY_ADDRESS,
|
||||||
this.customerQuestions.addressQuestions.state
|
{
|
||||||
);
|
licenseLastName: this.customerQuestions.lastName,
|
||||||
|
licenseStreetAddress: this.customerQuestions.addressQuestions.streetAddress,
|
||||||
|
licenseZip: this.customerQuestions.addressQuestions.zipCode,
|
||||||
|
licenseState: this.customerQuestions.addressQuestions.state
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
// Settle promises and get results
|
||||||
|
const promiseResultMap = [
|
||||||
|
{
|
||||||
|
resultKey: "vinLookupResponse",
|
||||||
|
promise: vinLookupResponse
|
||||||
|
},
|
||||||
|
{
|
||||||
|
resultKey: "serviceZipValidationResponse",
|
||||||
|
promise: this.serviceZipCode ?
|
||||||
|
this.dispatchStoreAction(storeActions.VALIDATE_ZIP, {zip: this.serviceZipCode }) :
|
||||||
|
this.dispatchStoreAction(storeActions.VALIDATE_ZIP, {zip: this.customerQuestions.addressQuestions.zipCode })
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
const resultMap = await settleAllPromises(promiseResultMap);
|
||||||
|
|
||||||
// Verify if the service zip code or registration zip code provided is serviceable
|
// Verify if the service zip code or registration zip code provided is serviceable
|
||||||
const serviceZipValidationPromise = this.serviceZipCode ? this.validateZip(this.serviceZipCode) : this.validateZip(this.customerQuestions.addressQuestions.zipCode);
|
if (!resultMap.vinLookupResponse.isStatePermissible) {
|
||||||
|
|
||||||
const vinLookupResponse = await vinLookupPromise;
|
|
||||||
const serviceZipValidationResponse = await serviceZipValidationPromise;
|
|
||||||
|
|
||||||
if (!vinLookupResponse.data.isStatePermissible) {
|
|
||||||
// State Restrictions forbid lookup by address
|
// State Restrictions forbid lookup by address
|
||||||
this.displayVinLookupByHomeAddressNotAllowedAlert = true;
|
this.displayVinLookupByHomeAddressNotAllowedAlert = true;
|
||||||
this.$refs.funnelFooter.removeLoader();
|
return this.$refs.funnelFooter.removeLoader();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the neither the registration zip code or service zip code are not serviceable
|
// if the neither the registration zip code or service zip code are not serviceable
|
||||||
this.isZipServicable = serviceZipValidationResponse.data.isServiceable;
|
this.isZipServiceable = resultMap.serviceZipValidationResponse.isServiceable;
|
||||||
if (!this.isZipServicable) {
|
|
||||||
|
if (!this.isZipServiceable) {
|
||||||
this.displayNonServiceableZipAlert = true;
|
this.displayNonServiceableZipAlert = true;
|
||||||
this.showServiceZipField = true;
|
this.showServiceZipField = true;
|
||||||
this.$refs.funnelFooter.removeLoader();
|
return this.$refs.funnelFooter.removeLoader();
|
||||||
} else if (!this.serviceZipCode) {
|
}
|
||||||
// if the registration zip code is servicable and nothing was entered for the service zip code
|
|
||||||
// then set the service zip code to the registration zip code
|
// if the registration zip code is serviceable and nothing was entered for the service zip code
|
||||||
|
// then set the service zip code to the registration zip code
|
||||||
|
if (!this.serviceZipCode) {
|
||||||
this.serviceZipCode = this.customerQuestions.addressQuestions.zipCode;
|
this.serviceZipCode = this.customerQuestions.addressQuestions.zipCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
const carEntered = store.getters.vehicle;
|
//const carEntered = store.getters.vehicle;
|
||||||
const carsFound = vinLookupResponse.data.vinVehicles;
|
const vinsFound = resultMap.vinLookupResponse.vinVehicles;
|
||||||
|
|
||||||
if (carsFound.length == 0) {
|
// No VINs found
|
||||||
// No VINs found
|
if (vinsFound.length == 0) {
|
||||||
this.displayVinNotFoundAlert = true;
|
this.displayVinNotFoundAlert = true;
|
||||||
this.$refs.funnelFooter.removeLoader();
|
return this.$refs.funnelFooter.removeLoader();
|
||||||
return;
|
}
|
||||||
} else if (carsFound.length == 1) {
|
|
||||||
const carFound = carsFound[0].vehicle;
|
// Single VIN found
|
||||||
this.isCarIdDifferent = carFound.carId !== carEntered.carId;
|
if (vinsFound.length == 1) {
|
||||||
|
const carFound = vinsFound[0].vehicle;
|
||||||
|
this.isCarIdDifferent = carFound.carId !== this.$store.getters.vehicle.carId;
|
||||||
|
|
||||||
if (this.isCarIdDifferent && carFound.carId !== this.previouslyEnteredCarId) {
|
if (this.isCarIdDifferent && carFound.carId !== this.previouslyEnteredCarId) {
|
||||||
// Display Alert
|
// Display Alert
|
||||||
|
|
@ -242,49 +257,93 @@ export default {
|
||||||
|
|
||||||
// Update button "Continue with..."
|
// Update button "Continue with..."
|
||||||
this.$refs.funnelFooter.updateButtonText(`Continue with ${carFound.year} ${carFound.make} ${carFound.model}`);
|
this.$refs.funnelFooter.updateButtonText(`Continue with ${carFound.year} ${carFound.make} ${carFound.model}`);
|
||||||
this.$refs.funnelFooter.removeLoader();
|
return this.$refs.funnelFooter.removeLoader();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.isZipServiceable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.isZipServicable) {
|
// update data if the zip or service zip is serviceable
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// update data if the zip or service zip is servicable
|
// --> New Save Method
|
||||||
this.updateVehicleInfo(carsFound[0].vin, carFound);
|
|
||||||
this.updateCustomerInfo(serviceZipValidationResponse.data.state);
|
|
||||||
|
|
||||||
} else if (carsFound.length > 1) {
|
// state.order.vehicle.registration.licensePlate = registrationInfo?.licensePlate;
|
||||||
if (!this.isZipServicable) {
|
// state.order.vehicle.registration.address = registrationInfo?.address;
|
||||||
|
// state.order.vehicle.registration.city = registrationInfo?.city;
|
||||||
|
// state.order.vehicle.registration.state = registrationInfo?.state;
|
||||||
|
// state.order.vehicle.registration.zipCode = registrationInfo?.zipCode;
|
||||||
|
// state.order.vehicle.registration.firstName = registrationInfo?.firstName;
|
||||||
|
// state.order.vehicle.registration.lastName = registrationInfo?.lastName;
|
||||||
|
|
||||||
|
vehicleInfoToCommit = Object.assign(carFound, { vin: vinsFound[0].vin});
|
||||||
|
registrationInfoToCommit = {
|
||||||
|
firstName: this.customerQuestions.firstName,
|
||||||
|
lastName: this.customerQuestions.lastName,
|
||||||
|
address: this.customerQuestions.addressQuestions.streetAddress,
|
||||||
|
city: this.customerQuestions.addressQuestions.city,
|
||||||
|
state: this.customerQuestions.addressQuestions.state,
|
||||||
|
zipCode: this.customerQuestions.addressQuestions.zipCode
|
||||||
|
};
|
||||||
|
|
||||||
|
this.updateVehicleInfo(vinsFound[0].vin, carFound);
|
||||||
|
this.updateCustomerInfo(resultMap.serviceZipValidationResponse.state);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Found more than one VIN.
|
||||||
|
if (vinsFound.length > 1) {
|
||||||
|
if (!this.isZipServiceable) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if multiple cars were found
|
// if multiple cars were found
|
||||||
let matchingCars = carsFound.filter(car => car.vehicle.carId === carEntered.carId);
|
const matchingCars = vinsFound.filter(vin => vin.vehicle.carId === this.$store.getters.vehicle.carId);
|
||||||
|
|
||||||
|
// and one and only one of them matches the carId entered, save the vehicle info
|
||||||
|
// so we can go to the Heritage Funnel directly
|
||||||
if (matchingCars.length === 1) {
|
if (matchingCars.length === 1) {
|
||||||
// and one and only one of them matches the carId entered, save the vehicle info
|
|
||||||
// so we can go to the Heritage Funnel directly
|
this.updateVehicleInfo(matchingCars[0].vin, matchingCars[0].vehicle);
|
||||||
const matchingCar = matchingCars[0];
|
|
||||||
this.updateVehicleInfo(matchingCar.vin, matchingCar.vehicle);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update data if the zip or service zip is servicable
|
// update data if the zip or service zip is serviceable.
|
||||||
this.updateCustomerInfo(serviceZipValidationResponse.data.state);
|
this.updateCustomerInfo(resultMap.serviceZipValidationResponse.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.navigateForward(carEntered, carsFound);
|
// store.commit(storeMutations.UPDATE_REGISTRATION_ADDRESS, this.customerQuestions.addressQuestions.streetAddress);
|
||||||
|
// store.commit(storeMutations.UPDATE_REGISTRATION_CITY, this.customerQuestions.addressQuestions.city);
|
||||||
|
// store.commit(storeMutations.UPDATE_REGISTRATION_STATE, this.customerQuestions.addressQuestions.state);
|
||||||
|
// store.commit(storeMutations.UPDATE_REGISTRATION_ZIP_CODE, this.customerQuestions.addressQuestions.zipCode);
|
||||||
|
// store.commit(storeMutations.UPDATE_REGISTRATION_FIRST_NAME, this.customerQuestions.firstName);
|
||||||
|
// store.commit(storeMutations.UPDATE_REGISTRATION_LAST_NAME, this.customerQuestions.lastName);
|
||||||
|
// store.commit(storeMutations.UPDATE_SERVICE_LOCATION_ZIP_CODE, this.serviceZipCode);
|
||||||
|
// store.commit(storeMutations.UPDATE_SERVICE_LOCATION_STATE, serviceState);
|
||||||
|
// store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.customerQuestions.emailAddress);
|
||||||
|
|
||||||
|
// Save vin, vehicle, customer, service and registration information
|
||||||
|
await this.dispatchStoreAction(storeActions.SAVE_REGISTRATION_LICENSE_PLATE_LOOKUP, {
|
||||||
|
isCarIdDifferent: this.isCarIdDifferent,
|
||||||
|
isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle,
|
||||||
|
vehicleInfo: Object.assign(vinLookup.data.vehicle, { vin: vinLookup.data.vin }),
|
||||||
|
serviceLocationInfo: {
|
||||||
|
zipCode: this.serviceZip,
|
||||||
|
state: resultMap.serviceZipValidationResponse.state,
|
||||||
|
},
|
||||||
|
registrationInfo: {
|
||||||
|
licensePlate: this.licensePlate,
|
||||||
|
state: resultMap.registrationZipValidationResponse.state,
|
||||||
|
zipCode: this.registrationZip,
|
||||||
|
},
|
||||||
|
customerEmail: this.email,
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
return await this.navigateForward(carEntered, vinsFound);
|
||||||
},
|
},
|
||||||
resetWarningsAndErrors() {
|
async navigateForward(carEntered, vinsFound) {
|
||||||
this.displayVinNotFoundAlert = false;
|
|
||||||
this.displayNonServiceableZipAlert = false;
|
|
||||||
this.displayMatchedDifferentVehicleAlert = false;
|
|
||||||
this.displayVinLookupByHomeAddressNotAllowedAlert = false;
|
|
||||||
},
|
|
||||||
navigateForward(carEntered, carsFound) {
|
|
||||||
this.updateServiceLocationIfNecessary();
|
this.updateServiceLocationIfNecessary();
|
||||||
|
|
||||||
if (carsFound.length == 1) {
|
if (vinsFound.length == 1) {
|
||||||
// if a different vehicle is found than the one entered and the selected glass
|
// if a different vehicle is found than the one entered and the selected glass
|
||||||
// is not available for that vehicle
|
// is not available for that vehicle
|
||||||
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
|
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
|
||||||
|
|
@ -298,11 +357,11 @@ export default {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// otherwise
|
// otherwise
|
||||||
this.navigateForwardWithSingleCarMatch();
|
await this.navigateForwardWithSingleCarMatch();
|
||||||
}
|
}
|
||||||
} else if (carsFound.length > 1) {
|
} else if (vinsFound.length > 1) {
|
||||||
// if multiple cars were found
|
// if multiple cars were found
|
||||||
let matchingCars = carsFound.filter(car => car.vehicle.carId === carEntered.carId);
|
let matchingCars = vinsFound.filter(car => car.vehicle.carId === carEntered.carId);
|
||||||
if (matchingCars.length === 1) {
|
if (matchingCars.length === 1) {
|
||||||
// and one and only of them matches the car id entered
|
// and one and only of them matches the car id entered
|
||||||
const matchingCar = matchingCars[0];
|
const matchingCar = matchingCars[0];
|
||||||
|
|
@ -310,39 +369,18 @@ export default {
|
||||||
this.navigateForwardWithSingleCarMatch();
|
this.navigateForwardWithSingleCarMatch();
|
||||||
} else {
|
} else {
|
||||||
// if there are no matches or there are multiple matches, navigate to "address-vehicles" page
|
// if there are no matches or there are multiple matches, navigate to "address-vehicles" page
|
||||||
this.$router.navigate(this.navigationScenarios.CONTINUING_WITH_MULTIPLE_VEHICLES, this.$route, {}, {}, carsFound);
|
this.$router.navigate(this.navigationScenarios.CONTINUING_WITH_MULTIPLE_VEHICLES, this.$route, {}, {}, vinsFound);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
validateZip(zip) {
|
resetWarningsAndErrors() {
|
||||||
return this.dispatchStoreAction(
|
this.displayVinNotFoundAlert = false;
|
||||||
storeActions.VALIDATE_ZIP,
|
this.displayNonServiceableZipAlert = false;
|
||||||
{ zip });
|
this.displayMatchedDifferentVehicleAlert = false;
|
||||||
},
|
this.displayVinLookupByHomeAddressNotAllowedAlert = false;
|
||||||
lookupVin(lastName, streetAddress, zip, state) {
|
|
||||||
return this.dispatchStoreAction(
|
|
||||||
storeActions.LOOKUP_VIN_BY_ADDRESS,
|
|
||||||
{
|
|
||||||
licenseLastName: lastName,
|
|
||||||
licenseStreetAddress: streetAddress,
|
|
||||||
licenseZip: zip,
|
|
||||||
licenseState: state
|
|
||||||
}, false
|
|
||||||
);
|
|
||||||
},
|
|
||||||
updateVehicleInfo(vin, vehicleInfo) {
|
|
||||||
store.commit(storeMutations.UPDATE_VEHICLE_VIN, vin);
|
|
||||||
store.commit(storeMutations.UPDATE_YEAR, vehicleInfo.year);
|
|
||||||
store.commit(storeMutations.UPDATE_MAKE, vehicleInfo.make);
|
|
||||||
store.commit(storeMutations.UPDATE_MODEL, vehicleInfo.model);
|
|
||||||
store.commit(storeMutations.UPDATE_STYLE, vehicleInfo.style);
|
|
||||||
store.commit(storeMutations.UPDATE_CAR_ID, vehicleInfo.carId);
|
|
||||||
store.commit(storeMutations.UPDATE_VEHICLE_CATEGORY, vehicleInfo.category);
|
|
||||||
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_URL, vehicleInfo.imageUrl);
|
|
||||||
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_VIF_NUMBER, vehicleInfo.imageVifNumber);
|
|
||||||
store.commit(storeMutations.UPDATE_VEHICLE_IMAGE_COLOR, vehicleInfo.imageColor);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
updateCustomerInfo(serviceState) {
|
updateCustomerInfo(serviceState) {
|
||||||
store.commit(storeMutations.UPDATE_REGISTRATION_ADDRESS, this.customerQuestions.addressQuestions.streetAddress);
|
store.commit(storeMutations.UPDATE_REGISTRATION_ADDRESS, this.customerQuestions.addressQuestions.streetAddress);
|
||||||
store.commit(storeMutations.UPDATE_REGISTRATION_CITY, this.customerQuestions.addressQuestions.city);
|
store.commit(storeMutations.UPDATE_REGISTRATION_CITY, this.customerQuestions.addressQuestions.city);
|
||||||
|
|
|
||||||
|
|
@ -230,7 +230,7 @@ describe("addressVehicles.vue", () => {
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
||||||
wrapper.vm.$refs.loadingModal.showModal = jest.fn();
|
wrapper.vm.$refs.loadingModal.showModal = jest.fn();
|
||||||
navigateToHeritage.navigateAfterSaveToHeritageFunnel = jest.fn();
|
navigateToHeritage.navigateToHeritageFunnel = jest.fn();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.setData({
|
await wrapper.setData({
|
||||||
|
|
|
||||||
|
|
@ -246,7 +246,7 @@ describe("license-plate-lookup.vue", () => {
|
||||||
expect(wrapper.vm.$router.navigateAfterSave).toHaveBeenCalled();
|
expect(wrapper.vm.$router.navigateAfterSave).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("navigateAfterSaveToHeritageFunnel should be called if isCarIdDifferent is false or isSelectedGlassAvailableForVehicle is true when navigateForward is called", async () => {
|
test("navigateToHeritageFunnel should be called if isCarIdDifferent is false or isSelectedGlassAvailableForVehicle is true when navigateForward is called", async () => {
|
||||||
|
|
||||||
// Arrange
|
// Arrange
|
||||||
const { wrapper } = setupMocks({});
|
const { wrapper } = setupMocks({});
|
||||||
|
|
@ -258,11 +258,11 @@ describe("license-plate-lookup.vue", () => {
|
||||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
||||||
return '';
|
return '';
|
||||||
});
|
});
|
||||||
navigateToHeritage.navigateAfterSaveToHeritageFunnel = jest.fn();
|
navigateToHeritage.navigateToHeritageFunnel = jest.fn();
|
||||||
await wrapper.vm.navigateForward();
|
await wrapper.vm.navigateForward();
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
expect(navigateToHeritage.navigateAfterSaveToHeritageFunnel).toHaveBeenCalled();
|
expect(navigateToHeritage.navigateToHeritageFunnel).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("carId matches returned vehicle => navigateForwardWithSingleCarMatch", async () => {
|
test("carId matches returned vehicle => navigateForwardWithSingleCarMatch", async () => {
|
||||||
|
|
@ -366,7 +366,7 @@ describe("license-plate-lookup.vue", () => {
|
||||||
wrapper.vm.lookupVin = jest.fn().mockImplementation(() => new Promise(resolve => resolve(vinLookup)));
|
wrapper.vm.lookupVin = jest.fn().mockImplementation(() => new Promise(resolve => resolve(vinLookup)));
|
||||||
|
|
||||||
await wrapper.setData({ registrationZip: "00000" });
|
await wrapper.setData({ registrationZip: "00000" });
|
||||||
navigateToHeritage.navigateAfterSaveToHeritageFunnel = jest.fn();
|
navigateToHeritage.navigateToHeritageFunnel = jest.fn();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
@ -385,7 +385,7 @@ describe("license-plate-lookup.vue", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await wrapper.setData({ registrationZip: "00000" });
|
await wrapper.setData({ registrationZip: "00000" });
|
||||||
navigateToHeritage.navigateAfterSaveToHeritageFunnel = jest.fn();
|
navigateToHeritage.navigateToHeritageFunnel = jest.fn();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
|
|
@ -404,7 +404,7 @@ describe("license-plate-lookup.vue", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
await wrapper.setData({ registrationZip: "00000" });
|
await wrapper.setData({ registrationZip: "00000" });
|
||||||
navigateToHeritage.navigateAfterSaveToHeritageFunnel = jest.fn();
|
navigateToHeritage.navigateToHeritageFunnel = jest.fn();
|
||||||
await wrapper.vm.forwardButtonAction();
|
await wrapper.vm.forwardButtonAction();
|
||||||
wrapper.vm.$router.navigateAfterSave = jest.fn();
|
wrapper.vm.$router.navigateAfterSave = jest.fn();
|
||||||
// At this point, serviceZip field is shown
|
// At this point, serviceZip field is shown
|
||||||
|
|
@ -417,7 +417,7 @@ describe("license-plate-lookup.vue", () => {
|
||||||
const serviceZipField = wrapper.findComponent("[cmsWidgetName='ServiceZip']");
|
const serviceZipField = wrapper.findComponent("[cmsWidgetName='ServiceZip']");
|
||||||
expect(serviceZipField.exists()).toBe(true);
|
expect(serviceZipField.exists()).toBe(true);
|
||||||
expect(serviceZipField.isVisible()).toBe(true); 3
|
expect(serviceZipField.isVisible()).toBe(true); 3
|
||||||
expect(navigateToHeritage.navigateAfterSaveToHeritageFunnel).not.toHaveBeenCalled();
|
expect(navigateToHeritage.navigateToHeritageFunnel).not.toHaveBeenCalled();
|
||||||
expect(wrapper.vm.$router.navigateAfterSave).not.toHaveBeenCalled();
|
expect(wrapper.vm.$router.navigateAfterSave).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,13 +50,13 @@
|
||||||
class="my-3"
|
class="my-3"
|
||||||
:manualHeadline="NoServiceZipHeader"
|
:manualHeadline="NoServiceZipHeader"
|
||||||
:manualCopy="NoServiceZipBody"
|
:manualCopy="NoServiceZipBody"
|
||||||
v-if="!isRegistrationZipServicable && isVinValid && !isCarIdDifferent"
|
v-if="!isRegistrationZipServiceable && isVinValid && !isCarIdDifferent"
|
||||||
alertClass="alert-danger"
|
alertClass="alert-danger"
|
||||||
/>
|
/>
|
||||||
<div class="row my-2">
|
<div class="row my-2">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<textboxQuestion
|
<textboxQuestion
|
||||||
v-if="!isRegistrationZipServicable"
|
v-if="!isRegistrationZipServiceable"
|
||||||
cmsWidgetName="ServiceZip"
|
cmsWidgetName="ServiceZip"
|
||||||
v-model="serviceZip"
|
v-model="serviceZip"
|
||||||
inputId="serviceZip"
|
inputId="serviceZip"
|
||||||
|
|
@ -98,17 +98,15 @@ import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-he
|
||||||
import alert from "@/ux-components/alert/alert";
|
import alert from "@/ux-components/alert/alert";
|
||||||
import textboxQuestion from "@/common-components/textbox-question/textbox-question";
|
import textboxQuestion from "@/common-components/textbox-question/textbox-question";
|
||||||
import loadingModal from "@/common-components/loading-modal/loading-modal.vue";
|
import loadingModal from "@/common-components/loading-modal/loading-modal.vue";
|
||||||
|
|
||||||
// Supporting files
|
// Supporting files
|
||||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import { storeActions } from "@/constants/store-actions";
|
import { storeActions } from "@/constants/store-actions";
|
||||||
import { storeMutations } from "@/constants/store-mutations";
|
|
||||||
import { errorMessages } from "@/constants/error-messages";
|
import { errorMessages } from "@/constants/error-messages";
|
||||||
import {
|
import { getDamageString,isGlassAvailableForCarId} from "@/helpers/damage-helper";
|
||||||
getDamageString,
|
import { routerParams } from "@/router/router-constants/router-params";
|
||||||
isGlassAvailableForCarId,
|
|
||||||
} from "@/helpers/damage-helper";
|
|
||||||
import { required, regex } from "@/helpers/validation-rules";
|
import { required, regex } from "@/helpers/validation-rules";
|
||||||
import { Form, defineRule } from "vee-validate";
|
import { Form, defineRule } from "vee-validate";
|
||||||
import vinPagesMixin from "@/mixins/vin-pages-mixin";
|
import vinPagesMixin from "@/mixins/vin-pages-mixin";
|
||||||
|
|
@ -160,7 +158,7 @@ export default {
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
isRegistrationZipServicable: true,
|
isRegistrationZipServiceable: true,
|
||||||
isVinValid: true,
|
isVinValid: true,
|
||||||
isCarIdDifferent: false,
|
isCarIdDifferent: false,
|
||||||
licensePlate: this.getLicensePlateFromStore(),
|
licensePlate: this.getLicensePlateFromStore(),
|
||||||
|
|
@ -178,38 +176,20 @@ export default {
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
MatchedDifferentVehicleAlertHeader() {
|
MatchedDifferentVehicleAlertHeader() {
|
||||||
let text = this.getCmsContent(
|
return this.getCmsContent("MatchedDifferentVehicleAlertWidget","HeadlineText")
|
||||||
"MatchedDifferentVehicleAlertWidget",
|
.replaceAll("{custom:damage}", getDamageString());
|
||||||
"HeadlineText"
|
|
||||||
).replaceAll("{custom:damage}", getDamageString());
|
|
||||||
return text;
|
|
||||||
},
|
},
|
||||||
MatchedDifferentVehicleAlertBody() {
|
MatchedDifferentVehicleAlertBody() {
|
||||||
let text = this.getCmsContent(
|
return this.getCmsContent("MatchedDifferentVehicleAlertWidget","BodyText")
|
||||||
"MatchedDifferentVehicleAlertWidget",
|
|
||||||
"BodyText"
|
|
||||||
)
|
|
||||||
.replaceAll("{custom:damage}", getDamageString())
|
.replaceAll("{custom:damage}", getDamageString())
|
||||||
.replaceAll(
|
.replaceAll("{custom:plateLookupYear}",this.customAlertData?.vehicleInfo?.year)
|
||||||
"{custom:plateLookupYear}",
|
.replaceAll("{custom:plateLookupMake}",this.customAlertData?.vehicleInfo?.make)
|
||||||
this.customAlertData?.vehicleInfo?.year
|
.replaceAll("{custom:plateLookupModel}",this.customAlertData?.vehicleInfo?.model);
|
||||||
)
|
|
||||||
.replaceAll(
|
|
||||||
"{custom:plateLookupMake}",
|
|
||||||
this.customAlertData?.vehicleInfo?.make
|
|
||||||
)
|
|
||||||
.replaceAll(
|
|
||||||
"{custom:plateLookupModel}",
|
|
||||||
this.customAlertData?.vehicleInfo?.model
|
|
||||||
);
|
|
||||||
return text;
|
|
||||||
},
|
},
|
||||||
NoServiceZipHeader() {
|
NoServiceZipHeader() {
|
||||||
let text = this.getCmsContent(
|
return this.getCmsContent("NoServiceZipWidget","HeadlineText")
|
||||||
"NoServiceZipWidget",
|
.replaceAll("{custom:zip}", this.zipToDisplay);
|
||||||
"HeadlineText"
|
|
||||||
).replaceAll("{custom:zip}", this.zipToDisplay);
|
|
||||||
return text;
|
|
||||||
},
|
},
|
||||||
NoServiceZipBody() {
|
NoServiceZipBody() {
|
||||||
return this.getCmsContent("NoServiceZipWidget", "BodyText");
|
return this.getCmsContent("NoServiceZipWidget", "BodyText");
|
||||||
|
|
@ -230,110 +210,100 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getLicensePlateFromStore() {
|
getLicensePlateFromStore() {
|
||||||
return store.getters.vehicle.registration.licensePlate;
|
return this.$store.getters.vehicle.registration.licensePlate;
|
||||||
},
|
},
|
||||||
getRegistrationZipFromStore() {
|
getRegistrationZipFromStore() {
|
||||||
return store.getters.vehicle.registration.zipCode;
|
return this.$store.getters.vehicle.registration.zipCode;
|
||||||
},
|
},
|
||||||
getEmailFromStore() {
|
getEmailFromStore() {
|
||||||
return store.getters.order.customer.emailAddress;
|
return this.$store.getters.order.customer.emailAddress;
|
||||||
},
|
},
|
||||||
getServiceZipFromStore() {
|
getServiceZipFromStore() {
|
||||||
return store.getters.order.serviceLocation.zipCode;
|
return this.$store.getters.order.serviceLocation.zipCode;
|
||||||
},
|
},
|
||||||
backButtonAction() {
|
backButtonAction() {
|
||||||
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
|
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
|
||||||
},
|
},
|
||||||
async forwardButtonAction() {
|
async forwardButtonAction() {
|
||||||
//Call zip validation services
|
const registrationZipValidationResponse = this.dispatchStoreAction(storeActions.VALIDATE_ZIP, {zip: this.registrationZip });
|
||||||
const registrationZipValidationPromise = this.validateZip(this.registrationZip);
|
|
||||||
const registrationZipValidationResults = await registrationZipValidationPromise;
|
|
||||||
|
|
||||||
const serviceZipValidationPromise = this.serviceZip? this.validateZip(this.serviceZip): null;
|
// Settle promises and get results
|
||||||
const serviceZipValidationResults = serviceZipValidationPromise !== null ? await serviceZipValidationPromise: registrationZipValidationResults;
|
const promiseResultMap = [
|
||||||
|
{
|
||||||
|
resultKey: "registrationZipValidationResponse",
|
||||||
|
promise: registrationZipValidationResponse,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
resultKey: "serviceZipValidationResponse",
|
||||||
|
promise: this.serviceZip ? this.dispatchStoreAction(storeActions.VALIDATE_ZIP, {zip: this.serviceZip }) : registrationZipValidationResponse,
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
const resultMap = await settleAllPromises(promiseResultMap);
|
||||||
|
|
||||||
//Handle service zip validations
|
//Handle service zip validations
|
||||||
if (!serviceZipValidationResults.data.isServiceable) {
|
if (!resultMap.serviceZipValidationResponse.isServiceable) {
|
||||||
this.$refs.funnelFooter.removeLoader();
|
|
||||||
this.isVinValid = true;
|
this.isVinValid = true;
|
||||||
this.isRegistrationZipServicable = false;
|
this.isRegistrationZipServiceable = false;
|
||||||
this.isCarIdDifferent = false;
|
this.isCarIdDifferent = false;
|
||||||
this.zipToDisplay = this.serviceZip
|
this.zipToDisplay = this.serviceZip ? this.serviceZip : this.registrationZip;
|
||||||
? this.serviceZip
|
return this.$refs.funnelFooter.removeLoader();
|
||||||
: this.registrationZip;
|
}
|
||||||
return;
|
|
||||||
} else if (!this.serviceZip) {
|
if (!this.serviceZip) {
|
||||||
this.serviceZip = this.registrationZip;
|
this.serviceZip = this.registrationZip;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Lookup vin
|
//Lookup vin
|
||||||
const vinLookup = await this.lookupVin(
|
const vinLookup = await this.dispatchStoreAction(storeActions.LOOKUP_VIN_BY_PLATE,
|
||||||
this.licensePlate,
|
{ licensePlate: this.licensePlate, licenseState: resultMap.registrationZipValidationResponse.state }, false)
|
||||||
registrationZipValidationResults.data.state
|
.catch(() => {
|
||||||
).catch(() => {
|
|
||||||
this.$refs.funnelFooter.removeLoader();
|
|
||||||
this.isVinValid = false;
|
this.isVinValid = false;
|
||||||
this.isCarIdDifferent = false;
|
this.isCarIdDifferent = false;
|
||||||
return;
|
return this.$refs.funnelFooter.removeLoader();
|
||||||
});
|
});
|
||||||
|
|
||||||
this.isCarIdDifferent =
|
// Check if the CarId has changed.
|
||||||
vinLookup.data.vehicle.carId !== store.getters.vehicle.carId;
|
this.isCarIdDifferent = vinLookup.data.vehicle.carId !== this.$store.getters.vehicle.carId;
|
||||||
|
|
||||||
//Handle changing car
|
//Handle changing car
|
||||||
if (
|
if (this.isCarIdDifferent && vinLookup.data.vehicle.carId !== this.previouslyEnteredCarId) {
|
||||||
this.isCarIdDifferent &&
|
this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(vinLookup.data.vehicle.carId);
|
||||||
vinLookup.data.vehicle.carId !== this.previouslyEnteredCarId
|
this.$refs.funnelFooter.updateButtonText(`Continue with ${vinLookup.data.vehicle.year} ${vinLookup.data.vehicle.make} ${vinLookup.data.vehicle.model}`);
|
||||||
) {
|
|
||||||
this.previouslyEnteredCarId = vinLookup.data.vehicle.carId;
|
this.previouslyEnteredCarId = vinLookup.data.vehicle.carId;
|
||||||
this.customAlertData.vehicleInfo = vinLookup.data.vehicle;
|
this.customAlertData.vehicleInfo = vinLookup.data.vehicle;
|
||||||
this.$refs.funnelFooter.updateButtonText(
|
|
||||||
`Continue with ${vinLookup.data.vehicle.year} ${vinLookup.data.vehicle.make} ${vinLookup.data.vehicle.model}`
|
|
||||||
);
|
|
||||||
this.isVinValid = true;
|
this.isVinValid = true;
|
||||||
this.isSelectedGlassAvailableForVehicle = await isGlassAvailableForCarId(vinLookup.data.vehicle.carId);
|
|
||||||
this.$refs.funnelFooter.removeLoader();
|
return this.$refs.funnelFooter.removeLoader();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save vin and vehicle information
|
// Save vin, vehicle, customer, service and registration information
|
||||||
this.dispatchStoreAction(storeActions.SAVE_VIN_LOOKUP, {
|
await this.dispatchStoreAction(storeActions.SAVE_REGISTRATION_LICENSE_PLATE_LOOKUP, {
|
||||||
isCarIdDifferent: this.isCarIdDifferent,
|
isCarIdDifferent: this.isCarIdDifferent,
|
||||||
isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle,
|
isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle,
|
||||||
vehicleInfo: Object.assign(vinLookup.data.vehicle, { vin: vinLookup.data.vin})
|
vehicleInfo: Object.assign(vinLookup.data.vehicle, { vin: vinLookup.data.vin }),
|
||||||
});
|
serviceLocationInfo: {
|
||||||
|
zipCode: this.serviceZip,
|
||||||
|
state: resultMap.serviceZipValidationResponse.state,
|
||||||
|
},
|
||||||
|
registrationInfo: {
|
||||||
|
licensePlate: this.licensePlate,
|
||||||
|
state: resultMap.registrationZipValidationResponse.state,
|
||||||
|
zipCode: this.registrationZip,
|
||||||
|
},
|
||||||
|
customerEmail: this.email,
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
return await this.navigateForward();
|
||||||
//Navigate
|
|
||||||
this.navigateForward();
|
|
||||||
},
|
},
|
||||||
navigateForward() {
|
async navigateForward() {
|
||||||
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
|
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
|
||||||
this.$router.navigate(
|
this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD,this.$route,{}, {[routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true });
|
||||||
this.navigationScenarios.CLICKED_FORWARD,
|
|
||||||
this.$route,
|
|
||||||
{},
|
|
||||||
{ displayVehicleChangeAlert: true },
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
this.navigateForwardWithSingleCarMatch();
|
await this.navigateForwardWithSingleCarMatch();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
validateZip(zip) {
|
|
||||||
return this.dispatchStoreAction(storeActions.VALIDATE_ZIP, {
|
|
||||||
zip,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
lookupVin(plate, state) {
|
|
||||||
return this.dispatchStoreAction(
|
|
||||||
storeActions.LOOKUP_VIN_BY_PLATE,
|
|
||||||
{ licensePlate: plate, licenseState: state },
|
|
||||||
false
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
licensePlate() {
|
licensePlate() {
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,6 @@ import loadingModal from '@/common-components/loading-modal/loading-modal.vue';
|
||||||
// Supporting files
|
// Supporting files
|
||||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||||
import { settleAllPromises } from "@/helpers/layout-helper";
|
import { settleAllPromises } from "@/helpers/layout-helper";
|
||||||
import store from "@/store";
|
|
||||||
import { storeActions } from "@/constants/store-actions";
|
import { storeActions } from "@/constants/store-actions";
|
||||||
import { storeMutations } from "@/constants/store-mutations";
|
import { storeMutations } from "@/constants/store-mutations";
|
||||||
import { errorMessages } from "@/constants/error-messages";
|
import { errorMessages } from "@/constants/error-messages";
|
||||||
|
|
@ -133,6 +132,8 @@ import { required, regex } from "@/helpers/validation-rules";
|
||||||
import { Form, defineRule } from "vee-validate";
|
import { Form, defineRule } from "vee-validate";
|
||||||
import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper";
|
import { getFunnelCookie } from "@/helpers/heritage-integration/cookie-helper";
|
||||||
import { routerParams } from "@/router/router-constants/router-params";
|
import { routerParams } from "@/router/router-constants/router-params";
|
||||||
|
|
||||||
|
import store from "@/store";
|
||||||
import vinPagesMixin from "@/mixins/vin-pages-mixin";
|
import vinPagesMixin from "@/mixins/vin-pages-mixin";
|
||||||
|
|
||||||
// DEFINE VALIDATION RULES
|
// DEFINE VALIDATION RULES
|
||||||
|
|
@ -243,13 +244,13 @@ export default {
|
||||||
return store.getters.vehicle.carId !== null;
|
return store.getters.vehicle.carId !== null;
|
||||||
},
|
},
|
||||||
getEmailFromStore(){
|
getEmailFromStore(){
|
||||||
return store.getters.order.customer.emailAddress;
|
return this.$store.getters.order.customer.emailAddress;
|
||||||
},
|
},
|
||||||
getVinFromStore(){
|
getVinFromStore(){
|
||||||
return store.getters.vehicle.vin;
|
return this.$store.getters.vehicle.vin;
|
||||||
},
|
},
|
||||||
getZipFromStore(){
|
getZipFromStore(){
|
||||||
return store.getters.order.serviceLocation.zipCode;
|
return this.$store.getters.order.serviceLocation.zipCode;
|
||||||
},
|
},
|
||||||
attachCustomEvents() {
|
attachCustomEvents() {
|
||||||
this.prependActionToMethod(this, this.forwardButtonAction, () => {
|
this.prependActionToMethod(this, this.forwardButtonAction, () => {
|
||||||
|
|
@ -267,7 +268,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
backButtonAction() {
|
backButtonAction() {
|
||||||
if (store.getters.vehicle.vin) {
|
if (this.$store.getters.vehicle.vin) {
|
||||||
this.$router.navigate(this.navigationScenarios.CLICKED_BACK_WITH_VIN, this.$route);
|
this.$router.navigate(this.navigationScenarios.CLICKED_BACK_WITH_VIN, this.$route);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -327,7 +328,7 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save vin, vehicle, customer and service information
|
// Save vin, vehicle, customer and service information
|
||||||
this.dispatchStoreAction(storeActions.SAVE_VIN_LOOKUP, {
|
await this.dispatchStoreAction(storeActions.SAVE_VIN_LOOKUP, {
|
||||||
isCarIdDifferent: this.isCarIdDifferent,
|
isCarIdDifferent: this.isCarIdDifferent,
|
||||||
isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle,
|
isSelectedGlassAvailableForVehicle: this.isSelectedGlassAvailableForVehicle,
|
||||||
vehicleInfo: Object.assign(resultMap.vehicleLookupResponse, { vin: this.vin }),
|
vehicleInfo: Object.assign(resultMap.vehicleLookupResponse, { vin: this.vin }),
|
||||||
|
|
@ -338,7 +339,7 @@ export default {
|
||||||
customerEmail: this.email,
|
customerEmail: this.email,
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
this.navigateForward();
|
return await this.navigateForward();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If a VIN has already been found. Validate the Service Zip (in case of changes)
|
// If a VIN has already been found. Validate the Service Zip (in case of changes)
|
||||||
|
|
@ -348,14 +349,14 @@ export default {
|
||||||
if (zipValidationResponse.data.isServiceable) {
|
if (zipValidationResponse.data.isServiceable) {
|
||||||
|
|
||||||
// If the Service Zip entered is serviceable then save the Zip Info and Email Address and navigate forward
|
// If the Service Zip entered is serviceable then save the Zip Info and Email Address and navigate forward
|
||||||
this.$store.commit(storeActions.UPDATE_SERVICE_LOCATION, {
|
await this.dispatchStoreAction(storeActions.SAVE_SERVICE_LOCATION, {
|
||||||
zipCode: this.zip,
|
zipCode: this.zip,
|
||||||
state: zipValidationResponse.data.state
|
state: zipValidationResponse.data.state
|
||||||
});
|
}, false);
|
||||||
|
|
||||||
this.$store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.email);
|
await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.email, false);
|
||||||
|
|
||||||
this.navigateForward();
|
return await this.navigateForward();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the Service Zip is NOT serviceable then show an alert
|
// If the Service Zip is NOT serviceable then show an alert
|
||||||
|
|
@ -363,11 +364,11 @@ export default {
|
||||||
|
|
||||||
return this.$refs.funnelFooter.removeLoader();
|
return this.$refs.funnelFooter.removeLoader();
|
||||||
},
|
},
|
||||||
navigateForward(){
|
async navigateForward(){
|
||||||
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
|
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
|
||||||
this.$router.navigate(this.navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, this.$route, {}, { [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true });
|
this.$router.navigate(this.navigationScenarios.SELECTED_VIN_HAS_MISMATCHED_GLASS, this.$route, {}, { [routerParams.DISPLAY_VEHICLE_CHANGE_ALERT]: true });
|
||||||
} else {
|
} else {
|
||||||
this.navigateForwardWithSingleCarMatch();
|
await this.navigateForwardWithSingleCarMatch();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setupUiForNonServiceableZip(zip) {
|
setupUiForNonServiceableZip(zip) {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import { storeActions } from "@/constants/store-actions.js";
|
import { storeActions } from "@/constants/store-actions.js";
|
||||||
import { storeMutations } from "@/constants/store-mutations.js";
|
import { storeMutations } from "@/constants/store-mutations.js";
|
||||||
import { navigateAfterSaveToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -13,15 +13,15 @@ export default {
|
||||||
const hasGlassLocationWithMultipleParts = partsOrQuestions.some(pq => pq.parts?.length > 1);
|
const hasGlassLocationWithMultipleParts = partsOrQuestions.some(pq => pq.parts?.length > 1);
|
||||||
|
|
||||||
if (hasPartsQuestions) {
|
if (hasPartsQuestions) {
|
||||||
this.$router.navigateAfterSave(this.navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS, this.$route, {}, {}, result.data);
|
this.$router.navigate(this.navigationScenarios.SELECTED_VIN_WITH_PART_QUESTIONS, this.$route, {}, {}, result.data);
|
||||||
}
|
}
|
||||||
else if (hasGlassLocationWithMultipleParts) {
|
else if (hasGlassLocationWithMultipleParts) {
|
||||||
this.$router.navigateAfterSave(this.navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS, this.$route, {}, {}, result.data);
|
this.$router.navigate(this.navigationScenarios.SELECTED_VIN_WITH_MULTIPLE_PARTS, this.$route, {}, {}, result.data);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
store.commit(storeMutations.UPDATE_GLASS_PARTS, result.data);
|
store.commit(storeMutations.UPDATE_GLASS_PARTS, result.data);
|
||||||
this.$refs.loadingModal.showModal();
|
this.$refs.loadingModal.showModal();
|
||||||
navigateAfterSaveToHeritageFunnel(this.$route);
|
navigateToHeritageFunnel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,10 @@ import { storeMutations } from "@/constants/store-mutations";
|
||||||
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
|
import { navigationScenarios } from "@/router/router-constants/navigation-scenarios";
|
||||||
import store from "@/store";
|
import store from "@/store";
|
||||||
import loadingModal from '@/common-components/loading-modal/loading-modal.vue';
|
import loadingModal from '@/common-components/loading-modal/loading-modal.vue';
|
||||||
import { navigateAfterSaveToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
import { navigateToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
||||||
|
|
||||||
jest.mock("@/helpers/heritage-integration/navigation-helper", () => ({
|
jest.mock("@/helpers/heritage-integration/navigation-helper", () => ({
|
||||||
navigateAfterSaveToHeritageFunnel: jest.fn()
|
navigateToHeritageFunnel: jest.fn()
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe("vin-pages-mixin", () => {
|
describe("vin-pages-mixin", () => {
|
||||||
|
|
@ -771,7 +771,7 @@ describe("vin-pages-mixin", () => {
|
||||||
await wrapper.vm.navigateForwardWithSingleCarMatch();
|
await wrapper.vm.navigateForwardWithSingleCarMatch();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
expect(navigateAfterSaveToHeritageFunnel).toHaveBeenCalledTimes(1);
|
expect(navigateToHeritageFunnel).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("multiple glass locations selected, each has one part and no part questions => go to heritage funnel", async () => {
|
test("multiple glass locations selected, each has one part and no part questions => go to heritage funnel", async () => {
|
||||||
|
|
@ -864,7 +864,7 @@ describe("vin-pages-mixin", () => {
|
||||||
partsOrQuestions: partsOrQuestions
|
partsOrQuestions: partsOrQuestions
|
||||||
});
|
});
|
||||||
|
|
||||||
// wrapper.vm.navigateAfterSaveToHeritageFunnel = jest.fn();
|
// wrapper.vm.navigateToHeritageFunnel = jest.fn();
|
||||||
store.commit = jest.fn();
|
store.commit = jest.fn();
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
|
|
@ -874,7 +874,7 @@ describe("vin-pages-mixin", () => {
|
||||||
expect(store.commit).toHaveBeenCalledTimes(1);
|
expect(store.commit).toHaveBeenCalledTimes(1);
|
||||||
expect(store.commit).toHaveBeenCalledWith(storeMutations.UPDATE_GLASS_PARTS, { partsOrQuestions })
|
expect(store.commit).toHaveBeenCalledWith(storeMutations.UPDATE_GLASS_PARTS, { partsOrQuestions })
|
||||||
expect(wrapper.vm.$refs.loadingModal.showModal).toHaveBeenCalledTimes(1);
|
expect(wrapper.vm.$refs.loadingModal.showModal).toHaveBeenCalledTimes(1);
|
||||||
expect(navigateAfterSaveToHeritageFunnel).toHaveBeenCalledTimes(1);
|
expect(navigateToHeritageFunnel).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -653,6 +653,7 @@ export const actions = {
|
||||||
|
|
||||||
// Business domain actions
|
// Business domain actions
|
||||||
|
|
||||||
|
// Vehicle domain
|
||||||
saveVehicleYear(context, year) {
|
saveVehicleYear(context, year) {
|
||||||
|
|
||||||
//Reset dependent state when changing
|
//Reset dependent state when changing
|
||||||
|
|
@ -750,10 +751,29 @@ export const actions = {
|
||||||
context.commit(storeMutations.UPDATE_GLASS_TO_REPLACE, selectedGlassToReplace);
|
context.commit(storeMutations.UPDATE_GLASS_TO_REPLACE, selectedGlassToReplace);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
saveVinLookup(context, { isCarIdDifferent, isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo, serviceLocationInfo, customerEmail }) {
|
|
||||||
|
|
||||||
|
// Vin domain
|
||||||
|
saveVinLookup(context, { isCarIdDifferent, isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo, serviceLocationInfo, customerEmail }) {
|
||||||
//Reset dependent state when changing
|
//Reset dependent state when changing
|
||||||
if (registrationInfo?.licensePlate !== context.state.order.registration?.licensePlate) {
|
if (vehicleInfo.vin !== context.state.order.vehicle.vin) {
|
||||||
|
|
||||||
|
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
|
||||||
|
|
||||||
|
if (isCarIdDifferent && !isSelectedGlassAvailableForVehicle) {
|
||||||
|
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Save new values
|
||||||
|
context.dispatch(storeActions.SAVE_EMAIL, customerEmail);
|
||||||
|
context.dispatch(storeActions.SAVE_SERVICE_LOCATION, serviceLocationInfo);
|
||||||
|
|
||||||
|
context.commit(storeMutations.UPDATE_VEHICLE, vehicleInfo);
|
||||||
|
context.commit(storeMutations.UPDATE_REGISTRATION, registrationInfo);
|
||||||
|
},
|
||||||
|
saveRegistrationLicensePlateLookup(context, { isCarIdDifferent, isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo, serviceLocationInfo, customerEmail }) {
|
||||||
|
//Reset dependent state when changing
|
||||||
|
if (registrationInfo?.licensePlate !== context.state.order.vehicle.registration?.licensePlate) {
|
||||||
|
|
||||||
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
|
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
|
||||||
|
|
||||||
|
|
@ -765,57 +785,35 @@ export const actions = {
|
||||||
//Save new values
|
//Save new values
|
||||||
context.commit(storeMutations.UPDATE_VEHICLE, vehicleInfo);
|
context.commit(storeMutations.UPDATE_VEHICLE, vehicleInfo);
|
||||||
context.commit(storeMutations.UPDATE_REGISTRATION, registrationInfo);
|
context.commit(storeMutations.UPDATE_REGISTRATION, registrationInfo);
|
||||||
context.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, customerEmail);
|
|
||||||
|
context.dispatch(storeActions.SAVE_EMAIL, customerEmail);
|
||||||
|
context.dispatch(storeActions.SAVE_SERVICE_LOCATION, serviceLocationInfo);
|
||||||
|
},
|
||||||
|
saveRegistrationAddressLookup(context, { isCarIdDifferent, isSelectedGlassAvailableForVehicle, vehicleInfo, registrationInfo, serviceLocationInfo, customerEmail}) {
|
||||||
|
//Reset dependent state when changing
|
||||||
|
if (registrationInfo?.address !== context.state.order.vehicle.registration?.address || registrationInfo?.city !== context.state.order.vehicle.registration?.city || registrationInfo?.state !== context.state.order.vehicle.registration?.state || registrationInfo?.zipCode !== context.state.order.vehicle.registration?.zipCode || registrationInfo?.firstName !== context.state.order.vehicle.registration?.firstName || registrationInfo?.lastName !== context.state.order.vehicle.registration?.lastName) {
|
||||||
|
|
||||||
|
context.dispatch(storeActions.RESET_REGISTRATION_STATE_AND_DEPENDENCIES);
|
||||||
|
|
||||||
|
if (isCarIdDifferent && !isSelectedGlassAvailableForVehicle) {
|
||||||
|
context.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//Save new values
|
||||||
|
context.commit(storeMutations.UPDATE_VEHICLE, vehicleInfo);
|
||||||
|
context.commit(storeMutations.UPDATE_REGISTRATION, registrationInfo);
|
||||||
|
|
||||||
|
context.dispatch(storeActions.SAVE_EMAIL, customerEmail);
|
||||||
|
context.dispatch(storeActions.SAVE_SERVICE_LOCATION, serviceLocationInfo);
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
saveServiceLocation(context, serviceLocationInfo) {
|
||||||
context.commit(storeMutations.UPDATE_SERVICE_LOCATION, serviceLocationInfo);
|
context.commit(storeMutations.UPDATE_SERVICE_LOCATION, serviceLocationInfo);
|
||||||
},
|
},
|
||||||
|
|
||||||
saveRegistrationLicensePlateLookup(context, { registrationInfo, serviceState, serviceZip, customerEmail, vehicleInfo, isCarIdDifferent, isSelectedGlassAvailableForVehicle }) {
|
|
||||||
|
|
||||||
if (registrationInfo.licensePlate !== context.state.order.registration.licensePlate || registrationInfo.zipcode !== context.state.order.registration.zipcode) {
|
|
||||||
|
|
||||||
//Reset dependent state when changing
|
|
||||||
if (isCarIdDifferent && !isSelectedGlassAvailableForVehicle) {
|
|
||||||
context.dispatch(storeMutations.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
|
||||||
}
|
|
||||||
|
|
||||||
context.commit(storeMutations.UPDATE_REGISTRATION_ADDRESS, null);
|
|
||||||
context.commit(storeMutations.UPDATE_REGISTRATION_CITY, null);
|
|
||||||
context.commit(storeMutations.UPDATE_REGISTRATION_FIRST_NAME, null);
|
|
||||||
context.commit(storeMutations.UPDATE_REGISTRATION_LAST_NAME, null);
|
|
||||||
|
|
||||||
//Save new values
|
|
||||||
context.dispatch(storeActions.SAVE_VIN_LOOKUP, { isCarIdDifferent, isSelectedGlassAvailableForVehicle, vehicleInfo });
|
|
||||||
|
|
||||||
context.commit(storeMutations.UPDATE_REGISTRATION_LICENSE_PLATE, registrationInfo.licensePlate);
|
|
||||||
context.commit(storeMutations.UPDATE_REGISTRATION_STATE, registrationInfo.state);
|
|
||||||
context.commit(storeMutations.UPDATE_REGISTRATION_ZIP_CODE, registrationInfo.zipCode);
|
|
||||||
|
|
||||||
context.dispatch(storeActions.SAVE_SERVICE_ZIP, serviceZip);
|
|
||||||
context.dispatch(storeActions.SAVE_SERVICE_STATE, serviceState);
|
|
||||||
context.dispatch(storeActions.SAVE_EMAIL, customerEmail);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
saveRegistrationAddressLookup(context, { licensePlate }) {
|
|
||||||
|
|
||||||
|
|
||||||
if (context.isCarIdDifferent && !context.isSelectedGlassAvailableForVehicle) {
|
|
||||||
storeMutations.RESET_DAMAGE_STATE_AND_DEPENDENCIES;
|
|
||||||
}
|
|
||||||
context.commit(storeMutations.UPDATE_REGISTRATION_ADDRESS, null);
|
|
||||||
context.commit(storeMutations.UPDATE_REGISTRATION_CITY, null);
|
|
||||||
context.commit(storeMutations.UPDATE_REGISTRATION_FIRST_NAME, null);
|
|
||||||
context.commit(storeMutations.UPDATE_REGISTRATION_LAST_NAME, null);
|
|
||||||
},
|
|
||||||
saveServiceLocation(context, { zipcode, state }) {
|
|
||||||
if (zipcode !== context.state.order.service.zipcode || state !== context.state.order.service.state) {
|
|
||||||
context.commit(storeMutations.UPDATE_SERVICE_LOCATION_ZIP_CODE, zipcode);
|
|
||||||
context.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, state);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
saveEmail(context, email) {
|
saveEmail(context, email) {
|
||||||
if (email !== context.state.order.customer.email) {
|
context.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, email);
|
||||||
context.commit(storeMutations.UPDATE_CUSTOM, email);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
saveVin(context, { isCarIdDifferent, isSelectedGlassAvailableForVehicle, vehicleInfo }) {
|
saveVin(context, { isCarIdDifferent, isSelectedGlassAvailableForVehicle, vehicleInfo }) {
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue