Merge remote-tracking branch 'origin/develop' into feature/CSR-240
This commit is contained in:
commit
224d36c82c
15 changed files with 890 additions and 374 deletions
|
|
@ -11,11 +11,9 @@ module.exports = {
|
|||
"!src/constants/*.js",
|
||||
"!src/router/**/*.js",
|
||||
"!src/helpers/unit-test-helper.js",
|
||||
"!src/helpers/damage-helper.js",
|
||||
"!src/layouts/component-test/component-test.vue",
|
||||
"!src/layouts/form-test/form-test.vue",
|
||||
"!src/layouts/vin-lookup/vin-lookup.vue",
|
||||
"!src/layouts/license-plate-lookup/license-plate-lookup.vue",
|
||||
"!src/layouts/vehicle-damage/windshield-damage-type-question/windshield-damage-type-question.vue",
|
||||
"!src/layouts/vehicle-damage/windshield-options/windshield-options.vue",
|
||||
"!src/layouts/part-questions/**/*.vue",
|
||||
|
|
@ -28,7 +26,6 @@ module.exports = {
|
|||
"!src/common-components/dropdown-question/dropdown-question.vue",
|
||||
"!src/common-components/textbox-question/textbox-question.vue",
|
||||
"!src/helpers/validation-rules.js",
|
||||
"!src/helpers/damage-helper.js",
|
||||
// END
|
||||
], //! means exclude from coverage.
|
||||
testMatch: ["**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"],
|
||||
|
|
|
|||
BIN
src/assets/img/loader.gif
Normal file
BIN
src/assets/img/loader.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 70 KiB |
BIN
src/assets/img/windshield.png
Normal file
BIN
src/assets/img/windshield.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1 KiB |
126
src/common-components/loading-modal/loading-modal.vue
Normal file
126
src/common-components/loading-modal/loading-modal.vue
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
<template>
|
||||
<div v-show="isModalVisible" class="loading-modal-backdrop" v-on:click="canClose" @close="closeModal">
|
||||
<div class="loading-modal">
|
||||
<button v-if="showCloseButton" type="button" class="loading-modal-close" @click="closeModal">x</button>
|
||||
<section class="loading-modal-body">
|
||||
<div class="modal-icon-container text-center">
|
||||
<img class="loader-gif" alt="Loading" src="@/assets/img/loader.gif">
|
||||
<img class="modal-icon" alt="" src="@/assets/img/windshield.png">
|
||||
</div>
|
||||
<div class="text-center fw-bold fs-5 loading-modal-text">
|
||||
<slot name="body">
|
||||
Default text
|
||||
</slot>
|
||||
</div>
|
||||
<div class="text-center fs-5 loading-modal-text">
|
||||
<slot name="subtext">
|
||||
Default subtext
|
||||
</slot>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Modal',
|
||||
data() {
|
||||
return {
|
||||
isModalVisible: false,
|
||||
};
|
||||
},
|
||||
props: {
|
||||
showCloseButton: {type: Boolean, default: false},
|
||||
clickOutCloses: {type: Boolean, default: false},
|
||||
},
|
||||
methods: {
|
||||
showModal() {
|
||||
this.isModalVisible = true;
|
||||
},
|
||||
closeModal() {
|
||||
this.isModalVisible = false;
|
||||
},
|
||||
canClose() {
|
||||
this.clickOutCloses ? this.closeModal() : null;
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.loading-modal-backdrop {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
background-color: #e5e5e5;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 1050;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.loading-modal {
|
||||
position: absolute;
|
||||
background: #ffffff;
|
||||
padding: 0 0 32px 0;
|
||||
box-shadow: 2px 2px 20px 1px;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.2);
|
||||
border-radius: 4px;
|
||||
top: 48px;
|
||||
height: 246px;
|
||||
width: 327px;
|
||||
}
|
||||
|
||||
.loading-modal-body {
|
||||
position: relative;
|
||||
padding: 20px 10px;
|
||||
}
|
||||
|
||||
.loading-modal-text {
|
||||
padding: 0 24px 0 24px;
|
||||
}
|
||||
|
||||
.loading-modal-close {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
border: none;
|
||||
font-size: 20px;
|
||||
padding: 10px;
|
||||
cursor: pointer;
|
||||
font-weight: bold;
|
||||
color: $blue;
|
||||
background: transparent;
|
||||
z-index: 999;
|
||||
}
|
||||
|
||||
.modal-icon-container {
|
||||
position: relative;
|
||||
width: 75px;
|
||||
height: 75px;
|
||||
margin: 15px auto;
|
||||
padding-bottom: 26px;
|
||||
}
|
||||
|
||||
.modal-icon-container img {
|
||||
position: absolute;
|
||||
vertical-align: middle;
|
||||
border: 0;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
.loader-gif {
|
||||
width: 75px;
|
||||
height: 75px;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -3,9 +3,33 @@ import baseMixin from "@/mixins/base-mixin.js";
|
|||
import { storeActions } from "@/constants/store-actions";
|
||||
|
||||
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 function getIsWindshieldOnly () {
|
||||
const damageLocations = store.getters.damage.glassToReplace;
|
||||
const returnString = damageLocations.length === 1 && damageLocations[0]?.location === "Windshield" ? "windshield" : "glass";
|
||||
console.log(damageLocations);
|
||||
return returnString;
|
||||
}
|
||||
|
||||
export async function isGlassAvailableForCarId(carId){
|
||||
const newGlassOptions = await baseMixin.methods.dispatchStoreAction(
|
||||
storeActions.GET_DAMAGE_OPTIONS,
|
||||
|
|
|
|||
|
|
@ -1,16 +1,91 @@
|
|||
import {getDamageString, isGlassAvailableForCarId} from "./damage-helper";
|
||||
//import baseMixin from "@/mixins/base-mixin.js";
|
||||
import store from "@/store";
|
||||
|
||||
jest.mock("@/store", () => ({
|
||||
getters: {damage: {
|
||||
glassToReplace: [{location: "Windshield", name: "windshield"}]
|
||||
}
|
||||
}
|
||||
}));
|
||||
// Mock basemixin.
|
||||
jest.mock("@/mixins/base-mixin.js", () => ({
|
||||
methods: {
|
||||
dispatchStoreAction: jest.fn().mockImplementation(() => { return {
|
||||
data: {
|
||||
windshieldOptions: {availableReplacementOptions: ["windshield"]}
|
||||
}
|
||||
} }),
|
||||
},
|
||||
}));
|
||||
|
||||
describe("damage-helper.js", () => {
|
||||
it("Should return damage getter info", () => {
|
||||
it("Should return match when multiple selected damage options are in the store", () => {
|
||||
|
||||
// Arrange / Act
|
||||
store.getters.damage.glassToReplace = [{location: "Windshield", name: "windshield"}, {location: "Passenger", name: "sideWindow"}];
|
||||
|
||||
const damage = getDamageString();
|
||||
expect(damage).toEqual("Windshield")
|
||||
|
||||
// Assert
|
||||
expect(damage).toEqual("match");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("damage-helper.js", () => {
|
||||
it("Should return windshield when Windshield is the only selected damage option in the store", () => {
|
||||
|
||||
// Arrange / Act
|
||||
store.getters.damage.glassToReplace = [{location: "Windshield", name: "windshield"}];
|
||||
|
||||
const damage = getDamageString();
|
||||
|
||||
// Assert
|
||||
expect(damage).toEqual("windshield");
|
||||
});
|
||||
});
|
||||
|
||||
describe("damage-helper.js", () => {
|
||||
it("Should return side window when Driver or Passenger is the only selected damage option in the store", () => {
|
||||
|
||||
// Arrange / Act
|
||||
store.getters.damage.glassToReplace = [{location: "Passenger", name: "sideWindow"}];
|
||||
|
||||
const damage = getDamageString();
|
||||
|
||||
// Assert
|
||||
expect(damage).toEqual("side window");
|
||||
});
|
||||
});
|
||||
|
||||
describe("damage-helper.js", () => {
|
||||
it("Should return rear window when Rear is the only selected damage option in the store", () => {
|
||||
|
||||
// Arrange / Act
|
||||
store.getters.damage.glassToReplace = [{location: "Rear", name: "rear"}];
|
||||
|
||||
const damage = getDamageString();
|
||||
|
||||
// Assert
|
||||
expect(damage).toEqual("rear window");
|
||||
});
|
||||
});
|
||||
|
||||
describe("damage-helper.js", () => {
|
||||
it("Should return true if no mismatches between each array exist", async () => {
|
||||
// Arrange
|
||||
store.getters.damage.glassToReplace = [{location: "Windshield", name: "windshield"}];
|
||||
|
||||
// Act
|
||||
const isGlassAvailable = await isGlassAvailableForCarId();
|
||||
|
||||
// Assert
|
||||
expect(isGlassAvailable).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("damage-helper.js", () => {
|
||||
it("Should return false if any mismatches between each array exist", async () => {
|
||||
// Arrange
|
||||
store.getters.damage.glassToReplace = [{location: "Windshield", name: "sideWindow"}];
|
||||
|
||||
const isGlassAvailable = await isGlassAvailableForCarId();
|
||||
|
||||
// Assert
|
||||
expect(isGlassAvailable).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -140,4 +140,4 @@ function isVinRelatedPage(toRoute) {
|
|||
fmgPageValue === fmgPageValues.ADDRESS_LOOKUP ||
|
||||
fmgPageValue === fmgPageValues.ADDRESS_VEHICLES ||
|
||||
fmgPageValue === fmgPageValues.ESTIMATE;
|
||||
}
|
||||
}
|
||||
|
|
@ -367,4 +367,4 @@ describe("navigateToHeritageFunnel", () => {
|
|||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -6,6 +6,14 @@
|
|||
v-slot="{ meta }"
|
||||
autocomplete="off" >
|
||||
<div class="container-fluid shadow rounded-3 p-2 position-relative make-tall px-5">
|
||||
<loadingModal :showCloseButton=false :clickOutCloses=false ref="loadingModal">
|
||||
<template v-slot:body>
|
||||
Please wait...
|
||||
</template>
|
||||
<template v-slot:subtext>
|
||||
This process can take up 20 seconds.
|
||||
</template>
|
||||
</loadingModal>
|
||||
<funnelHeader cmsWidgetName="FunnelHeaderWidget" ref="funnelHeader" />
|
||||
<vehicleBanner ref="vehicleBanner" :displayGenericVehicleImage=false />
|
||||
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" ref="funnelSubHeader" />
|
||||
|
|
@ -68,6 +76,7 @@ import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-he
|
|||
import customerQuestions from "@/layouts/address-lookup/customer-questions/customer-questions";
|
||||
import alert from "@/ux-components/alert/alert";
|
||||
import textboxQuestion from "@/common-components/textbox-question/textbox-question";
|
||||
import loadingModal from '@/common-components/loading-modal/loading-modal.vue';
|
||||
|
||||
import { Form } from "vee-validate";
|
||||
import { defineRule } from "vee-validate";
|
||||
|
|
@ -251,6 +260,7 @@ export default {
|
|||
|
||||
// if the car entered is the same as the car found OR the glass options for the found car match the users damage selections
|
||||
if (carEntered.carId == carFound.carId || isGlassAvailableForCarId(carFound.carId)) {
|
||||
this.$refs.loadingModal.showModal();
|
||||
navigateAfterSaveToHeritageFunnel(this.$route);
|
||||
} else {
|
||||
// if not then navigate to the "vehicle-damage" page
|
||||
|
|
@ -260,6 +270,7 @@ export default {
|
|||
// if multiple cars were found
|
||||
if (carsFound.find(car => car.carId === carEntered.carId)) {
|
||||
// and one of them matches the car id entered
|
||||
this.$refs.loadingModal.showModal();
|
||||
navigateAfterSaveToHeritageFunnel(this.$route);
|
||||
} else {
|
||||
// and there is no match, navigate to "address-vehicle" page
|
||||
|
|
@ -359,6 +370,7 @@ export default {
|
|||
customerQuestions,
|
||||
textboxQuestion,
|
||||
alert,
|
||||
loadingModal,
|
||||
Form
|
||||
},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
// Components
|
||||
import vehicleDamage from "@/layouts/license-plate-lookup/license-plate-lookup.vue";
|
||||
import licensePlateLookup from "@/layouts/license-plate-lookup/license-plate-lookup.vue";
|
||||
|
||||
// Supporting Files
|
||||
import { settleAllPromises } from "@/helpers/layout-helper.js";
|
||||
import * as navigateToHeritage from "@/helpers/heritage-integration/navigation-helper";
|
||||
import baseMixin from "@/mixins/base-mixin";
|
||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||
import { shallowMount, flushPromises } from "@vue/test-utils";
|
||||
import { getMountOptions } from "@/helpers/unit-test-helper.js";
|
||||
import { nextTick } from "vue";
|
||||
import { storeActions } from "@/constants/store-actions";
|
||||
import { storeMutations } from "@/constants/store-mutations";
|
||||
import store from "@/store";
|
||||
import { validate } from "vee-validate";
|
||||
|
||||
jest.mock('@/assets/img/loader.gif', () => 'loader.gif')
|
||||
jest.mock('@/assets/img/windshield.png', () => 'windshield.png')
|
||||
|
||||
// Mock our module for promises.
|
||||
jest.mock("@/helpers/layout-helper.js", () => ({
|
||||
|
|
@ -29,25 +30,15 @@ jest.mock("@/store", () => ({
|
|||
dispatch: jest.fn(),
|
||||
getters: {
|
||||
order: {
|
||||
customer: {
|
||||
emailAddress: "test@test.com"
|
||||
},
|
||||
serviceLocation: {
|
||||
zipCode: "43443"
|
||||
}
|
||||
customer: { emailAddress: "test@test.com"},
|
||||
serviceLocation: {zip: "11111"},
|
||||
},
|
||||
vehicle: {
|
||||
carId: "C00000000",
|
||||
image: "test.jpg",
|
||||
payment: {
|
||||
insuranceCoverage: {
|
||||
isVerified: false
|
||||
}
|
||||
},
|
||||
carId: "TESTID",
|
||||
registration: {
|
||||
licensePlate: "HWV4445",
|
||||
zipCode: "43224"
|
||||
}
|
||||
licensePlate: "TESTPLATE",
|
||||
zipCode: "12345",
|
||||
},
|
||||
},
|
||||
eventBusItem: jest.fn(),
|
||||
damage: {
|
||||
|
|
@ -62,7 +53,7 @@ describe("license-plate-lookup.vue", () => {
|
|||
const { wrapper } = setupMocks({});
|
||||
|
||||
//Act
|
||||
vehicleDamage.beforeRouteEnter.call(
|
||||
licensePlateLookup.beforeRouteEnter.call(
|
||||
wrapper.vm,
|
||||
{ query: { fmgPage: "license-plate-lookup" } },
|
||||
undefined,
|
||||
|
|
@ -84,7 +75,7 @@ describe("license-plate-lookup.vue", () => {
|
|||
const { wrapper } = setupMocks({});
|
||||
|
||||
//Act
|
||||
vehicleDamage.beforeRouteEnter.call(
|
||||
licensePlateLookup.beforeRouteEnter.call(
|
||||
wrapper.vm,
|
||||
{ query: { fmgPage: "license-plate-lookup" } },
|
||||
undefined,
|
||||
|
|
@ -99,6 +90,340 @@ describe("license-plate-lookup.vue", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("license-plate-lookup.vue", () => {
|
||||
test("getLicensePlateFromStore returns store license plate", async () => {
|
||||
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
// ACT
|
||||
const licensePlate = wrapper.vm.getLicensePlateFromStore();
|
||||
|
||||
// Assert
|
||||
expect(licensePlate).toEqual("TESTPLATE");
|
||||
});
|
||||
});
|
||||
|
||||
describe("license-plate-lookup.vue", () => {
|
||||
test("getRegistrationZipFromStore returns store registration zip", async () => {
|
||||
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
// ACT
|
||||
const registrationZip = wrapper.vm.getRegistrationZipFromStore();
|
||||
|
||||
// Assert
|
||||
expect(registrationZip).toEqual("12345");
|
||||
});
|
||||
});
|
||||
|
||||
describe("license-plate-lookup.vue", () => {
|
||||
test("getEmailFromStore returns store customer email", async () => {
|
||||
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
// ACT
|
||||
const customerEmail = wrapper.vm.getEmailFromStore();
|
||||
|
||||
// Assert
|
||||
expect(customerEmail).toEqual("test@test.com");
|
||||
});
|
||||
});
|
||||
|
||||
describe("license-plate-lookup.vue", () => {
|
||||
test("getServiceZipFromStore returns store service zip", async () => {
|
||||
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
// ACT
|
||||
const serviceZip = wrapper.vm.getServiceZipFromStore();
|
||||
|
||||
// Assert
|
||||
expect(serviceZip).toEqual("11111");
|
||||
});
|
||||
});
|
||||
|
||||
describe("license-plate-lookup.vue", () => {
|
||||
test("Navigate forward should be called and isCarId should be set to false when data entered matches store data on forwardButtonAction click", async () => {
|
||||
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
wrapper.vm.validateZip = jest.fn().mockImplementation(() => {
|
||||
return {data: {isServiceable: true}};
|
||||
});
|
||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
||||
return '';
|
||||
});
|
||||
const vinLookup = {data: {vehicle: {carId: "TESTID"}}}
|
||||
wrapper.vm.lookupVin = jest.fn().mockImplementation(() => {
|
||||
return {catch: () => vinLookup};
|
||||
});
|
||||
wrapper.vm.navigateForward = jest.fn();
|
||||
|
||||
//Act
|
||||
licensePlateLookup.beforeRouteEnter.call(
|
||||
wrapper.vm,
|
||||
{ query: { fmgPage: "license-plate-lookup" } },
|
||||
undefined,
|
||||
(c) => c(wrapper.vm)
|
||||
);
|
||||
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
//Assert
|
||||
expect(wrapper.vm.navigateForward).toHaveBeenCalled();
|
||||
expect(wrapper.vm.isCarIdDifferent).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("license-plate-lookup.vue", () => {
|
||||
test("Function should stop and datam isRegistrationZipServicable should be set to false when service zip entered returns false on forwardButtonAction click", async () => {
|
||||
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
wrapper.vm.validateZip = jest.fn().mockImplementation(() => {
|
||||
return {data: {isServiceable: false}};
|
||||
});
|
||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
||||
return '';
|
||||
});
|
||||
wrapper.vm.$refs.funnelFooter.removeLoader = jest.fn();
|
||||
//Act
|
||||
licensePlateLookup.beforeRouteEnter.call(
|
||||
wrapper.vm,
|
||||
{ query: { fmgPage: "license-plate-lookup" } },
|
||||
undefined,
|
||||
(c) => c(wrapper.vm)
|
||||
);
|
||||
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
//Assert
|
||||
expect(wrapper.vm.isRegistrationZipServicable).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("license-plate-lookup.vue", () => {
|
||||
test("Function should stop and datam isCarIdDifferent should be set to true when carId entered doesn't match store carId or previously entered carId on forwardButtonAction click", async () => {
|
||||
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
wrapper.vm.validateZip = jest.fn().mockImplementation(() => {
|
||||
return {data: {isServiceable: true}};
|
||||
});
|
||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
||||
return '';
|
||||
});
|
||||
const vinLookup = {data: {vehicle: {carId: "TESTID1"}}}
|
||||
wrapper.vm.lookupVin = jest.fn().mockImplementation(() => {
|
||||
return {catch: () => vinLookup};
|
||||
});
|
||||
wrapper.vm.$refs.funnelFooter.removeLoader = jest.fn();
|
||||
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
||||
|
||||
//Act
|
||||
licensePlateLookup.beforeRouteEnter.call(
|
||||
wrapper.vm,
|
||||
{ query: { fmgPage: "license-plate-lookup" } },
|
||||
undefined,
|
||||
(c) => c(wrapper.vm)
|
||||
);
|
||||
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
//Assert
|
||||
expect(wrapper.vm.isCarIdDifferent).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("license-plate-lookup.vue", () => {
|
||||
test("Navigate forward should be called and isCarId should be set to true when carId entered matches previously entered carId and rest of data entered matches store data on forwardButtonAction click", async () => {
|
||||
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
wrapper.vm.validateZip = jest.fn().mockImplementation(() => {
|
||||
return {data: {isServiceable: true}};
|
||||
});
|
||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
||||
return '';
|
||||
});
|
||||
const vinLookup = {data: {vehicle: {carId: "TESTID1"}}}
|
||||
wrapper.vm.lookupVin = jest.fn().mockImplementation(() => {
|
||||
return {catch: () => vinLookup};
|
||||
});
|
||||
wrapper.vm.previouslyEnteredCarId = "TESTID1";
|
||||
wrapper.vm.navigateForward = jest.fn();
|
||||
|
||||
//Act
|
||||
licensePlateLookup.beforeRouteEnter.call(
|
||||
wrapper.vm,
|
||||
{ query: { fmgPage: "license-plate-lookup" } },
|
||||
undefined,
|
||||
(c) => c(wrapper.vm)
|
||||
);
|
||||
|
||||
await wrapper.vm.forwardButtonAction();
|
||||
|
||||
//Assert
|
||||
expect(wrapper.vm.navigateForward).toHaveBeenCalled();
|
||||
expect(wrapper.vm.isCarIdDifferent).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("license-plate-lookup.vue", () => {
|
||||
test("Button Text should revert to initial value when licensePlate textfield has new text", async () => {
|
||||
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
//Act
|
||||
wrapper.vm.licensePlate = "NEWPLATE";
|
||||
wrapper.vm.getCmsContent = jest.fn();
|
||||
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
//Assert
|
||||
expect(wrapper.vm.$refs.funnelFooter.updateButtonText).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("license-plate-lookup.vue", () => {
|
||||
test("Button Text should revert to initial value when registrationZip textfield has new text", async () => {
|
||||
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
//Act
|
||||
wrapper.vm.registrationZip = "55555";
|
||||
wrapper.vm.getCmsContent = jest.fn();
|
||||
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
//Assert
|
||||
expect(wrapper.vm.$refs.funnelFooter.updateButtonText).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("license-plate-lookup.vue", () => {
|
||||
test("Button Text should revert to initial value when serviceZip textfield has new text", async () => {
|
||||
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
//Act
|
||||
wrapper.vm.serviceZip = "55555";
|
||||
wrapper.vm.getCmsContent = jest.fn();
|
||||
wrapper.vm.$refs.funnelFooter.updateButtonText = jest.fn();
|
||||
await wrapper.vm.$nextTick();
|
||||
|
||||
//Assert
|
||||
expect(wrapper.vm.$refs.funnelFooter.updateButtonText).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("license-plate-lookup.vue", () => {
|
||||
test("Dispatch reset damage and dependencies should be called if isCarIdDifferent is true and isSelectedGlassAvailableForVehicle is false when updateCustomerInfo is called", async () => {
|
||||
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
//Act
|
||||
wrapper.vm.isCarIdDifferent = true;
|
||||
wrapper.vm.isSelectedGlassAvailableForVehicle = false;
|
||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
||||
return '';
|
||||
});
|
||||
store.commit = jest.fn();
|
||||
store.dispatch = jest.fn();
|
||||
|
||||
const vehicleInfo = {year: "2020", make: "honda", model: "civic", style: "2 door", carId: "TestId", category: "testCat", imageUrl: "image.jpg", imageVifNumber: "123", imageColor: "blue"}
|
||||
await wrapper.vm.updateCustomerInfo('vin', vehicleInfo, 'registrationState');
|
||||
|
||||
//Assert
|
||||
expect(store.dispatch).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("license-plate-lookup.vue", () => {
|
||||
test("NavigateAfterSave should be called if isCarIdDifferent is true and isSelectedGlassAvailableForVehicle is false when navigateForward is called", async () => {
|
||||
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
//Act
|
||||
wrapper.vm.isCarIdDifferent = true;
|
||||
wrapper.vm.isSelectedGlassAvailableForVehicle = false;
|
||||
wrapper.vm.$router.navigateAfterSave = jest.fn();
|
||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
||||
return '';
|
||||
});
|
||||
store.dispatch = jest.fn();
|
||||
|
||||
await wrapper.vm.navigateForward();
|
||||
|
||||
//Assert
|
||||
expect(wrapper.vm.$router.navigateAfterSave).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("license-plate-lookup.vue", () => {
|
||||
test("navigateAfterSaveToHeritageFunnel should be called if isCarIdDifferent is false or isSelectedGlassAvailableForVehicle is true when navigateForward is called", async () => {
|
||||
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
//Act
|
||||
wrapper.vm.isCarIdDifferent = false;
|
||||
wrapper.vm.$refs.loadingModal.showModal = jest.fn();
|
||||
wrapper.vm.getCmsContent = jest.fn().mockImplementation(() => {
|
||||
return '';
|
||||
});
|
||||
navigateToHeritage.navigateAfterSaveToHeritageFunnel = jest.fn();
|
||||
await wrapper.vm.navigateForward();
|
||||
|
||||
//Assert
|
||||
expect(navigateToHeritage.navigateAfterSaveToHeritageFunnel).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("license-plate-lookup.vue", () => {
|
||||
test("dispatch non blocking store action called on validate zip", async () => {
|
||||
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
//Act
|
||||
await wrapper.vm.validateZip("12345");
|
||||
|
||||
|
||||
//Assert
|
||||
expect(baseMixin.methods.dispatchStoreAction).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("license-plate-lookup.vue", () => {
|
||||
test("dispatch non blocking store action called on lookup vin", async () => {
|
||||
|
||||
// Arrange
|
||||
const { wrapper } = setupMocks({});
|
||||
|
||||
//Act
|
||||
await wrapper.vm.lookupVin("zzz123fqsfwg");
|
||||
|
||||
|
||||
//Assert
|
||||
expect(baseMixin.methods.dispatchStoreAction).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
function setupMocks({
|
||||
pageHeaderWidgetHeaderText = {},
|
||||
|
|
@ -106,12 +431,8 @@ function setupMocks({
|
|||
router: {
|
||||
navigate: jest.fn(),
|
||||
},
|
||||
store: {
|
||||
getters: {
|
||||
vehicle: {},
|
||||
payment: { insuranceCoverage: { isVerified: false } },
|
||||
},
|
||||
},
|
||||
licensePlate: "TESTPLATE",
|
||||
registrationZip: "12345"
|
||||
},
|
||||
}) {
|
||||
//Mock api responses
|
||||
|
|
@ -139,7 +460,7 @@ function setupMocks({
|
|||
const mountOptions = getMountOptions(mountOptionsMockData);
|
||||
mountOptions['attachTo'] = document.body; // append wrapper to document.body to test DOM methods
|
||||
|
||||
const wrapper = shallowMount(vehicleDamage, mountOptions);
|
||||
const wrapper = shallowMount(licensePlateLookup, mountOptions);
|
||||
|
||||
wrapper.vm.setCmsContent = baseMixin.methods.setCmsContent;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,95 +1,48 @@
|
|||
<template>
|
||||
<Form
|
||||
@submit="onSubmit"
|
||||
@invalid-submit="onInvalidSubmit"
|
||||
ref="theForm"
|
||||
v-slot="{ meta }"
|
||||
>
|
||||
<div
|
||||
class="container-fluid shadow rounded-3 p-2 position-relative make-tall px-5"
|
||||
>
|
||||
<Form @submit="onSubmit" @invalid-submit="onInvalidSubmit" ref="theForm" v-slot="{ meta }">
|
||||
<div class="container-fluid shadow rounded-3 p-2 position-relative make-tall px-5">
|
||||
<loadingModal :showCloseButton=false :clickOutCloses=false ref="loadingModal">
|
||||
<template v-slot:body>
|
||||
Please wait...
|
||||
</template>
|
||||
<template v-slot:subtext>
|
||||
This process can take up 20 seconds.
|
||||
</template>
|
||||
</loadingModal>
|
||||
<funnelHeader cmsWidgetName="FunnelHeaderWidget" />
|
||||
<vehicleBanner
|
||||
cmsWidgetName="VehicleBannerWidget"
|
||||
:displayGenericVehicleImage="false"
|
||||
/>
|
||||
<vehicleBanner cmsWidgetName="VehicleBannerWidget" :displayGenericVehicleImage="false" />
|
||||
<funnelSubHeader cmsWidgetName="FunnelSubHeaderWidget" />
|
||||
<div class="fade-on-route-transition sub-container make-tall">
|
||||
<div class="row my-2">
|
||||
<div class="col">
|
||||
<textboxQuestion
|
||||
cmsWidgetName="LicensePlateNumber"
|
||||
v-model="licensePlate"
|
||||
isRequired
|
||||
inputId="license_plate"
|
||||
validationRules="license-plate-required"
|
||||
/>
|
||||
<textboxQuestion cmsWidgetName="LicensePlateNumber" v-model="licensePlate" isRequired inputId="license_plate" validationRules="license-plate-required" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row my-2">
|
||||
<div class="col">
|
||||
<textboxQuestion
|
||||
cmsWidgetName="RegistrationZip"
|
||||
v-model="registrationZip"
|
||||
inputId="zip"
|
||||
mask="#####"
|
||||
validationRules="zip-required"
|
||||
/>
|
||||
<textboxQuestion cmsWidgetName="RegistrationZip" v-model="registrationZip" inputId="zip" mask="#####" validationRules="zip-required" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="row my-2">
|
||||
<div class="col">
|
||||
<textboxQuestion
|
||||
cmsWidgetName="EmailAddress"
|
||||
v-model="email"
|
||||
inputId="email"
|
||||
validationRules="email-address-required|email-address-format"
|
||||
/>
|
||||
<textboxQuestion cmsWidgetName="EmailAddress" v-model="email" inputId="email" validationRules="email-address-required|email-address-format" />
|
||||
</div>
|
||||
</div>
|
||||
<alert
|
||||
class="my-3"
|
||||
:manualHeadline="NoServiceZipHeader"
|
||||
:manualCopy="NoServiceZipBody"
|
||||
v-if="!isRegistrationZipServicable && isVinValid && !isCarIdDifferent"
|
||||
alertClass="alert-danger"
|
||||
/>
|
||||
<alert class="my-3" :manualHeadline="NoServiceZipHeader" :manualCopy="NoServiceZipBody" v-if="!isRegistrationZipServicable && isVinValid && !isCarIdDifferent" alertClass="alert-danger" />
|
||||
<div class="row my-2">
|
||||
<div class="col">
|
||||
<textboxQuestion
|
||||
v-if="!isRegistrationZipServicable"
|
||||
cmsWidgetName="ServiceZip"
|
||||
v-model="serviceZip"
|
||||
inputId="serviceZip"
|
||||
validationRules="zip-required"
|
||||
/>
|
||||
<textboxQuestion v-if="!isRegistrationZipServicable" cmsWidgetName="ServiceZip" v-model="serviceZip" inputId="serviceZip" validationRules="zip-required" />
|
||||
</div>
|
||||
</div>
|
||||
<alert
|
||||
class="my-3"
|
||||
cmsWidgetName="NoMatchAlertWidget"
|
||||
v-if="!isVinValid"
|
||||
alertClass="alert-danger"
|
||||
/>
|
||||
<alert
|
||||
class="my-3"
|
||||
:manualHeadline="MatchedDifferentVehicleAlertHeader"
|
||||
:manualCopy="MatchedDifferentVehicleAlertBody"
|
||||
v-if="isCarIdDifferent"
|
||||
alertClass="alert-warning"
|
||||
/>
|
||||
<funnelFooter
|
||||
ref="funnelFooter"
|
||||
cmsWidgetName="FunnelFooterWidget"
|
||||
:isForwardActionDisabled="!meta.valid"
|
||||
@back-clicked="backButtonAction"
|
||||
@ForwardClicked="forwardButtonAction"
|
||||
/>
|
||||
<alert class="my-3" cmsWidgetName="NoMatchAlertWidget" v-if="!isVinValid" />
|
||||
<alert class="my-3" :manualHeadline="MatchedDifferentVehicleAlertHeader" :manualCopy="MatchedDifferentVehicleAlertBody" v-if="isCarIdDifferent" alertClass="alert-warning" />
|
||||
<funnelFooter ref="funnelFooter" cmsWidgetName="FunnelFooterWidget" :isForwardActionDisabled="!meta.valid" @back-clicked="backButtonAction" @ForwardClicked="forwardButtonAction" />
|
||||
</div>
|
||||
</div>
|
||||
</Form>
|
||||
</template>
|
||||
|
||||
|
||||
<script>
|
||||
// Components
|
||||
import funnelHeader from "@/common-components/funnel-header/funnel-header";
|
||||
|
|
@ -98,59 +51,58 @@ import vehicleBanner from "@/common-components/vehicle-banner/vehicle-banner";
|
|||
import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-header";
|
||||
import alert from "@/ux-components/alert/alert";
|
||||
import textboxQuestion from "@/common-components/textbox-question/textbox-question";
|
||||
|
||||
import loadingModal from '@/common-components/loading-modal/loading-modal.vue';
|
||||
// Supporting files
|
||||
import {
|
||||
fetchCmsContentForPage
|
||||
import {
|
||||
fetchCmsContentForPage
|
||||
} from "@/helpers/cms-content-helper";
|
||||
import {
|
||||
settleAllPromises
|
||||
settleAllPromises
|
||||
} from "@/helpers/layout-helper";
|
||||
import store from "@/store";
|
||||
import baseMixin from "@/mixins/base-mixin.js";
|
||||
import {
|
||||
storeActions
|
||||
storeActions
|
||||
} from "@/constants/store-actions";
|
||||
import {
|
||||
storeMutations
|
||||
storeMutations
|
||||
} from "@/constants/store-mutations";
|
||||
import {
|
||||
errorMessages
|
||||
errorMessages
|
||||
} from "@/constants/error-messages";
|
||||
import {
|
||||
navigateAfterSaveToHeritageFunnel
|
||||
} from "@/helpers/heritage-integration/navigation-helper";
|
||||
import {
|
||||
getDamageString,
|
||||
isGlassAvailableForCarId,
|
||||
getDamageString,
|
||||
isGlassAvailableForCarId,
|
||||
} from "@/helpers/damage-helper";
|
||||
import {
|
||||
required,
|
||||
regex
|
||||
required,
|
||||
regex,
|
||||
} from "@/helpers/validation-rules";
|
||||
import {
|
||||
Form,
|
||||
defineRule
|
||||
Form,
|
||||
defineRule,
|
||||
} from "vee-validate";
|
||||
import {
|
||||
navigateAfterSaveToHeritageFunnel
|
||||
} from "@/helpers/heritage-integration/navigation-helper";
|
||||
|
||||
// DEFINE VALIDATION RULES
|
||||
defineRule(
|
||||
"license-plate-required",
|
||||
required(errorMessages.LICENSE_PLATE_REQUIRED)
|
||||
"license-plate-required",
|
||||
required(errorMessages.LICENSE_PLATE_REQUIRED)
|
||||
);
|
||||
defineRule("zip-required", required(errorMessages.ZIP_REQUIRED));
|
||||
defineRule(
|
||||
"email-address-required",
|
||||
required(errorMessages.EMAIL_ADDRESS_REQUIRED)
|
||||
"email-address-required",
|
||||
required(errorMessages.EMAIL_ADDRESS_REQUIRED)
|
||||
);
|
||||
defineRule(
|
||||
"email-address-format",
|
||||
regex(
|
||||
/^([a-zA-Z0-9_\-.+]+)@([a-zA-Z0-9_\-.]+).([a-zA-Z]{2,})$/,
|
||||
errorMessages.EMAIL_ADDRESS_FORMAT
|
||||
)
|
||||
"email-address-format",
|
||||
regex(
|
||||
/^([a-zA-Z0-9_\-.+]+)@([a-zA-Z0-9_\-.]+).([a-zA-Z]{2,})$/,
|
||||
errorMessages.EMAIL_ADDRESS_FORMAT
|
||||
)
|
||||
);
|
||||
|
||||
export default {
|
||||
name: "license-plate-lookup",
|
||||
async beforeRouteEnter(to, from, next) {
|
||||
|
|
@ -164,14 +116,15 @@ export default {
|
|||
promise: cmsContentPromise,
|
||||
},
|
||||
];
|
||||
|
||||
const resultMap = await settleAllPromises(promiseResultMap);
|
||||
|
||||
// Call the "next" function to complete the transition to this page.
|
||||
next((vm) => {
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
});
|
||||
},
|
||||
props: {
|
||||
validationRules: String,
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
isRegistrationZipServicable: true,
|
||||
|
|
@ -184,221 +137,209 @@ export default {
|
|||
previouslyEnteredCarId: "",
|
||||
customAlertData: {},
|
||||
isSelectedGlassAvailableForVehicle: true,
|
||||
zipToDisplay: this.getRegistrationZipFromStore(),
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.attachCustomEvents();
|
||||
},
|
||||
computed: {
|
||||
MatchedDifferentVehicleAlertHeader() {
|
||||
let text = this.getCmsContent(
|
||||
"MatchedDifferentVehicleAlertWidget",
|
||||
"HeadlineText"
|
||||
).replaceAll("{custom:damage}", getDamageString());
|
||||
|
||||
return text;
|
||||
},
|
||||
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
|
||||
);
|
||||
|
||||
return text;
|
||||
},
|
||||
NoServiceZipHeader() {
|
||||
let text = this.getCmsContent(
|
||||
"NoServiceZipWidget",
|
||||
"HeadlineText"
|
||||
).replaceAll("{custom:zip}", this.registrationZip);
|
||||
|
||||
return text;
|
||||
},
|
||||
NoServiceZipBody() {
|
||||
return this.getCmsContent("NoServiceZipWidget", "BodyText");
|
||||
},
|
||||
computed: {
|
||||
MatchedDifferentVehicleAlertHeader() {
|
||||
let text = this.getCmsContent(
|
||||
"MatchedDifferentVehicleAlertWidget",
|
||||
"HeadlineText"
|
||||
).replaceAll("{custom:damage}", getDamageString());
|
||||
return text;
|
||||
},
|
||||
methods: {
|
||||
arePagePrerequisitesValid() {
|
||||
return store.getters.vehicle.carId !== null;
|
||||
},
|
||||
resetDependentState() {
|
||||
store.commit(storeMutations.UPDATE_REGISTRATION_ADDRESS, null);
|
||||
store.commit(storeMutations.UPDATE_REGISTRATION_CITY, null);
|
||||
store.commit(storeMutations.UPDATE_REGISTRATION_FIRST_NAME, null);
|
||||
store.commit(storeMutations.UPDATE_REGISTRATION_LAST_NAME, null);
|
||||
store.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
|
||||
},
|
||||
attachCustomEvents() {
|
||||
this.prependActionToMethod(this, this.forwardButtonAction, () => {
|
||||
this.pushEventToGA(
|
||||
this.$route.query[this.queryStrings.FMG_PAGE],
|
||||
this.GaActions.SUBMITTED,
|
||||
this.GaLabels.LICENSE_PLATE_LOOKUP,
|
||||
true
|
||||
);
|
||||
});
|
||||
},
|
||||
getLicensePlateFromStore() {
|
||||
return store.getters.vehicle.registration.licensePlate;
|
||||
},
|
||||
getRegistrationZipFromStore() {
|
||||
return store.getters.vehicle.registration.zipCode;
|
||||
},
|
||||
getEmailFromStore() {
|
||||
return store.getters.order.customer.emailAddress;
|
||||
},
|
||||
getServiceZipFromStore() {
|
||||
return store.getters.order.serviceLocation.zipCode
|
||||
},
|
||||
backButtonAction() {
|
||||
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
|
||||
},
|
||||
async forwardButtonAction() {
|
||||
const zipValidation = this.serviceZip ?
|
||||
await this.validateZip(this.serviceZip) :
|
||||
await this.validateZip(this.registrationZip);
|
||||
if (!zipValidation.data.isServiceable) {
|
||||
this.$refs.funnelFooter.removeLoader();
|
||||
this.isVinValid = true;
|
||||
this.isRegistrationZipServicable = false;
|
||||
this.isCarIdDifferent = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const vinLookup = await this.lookupVin(
|
||||
this.licensePlate,
|
||||
zipValidation.data.state
|
||||
).catch(() => {
|
||||
this.$refs.funnelFooter.removeLoader();
|
||||
this.isVinValid = false;
|
||||
this.isCarIdDifferent = false;
|
||||
return;
|
||||
});
|
||||
|
||||
this.isCarIdDifferent =
|
||||
vinLookup.data.vehicle.carId !== store.getters.vehicle.carId;
|
||||
|
||||
if (
|
||||
this.isCarIdDifferent &&
|
||||
vinLookup.data.vehicle.carId !== this.previouslyEnteredCarId
|
||||
) {
|
||||
this.previouslyEnteredCarId = vinLookup.data.vehicle.carId;
|
||||
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.isSelectedGlassAvailableForVehicle =
|
||||
await isGlassAvailableForCarId(vinLookup.data.vehicle.carId);
|
||||
this.$refs.funnelFooter.removeLoader();
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateCustomerInfo(
|
||||
vinLookup.data.vin,
|
||||
vinLookup.data.vehicle,
|
||||
zipValidation.data.state
|
||||
);
|
||||
|
||||
const partsData = await baseMixin.methods.dispatchStoreAction(
|
||||
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) {
|
||||
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
|
||||
this.$router.navigateAfterSave(
|
||||
this.navigationScenarios.CLICKED_FORWARD,
|
||||
this.$route, {}, {
|
||||
displayVehicleChangeAlert: true
|
||||
},
|
||||
partsData.data
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
navigateAfterSaveToHeritageFunnel(this.$route);
|
||||
return;
|
||||
}
|
||||
},
|
||||
validateZip(zip) {
|
||||
return baseMixin.methods.dispatchStoreAction(storeActions.VALIDATE_ZIP, {
|
||||
zip,
|
||||
});
|
||||
},
|
||||
lookupVin(plate, state) {
|
||||
return baseMixin.methods.dispatchStoreAction(
|
||||
storeActions.LOOKUP_VIN_BY_PLATE, {
|
||||
licensePlate: plate,
|
||||
licenseState: state
|
||||
}
|
||||
);
|
||||
},
|
||||
updateCustomerInfo(vin, vehicleInfo, registrationState) {
|
||||
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
|
||||
store.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
||||
}
|
||||
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);
|
||||
store.commit(storeMutations.UPDATE_REGISTRATION_LICENSE_PLATE, this.licensePlate);
|
||||
store.commit(storeMutations.UPDATE_REGISTRATION_STATE, registrationState);
|
||||
store.commit(storeMutations.UPDATE_REGISTRATION_ZIP_CODE, this.registrationZip);
|
||||
store.commit(storeMutations.UPDATE_SERVICE_LOCATION_ZIP_CODE, this.serviceZip);
|
||||
store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.email);
|
||||
},
|
||||
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
|
||||
);
|
||||
return text;
|
||||
},
|
||||
watch: {
|
||||
licensePlate() {
|
||||
this.$refs.funnelFooter.updateButtonText(
|
||||
this.getCmsContent("FunnelFooterWidget", "ForwardButtonText")
|
||||
);
|
||||
},
|
||||
registrationZip() {
|
||||
this.$refs.funnelFooter.updateButtonText(
|
||||
this.getCmsContent("FunnelFooterWidget", "ForwardButtonText")
|
||||
);
|
||||
},
|
||||
serviceZip() {
|
||||
this.$refs.funnelFooter.updateButtonText(
|
||||
this.getCmsContent("FunnelFooterWidget", "ForwardButtonText")
|
||||
);
|
||||
},
|
||||
NoServiceZipHeader() {
|
||||
let text = this.getCmsContent(
|
||||
"NoServiceZipWidget",
|
||||
"HeadlineText"
|
||||
).replaceAll("{custom:zip}", this.zipToDisplay);
|
||||
return text;
|
||||
},
|
||||
components: {
|
||||
Form,
|
||||
funnelHeader,
|
||||
vehicleBanner,
|
||||
funnelSubHeader,
|
||||
textboxQuestion,
|
||||
alert,
|
||||
funnelFooter,
|
||||
NoServiceZipBody() {
|
||||
return this.getCmsContent("NoServiceZipWidget", "BodyText");
|
||||
},
|
||||
}
|
||||
</script>
|
||||
},
|
||||
methods: {
|
||||
arePagePrerequisitesValid() {
|
||||
return store.getters.vehicle.carId !== null;
|
||||
},
|
||||
resetDependentState() {
|
||||
store.commit(storeMutations.UPDATE_REGISTRATION_ADDRESS, null);
|
||||
store.commit(storeMutations.UPDATE_REGISTRATION_CITY, null);
|
||||
store.commit(storeMutations.UPDATE_REGISTRATION_FIRST_NAME, null);
|
||||
store.commit(storeMutations.UPDATE_REGISTRATION_LAST_NAME, null);
|
||||
store.dispatch(storeActions.RESET_PARTS_STATE_AND_DEPENDENCIES);
|
||||
},
|
||||
attachCustomEvents() {
|
||||
this.prependActionToMethod(this, this.forwardButtonAction, () => {
|
||||
this.pushEventToGA(
|
||||
this.$route.query[this.queryStrings.FMG_PAGE],
|
||||
this.GaActions.SUBMITTED,
|
||||
this.GaLabels.LICENSE_PLATE_LOOKUP,
|
||||
true
|
||||
);
|
||||
});
|
||||
},
|
||||
getLicensePlateFromStore() {
|
||||
return store.getters.vehicle.registration.licensePlate;
|
||||
},
|
||||
getRegistrationZipFromStore() {
|
||||
return store.getters.vehicle.registration.zipCode;
|
||||
},
|
||||
getEmailFromStore() {
|
||||
return store.getters.order.customer.emailAddress;
|
||||
},
|
||||
getServiceZipFromStore() {
|
||||
return store.getters.order.serviceLocation.zip;
|
||||
},
|
||||
backButtonAction() {
|
||||
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
|
||||
},
|
||||
async forwardButtonAction() {
|
||||
const zipValidation = this.serviceZip ?
|
||||
await this.validateZip(this.serviceZip) :
|
||||
await this.validateZip(this.registrationZip);
|
||||
if (!zipValidation.data.isServiceable) {
|
||||
this.$refs.funnelFooter.removeLoader();
|
||||
this.isVinValid = true;
|
||||
this.isRegistrationZipServicable = false;
|
||||
this.isCarIdDifferent = false;
|
||||
this.zipToDisplay = this.serviceZip ? this.serviceZip : this.registrationZip;
|
||||
return;
|
||||
}
|
||||
const vinLookup = await this.lookupVin(
|
||||
this.licensePlate,
|
||||
zipValidation.data.state
|
||||
).catch(() => {
|
||||
this.$refs.funnelFooter.removeLoader();
|
||||
this.isVinValid = false;
|
||||
this.isCarIdDifferent = false;
|
||||
return;
|
||||
});
|
||||
this.isCarIdDifferent =
|
||||
vinLookup.data.vehicle.carId !== store.getters.vehicle.carId;
|
||||
|
||||
if (
|
||||
this.isCarIdDifferent &&
|
||||
vinLookup.data.vehicle.carId !== this.previouslyEnteredCarId
|
||||
) {
|
||||
this.previouslyEnteredCarId = vinLookup.data.vehicle.carId;
|
||||
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.isSelectedGlassAvailableForVehicle =
|
||||
await isGlassAvailableForCarId(vinLookup.data.vehicle.carId);
|
||||
this.$refs.funnelFooter.removeLoader();
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateCustomerInfo(
|
||||
vinLookup.data.vin,
|
||||
vinLookup.data.vehicle,
|
||||
zipValidation.data.state
|
||||
);
|
||||
|
||||
this.navigateForward();
|
||||
},
|
||||
navigateForward() {
|
||||
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
|
||||
this.$router.navigateAfterSave(
|
||||
this.navigationScenarios.CLICKED_FORWARD,
|
||||
this.$route,
|
||||
{},
|
||||
{ displayVehicleChangeAlert: true },
|
||||
{}
|
||||
);
|
||||
return;
|
||||
} else {
|
||||
this.$refs.loadingModal.showModal();
|
||||
navigateAfterSaveToHeritageFunnel(this.$route);
|
||||
return;
|
||||
}
|
||||
},
|
||||
validateZip(zip) {
|
||||
return baseMixin.methods.dispatchStoreAction(storeActions.VALIDATE_ZIP, {
|
||||
zip,
|
||||
});
|
||||
},
|
||||
lookupVin(plate, state) {
|
||||
return baseMixin.methods.dispatchStoreAction(
|
||||
storeActions.LOOKUP_VIN_BY_PLATE,
|
||||
{ licensePlate: plate, licenseState: state }
|
||||
);
|
||||
},
|
||||
updateCustomerInfo(vin, vehicleInfo, registrationState) {
|
||||
if (this.isCarIdDifferent && !this.isSelectedGlassAvailableForVehicle) {
|
||||
store.dispatch(storeActions.RESET_DAMAGE_STATE_AND_DEPENDENCIES);
|
||||
}
|
||||
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.imageVifColor);
|
||||
store.commit(storeMutations.UPDATE_REGISTRATION_LICENSE_PLATE, this.licensePlate);
|
||||
store.commit(storeMutations.UPDATE_REGISTRATION_STATE, registrationState);
|
||||
store.commit(storeMutations.UPDATE_REGISTRATION_ZIP_CODE, this.registrationZip);
|
||||
store.commit(storeMutations.UPDATE_SERVICE_LOCATION_ZIP_CODE, this.serviceZip);
|
||||
store.commit(storeMutations.UPDATE_CUSTOMER_EMAIL_ADDRESS, this.email);
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
licensePlate() {
|
||||
this.$refs.funnelFooter.updateButtonText(
|
||||
this.getCmsContent("FunnelFooterWidget", "ForwardButtonText")
|
||||
);
|
||||
},
|
||||
registrationZip() {
|
||||
this.$refs.funnelFooter.updateButtonText(
|
||||
this.getCmsContent("FunnelFooterWidget", "ForwardButtonText")
|
||||
);
|
||||
},
|
||||
serviceZip() {
|
||||
this.$refs.funnelFooter.updateButtonText(
|
||||
this.getCmsContent("FunnelFooterWidget", "ForwardButtonText")
|
||||
);
|
||||
},
|
||||
},
|
||||
components: {
|
||||
Form,
|
||||
funnelHeader,
|
||||
vehicleBanner,
|
||||
funnelSubHeader,
|
||||
textboxQuestion,
|
||||
alert,
|
||||
funnelFooter,
|
||||
loadingModal,
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
@ -5,9 +5,15 @@
|
|||
ref="theForm"
|
||||
v-slot="{ meta }"
|
||||
>
|
||||
<div
|
||||
class="container-fluid shadow rounded-3 p-2 position-relative make-tall px-5"
|
||||
>
|
||||
<div class="container-fluid shadow rounded-3 p-2 position-relative make-tall px-5">
|
||||
<loadingModal :showCloseButton=false :clickOutCloses=false ref="loadingModal">
|
||||
<template v-slot:body>
|
||||
Please wait...
|
||||
</template>
|
||||
<template v-slot:subtext>
|
||||
This process can take up 20 seconds.
|
||||
</template>
|
||||
</loadingModal>
|
||||
<funnelHeader cmsWidgetName="FunnelHeaderWidget" />
|
||||
<vehicleBanner
|
||||
cmsWidgetName="VehicleBannerWidget"
|
||||
|
|
@ -102,6 +108,14 @@
|
|||
alertClass="alert-warning"
|
||||
cmsWidgetName="PerfectMatchNewVinAlert"
|
||||
/>
|
||||
<alert
|
||||
class="my-3"
|
||||
:manualHeadline="PerfectMatchNewVinAlertReadOnlyHeader"
|
||||
:manualCopy="PerfectMatchNewVinAlertReadOnlyBody"
|
||||
v-model="customAlertData"
|
||||
v-if="isVinFieldReadOnly"
|
||||
alertClass="alert-success"
|
||||
/>
|
||||
<funnelFooter
|
||||
cmsWidgetName="FunnelFooterWidget"
|
||||
ref="funnelFooter"
|
||||
|
|
@ -140,13 +154,6 @@
|
|||
alertClass="alert-success"
|
||||
cmsWidgetName="PerfectMatchNewVinAlert"
|
||||
/>
|
||||
<funnelFooter
|
||||
cmsWidgetName="FunnelFooterWidget"
|
||||
ref="funnelFooter"
|
||||
:isForwardActionDisabled="!meta.valid"
|
||||
@back-clicked="backButtonAction"
|
||||
@ForwardClicked="forwardButtonAction"
|
||||
/>
|
||||
</div>
|
||||
</Form>
|
||||
</template>
|
||||
|
|
@ -160,6 +167,7 @@ import funnelSubHeader from "@/common-components/funnel-sub-header/funnel-sub-he
|
|||
import alert from "@/ux-components/alert/alert";
|
||||
import textboxQuestion from "@/common-components/textbox-question/textbox-question";
|
||||
import vinInformation from "@/layouts/vin-lookup/vin-information/vin-information";
|
||||
import loadingModal from '@/common-components/loading-modal/loading-modal.vue';
|
||||
|
||||
// Supporting files
|
||||
import { fetchCmsContentForPage } from "@/helpers/cms-content-helper";
|
||||
|
|
@ -169,7 +177,7 @@ import baseMixin from "@/mixins/base-mixin.js";
|
|||
import { storeActions } from "@/constants/store-actions";
|
||||
import { storeMutations } from "@/constants/store-mutations";
|
||||
import { errorMessages } from "@/constants/error-messages";
|
||||
import { getDamageString, isGlassAvailableForCarId } from "@/helpers/damage-helper";
|
||||
import { getDamageString, getIsWindshieldOnly, isGlassAvailableForCarId } from "@/helpers/damage-helper";
|
||||
import { required, regex } from "@/helpers/validation-rules";
|
||||
import { Form, defineRule } from "vee-validate";
|
||||
import { navigateAfterSaveToHeritageFunnel } from "@/helpers/heritage-integration/navigation-helper";
|
||||
|
|
@ -260,6 +268,13 @@ export default {
|
|||
return this.getCmsContent("PerfectMatchNewVinAlert", "BodyText").replaceAll("{custom:damage}",
|
||||
getDamageString())
|
||||
},
|
||||
PerfectMatchNewVinAlertReadOnlyHeader () {
|
||||
return this.getCmsContent("PerfectMatchNewVinAlertReadOnly", "HeadlineText");
|
||||
},
|
||||
PerfectMatchNewVinAlertReadOnlyBody () {
|
||||
return this.getCmsContent("PerfectMatchNewVinAlertReadOnly", "BodyText").replaceAll("{custom:damage}",
|
||||
getIsWindshieldOnly())
|
||||
},
|
||||
isVinFieldReadOnly(){
|
||||
return this.$store.getters.payment.insuranceCoverage.isVerified;
|
||||
},
|
||||
|
|
@ -333,6 +348,7 @@ export default {
|
|||
this.$router.navigateAfterSave(this.navigationScenarios.CLICKED_FORWARD, this.$route, {}, { displayVehicleChangeAlert: true }, {});
|
||||
return;
|
||||
} else {
|
||||
this.$refs.loadingModal.showModal();
|
||||
navigateAfterSaveToHeritageFunnel(this.$route);
|
||||
return;
|
||||
}
|
||||
|
|
@ -375,6 +391,7 @@ export default {
|
|||
alert,
|
||||
funnelFooter,
|
||||
vinInformation,
|
||||
loadingModal,
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -117,18 +117,6 @@ const routingTable = [
|
|||
scenario: navigationScenarios.CLICKED_BACK,
|
||||
destinationFmgPageValue: fmgPageValues.ESTIMATE,
|
||||
},
|
||||
{
|
||||
scenario: navigationScenarios.CONTINUING_WITH_PARTS_QUESTION,
|
||||
destinationFmgPageValue: fmgPageValues.PART_QUESTIONS,
|
||||
},
|
||||
{
|
||||
scenario: navigationScenarios.CONTINUING_WITH_MULTIPLE_PARTS,
|
||||
destinationFmgPageValue: fmgPageValues.VEHICLE_PARTS,
|
||||
},
|
||||
{
|
||||
scenario: navigationScenarios.CONTINUING_WITH_SINGLE_PART,
|
||||
destinationFmgPageValue: fmgPageValues.REVEAL,
|
||||
},
|
||||
{
|
||||
scenario: navigationScenarios.CLICKED_FORWARD,
|
||||
destinationFmgPageValue: fmgPageValues.VEHICLE_DAMAGE,
|
||||
|
|
|
|||
|
|
@ -144,9 +144,9 @@ export const mutations = {
|
|||
updateRegistrationAddress(state, registrationAddress){
|
||||
state.order.vehicle.registration.address = registrationAddress;
|
||||
},
|
||||
updateServiceLocationZip(state, serviceLocationZip){
|
||||
updateServiceLocationZipCode(state, serviceLocationZip){
|
||||
state.order.vehicle.registration.zip = serviceLocationZip;
|
||||
},
|
||||
},
|
||||
updateRegistrationCity(state, serviceCity){
|
||||
state.order.vehicle.registration.city = serviceCity;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -47,6 +47,21 @@ describe("alert.vue", () => {
|
|||
expect(wrapperDiv.classes()).toContain('warning')
|
||||
});
|
||||
|
||||
it("Should update alert Headline to manualHeadline datam entered and alert copy to manualCopy datam entered when no cmsWidgetName entered", async () => {
|
||||
// Arrange
|
||||
const wrapper = shallowMount(alert, {
|
||||
propsData: {
|
||||
manualHeadline: 'testHeader',
|
||||
manualCopy: 'testCopy'
|
||||
},
|
||||
mixins: [mockMixin]
|
||||
});
|
||||
|
||||
// Assert
|
||||
expect(wrapper.vm.alertHeadline).toBe("testHeader");
|
||||
expect(wrapper.vm.alertCopy).toBe("testCopy");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
const mockMixin = {
|
||||
|
|
|
|||
Loading…
Reference in a new issue