From eedcf4dfddcc7b88f18e3e81cacff300b5a38d44 Mon Sep 17 00:00:00 2001 From: CarlNation Date: Sat, 22 Feb 2025 06:09:45 -0500 Subject: [PATCH] CASH-291 CASH-291 The issue here is that when computing the tier one price for determining which tab to select. we are including the service package discount of $50 bringing the tier one price to $287(337-50), which is less than $300 and causing the cash tab to be selected. This is not the tier one price we show but only used in the computation for determining which tab to default. --- .../service-package-radio.vue | 2 +- src/layouts/address-lookup/address-lookup.vue | 9 +- .../insurance-company.spec.js | 137 +++++++++--------- .../license-plate-lookup.vue | 3 +- src/layouts/quote/quote.vue | 18 ++- src/layouts/vin-lookup/vin-lookup.vue | 30 +++- src/mixins/base-mixin.js | 13 ++ 7 files changed, 121 insertions(+), 91 deletions(-) diff --git a/src/experiment-components/service-package-radio.vue b/src/experiment-components/service-package-radio.vue index 4aae00bc0..e53f1143a 100644 --- a/src/experiment-components/service-package-radio.vue +++ b/src/experiment-components/service-package-radio.vue @@ -233,7 +233,7 @@ export default { min-height: 52px; max-height: 126px; @include media-breakpoint-up(md) { - max-height: 500px; + max-height: 500px; } transition: max-height 0.25s ease-in; diff --git a/src/layouts/address-lookup/address-lookup.vue b/src/layouts/address-lookup/address-lookup.vue index 08f602fb4..6e3520704 100644 --- a/src/layouts/address-lookup/address-lookup.vue +++ b/src/layouts/address-lookup/address-lookup.vue @@ -361,13 +361,16 @@ export default { if (!this.customerQuestions.emailOrSms) { await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, "", false); await this.dispatchStoreAction(storeActions.SAVE_EMAIL, "", false); - } - else { + } else { if (vinPagesMixin.methods.isPhoneNumber(this.customerQuestions.emailOrSms)) { const phone = this.customerQuestions.emailOrSms.replace(/[()]/g, ""); await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, phone, false); } else { - await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.customerQuestions.emailOrSms, false); + await this.dispatchStoreAction( + storeActions.SAVE_EMAIL, + this.customerQuestions.emailOrSms, + false + ); } } diff --git a/src/layouts/insurance-company/insurance-company.spec.js b/src/layouts/insurance-company/insurance-company.spec.js index b1297d13b..a35be3b87 100644 --- a/src/layouts/insurance-company/insurance-company.spec.js +++ b/src/layouts/insurance-company/insurance-company.spec.js @@ -1,105 +1,102 @@ -import { shallowMount } from '@vue/test-utils'; -import InsuranceCompany from '@/layouts/insurance-company/insurance-company.vue'; -import { applicationConfig } from '@/constants/application-config.js'; +import { shallowMount } from "@vue/test-utils"; +import InsuranceCompany from "@/layouts/insurance-company/insurance-company.vue"; +import { applicationConfig } from "@/constants/application-config.js"; import store from "@/store"; import baseMixin from "@/mixins/base-mixin.js"; - -jest.mock('@/store', () => ({ +jest.mock("@/store", () => ({ getters: { - order: { - payment: { - parentAccountNumber: '12345', + order: { + payment: { + parentAccountNumber: "12345", + }, }, - }, }, - })); +})); var mockRouter = { navigateWithoutSaving: jest.fn(), - }; +}; - jest.mock('@/mixins/base-mixin.js', () => ({ +jest.mock("@/mixins/base-mixin.js", () => ({ methods: { - navigateWithoutSaving: jest.fn(), + navigateWithoutSaving: jest.fn(), }, data() { - return { - navigationScenarios: { - CLICKED_BACK: 'clicked_back', - }, - }; + return { + navigationScenarios: { + CLICKED_BACK: "clicked_back", + }, + }; }, - })); +})); describe("insurance-company.vue", () => { - beforeEach(() => { // Reset the store's parentAccountNumber before each test - store.getters.order.payment.parentAccountNumber = '12345'; - }); + store.getters.order.payment.parentAccountNumber = "12345"; + }); - test('should return true when parentAccountNumber matches CASH_PARENT_ACCOUNT_NUMBER', () => { + test("should return true when parentAccountNumber matches CASH_PARENT_ACCOUNT_NUMBER", () => { applicationConfig.CASH_PARENT_ACCOUNT_NUMBER = "12345"; - const wrapper = shallowMount(InsuranceCompany, { - global: { - mocks: { - $store: store - }, - }, - }); - - expect(wrapper.vm.isCashParentAccountNumber()).toBe(true); - }); - - test('should return false when parentAccountNumber does not match CASH_PARENT_ACCOUNT_NUMBER', () => { - applicationConfig.CASH_PARENT_ACCOUNT_NUMBER = "12345"; - store.getters.order.payment.parentAccountNumber = '67890'; - const wrapper = shallowMount(InsuranceCompany, { - global: { - mocks: { - $store: store, - }, - }, - }); - - expect(wrapper.vm.isCashParentAccountNumber()).toBe(false); - }); - - test('should call navigateWithoutSaving with { isCashSelected: true } when forceCashSelection is true', () => { const wrapper = shallowMount(InsuranceCompany, { global: { - mocks: { - $store: store, - $router: mockRouter, - }, - mixins: [baseMixin], + mocks: { + $store: store, + }, }, - }); + }); + expect(wrapper.vm.isCashParentAccountNumber()).toBe(true); + }); + + test("should return false when parentAccountNumber does not match CASH_PARENT_ACCOUNT_NUMBER", () => { + applicationConfig.CASH_PARENT_ACCOUNT_NUMBER = "12345"; + store.getters.order.payment.parentAccountNumber = "67890"; + const wrapper = shallowMount(InsuranceCompany, { + global: { + mocks: { + $store: store, + }, + }, + }); + + expect(wrapper.vm.isCashParentAccountNumber()).toBe(false); + }); + + test("should call navigateWithoutSaving with { isCashSelected: true } when forceCashSelection is true", () => { + const wrapper = shallowMount(InsuranceCompany, { + global: { + mocks: { + $store: store, + $router: mockRouter, + }, + mixins: [baseMixin], + }, + }); wrapper.vm.backButtonAction(true); expect(mockRouter.navigateWithoutSaving).toHaveBeenCalledWith( - wrapper.vm.navigationScenarios.CLICKED_BACK, - wrapper.vm.$route, - { isCashSelected: true } + wrapper.vm.navigationScenarios.CLICKED_BACK, + wrapper.vm.$route, + { isCashSelected: true } ); - }); - - test('should call navigateWithoutSaving with no extra parameter when forceCashSelection is false', () => { + }); + + test("should call navigateWithoutSaving with no extra parameter when forceCashSelection is false", () => { const wrapper = shallowMount(InsuranceCompany, { global: { - mocks: { - $store: store, - $router: mockRouter, + mocks: { + $store: store, + $router: mockRouter, + }, + mixins: [baseMixin], }, - mixins: [baseMixin], - }, - }); + }); wrapper.vm.backButtonAction(false); expect(mockRouter.navigateWithoutSaving).toHaveBeenCalledWith( - wrapper.vm.navigationScenarios.CLICKED_BACK, - wrapper.vm.$route + wrapper.vm.navigationScenarios.CLICKED_BACK, + wrapper.vm.$route ); - }); + }); }); diff --git a/src/layouts/license-plate-lookup/license-plate-lookup.vue b/src/layouts/license-plate-lookup/license-plate-lookup.vue index 6f6521dde..8b9c83c67 100644 --- a/src/layouts/license-plate-lookup/license-plate-lookup.vue +++ b/src/layouts/license-plate-lookup/license-plate-lookup.vue @@ -315,8 +315,7 @@ export default { if (!this.emailOrSms) { await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, "", false); await this.dispatchStoreAction(storeActions.SAVE_EMAIL, "", false); - } - else { + } else { if (vinPagesMixin.methods.isPhoneNumber(this.emailOrSms)) { const phone = this.emailOrSms.replace(/[()]/g, ""); await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, phone, false); diff --git a/src/layouts/quote/quote.vue b/src/layouts/quote/quote.vue index 838fbf256..d32054108 100644 --- a/src/layouts/quote/quote.vue +++ b/src/layouts/quote/quote.vue @@ -361,24 +361,28 @@ export default { ) : baseMixin.methods.filterOutFees(availableLineItems); + const lineItemsNoDiscount = + baseMixin.methods.filterOutServicePackageDiscountPart( + lineItemsForCalculatingPrice + ); + if (isInsuranceFromQueryString != null) { if (isInsuranceFromQueryString.toLowerCase() === "true") { return true; } } - const tierOnePrice = baseMixin.methods.getTierOnePackagePrice(lineItemsForCalculatingPrice); + const tierOnePrice = + baseMixin.methods.getTierOnePackagePrice(lineItemsNoDiscount); // prettier-ignore { if (store.getters.applicationUser.loggingOption) { - console.log(new Date() + " tierOnePrice type: " + typeof tierOnePrice); - console.log(new Date() + " insuranceThreshold type: " + typeof insuranceThreshold); - console.log(new Date() + " tierOnePrice comparison: " + tierOnePrice + " > " + insuranceThreshold + "=" + (tierOnePrice > insuranceThreshold)); + console.log(new Date() + " quote tierOnePrice comparison: " + tierOnePrice + " > " + insuranceThreshold + "=" + (tierOnePrice > insuranceThreshold)); } - } + } // compare base price vs arbitrary threshold (representing insurance price) - return (tierOnePrice > insuranceThreshold); + return tierOnePrice > insuranceThreshold; } return null; @@ -428,7 +432,7 @@ export default { console.log(new Date() + "quote.vue tab select EXTERNAL ISINSURANCE"); } } - + // did user intentionally select insurance? vm.isInsuranceSelected = true; vm.servicePackage = store.getters.externalParameterQuote.servicePackage; diff --git a/src/layouts/vin-lookup/vin-lookup.vue b/src/layouts/vin-lookup/vin-lookup.vue index 2c93e7182..f913993b2 100644 --- a/src/layouts/vin-lookup/vin-lookup.vue +++ b/src/layouts/vin-lookup/vin-lookup.vue @@ -334,13 +334,20 @@ export default { if (!this.emailOrSms) { await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, "", false); await this.dispatchStoreAction(storeActions.SAVE_EMAIL, "", false); - } - else { + } else { if (vinPagesMixin.methods.isPhoneNumber(this.emailOrSms)) { const phone = this.emailOrSms.replace(/[()]/g, ""); - await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, phone, false); + await this.dispatchStoreAction( + storeActions.SAVE_PHONE_NUMBER, + phone, + false + ); } else { - await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.emailOrSms, false); + await this.dispatchStoreAction( + storeActions.SAVE_EMAIL, + this.emailOrSms, + false + ); } } @@ -391,13 +398,20 @@ export default { if (!this.emailOrSms) { await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, "", false); await this.dispatchStoreAction(storeActions.SAVE_EMAIL, "", false); - } - else { + } else { if (vinPagesMixin.methods.isPhoneNumber(this.emailOrSms)) { const phone = this.emailOrSms.replace(/[()]/g, ""); - await this.dispatchStoreAction(storeActions.SAVE_PHONE_NUMBER, phone, false); + await this.dispatchStoreAction( + storeActions.SAVE_PHONE_NUMBER, + phone, + false + ); } else { - await this.dispatchStoreAction(storeActions.SAVE_EMAIL, this.emailOrSms, false); + await this.dispatchStoreAction( + storeActions.SAVE_EMAIL, + this.emailOrSms, + false + ); } } diff --git a/src/mixins/base-mixin.js b/src/mixins/base-mixin.js index b6d3e0074..1983933ea 100644 --- a/src/mixins/base-mixin.js +++ b/src/mixins/base-mixin.js @@ -92,6 +92,13 @@ export default { }); let totalPrice = this.getTotalPriceOfAllLineItemsAndChildParts(lineItemsToPrice, false); + // prettier-ignore + { + if (store.getters.applicationUser.loggingOption) { + console.log(new Date() + " base-mixin getTierOnePackagePrice lineItemsToPrice: " + JSON.stringify(lineItemsToPrice)); + console.log(new Date() + " base-mixin getTierOnePackagePrice totalPrice: " + totalPrice); + } + } return totalPrice; }, filterOutFees(lineItems) { @@ -103,6 +110,12 @@ export default { }); return filteredLineItems; }, + filterOutServicePackageDiscountPart(lineItems) { + const filteredLineItems = lineItems?.filter((item) => { + return !item?.partType?.includes(partTypeStrings.SERVICE_PACKAGE_DISCOUNT); + }); + return filteredLineItems; + }, filterOutRecalibration(lineItems) { return getItemsWithoutRecalParts(lineItems); },