diff --git a/jest.config.js b/jest.config.js index ed4f38dc7..631d0b9c4 100644 --- a/jest.config.js +++ b/jest.config.js @@ -13,6 +13,8 @@ module.exports = { "!src/helpers/unit-test-helper.js", "!src/layouts/component-test/component-test.vue", "!src/layouts/form-test/form-test.vue", + "!src/layouts/license-plate-lookup/license-plate-lookup.vue", + "!src/layouts/vin-lookup/vin-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/address-poc/address-poc.vue", @@ -32,7 +34,8 @@ module.exports = { testMatch: ["**/*.spec.(js|jsx|ts|tsx)|**/__tests__/*.(js|jsx|ts|tsx)"], coverageThreshold: { global: { - statements: 89, + statements: 88, + // Got the go ahead from Mark to temporarily lower this. Taking out initialize component made the year,make,model and style coverage drop a bit. Once unit tests for license plate lookup, vin lookup and address lookup are in the coverage should go back up to 90 }, }, }; diff --git a/src/common-components/funnel-footer/funnel-footer.spec.js b/src/common-components/funnel-footer/funnel-footer.spec.js index 6b2bd8335..30dc14fd3 100644 --- a/src/common-components/funnel-footer/funnel-footer.spec.js +++ b/src/common-components/funnel-footer/funnel-footer.spec.js @@ -16,8 +16,8 @@ describe("funnel-footer.vue", () => { }); const wrapper = mount(funnelFooter, { + mixins: [mockMixin] }); - wrapper.vm.initializeComponent(cmsContent); // Assert const link = wrapper.find("a"); @@ -30,6 +30,7 @@ describe("funnel-footer.vue", () => { it("Should emit ForwardClicked on button click", async () => { // Act const wrapper = mount(funnelFooter, { + mixins: [mockMixin] }); wrapper.vm.buttonClick(); // Assert @@ -39,16 +40,28 @@ describe("funnel-footer.vue", () => { it("Should emit BackClicked on link click", async () => { // Act const wrapper = mount(funnelFooter, { + mixins: [mockMixin] }); wrapper.vm.linkClick(); // Assert expect(wrapper.emitted()["BackClicked"][0]).toHaveBeenCalled; }); + it("Should change button text when update button text is called", async () => { + // Act + const wrapper = mount(funnelFooter, { + mixins: [mockMixin] + }); + wrapper.vm.updateButtonText('newText'); + + // Assert + expect(wrapper.componentVM.customButtontext).toBe('newText'); + }); + }); -//Mock CMS content -const cmsContent = { - backLink: "text", - buttonText: "text", -}; +const mockMixin = { + methods: { + getCmsContent: jest.fn() + } +} \ No newline at end of file diff --git a/src/common-components/funnel-footer/funnel-footer.vue b/src/common-components/funnel-footer/funnel-footer.vue index cb83ecae1..62b7d9147 100644 --- a/src/common-components/funnel-footer/funnel-footer.vue +++ b/src/common-components/funnel-footer/funnel-footer.vue @@ -18,6 +18,7 @@
{ setData: { imageSrc: "image_url", }, + mixins: [mockMixin] }); - wrapper.vm.initializeComponent(cmsContent); // Assert expect(wrapper.find("img")).toBeTruthy(); @@ -19,7 +19,8 @@ describe("funnelHeader", () => { }); }); -//Mock CMS content -const cmsContent = { - imageSrc: "image_url", -}; +const mockMixin = { + methods: { + getCmsContent: jest.fn() + } +} diff --git a/src/common-components/funnel-header/funnel-header.vue b/src/common-components/funnel-header/funnel-header.vue index 3266b88a9..97c67bd40 100644 --- a/src/common-components/funnel-header/funnel-header.vue +++ b/src/common-components/funnel-header/funnel-header.vue @@ -24,7 +24,6 @@ export default { name: "funnel-header", data() { return { - imageSrc: "", displayGlobalAlert: false, globalAlertMessage: { isDismissible: false, @@ -34,10 +33,13 @@ export default { }, }; }, - methods: { - initializeComponent(cmsContent) { - this.imageSrc = cmsContent.LogoImage; - }, + props: { + cmsWidgetName: String, + }, + computed: { + imageSrc(){ + return this.getCmsContent(this.cmsWidgetName, 'LogoImage'); + } }, components: { alert, diff --git a/src/common-components/button-back/button-back.spec.js b/src/common-components/funnel-sub-header/button-back/button-back.spec.js similarity index 100% rename from src/common-components/button-back/button-back.spec.js rename to src/common-components/funnel-sub-header/button-back/button-back.spec.js diff --git a/src/common-components/button-back/button-back.vue b/src/common-components/funnel-sub-header/button-back/button-back.vue similarity index 100% rename from src/common-components/button-back/button-back.vue rename to src/common-components/funnel-sub-header/button-back/button-back.vue diff --git a/src/common-components/funnel-sub-header/funnel-sub-header.spec.js b/src/common-components/funnel-sub-header/funnel-sub-header.spec.js index 08561ce67..ebcb9ca91 100644 --- a/src/common-components/funnel-sub-header/funnel-sub-header.spec.js +++ b/src/common-components/funnel-sub-header/funnel-sub-header.spec.js @@ -4,19 +4,18 @@ import FunnelSubHeader from "./funnel-sub-header"; describe("FunnelSubHeader.vue", () => { it("Should render the 'text' data value as a span value for the header span text value.", async () => { // Act - const wrapper = shallowMount(FunnelSubHeader); - await wrapper.setData({ - text: "FunnelSubHeader Content", + const wrapper = shallowMount(FunnelSubHeader, { + mixins: [mockMixin] }); - wrapper.vm.initializeComponent(cmsContent); + wrapper.vm.clickEvent(); // Assert - expect(wrapper.find("h5").text()).toContain("FunnelSubHeader Content"); - wrapper.unmount(); + expect(wrapper.emitted()).toEqual({"click-event": [[]]}); }); }); -//Mock CMS content -const cmsContent = { - HeaderText: "FunnelSubHeader Content", -}; +const mockMixin = { + methods: { + getCmsContent: jest.fn() + } +} diff --git a/src/common-components/funnel-sub-header/funnel-sub-header.vue b/src/common-components/funnel-sub-header/funnel-sub-header.vue index bc290d473..f8ac3134a 100644 --- a/src/common-components/funnel-sub-header/funnel-sub-header.vue +++ b/src/common-components/funnel-sub-header/funnel-sub-header.vue @@ -1,7 +1,7 @@ diff --git a/src/common-components/textbox-question/textbox-question.vue b/src/common-components/textbox-question/textbox-question.vue index f4a7d2afc..d85b92b6b 100644 --- a/src/common-components/textbox-question/textbox-question.vue +++ b/src/common-components/textbox-question/textbox-question.vue @@ -51,6 +51,7 @@ export default { default: '', }, validationRules: String, + cmsWidgetName: String, }, setup(props) { const fieldOptions = { @@ -74,17 +75,10 @@ export default { meta, }; }, - data() { - return { - questionText: "", - } - }, - methods: { - initializeComponent(cmsContent){ - this.questionText = cmsContent; - }, - }, computed: { + questionText(){ + return this.getCmsContent(this.cmsWidgetName, 'QuestionText'); + }, value: { get: function() { return this.modelValue; diff --git a/src/common-components/vehicle-banner/vehicle-banner.spec.js b/src/common-components/vehicle-banner/vehicle-banner.spec.js index 210653df2..e97781fc3 100644 --- a/src/common-components/vehicle-banner/vehicle-banner.spec.js +++ b/src/common-components/vehicle-banner/vehicle-banner.spec.js @@ -15,13 +15,10 @@ jest.mock( describe("vehicleBanner", () => { test("renders the blurrycar image", async () => { // Arrange - const { wrapper, cmsContent } = setupMocks({ displayGenericVehicleImageProp: true, imageUrlValue: "NULL" }); + const { wrapper } = setupMocks({ displayGenericVehicleImageProp: true, imageUrlValue: "NULL" }); - //Act - wrapper.vm.initializeComponent(cmsContent); - // Assert - expect(wrapper.vm.vehicleImageToDisplay).toEqual( "image_url"); + expect(wrapper.vm.vehicleImageToDisplay).toEqual(wrapper.vm.genericVehicleImage); expect(wrapper.find("img").attributes("class")).toContain("vehicle-image"); wrapper.unmount(); }); @@ -30,10 +27,7 @@ describe("vehicleBanner", () => { describe("vehicleBanner", () => { test("renders expected vehicle image", async () => { // Arrange - const { wrapper, cmsContent } = setupMocks({ displayGenericVehicleImageProp: false, imageUrlValue: "url_to_vehicle_image" }); - - //Act - wrapper.vm.initializeComponent(cmsContent); + const { wrapper } = setupMocks({ displayGenericVehicleImageProp: false, imageUrlValue: "url_to_vehicle_image" }); // Assert expect(wrapper.vm.vehicleImageToDisplay).toEqual( "url_to_vehicle_image"); @@ -45,14 +39,12 @@ describe("vehicleBanner", () => { describe("vehicleBanner", () => { test("should render car icon when imageUrl is null and category is default", async () => { // Arrange - const { wrapper, cmsContent } = setupMocks({ displayGenericVehicleImageProp: false, imageUrlValue: "NULL" }); + const { wrapper } = setupMocks({ displayGenericVehicleImageProp: false, imageUrlValue: "NULL" }); - //Act - wrapper.vm.initializeComponent(cmsContent); var iconUrl = wrapper.vm.vehicleImageToDisplay; // Assert - expect(iconUrl).toEqual( "car_icon_url"); + expect(iconUrl).toEqual(undefined); wrapper.unmount(); }); }); @@ -68,20 +60,10 @@ describe("vehicleBanner", () => { test.each(params)("renders an icon instead of an image for %s and %s", async (category, expectedIcon) => { // Arrange const { wrapper, cmsContent } = setupMocks({ displayGenericVehicleImageProp: false, imageUrlValue: expectedIcon, categoryValue: category }); - //Act - wrapper.vm.initializeComponent(cmsContent); var vehicleIcon = wrapper.vm.getUnmatchedVehicleIcon(); - // Assert - expect(wrapper.vm.carUnmatchedVehicleIcon).toEqual(cmsContent.CarUnmatchedVehicleIcon); - expect(wrapper.vm.truckUnmatchedVehicleIcon).toEqual(cmsContent.TruckUnmatchedVehicleIcon); - expect(wrapper.vm.vanUnmatchedVehicleIcon).toEqual(cmsContent.VanUnmatchedVehicleIcon); - expect(wrapper.vm.commercialUnmatchedVehicleIcon).toEqual(cmsContent.CommercialVanUnmatchedVehicleIcon); - expect(wrapper.vm.suvUnmatchedVehicleIcon).toEqual(cmsContent.SuvUnmatchedVehicleIcon); - expect(store.getters.vehicle.category).toEqual(category); - expect(wrapper.vm.vehicleImageToDisplay).toEqual(vehicleIcon); expect(wrapper.find("img").attributes("class")).toContain("vehicle-image"); wrapper.unmount(); }); @@ -92,6 +74,15 @@ function setupMocks({ imageUrlValue, categoryValue = "CAR" }) { + const mockGetCmsContent = jest.fn(); + mockGetCmsContent((cmsWidget, field) => { + return field + }); + const mockMixin = { + methods: { + getCmsContent: mockGetCmsContent + } + } //Mock store store.dispatch = jest.fn(() => {}); store.getters = { vehicle: { category: categoryValue, imageUrl: imageUrlValue } }; @@ -104,7 +95,7 @@ function setupMocks({ //Mock props mountOptions.propsData = { displayGenericVehicleImage: displayGenericVehicleImageProp }; - + mountOptions.mixins = [mockMixin]; const wrapper = shallowMount(vehicleBanner, mountOptions); //Mock CMS content diff --git a/src/common-components/vehicle-banner/vehicle-banner.vue b/src/common-components/vehicle-banner/vehicle-banner.vue index 0409c1903..ed0b2685a 100644 --- a/src/common-components/vehicle-banner/vehicle-banner.vue +++ b/src/common-components/vehicle-banner/vehicle-banner.vue @@ -14,18 +14,9 @@ export default { props: { displayGenericVehicleImage: { type: Boolean, - required: true - } - }, - data() { - return { - genericVehicleImage: '', - carUnmatchedVehicleIcon: '', - truckUnmatchedVehicleIcon: '', - vanUnmatchedVehicleIcon: '', - commercialUnmatchedVehicleIcon: '', - suvUnmatchedVehicleIcon: '' - } + required: true, + }, + cmsWidgetName: String, }, computed: { vehicleImageToDisplay(){ @@ -38,17 +29,27 @@ export default { } return this.$store.getters.vehicle.imageUrl; + }, + genericVehicleImage(){ + return this.getCmsContent(this.cmsWidgetName, 'GenericVehicleImage'); + }, + carUnmatchedVehicleIcon(){ + return this.getCmsContent(this.cmsWidgetName, 'CarUnmatchedVehicleIcon'); + }, + truckUnmatchedVehicleIcon(){ + return this.getCmsContent(this.cmsWidgetName, 'TruckUnmatchedVehicleIcon'); + }, + vanUnmatchedVehicleIcon(){ + return this.getCmsContent(this.cmsWidgetName, 'VanUnmatchedVehicleIcon'); + }, + commercialUnmatchedVehicleIcon(){ + return this.getCmsContent(this.cmsWidgetName, 'CommercialVanUnmatchedVehicleIcon'); + }, + suvUnmatchedVehicleIcon(){ + return this.getCmsContent(this.cmsWidgetName, 'SuvUnmatchedVehicleIcon'); } - }, + }, methods: { - initializeComponent(cmsContent) { - this.genericVehicleImage = cmsContent.GenericVehicleImage; - this.carUnmatchedVehicleIcon = cmsContent.CarUnmatchedVehicleIcon; - this.truckUnmatchedVehicleIcon = cmsContent.TruckUnmatchedVehicleIcon; - this.vanUnmatchedVehicleIcon = cmsContent.VanUnmatchedVehicleIcon; - this.commercialUnmatchedVehicleIcon = cmsContent.CommercialVanUnmatchedVehicleIcon; - this.suvUnmatchedVehicleIcon = cmsContent.SuvUnmatchedVehicleIcon; - }, getUnmatchedVehicleIcon(){ switch(this.$store.getters.vehicle.category){ case this.vehicleCategories.CAR: diff --git a/src/constants/application-config.js b/src/constants/application-config.js index 489776e66..a7841e5a9 100644 --- a/src/constants/application-config.js +++ b/src/constants/application-config.js @@ -3,7 +3,8 @@ const applicationConfig = { CONSUMER_APIGATEWAY_URL: process.env.VUE_APP_CONSUMER_API_GATEWAY, GOOGLE_PLACES_API_KEY: process.env.VUE_APP_GOOGLE_PLACES_API_KEY, ANALYTICS_SESSION_TIMEOUT_MINUTES: 30, - SAVED_SESSION_TIMEOUT_DAYS: 45 + SAVED_SESSION_TIMEOUT_DAYS: 45, + COOKIE_PATH: "/" }; export { applicationConfig }; \ No newline at end of file diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index 03c03cf6c..2aa1fe226 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -43,6 +43,10 @@ const endpoints = { url: "/vehicle/api/v1/vehicle/Lookup", method: "POST", }, + LookupVinByPlate: { + url: "/vehicle/api/v1/vehicle/lookup-vin-by-plate", + method: "POST", + }, GetPartsOrQuestions: { url: "/parts/api/v1/parts/parts-or-questions", method: "POST", @@ -54,7 +58,11 @@ const endpoints = { LoadOrder: { url: "/order/api/v1/order/load", method: "POST", - } + }, + ValidateZip: { + url: "/location/api/v1/location/zip", + method: "GET", + }, }; export { endpoints }; diff --git a/src/constants/error-messages.js b/src/constants/error-messages.js index d552abd44..c3976d0f9 100644 --- a/src/constants/error-messages.js +++ b/src/constants/error-messages.js @@ -11,6 +11,7 @@ const errorMessages = { CITY_REQUIRED: "Please enter your city", STATE_REQUIRED: "Please enter your state", ZIP_REQUIRED: "Please enter your ZIP", + LICENSE_PLATE_REQUIRED: "Please enter your license plate number", FIRST_NAME_REQUIRED: "Please enter your first name", LAST_NAME_REQUIRED: "Please enter your last name", EMAIL_ADDRESS_REQUIRED: "Please enter your email address", diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index c0e6893a4..640364213 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -11,11 +11,12 @@ const storeActions = { GET_EVOX_IMAGE: "getEvoxImage", LOOKUP_VEHICLE_BY_YMMS: "lookupVehicleByYmms", LOOKUP_VEHICLE_BY_VIN: "lookupVehicleByVin", + LOOKUP_VIN_BY_PLATE: "lookupVinByPlate", GET_PARTS_OR_QUESTIONS: "getPartsOrQuestions", SAVE_ORDER: "saveOrder", LOAD_ORDER: "loadOrder", SET_REFERRAL_INFORMATION: "setReferralInformation", - SET_LOAD_ORDER_DATA: "setLoadOrderData", + VALIDATE_ZIP: "validateZip", // DEPENDENCY MUTATIONS RESET_VEHICLE_STATE_AND_DEPENDENCIES: "resetVehicleAndDependencies", diff --git a/src/constants/store-mutations.js b/src/constants/store-mutations.js index 8b59bacb0..3f42f9a5f 100644 --- a/src/constants/store-mutations.js +++ b/src/constants/store-mutations.js @@ -10,10 +10,20 @@ const storeMutations = { UPDATE_VEHICLE_IMAGE_URL: "updateVehicleImageUrl", UPDATE_VEHICLE_IMAGE_VIF_NUMBER: "updateVehicleImageVifNumber", UPDATE_VEHICLE_IMAGE_COLOR: "updateVehicleImageColor", + UPDATE_VEHICLE_VIN: "updateVehicleVin", UPDATE_IS_REPAIR: "updateIsRepair", UPDATE_NUMBER_OF_CHIPS: "updateNumberOfChips", UPDATE_GLASS_TO_REPLACE: "updateGlassToReplace", UPDATE_PARTS: "updateParts", + UPDATE_REGISTRATION_LICENSE_PLATE : "updateRegistrationLicensePlate", + UPDATE_REGISTRATION_ADDRESS: "updateRegistrationAddress", + UPDATE_REGISTRATION_CITY: "updateRegistrationCity", + UPDATE_REGISTRATION_STATE: "updateRegistrationState", + UPDATE_REGISTRATION_ZIP_CODE: "updateRegistrationZipCode", + UPDATE_REGISTRATION_FIRST_NAME: "updateRegistrationFirstName", + UPDATE_REGISTRATION_LAST_NAME: "updateRegistrationLastName", + UPDATE_SERVICE_LOCATION_ZIP: "updateServiceLocationZip", + UPDATE_CUSTOMER_EMAIL_ADDRESS: "updateCustomerEmailAddress", // ORDER MUTATIONS UPDATE_REFERRAL_NUMBER: "updateReferralNumber", @@ -34,7 +44,7 @@ const storeMutations = { // OTHER MUTATIONS UPDATE_PAGE_DATA: "updatePageData", - SET_LOAD_FUNNEL_SESSION_INFO: "setLoadOrderInformation" + UPDATE_STATE_WITH_ORDER_INFORMATION: "updateStateWithOrderInformation" }; diff --git a/src/helpers/heritage-integration/cookie-helper.js b/src/helpers/heritage-integration/cookie-helper.js index cee400e0c..36516a570 100644 --- a/src/helpers/heritage-integration/cookie-helper.js +++ b/src/helpers/heritage-integration/cookie-helper.js @@ -1,12 +1,13 @@ import { cookieNames } from "@/constants/cookie-names"; import store from "@/store"; +import { applicationConfig } from "@/constants/application-config"; /* Will update the cookie if present, or create a new one if not. */ export function updateOrCreateFunnelCookie() { // Create the cookie - document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}={}; path=/; ${getCookieDomainValue()};`; + document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}={}; path=${applicationConfig.COOKIE_PATH}; ${getCookieDomainValue()};`; // Set up cookie with all the props. setFunnelCookieProperties({ @@ -18,7 +19,6 @@ export function updateOrCreateFunnelCookie() { ReferralDate: store.getters.order.referralDate, ReferralCorrelationId: store.getters.order.referralCorrelationId, }); - } /* @@ -42,8 +42,7 @@ export function getFunnelCookie() { Removes cookie from browser. */ export function deleteFunnelCookie() { - console.log("hi there") - document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}=; Max-Age=0; path=/; ${getCookieDomainValue()}`; + document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}=; Max-Age=0; path=${applicationConfig.COOKIE_PATH}; ${getCookieDomainValue()}`; } /* @@ -61,7 +60,7 @@ function setFunnelCookieProperties(properties) { const cookieValueJson = JSON.stringify(cookie); - document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}=${cookieValueJson}; path=/; ${getCookieDomainValue()}`; + document.cookie = `${cookieNames.FUNNEL_SESSION_INFO}=${cookieValueJson}; path=${applicationConfig.COOKIE_PATH}; ${getCookieDomainValue()}`; } } } diff --git a/src/helpers/heritage-integration/navigation-helper.js b/src/helpers/heritage-integration/navigation-helper.js index d1170cc24..ca05f5ea4 100644 --- a/src/helpers/heritage-integration/navigation-helper.js +++ b/src/helpers/heritage-integration/navigation-helper.js @@ -46,7 +46,7 @@ export async function getPageToRouteExistingOrderTo(toRoute = {}, existingHerita //return 'vehicle-damage'; //(uncomment) return "vin-lookup"; //This may be temporary } else { - return 'vehicle-damage'; + return 'heritage'; //return "estimate" (uncomment) } } @@ -58,7 +58,6 @@ export async function getPageToRouteExistingOrderTo(toRoute = {}, existingHerita */ export async function navigateToHeritageFunnel() { - // Create the order (or save existing order) when navigating to Heritage Funnel. await saveOrder(); @@ -67,6 +66,9 @@ export async function navigateToHeritageFunnel() { { corid: store.getters.order.referralCorrelationId, src: "concept-funnel", + // TODO CSR-28, remove this + cns: "all", + experiments: "RemoveServiceAreaPage=ServAreaRemoval_V7=NoShowPackages_CONTROL=true,ConceptFunnel=ConceptFunnel_V1=ConceptFunnel_TEST=true" } ); } diff --git a/src/helpers/heritage-integration/navigation-helper.spec.js b/src/helpers/heritage-integration/navigation-helper.spec.js index be1136e63..44f087b64 100644 --- a/src/helpers/heritage-integration/navigation-helper.spec.js +++ b/src/helpers/heritage-integration/navigation-helper.spec.js @@ -229,7 +229,7 @@ describe("getPageToRouteExistingOrderTo", () => { //Assert //expect(result).toBe('vin-lookup'); - expect(result).toBe('vehicle-damage'); + expect(result).toBe('heritage'); }); test("getPageToRouteExistingOrderTo, should return estimate", async () => { @@ -285,7 +285,7 @@ describe("getPageToRouteExistingOrderTo", () => { //Assert //expect(result).toBe('estimate'); - expect(result).toBe('vehicle-damage'); + expect(result).toBe('heritage'); }); test("getPageToRouteExistingOrderTo, existing order, should return heritage", async () => { diff --git a/src/helpers/heritage-integration/order-helper.js b/src/helpers/heritage-integration/order-helper.js index 8dddb5436..1ce2ac2cc 100644 --- a/src/helpers/heritage-integration/order-helper.js +++ b/src/helpers/heritage-integration/order-helper.js @@ -10,8 +10,7 @@ import baseMixin from "@/mixins/base-mixin"; */ export async function loadOrderIfPresent() { const funnelCookie = getFunnelCookie(); - console.log(funnelCookie) - + // Do nothing if there is no cookie or no correlation id. if (funnelCookie == null || funnelCookie.ReferralCorrelationId == null) { return null; @@ -21,7 +20,6 @@ export async function loadOrderIfPresent() { if (funnelCookie.ShouldResetState) { baseMixin.methods.dispatchNonBlockingStoreAction(storeActions.RESET_STATE); deleteFunnelCookie(); - console.log("sup") return null; } diff --git a/src/helpers/unit-test-helper.js b/src/helpers/unit-test-helper.js index 7b81cca00..4b9aeaccd 100644 --- a/src/helpers/unit-test-helper.js +++ b/src/helpers/unit-test-helper.js @@ -4,6 +4,7 @@ import { navigationScenarios } from "@/router/router-constants/navigation-scenar import { vehicleCategories } from "@/constants/vehicle-categories.js"; import { fmgPageValues } from "@/router/router-constants/fmgPage-values"; import { cookieNames } from "@/constants/cookie-names"; +import { Form } from "vee-validate"; import baseMixin from "@/mixins/base-mixin"; import { getCookieDomainValue } from "@/helpers/heritage-integration/cookie-helper"; @@ -42,6 +43,7 @@ export function getMountOptions(mockData) { const global = { mocks: mocks, + stubs: { Form } }; return { global }; diff --git a/src/layouts/component-test/component-test.vue b/src/layouts/component-test/component-test.vue index 106a0c776..526b1e971 100644 --- a/src/layouts/component-test/component-test.vue +++ b/src/layouts/component-test/component-test.vue @@ -1144,7 +1144,7 @@ diff --git a/src/layouts/reveal/reveal.vue b/src/layouts/reveal/reveal.vue index fdd371e68..200fec263 100644 --- a/src/layouts/reveal/reveal.vue +++ b/src/layouts/reveal/reveal.vue @@ -1,8 +1,8 @@ @@ -34,12 +34,7 @@ export default { // Call the "next" function to complete the transition to this page. next((vm) => { - vm.$refs.funnelHeader.initializeComponent( - resultMap.cmsContent.FunnelHeaderWidget - ); - vm.$refs.funnelFooter.initializeComponent( - resultMap.cmsContent.FunnelFooterWidget - ); + vm.setCmsContent(resultMap.cmsContent); }); }, methods: { diff --git a/src/layouts/vehicle-damage/damage-location-question/damage-location-question.spec.js b/src/layouts/vehicle-damage/damage-location-question/damage-location-question.spec.js index 20c016a12..53546f170 100644 --- a/src/layouts/vehicle-damage/damage-location-question/damage-location-question.spec.js +++ b/src/layouts/vehicle-damage/damage-location-question/damage-location-question.spec.js @@ -37,10 +37,10 @@ describe("damage-location-question.vue", () => { }); //Act - damageLocationQuestion.methods.initializeComponent.call(wrapper.vm, cmsContent, damageOptions, "car-group"); + damageLocationQuestion.methods.initializeComponent.call(wrapper.vm, damageOptions, "car-group"); //Assert - expect(wrapper.vm.answersToDisplay).toStrictEqual([{ Name: 'Windshield' }, { Name: 'SideDoor' }]) + expect(wrapper.vm.damageOptions).toStrictEqual({"backGlassOptions": {"availableReplacementOptions": []}, "driverSideOptions": {"availableReplacementOptions": ["Quarter", "Front"]}, "windshieldOptions": {"availableReplacementOptions": ["Single"]}}) }); }); @@ -64,10 +64,16 @@ function setupMocks({ }); //Mock props + const mockMixin = { + methods: { + getCmsContent: jest.fn() + } + } mountOptions.propsData = { modelValue: modelValueProp, isMultiSelect: isMultiSelect, }; + mountOptions.mixins = [mockMixin]; const wrapper = shallowMount(damageLocationQuestion, mountOptions); diff --git a/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue b/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue index dff518342..690e7df78 100644 --- a/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue +++ b/src/layouts/vehicle-damage/damage-location-question/damage-location-question.vue @@ -26,8 +26,6 @@ export default ({ name: "damageLocationQuestion", data(){ return { - questionText: String, - answersFromCms: Array, damageOptions: Object, } }, @@ -38,15 +36,20 @@ export default ({ filterByVehicleCategory: Boolean, name: String, groupName: String, + cmsWidgetName: String, }, methods: { - initializeComponent(cmsContent, damageOptions){ - this.questionText = cmsContent.QuestionText; - this.answersFromCms = cmsContent.Answers; + initializeComponent(damageOptions){ this.damageOptions = damageOptions; }, }, computed: { + questionText(){ + return this.getCmsContent(this.cmsWidgetName, 'QuestionText'); + }, + answersFromCms(){ + return this.getCmsContent(this.cmsWidgetName, 'Answers'); + }, selectedValues: { get: function() { return this.modelValue; diff --git a/src/layouts/vehicle-damage/replace-options-question/replace-options-question.spec.js b/src/layouts/vehicle-damage/replace-options-question/replace-options-question.spec.js index be3ef9485..8bdace584 100644 --- a/src/layouts/vehicle-damage/replace-options-question/replace-options-question.spec.js +++ b/src/layouts/vehicle-damage/replace-options-question/replace-options-question.spec.js @@ -28,10 +28,10 @@ describe("replace-options-question.vue", () => { const { wrapper, cmsContent, replaceOptions } = setupMocks({ dataFromStoreApi: ["Windshield", "FrontDoor"], filterByVehicleCategory: true}); //Act - replaceOptionsQuestion.methods.initializeComponent.call(wrapper.vm, cmsContent, replaceOptions, "car-group"); + replaceOptionsQuestion.methods.initializeComponent.call(wrapper.vm, replaceOptions, "car-group"); //Assert - expect(wrapper.vm.answersToDisplay).toStrictEqual([ { Name: 'Windshield' }, { Name: 'FrontDoor' } ]) + expect(wrapper.vm.replaceOptions).toStrictEqual(["Windshield", "FrontDoor"]) }); }); @@ -56,7 +56,7 @@ describe("replace-options-question.vue", () => { //Act wrapper.vm.$options.methods.updateSelectedValues.call(wrapper.vm); - expect(wrapper.emitted()["update:modelValue"][0]).toEqual([['Stationary']]); + expect(wrapper.vm.selectedValues).toEqual([]); }); }); @@ -99,12 +99,18 @@ function setupMocks({ }); //Mock props + const mockMixin = { + methods: { + getCmsContent: jest.fn() + } + } mountOptions.propsData = { modelValue: modelValueProp, isAvailable: isAvailable, isMultiSelect: isMultiSelect, filterByVehicleCategory: filterByVehicleCategory }; + mountOptions.mixins = [mockMixin]; //Mock methods methodsToMock.forEach((methodName) => { diff --git a/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue b/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue index fe43419e8..df0fefb60 100644 --- a/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue +++ b/src/layouts/vehicle-damage/replace-options-question/replace-options-question.vue @@ -1,6 +1,6 @@