diff --git a/src/constants/query-strings.js b/src/constants/query-strings.js index 76411c542..a3b3c732c 100644 --- a/src/constants/query-strings.js +++ b/src/constants/query-strings.js @@ -25,6 +25,14 @@ const queryStrings = { REFERRAL_NUMBER: "rn", PARENT_ACCOUNT: "pa", CORRELATION_ID: "ci", + VEHICLE_YEAR: "vehicleyear", + VEHICLE_MAKE: "vehiclemake", + VEHICLE_MODEL: "vehiclemodel", + VEHICLE_STYLE: "vehiclestyle", + VEHICLE_DAMAGE: "vehicledamage", + SERVICE_ZIP: "servicezip", + EMAIL: "email", + IS_INSURANCE: "isinsurance", }; export { queryStrings }; diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index bd772cafe..0001daf6a 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -96,6 +96,7 @@ const storeActions = { CREATE_SUBMITTED_ORDER: "createSubmittedOrder", RESET_SUBMITTED_ORDER: "resetSubmittedOrder", + RESET_IS_LEAD_GEN: "resetIsLeadGen", }; export { storeActions }; diff --git a/src/constants/store-mutations.js b/src/constants/store-mutations.js index 8d23f50ab..f78b970c3 100644 --- a/src/constants/store-mutations.js +++ b/src/constants/store-mutations.js @@ -60,6 +60,7 @@ const storeMutations = { Customer_Portal_Login_Token: "updateCustomerPortalLoginToken", LOCK_TOKEN: "updateLockToken", UPDATE_SETTLED_TENDER_AMOUNT: "updateSettledTenderAmount", + UPDATE_IS_LEAD_GEN: "updateIsLeadGen", // EVENT BUS MUTATIONS ADD_EVENT_TO_BUS: "addEventToBus", diff --git a/src/constants/vin-lookup-method-selections.js b/src/constants/vin-lookup-method-selections.js index 8f78ecf68..3147a9ecb 100644 --- a/src/constants/vin-lookup-method-selections.js +++ b/src/constants/vin-lookup-method-selections.js @@ -2,6 +2,7 @@ const vinLookupMethodSelections = { MANUALVIN: "ManualVin", LICENSEPLATE: "LicensePlate", HOMEADDRESS: "HomeAddress", + DECLINE: "Decline", }; export { vinLookupMethodSelections }; diff --git a/src/digital-components/button-question/button-question.vue b/src/digital-components/button-question/button-question.vue index 24a8b8f41..2bb4bec7f 100644 --- a/src/digital-components/button-question/button-question.vue +++ b/src/digital-components/button-question/button-question.vue @@ -213,7 +213,7 @@ export default { classes = "ui-checkbox d-flex"; break; case "servicePackageRadio": - classes = "package-main"; + classes = "package-main d-md-flex justify-content-center"; break; } return classes; @@ -226,7 +226,7 @@ export default { if (this.buttonTypeString == "radio") { classes += " radio-button-container"; } else if (this.buttonTypeString == "servicePackageRadio") { - classes = "package-wrapper"; + classes = "package-wrapper col-md-4"; } if (this.buttonTypeString == "listCard" && this.buttonsInfo.length > 2) { diff --git a/src/fmg-components/address-questions/address-questions.vue b/src/fmg-components/address-questions/address-questions.vue index dfbbb7c52..7acd0f4f0 100644 --- a/src/fmg-components/address-questions/address-questions.vue +++ b/src/fmg-components/address-questions/address-questions.vue @@ -243,11 +243,11 @@ export default { this.fillInAddress ); - // When the Street Address textbox receives focus, + // When the Street Address textbox receives input for the first time, // append the search results list container to the bottom of the textbox // and disable browser autofill this.addressField1.addEventListener( - "focus", + "keydown", (e) => { // Make place results box stick to the input on scroll const streetAddressField = document.getElementById("streetAddressField"); @@ -276,6 +276,7 @@ export default { const addressFields = document.querySelectorAll( ".address-questions input, .address-questions select" ); + for (let addressField of addressFields) { addressField.addEventListener("input", (e) => { switch (e.inputType) { diff --git a/src/fmg-components/cart/cart.spec.js b/src/fmg-components/cart/cart.spec.js index 10207c8bb..3e1e9760f 100644 --- a/src/fmg-components/cart/cart.spec.js +++ b/src/fmg-components/cart/cart.spec.js @@ -263,49 +263,6 @@ describe("cart.vue", () => { expect(found).toBe(true); }); - // Mobile Fee Cart Item - test("if there is mobile fee on the order, a mobile fee cart item should be added to the cart", () => { - // Arrange - const lineItems = { - glassParts: [], - supportingItems: [ - { - description: null, - id: "9ff98501-03a4-432b-884e-e4e28f884a2f", - kitPrice: 0, - laborAmount: 34.98, - partNumber: "MOBILE FEE", - partType: "MOBILE FEE", - salesTax: 2.62, - sellingPrice: 0, - }, - ], - vaps: [], - promos: [], - }; - - const availableVaps = []; - - // Act - const { wrapper } = setupMocks({ - props: { - modelValue: lineItems, - availableVaps: availableVaps, - }, - }); - - // Assert - expect(wrapper.vm.mobileFeeCartItem).not.toBeNull(); - expect(wrapper.vm.mobileFeeCartItem.subTotal).toEqual(34.98); - expect(wrapper.vm.mobileFeeCartItem.salesTax).toEqual(2.62); - - const found = - wrapper.vm.cartItems.findIndex( - (cartItem) => cartItem == wrapper.vm.mobileFeeCartItem - ) >= 0; - expect(found).toBe(true); - }); - // Service package discount Fee Cart Item test("if there is service package discount fee on the order, a service package discount cart item should be added to the cart", () => { // Arrange diff --git a/src/fmg-components/cart/cart.vue b/src/fmg-components/cart/cart.vue index f268e7831..a712b8127 100644 --- a/src/fmg-components/cart/cart.vue +++ b/src/fmg-components/cart/cart.vue @@ -377,9 +377,6 @@ export default { cartItems.push(this.suppliesRepairCartItem); } - if (this.mobileFeeCartItem) { - cartItems.push(this.mobileFeeCartItem); - } if (this.servicePackageDiscountCartItem) { cartItems.push(this.servicePackageDiscountCartItem); } @@ -670,13 +667,27 @@ export default { recycleFeeCartItemName() { return this.getCmsContent("RecycleFeeTextWidget", "Text"); }, + requiresRecycleFeeCartItem() { + return !this.isRepair; + }, recycleFeeCartItem() { let cartItem = null; - const recycleFeeLineItem = this.supportingItems.find( + let recycleFeeLineItem = this.supportingItems.find( (supportingItem) => supportingItem.partType == partTypeStrings.REPLACE_FEE ); + if (!recycleFeeLineItem && this.requiresRecycleFeeCartItem) { + recycleFeeLineItem = { + partNumber: partTypeStrings.RECYCLE_FEE, + partType: partTypeStrings.REPLACE_FEE, + laborAmount: 0, + kitPrice: 0, + sellingPrice: 0, + salesTax: 0, + }; + } + if (recycleFeeLineItem) { cartItem = { name: this.recycleFeeCartItemName, @@ -745,44 +756,6 @@ export default { return cartItem; }, - mobileFeeCartItemName() { - return this.getCmsContent("MobileServiceTextWidget", "Text"); - }, - mobileFeeCartItem() { - let cartItem = null; - - const mobileFeeLineItem = this.supportingItems.find( - (lineItem) => lineItem.partType == partTypeStrings.MOBILE_FEE - ); - - if (mobileFeeLineItem) { - cartItem = { - name: this.mobileFeeCartItemName, - category: cartItemCategories.SUPPORTING_ITEMS, - cartItemType: cartItemTypes.MOBILE_FEE, - isDisplayed: true, - isRemovable: false, - subTotal: 0, - salesTax: 0, - lineItems: [], - isCoveredByInsurance: cartItemTypesCoveredByInsurance.includes( - cartItemTypes.MOBILE_FEE - ), - }; - - mobileFeeLineItem.cartItemType = cartItem.cartItemType; - cartItem.lineItems.push(mobileFeeLineItem); - - cartItem.subTotal += - (mobileFeeLineItem.kitPrice ?? 0) + - (mobileFeeLineItem.laborAmount ?? 0) + - (mobileFeeLineItem.sellingPrice ?? 0); - - cartItem.salesTax += mobileFeeLineItem.salesTax ?? 0; - } - - return cartItem; - }, servicePackageDiscountCartItemName() { return this.getCmsContent("ServicePackageDiscountTextWidget", "Text"); }, @@ -986,7 +959,10 @@ export default { if (!this.showAsPaid) { return 0; } - return this.subTotal + this.salesTax; + + // unary plus operator to convert string amount to numeric so we can add them together + var amtPaid = +this.subTotal + +this.salesTax; + return amtPaid; }, }, components: { diff --git a/src/fmg-components/content-group-modal/content-group-modal.vue b/src/fmg-components/content-group-modal/content-group-modal.vue index a64d10fa3..fa64fd069 100644 --- a/src/fmg-components/content-group-modal/content-group-modal.vue +++ b/src/fmg-components/content-group-modal/content-group-modal.vue @@ -4,15 +4,17 @@ :modalId="ModalName" :footerButtonText="ModalCloseButtonText" @footer-button-event="footerButtonClick"> - -
-

-

- - +
+ +
+

+

+ + +
@@ -27,6 +29,7 @@ export default { type: String, default: null, }, + isRecal: Boolean, }, computed: { ModalName() { @@ -78,6 +81,21 @@ export default { .modal-dialog { .modal-content { .modal-body { + .recal-modal { + display: flex; + flex-direction: column; + h5 { + text-align: center; + line-height: 32px; + order: 1; + } + p { + order: 3; + } + img { + order: 2; + } + } .modal-sub-body { color: $gray-600; } diff --git a/src/layouts/estimate/estimate.spec.js b/src/layouts/estimate/estimate.spec.js index b8517d833..14752e171 100644 --- a/src/layouts/estimate/estimate.spec.js +++ b/src/layouts/estimate/estimate.spec.js @@ -86,15 +86,18 @@ describe("estimate.vue", () => { expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalled(); }); - // TODO KO - describe("isRepair", () => { - test.todo("is repair and zip codes are valid/serviceable => go to quote page"); - test.todo( - "is repair and zip codes are valid but not serviceable => show correct alert, remove loader" - ); - test.todo( - "is repair and zip codes are not valid/serviceable => show correct alert, remove loader" - ); + test("Selecting no vin on ForwardButtonAction triggers a router.navigateWithSaving", async () => { + //Arrange + const { wrapper } = setupMocks({}); + await wrapper.setData({ + selectedVinLookupMethod: vinLookupMethodSelections.DECLINE, + }); + + //Act + wrapper.vm.forwardButtonAction(); + + //Assert + expect(wrapper.vm.$router.navigateWithSaving).toHaveBeenCalled(); }); }); @@ -207,43 +210,33 @@ describe("estimate.vue", () => { expect(arePagePrerequisitesValid).toBe(true); }); }); - - test("Changing zip should reset alert", async () => { - //Arrange - const { wrapper } = setupMocks({}); - - //Act - wrapper.vm.displayNonServiceableZipAlert = "true"; - wrapper.vm.serviceZipCode = "43015"; - - await wrapper.vm.$nextTick(); - - //Assert - expect(wrapper.vm.displayNonServiceableZipAlert).toEqual(false); - }); }); -describe("test alertInfo and isRepair", () => { - const skipOptions = [ - [true, false, "AlertQuoteReady"], - [false, true, "AlertQuoteVinOptional"], - [false, false, "AlertQuoteReady"], - [true, true, "AlertQuoteVinOptional"], - ]; - test.each(skipOptions)( - "isRepair %s, skipVinNotRepair %s alertInfo should return %s", - async (isRepair, skipVinNotRepair, expectedAlertInfo) => { - const { wrapper } = setupMocks({}); - await wrapper.setData({ - skipVinNotRepair: skipVinNotRepair, - }); +describe("estimate.vue", () => { + test("should call forwardButtonAction if isLeadGen is true", async () => { + // update store with isLeadGen as true + store.commit(storeMutations.UPDATE_IS_LEAD_GEN, true); - store.commit(storeMutations.UPDATE_IS_REPAIR, isRepair); + // Set up the component + const { wrapper } = setupMocks({}); + wrapper.vm.forwardButtonAction = jest.fn(); + const nextFunction = jest.fn((c) => { + c(wrapper.vm); + }); - expect(wrapper.vm.alertInfo).toEqual(expectedAlertInfo); - expect(wrapper.vm.isRepair).toEqual(isRepair); - } - ); + // Set selectedVinLookupMethod to decline + wrapper.setData({ selectedVinLookupMethod: vinLookupMethodSelections.DECLINE }); + + // Call the method that contains the if-else logic + await estimate.beforeRouteEnter.call( + wrapper.vm, + { query: { fmgPage: "estimate" } }, + undefined, + nextFunction + ); + expect(nextFunction).toHaveBeenCalled(); + expect(wrapper.vm.forwardButtonAction).toHaveBeenCalled(); + }); }); function setupMocks({ diff --git a/src/layouts/estimate/estimate.vue b/src/layouts/estimate/estimate.vue index b298132ca..913520626 100644 --- a/src/layouts/estimate/estimate.vue +++ b/src/layouts/estimate/estimate.vue @@ -11,7 +11,7 @@
-
+
- -
-
- - - - - - - - - - - - -
+
@@ -94,9 +43,6 @@ import navbar from "@/fmg-components/nav-bar/nav-bar"; import vehicleBanner from "@/fmg-components/vehicle-banner/vehicle-banner"; import funnelSubHeader from "@/fmg-components/funnel-sub-header/funnel-sub-header"; import buttonQuestion from "@/digital-components/button-question/button-question"; -import alert from "@/ux-components/alert/alert"; -import textboxQuestion from "@/digital-components/textbox-question/textbox-question"; -import textBlock from "@/digital-components/text-block/text-block"; import loadingModal from "@/fmg-components/loading-modal/loading-modal.vue"; //Supporting Files @@ -137,10 +83,6 @@ export default { data() { return { selectedVinLookupMethod: null, - serviceZipCode: this.getZipFromStore() ?? this.$route.query.zipcode, - emailAddress: this.getEmailFromStore(), - displayInvalidZipAlert: false, - displayNonServiceableZipAlert: false, skipVin: false, skipVinNotRepair: false, }; @@ -185,22 +127,12 @@ export default { ]; const resultMap = await settleAllPromises(promiseResultMap); - const skipVin = await skipVinLookup(); - const skipVinNotRepair = await skipVinLookupNotRepair(); next((vm) => { - vm.skipVin = skipVin; - vm.skipVinNotRepair = skipVinNotRepair; if (resultMap.cmsContent.FunnelFooterWidget.ForwardButtonText.includes("|")) { const forwardTextOption = resultMap.cmsContent.FunnelFooterWidget.ForwardButtonText.split("|"); - if (skipVin) { - resultMap.cmsContent.FunnelFooterWidget.ForwardButtonText = - forwardTextOption[1]; - } else { - resultMap.cmsContent.FunnelFooterWidget.ForwardButtonText = - forwardTextOption[0]; - } + resultMap.cmsContent.FunnelFooterWidget.ForwardButtonText = forwardTextOption[0]; } if (!zip || resultMap.vinByAddress === false) { @@ -213,15 +145,16 @@ export default { } vm.setCmsContent(resultMap.cmsContent); + if (store.getters.isLeadGen) { + vm.selectedVinLookupMethod = vinLookupMethodSelections.DECLINE; + vm.forwardButtonAction(); + } else { + baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN); + baseMixin.methods.hideFmgLoadingModal(); + } }); }, methods: { - getZipFromStore() { - return store.getters.order.serviceLocation.zipCode; - }, - getEmailFromStore() { - return store.getters.order.customer.emailAddress; - }, arePagePrerequisitesValid() { return store.getters.damage.isRepair || store.getters.damage.glassToReplace?.length > 0; }, @@ -230,80 +163,6 @@ export default { this.$router.navigateWithoutSaving(this.navigationScenarios.CLICKED_BACK, this.$route); }, async forwardButtonAction() { - if (this.skipVin) { - const zipCodeData = await this.getZipCodeData(this.serviceZipCode); - await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.emailAddress, false); - await this.dispatchStoreAction( - storeActions.SAVE_SERVICE_ZIP_CODE_INFO, - { - zipCode: this.serviceZipCode, - state: zipCodeData.state, - zipCodeCtu: zipCodeData.zipCodeCtu, - }, - false - ); - - if (!zipCodeData.isValid) { - this.displayInvalidZipAlert = true; - return this.$refs.navbar.removeLoader(); - } - this.displayInvalidZipAlert = false; - - if (!zipCodeData.isServiceable) { - this.displayNonServiceableZipAlert = true; - return this.$refs.navbar.removeLoader(); - } - this.displayNonServiceableZipAlert = false; - - const payment = this.$store.getters.payment; - const policy = this.$store.getters.policy; - - const vehicleChangedDuringPolicyLookupInHeritage = - payment.isInsurance && - payment.insuranceCoverage.coverageStatus && - policy.policyNumber !== ""; - - if (vehicleChangedDuringPolicyLookupInHeritage) { - navigateToHeritageFunnel({ - shouldSaveSession: true, - pageNameToLog: "estimate", - }); - } else if (this.$store.getters.order.referralNumber?.length === 6) { - await this.navigateForwardWithSingleCarMatch(); - } else if (this.isRepair) { - const supportingItemsPromise = await this.dispatchStoreActionWithLogging( - storeActions.GET_SUPPORTING_ITEMS, - null, - "estimate" - ); - - const promiseResultMap = [ - { - resultKey: "supportingItems", - promise: supportingItemsPromise, - }, - ]; - - const resultMap = await settleAllPromises(promiseResultMap); - - this.dispatchStoreAction( - this.storeActions.SAVE_SUPPORTING_ITEMS, - resultMap.supportingItems, - false - ); - - // call saveSession here - navigateWithSaving saves too late in the flow - await saveSession({ pageNameToLog: "estimate" }); - return this.$router.navigateWithSaving( - this.navigationScenarios.CLICKED_FORWARD_WITH_NO_QUESTIONS, - this.$route - ); - } else { - // if we're skipping the vin-lookup but it's not a repair, we still need to get the parts - await this.navigateForwardWithSingleCarMatch(); - } - } - if (this.selectedVinLookupMethod === vinLookupMethodSelections.MANUALVIN) { await this.dispatchStoreAction(storeActions.CLEAR_VIN); return this.$router.navigateWithSaving( @@ -323,18 +182,15 @@ export default { this.$route ); } + if (this.selectedVinLookupMethod === vinLookupMethodSelections.DECLINE) { + return this.$router.navigateWithSaving( + this.navigationScenarios.SELECTED_NO_VIN, + this.$route + ); + } }, }, computed: { - AlertNonServiceableZipHeader() { - return this.getCmsContent("AlertNonServiceableZipWidget", "HeadlineText").replaceAll( - "{custom:serviceZip}", - this.serviceZipCode - ); - }, - AlertNonServiceableZipBody() { - return this.getCmsContent("AlertNonServiceableZipWidget", "BodyText"); - }, questionText() { return this.getCmsContent("VinLookupMethod", "QuestionText"); }, @@ -344,18 +200,10 @@ export default { isRepair() { return store.getters.damage.isRepair; }, - alertInfo() { - return this.skipVinNotRepair ? "AlertQuoteVinOptional" : "AlertQuoteReady"; - }, VinLookupQuestionText() { return this.getCmsContent("VinLookupQuestion", "BodyText"); }, }, - watch: { - serviceZipCode() { - this.displayNonServiceableZipAlert = false; - }, - }, components: { funnelHeader, vehicleBanner, @@ -363,9 +211,6 @@ export default { navbar, buttonQuestion, Form, - alert, - textboxQuestion, - textBlock, loadingModal, }, }; diff --git a/src/layouts/insurance-company/insurance-company.vue b/src/layouts/insurance-company/insurance-company.vue index a15de8311..8cdec3afa 100644 --- a/src/layouts/insurance-company/insurance-company.vue +++ b/src/layouts/insurance-company/insurance-company.vue @@ -76,6 +76,10 @@ export default { next((vm) => { vm.setCmsContent(resultMap.cmsContent); vm.originalList = resultMap.insuranceCompanyList; + if (store.getters.isLeadGen) { + baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN); + baseMixin.methods.hideFmgLoadingModal(); + } }); }, data() { diff --git a/src/layouts/part-questions/part-questions.vue b/src/layouts/part-questions/part-questions.vue index 9f4a13902..9249a5a57 100644 --- a/src/layouts/part-questions/part-questions.vue +++ b/src/layouts/part-questions/part-questions.vue @@ -29,6 +29,8 @@ import { Form, defineRule } from "vee-validate"; import { required } from "@/helpers/validation-rules"; import { errorMessages } from "@/constants/error-messages"; import vehicleQuestionsMixin from "@/mixins/vehicle-questions-mixin"; +import baseMixin from "@/mixins/base-mixin.js"; +import { storeActions } from "@/constants/store-actions"; // DEFINE VALIDATION RULES defineRule("questions-required", required(errorMessages.OPTION_REQUIRED)); @@ -53,6 +55,10 @@ export default { // Call the "next" function to complete the transition to this page. next((vm) => { vm.setCmsContent(resultMap.cmsContent); + if (store.getters.isLeadGen) { + baseMixin.methods.dispatchStoreAction(storeActions.RESET_IS_LEAD_GEN); + baseMixin.methods.hideFmgLoadingModal(); + } }); }, data() { diff --git a/src/layouts/payment-method/payment-method.spec.js b/src/layouts/payment-method/payment-method.spec.js index ab0a0df99..16b64a58b 100644 --- a/src/layouts/payment-method/payment-method.spec.js +++ b/src/layouts/payment-method/payment-method.spec.js @@ -51,6 +51,14 @@ function setupMocks() { order: { payment: { isPia: false, + insuranceCoverage: { + isVerified: true, + }, + }, + policy: { + currentDeductible: 123, + isNoComp: false, + isItac: false, }, }, policy: { diff --git a/src/layouts/payment-method/payment-method.vue b/src/layouts/payment-method/payment-method.vue index 103d15842..1ea5a16ab 100644 --- a/src/layouts/payment-method/payment-method.vue +++ b/src/layouts/payment-method/payment-method.vue @@ -22,6 +22,7 @@
0; } else { - isEnabled = piaExperience === "PIA Optional" || piaExperience === "PIA Required"; + return piaExperience === "PIA Optional" || piaExperience === "PIA Required"; } - - return !isEnabled; }, paymentMethod() { - if (this.isPiaDisabled) { + if (!this.isPiaEnabled) { return paymentMethods.LATER; } diff --git a/src/layouts/quote/quote.spec.js b/src/layouts/quote/quote.spec.js index 56a8d66e6..9fd4153f7 100644 --- a/src/layouts/quote/quote.spec.js +++ b/src/layouts/quote/quote.spec.js @@ -8,6 +8,7 @@ import * as navigateToHeritage from "@/helpers/heritage-integration/navigation-h import { nextTick } from "vue"; import { experimentSettings } from "@/constants/experiments"; import baseMixin from "@/mixins/base-mixin.js"; +import { containsLineItemWithPartType } from "../../helpers/service-package-helper"; jest.mock("@/store", () => ({ commit: jest.fn(), @@ -22,6 +23,9 @@ jest.mock("@/helpers/cms-content-helper", () => ({ jest.mock("@/helpers/heritage-integration/navigation-helper", () => ({ navigateToHeritageFunnel: jest.fn(), })); +jest.mock("@/helpers/service-package-helper", () => ({ + containsLineItemWithPartType: jest.fn(), +})); jest.mock("@/helpers/promotions-helper", () => ({ revalidatePromosAndValidateQueryStringPromo: jest.fn(() => { @@ -636,12 +640,122 @@ describe("quote.vue", () => { ); }); }); +describe("quote.vue", () => { + test("should call forwardButtonAction if isLeadGen is true and Insurance is true", async () => { + // Set up the store with isLeadGen as true + + store.getters = { + lineItems: { + glassParts: ["item", "item2"], + }, + order: { + lineItems: { + glassParts: ["item", "item2"], + }, + serviceLocation: { + zipCode: "12345", + zipCodeCtu: "value", + }, + damage: { + isRepair: false, + }, + referralNumber: "1234567", + payment: { + isInsurance: true, + inactivePromos: [], + }, + }, + isLeadGen: true, + payment: { + isInsurance: true, + inactivePromos: [], + }, + vehicle: { + cardId: "123", + }, + experimentSettings: { + settingName: "SERVICE_PACKAGE_DISCOUNT", + }, + }; + + // Set up the component + const { wrapper } = setupMocks({}); + wrapper.vm.$route = { query: null }; + wrapper.vm.forwardButtonAction = jest.fn(); + const nextFunction = jest.fn((c) => { + c(wrapper.vm); + }); + + // Call the method that contains the if-else logic + await quote.beforeRouteEnter.call( + wrapper.vm, + { query: { fmgPage: "quote" } }, + undefined, + nextFunction + ); + expect(nextFunction).toHaveBeenCalled(); + expect(wrapper.vm.forwardButtonAction).toHaveBeenCalled(); + }); + test("should not call forwardButtonAction if isLeadGen is true and Insurance is false", async () => { + // Set up the store with isLeadGen as true + store.getters = { + lineItems: { + glassParts: ["item", "item2"], + }, + order: { + lineItems: { + glassParts: ["item", "item2"], + }, + serviceLocation: { + zipCode: "12345", + zipCodeCtu: "value", + }, + damage: { + isRepair: false, + }, + referralNumber: "1234567", + payment: { + isInsurance: null, + inactivePromos: [], + }, + }, + isLeadGen: true, + payment: { + isInsurance: null, + inactivePromos: [], + }, + vehicle: { + cardId: "123", + }, + experimentSettings: { + settingName: "SERVICE_PACKAGE_DISCOUNT", + }, + }; + + // Set up the component + const { wrapper } = setupMocks({}); + wrapper.vm.$route = { query: null }; + wrapper.vm.forwardButtonAction = jest.fn(); + const nextFunction = jest.fn((c) => { + c(wrapper.vm); + }); + + // Call the method that contains the if-else logic + await quote.beforeRouteEnter.call( + wrapper.vm, + { query: { fmgPage: "quote" } }, + undefined, + nextFunction + ); + expect(wrapper.vm.forwardButtonAction).not.toHaveBeenCalled(); + }); +}); function setupMocks({ customMountOptions }) { const mountOptions = getMountOptions({ ...customMountOptions, }); - + baseMixin.methods.hideFmgLoadingModal = jest.fn(); mountOptions.global.mocks["$store"] = store; mountOptions["attachTo"] = document.body; diff --git a/src/layouts/quote/quote.vue b/src/layouts/quote/quote.vue index 7effa6332..414c62149 100644 --- a/src/layouts/quote/quote.vue +++ b/src/layouts/quote/quote.vue @@ -1,7 +1,7 @@