Omitting unneeded api parts call and adding unit tests
This commit is contained in:
parent
017ae832c5
commit
768191ea1a
4 changed files with 65 additions and 54 deletions
|
|
@ -11,7 +11,6 @@ module.exports = {
|
||||||
"!src/constants/*.js",
|
"!src/constants/*.js",
|
||||||
"!src/router/**/*.js",
|
"!src/router/**/*.js",
|
||||||
"!src/helpers/unit-test-helper.js",
|
"!src/helpers/unit-test-helper.js",
|
||||||
"!src/helpers/damage-helper.js",
|
|
||||||
"!src/layouts/component-test/component-test.vue",
|
"!src/layouts/component-test/component-test.vue",
|
||||||
"!src/layouts/form-test/form-test.vue",
|
"!src/layouts/form-test/form-test.vue",
|
||||||
"!src/layouts/vin-lookup/vin-lookup.vue",
|
"!src/layouts/vin-lookup/vin-lookup.vue",
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,24 @@ import baseMixin from "@/mixins/base-mixin.js";
|
||||||
import { storeActions } from "@/constants/store-actions";
|
import { storeActions } from "@/constants/store-actions";
|
||||||
|
|
||||||
export function getDamageString() {
|
export function getDamageString() {
|
||||||
return store.getters.damage.glassToReplace.length > 1 ? "match" : store.getters.damage.glassToReplace[0].location;
|
const damageLocations = store.getters.damage.glassToReplace;
|
||||||
|
let returnString;
|
||||||
|
if(damageLocations.length > 1){
|
||||||
|
returnString = "match"
|
||||||
|
} else {
|
||||||
|
switch(damageLocations[0].location) {
|
||||||
|
case "Windshield":
|
||||||
|
returnString = "windshield"
|
||||||
|
break;
|
||||||
|
case "Driver":
|
||||||
|
case "Passenger":
|
||||||
|
returnString = "side window"
|
||||||
|
break;
|
||||||
|
case "Rear":
|
||||||
|
returnString = "rear window"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return returnString;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function isGlassAvailableForCarId(carId){
|
export async function isGlassAvailableForCarId(carId){
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1,47 @@
|
||||||
import {getDamageString, isGlassAvailableForCarId} from "./damage-helper";
|
import {getDamageString, isGlassAvailableForCarId} from "./damage-helper";
|
||||||
//import baseMixin from "@/mixins/base-mixin.js";
|
import baseMixin from "@/mixins/base-mixin.js";
|
||||||
|
|
||||||
jest.mock("@/store", () => ({
|
jest.mock("@/store", () => ({
|
||||||
getters: {damage: {
|
getters: {damage: {
|
||||||
glassToReplace: [{location: "Windshield", name: "windshield"}]
|
glassToReplace: [{location: "Windshield", name: "windshield"}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe("damage-helper.js", () => {
|
describe("damage-helper.js", () => {
|
||||||
it("Should return damage getter info", () => {
|
it("Should return damage getter info", () => {
|
||||||
const damage = getDamageString();
|
const damage = getDamageString();
|
||||||
expect(damage).toEqual("Windshield")
|
expect(damage).toEqual("windshield")
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// describe("damage-helper.js", () => {
|
describe("damage-helper.js", () => {
|
||||||
// it("Should return false if no mismatches between each array", async () => {
|
it("Should return true if no mismatches between each array exist", async () => {
|
||||||
// const updatedOptions = {
|
const updatedOptions = {
|
||||||
// data: {
|
data: {
|
||||||
// windshieldOptions: {availableReplacementOptions: ["windshield"]}
|
windshieldOptions: {availableReplacementOptions: ["windshield"]}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// baseMixin.methods.dispatchNonBlockingStoreAction = jest.fn().mockImplementation(()=> {
|
baseMixin.methods.dispatchNonBlockingStoreAction = jest.fn().mockImplementation(()=> {
|
||||||
// return updatedOptions;
|
return updatedOptions;
|
||||||
// });
|
});
|
||||||
// const misMatch = await isGlassAvailableForCarId();
|
const misMatch = await isGlassAvailableForCarId();
|
||||||
// expect(misMatch).toEqual(false);
|
expect(misMatch).toEqual(true);
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
|
|
||||||
|
describe("damage-helper.js", () => {
|
||||||
|
it("Should return false if any mismatches between each array exist", async () => {
|
||||||
|
const updatedOptions = {
|
||||||
|
data: {
|
||||||
|
windshieldOptions: {availableReplacementOptions: ["Crack"]}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
baseMixin.methods.dispatchNonBlockingStoreAction = jest.fn().mockImplementation(()=> {
|
||||||
|
return updatedOptions;
|
||||||
|
});
|
||||||
|
const misMatch = await isGlassAvailableForCarId();
|
||||||
|
expect(misMatch).toEqual(false);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// describe("damage-helper.js", () => {
|
|
||||||
// it("Should return true if there are any mismatches between arrays", () => {
|
|
||||||
// const newOptions = {
|
|
||||||
// windshieldOptions: {availableReplacementOptions: ["window"]}
|
|
||||||
// }
|
|
||||||
// const currentOptions = [{location: "Windshield", name: "windshield"}];
|
|
||||||
// const misMatch = compareGlassOptions(newOptions, currentOptions);
|
|
||||||
// expect(misMatch).toEqual(true);
|
|
||||||
// });
|
|
||||||
// });
|
|
||||||
|
|
@ -128,22 +128,22 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
MatchedDifferentVehicleAlertHeader(){
|
MatchedDifferentVehicleAlertHeader() {
|
||||||
let text = this.getCmsContent("MatchedDifferentVehicleAlertWidget", "HeadlineText").replaceAll("{custom:damage}", getDamageString());
|
let text = this.getCmsContent("MatchedDifferentVehicleAlertWidget", "HeadlineText").replaceAll("{custom:damage}", getDamageString());
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
},
|
},
|
||||||
MatchedDifferentVehicleAlertBody(){
|
MatchedDifferentVehicleAlertBody() {
|
||||||
let text = this.getCmsContent("MatchedDifferentVehicleAlertWidget", "BodyText").replaceAll("{custom:damage}", getDamageString()).replaceAll("{custom:plateLookupYear}", this.customAlertData?.vehicleInfo?.year).replaceAll("{custom:plateLookupMake}", this.customAlertData?.vehicleInfo?.make).replaceAll("{custom:plateLookupModel}", this.customAlertData?.vehicleInfo?.model);
|
let text = this.getCmsContent("MatchedDifferentVehicleAlertWidget", "BodyText").replaceAll("{custom:damage}", getDamageString()).replaceAll("{custom:plateLookupYear}", this.customAlertData?.vehicleInfo?.year).replaceAll("{custom:plateLookupMake}", this.customAlertData?.vehicleInfo?.make).replaceAll("{custom:plateLookupModel}", this.customAlertData?.vehicleInfo?.model);
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
},
|
},
|
||||||
NoServiceZipHeader(){
|
NoServiceZipHeader() {
|
||||||
let text = this.getCmsContent("NoServiceZipWidget", "HeadlineText").replaceAll("{custom:zip}", this.registrationZip);
|
let text = this.getCmsContent("NoServiceZipWidget", "HeadlineText").replaceAll("{custom:zip}", this.registrationZip);
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
},
|
},
|
||||||
NoServiceZipBody(){
|
NoServiceZipBody() {
|
||||||
return this.getCmsContent("NoServiceZipWidget", "BodyText");
|
return this.getCmsContent("NoServiceZipWidget", "BodyText");
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -158,16 +158,16 @@ export default {
|
||||||
store.commit(storeMutations.UPDATE_REGISTRATION_LAST_NAME, null);
|
store.commit(storeMutations.UPDATE_REGISTRATION_LAST_NAME, null);
|
||||||
store.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
|
store.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
|
||||||
},
|
},
|
||||||
getLicensePlateFromStore(){
|
getLicensePlateFromStore() {
|
||||||
return store.getters.vehicle.registration.licensePlate
|
return store.getters.vehicle.registration.licensePlate
|
||||||
},
|
},
|
||||||
getRegistrationZipFromStore(){
|
getRegistrationZipFromStore() {
|
||||||
return store.getters.vehicle.registration.zipCode
|
return store.getters.vehicle.registration.zipCode
|
||||||
},
|
},
|
||||||
getEmailFromStore(){
|
getEmailFromStore() {
|
||||||
return store.getters.order.customer.emailAddress
|
return store.getters.order.customer.emailAddress
|
||||||
},
|
},
|
||||||
getServiceZipFromStore(){
|
getServiceZipFromStore() {
|
||||||
return store.getters.order.serviceLocation.zip
|
return store.getters.order.serviceLocation.zip
|
||||||
},
|
},
|
||||||
backButtonAction() {
|
backButtonAction() {
|
||||||
|
|
@ -202,23 +202,13 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateCustomerInfo(vinLookup.data.vin, vinLookup.data.vehicle, zipValidation.data.state);
|
this.updateStoreInfo(vinLookup.data.vin, vinLookup.data.vehicle, zipValidation.data.state);
|
||||||
|
|
||||||
const partsData = await baseMixin.methods.dispatchNonBlockingStoreAction(
|
this.navigateForward();
|
||||||
this.storeActions.GET_PARTS_OR_QUESTIONS,
|
|
||||||
{
|
|
||||||
carId: vinLookup.data.vehicle.carId,
|
|
||||||
glassArray: this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle ? [] : store.getters.damage.glassToReplace,
|
|
||||||
zipCode: this.serviceZip ? this.serviceZip : this.registrationZip,
|
|
||||||
vin: vinLookup.data.vin
|
|
||||||
},
|
|
||||||
false
|
|
||||||
);
|
|
||||||
this.navigateForward(partsData);
|
|
||||||
},
|
},
|
||||||
navigateForward(partsData){
|
navigateForward() {
|
||||||
if(this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle){
|
if(this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle){
|
||||||
this.$router.navigateAfterSave(this.navigationScenarios.CLICKED_FORWARD, this.$route, {}, { displayVehicleChangeAlert: true }, partsData.data);
|
this.$router.navigateAfterSave(this.navigationScenarios.CLICKED_FORWARD, this.$route, {}, { displayVehicleChangeAlert: true }, {});
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
navigateAfterSaveToHeritageFunnel(this.$route);
|
navigateAfterSaveToHeritageFunnel(this.$route);
|
||||||
|
|
@ -237,7 +227,7 @@ export default {
|
||||||
{ licensePlate: plate, licenseState: state }
|
{ licensePlate: plate, licenseState: state }
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
updateCustomerInfo(vin, vehicleInfo, registrationState) {
|
updateStoreInfo(vin, vehicleInfo, registrationState) {
|
||||||
if(this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle){
|
if(this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle){
|
||||||
store.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
store.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
||||||
}
|
}
|
||||||
|
|
@ -262,10 +252,10 @@ export default {
|
||||||
licensePlate() {
|
licensePlate() {
|
||||||
this.$refs.funnelFooter.updateButtonText(this.getCmsContent("FunnelFooterWidget", "ForwardButtonText"));
|
this.$refs.funnelFooter.updateButtonText(this.getCmsContent("FunnelFooterWidget", "ForwardButtonText"));
|
||||||
},
|
},
|
||||||
registrationZip(){
|
registrationZip() {
|
||||||
this.$refs.funnelFooter.updateButtonText(this.getCmsContent("FunnelFooterWidget", "ForwardButtonText"));
|
this.$refs.funnelFooter.updateButtonText(this.getCmsContent("FunnelFooterWidget", "ForwardButtonText"));
|
||||||
},
|
},
|
||||||
serviceZip(){
|
serviceZip() {
|
||||||
this.$refs.funnelFooter.updateButtonText(this.getCmsContent("FunnelFooterWidget", "ForwardButtonText"));
|
this.$refs.funnelFooter.updateButtonText(this.getCmsContent("FunnelFooterWidget", "ForwardButtonText"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue