diff --git a/jest.config.js b/jest.config.js index e75fc82ab..b594d4aef 100644 --- a/jest.config.js +++ b/jest.config.js @@ -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)"], diff --git a/src/assets/img/loader.gif b/src/assets/img/loader.gif new file mode 100644 index 000000000..c069b049d Binary files /dev/null and b/src/assets/img/loader.gif differ diff --git a/src/assets/img/windshield.png b/src/assets/img/windshield.png new file mode 100644 index 000000000..4f0c5e5de Binary files /dev/null and b/src/assets/img/windshield.png differ diff --git a/src/common-components/loading-modal/loading-modal.vue b/src/common-components/loading-modal/loading-modal.vue new file mode 100644 index 000000000..4f1365802 --- /dev/null +++ b/src/common-components/loading-modal/loading-modal.vue @@ -0,0 +1,126 @@ + + + + + \ No newline at end of file diff --git a/src/helpers/damage-helper.js b/src/helpers/damage-helper.js index e56761dc5..a9b14b98d 100644 --- a/src/helpers/damage-helper.js +++ b/src/helpers/damage-helper.js @@ -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, diff --git a/src/helpers/damage-helper.spec.js b/src/helpers/damage-helper.spec.js index ad5f8f878..2a46978dc 100644 --- a/src/helpers/damage-helper.spec.js +++ b/src/helpers/damage-helper.spec.js @@ -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"); }); - }); \ No newline at end of file + }); + + 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); + }); + }); + diff --git a/src/helpers/heritage-integration/navigation-helper.js b/src/helpers/heritage-integration/navigation-helper.js index 61c07203d..c7cf34940 100644 --- a/src/helpers/heritage-integration/navigation-helper.js +++ b/src/helpers/heritage-integration/navigation-helper.js @@ -140,4 +140,4 @@ function isVinRelatedPage(toRoute) { fmgPageValue === fmgPageValues.ADDRESS_LOOKUP || fmgPageValue === fmgPageValues.ADDRESS_VEHICLES || fmgPageValue === fmgPageValues.ESTIMATE; -} +} \ No newline at end of file diff --git a/src/helpers/heritage-integration/navigation-helper.spec.js b/src/helpers/heritage-integration/navigation-helper.spec.js index fd06920c2..01bf5dcdc 100644 --- a/src/helpers/heritage-integration/navigation-helper.spec.js +++ b/src/helpers/heritage-integration/navigation-helper.spec.js @@ -367,4 +367,4 @@ describe("navigateToHeritageFunnel", () => { }) ); }); -}); +}); \ No newline at end of file diff --git a/src/layouts/address-lookup/address-lookup.vue b/src/layouts/address-lookup/address-lookup.vue index 6209c6753..7d72483c6 100644 --- a/src/layouts/address-lookup/address-lookup.vue +++ b/src/layouts/address-lookup/address-lookup.vue @@ -1,6 +1,14 @@ @@ -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, }, }; diff --git a/src/router/router-constants/routing-table.js b/src/router/router-constants/routing-table.js index bd6124b30..cd2d876b3 100644 --- a/src/router/router-constants/routing-table.js +++ b/src/router/router-constants/routing-table.js @@ -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, diff --git a/src/store/index.js b/src/store/index.js index e3319fdcf..88a8f3cab 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -149,7 +149,7 @@ export const mutations = { }, updateRegistrationCity(state, registrationCity){ state.order.vehicle.registration.city = registrationCity; - }, + }, updateRegistrationFirstName(state, firstName){ state.order.vehicle.registration.firstName = firstName; }, diff --git a/src/ux-components/alert/alert.spec.js b/src/ux-components/alert/alert.spec.js index 17ed6988a..6f4bb9822 100644 --- a/src/ux-components/alert/alert.spec.js +++ b/src/ux-components/alert/alert.spec.js @@ -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 = {