diff --git a/src/helpers/recal-helper.js b/src/helpers/recal-helper.js index 0bb650ff..5b86e63a 100644 --- a/src/helpers/recal-helper.js +++ b/src/helpers/recal-helper.js @@ -120,5 +120,9 @@ export function anyPartWithRequiresRecalFlag(lineItems) { } export function hasMSRPart(lineItems) { - return lineItems?.feeItems?.some((item) => item.partNumber === partNumberStrings.RECAL_MOBILEDUAL || item.partNumber === partNumberStrings.RECAL_MOBILE) ?? false + return lineItems?.feeItems?.some((item) => isMSRPart(item)) ?? false; +} + +export function isMSRPart(part) { + return part.partNumber === partNumberStrings.RECAL_MOBILEDUAL || part.partNumber === partNumberStrings.RECAL_MOBILE; } diff --git a/src/layouts/schedule-page/service-location/service-location.spec.js b/src/layouts/schedule-page/service-location/service-location.spec.js index eb77d52c..f3485ac4 100644 --- a/src/layouts/schedule-page/service-location/service-location.spec.js +++ b/src/layouts/schedule-page/service-location/service-location.spec.js @@ -4,9 +4,11 @@ import { createTestingPinia } from '@pinia/testing'; import { AppointmentTypeStrings } from '@/constants/schedule-constants'; import navigationScenarios from '@/router/router-constants/navigation-scenarios'; import routerParams from '@/router/router-constants/router-params'; -import { getPricedMobileFeePart } from '@/helpers/service-location-helper'; import { useMainStore } from '@/store'; import serviceLocation from '@/layouts/schedule-page/service-location/service-location.vue'; +import coverageTypes from '@/constants/coverage-type'; +import coverageStatuses from '@/constants/coverage-statuses'; +import { experimentSettings } from '@/constants/experiments'; const mockGetServiceabilityDetails = () => { const serviceabilityDetails = { @@ -84,12 +86,23 @@ const mockProviders = () => Promise.resolve([ isSafeliteShop: true } ]); +const defaultMobileFeePart = { + "partNumber": "RECAL MOBILEDUAL", + "description": null, + "partType": "MOBILE FEE", + "isInsurable": false, + "displayName": "Advanced mobile", + "type": null, + "laborAmount": 0, + "sellingPrice": 50, + "kitPrice": 0 +} jest.mock( '@/helpers/service-location-helper', () => ({ getZipCodeData: jest.fn((mockServiceZipCode) => mockZipcodeData(mockServiceZipCode)), getMobileZipCodeData: jest.fn((mockServiceZipCode) => mockZipcodeData(mockServiceZipCode)), - getPricedMobileFeePart: jest.fn(() => Promise.resolve(null)) + getPricedMobileFeePart: jest.fn(() => Promise.resolve(defaultMobileFeePart)) }) ); @@ -135,13 +148,17 @@ const mountOptions = { } } }; -function setupMocks({ appointmentType = AppointmentTypeStrings.IN_SHOP }) { +function setupMocks({ appointmentType = AppointmentTypeStrings.IN_SHOP, coverageStatus = coverageStatuses.PENDING, coverageType = coverageTypes.NONE }, splitPaySettingValue = 'false') { mountOptions.global.plugins = [createTestingPinia({ initialState: { main: { order: { serviceLocation: { appointmentType + }, + insuranceCoverage: { + coverageStatus, + coverageType } } } @@ -149,6 +166,23 @@ function setupMocks({ appointmentType = AppointmentTypeStrings.IN_SHOP }) { })]; useMainStore().getSafeliteProviders = jest.fn().mockImplementation(() => mockProviders()); useMainStore().getServiceabilityDetails = jest.fn((mockServiceZipCode) => mockGetServiceabilityDetails(mockServiceZipCode)); + const mockMixin = { + methods: { + getSettingValue: jest.fn((settingName) => { + if (settingName === experimentSettings.MSR_SPLIT_PAY_ENABLED) { + return splitPaySettingValue; + } + + return 'false'; + }) + } + }; + const cmsMixin = { + methods: { + getCmsContent: jest.fn(() => "") + } + } + mountOptions.mixins = [mockMixin, cmsMixin]; const wrapper = mount(serviceLocation, mountOptions); wrapper.vm.$router.navigateWithSpinner = jest.fn(); @@ -212,4 +246,91 @@ describe('service-location.vue', () => { expect(wrapper.vm.zipContainsMilitaryBase).toBe(true); }); }); + describe('computed', () => { + describe('displayMSRFeeAlert', () => { + test('returns false with no mobile fee', () => { + // Arrange + const { wrapper } = setupMocks({}); + wrapper.vm.mobileFeePart = null; + + // Act + const result = wrapper.vm.displayMSRFeeAlert; + + // Assert + expect(result).toBe(false); + }); + + test('returns false with a mobile fee with no price', () => { + // Arrange + const { wrapper } = setupMocks({}); + wrapper.vm.mobileFeePart = { ...defaultMobileFeePart, sellingPrice: 0 }; + + // Act + const result = wrapper.vm.displayMSRFeeAlert; + + // Assert + expect(result).toBe(false); + }); + + test('returns true for priced mobile fee for No Comp', () => { + // Arrange + const { wrapper } = setupMocks({ coverageStatus: coverageStatuses.VERIFIED, coverageType: coverageTypes.NO_COMP }); + wrapper.vm.mobileFeePart = defaultMobileFeePart; + + // Act + const result = wrapper.vm.displayMSRFeeAlert; + + // Assert + expect(result).toBe(true); + }); + + test('returns true for priced mobile fee for ITAC', () => { + // Arrange + const { wrapper } = setupMocks({ coverageStatus: coverageStatuses.VERIFIED, coverageType: coverageTypes.ITAC }); + wrapper.vm.mobileFeePart = defaultMobileFeePart; + + // Act + const result = wrapper.vm.displayMSRFeeAlert; + + // Assert + expect(result).toBe(true); + }); + + test('returns false for priced mobile fee for Deductible without Split Pay', () => { + // Arrange + const { wrapper } = setupMocks({ coverageStatus: coverageStatuses.VERIFIED, coverageType: coverageTypes.Deductible }, 'false'); + wrapper.vm.mobileFeePart = defaultMobileFeePart; + + // Act + const result = wrapper.vm.displayMSRFeeAlert; + + // Assert + expect(result).toBe(false); + }); + + test('returns false for priced mobile fee for Deductible with Split Pay and isInsurable=true', () => { + // Arrange + const { wrapper } = setupMocks({ coverageStatus: coverageStatuses.VERIFIED, coverageType: coverageTypes.Deductible }, 'true'); + wrapper.vm.mobileFeePart = { ...defaultMobileFeePart, isInsurable: true }; + + // Act + const result = wrapper.vm.displayMSRFeeAlert; + + // Assert + expect(result).toBe(false); + }); + + test('returns true for priced mobile fee for Deductible with Split Pay and isInsurable=false', () => { + // Arrange + const { wrapper } = setupMocks({ coverageStatus: coverageStatuses.VERIFIED, coverageType: coverageTypes.Deductible }, 'true'); + wrapper.vm.mobileFeePart = { ...defaultMobileFeePart, isInsurable: false }; + + // Act + const result = wrapper.vm.displayMSRFeeAlert; + + // Assert + expect(result).toBe(true); + }); + }); + }); }); diff --git a/src/layouts/schedule-page/service-location/service-location.vue b/src/layouts/schedule-page/service-location/service-location.vue index 0681c0f9..595cc5cb 100644 --- a/src/layouts/schedule-page/service-location/service-location.vue +++ b/src/layouts/schedule-page/service-location/service-location.vue @@ -94,6 +94,12 @@ {{ militaryBaseWarningText }} + ({ }, firstName: null, lastName: null, - emailAddress: null + emailAddress: null, + companyCode: null }, serviceLocation: { address: null, @@ -596,6 +597,7 @@ export const useMainStore = defineStore({ order.customer.address.zipCode = insured?.zipCode?.toString(); order.customer.firstName = insured?.firstName; order.customer.lastName = insured?.lastName; + order.customer.companyCode = insured?.companyCode; // populate additional fields order.policy.policyData = responsePolicy.policyData; @@ -646,6 +648,7 @@ export const useMainStore = defineStore({ // This is here in case we have to deploy site for other fixes before coverage service gets updated. isRepair: this.order.damage.isRepair, isItac: isITAC, + sourceSystem: applicationConfig.APPLICATION_NAME, insured: { firstName: this.order.customer.firstName, lastName: this.order.customer.lastName, @@ -676,6 +679,7 @@ export const useMainStore = defineStore({ actualDeductible: this.currentDeductible.toString() ?? '', currentRepairDeductible: this.order.currentDeductible.repair, currentReplaceDeductible: this.order.currentDeductible.replace, + company: this.order.customer.companyCode }, lossInfo: { dateOfLoss: this.order.policy.dateOfLoss, @@ -2175,6 +2179,7 @@ export const useMainStore = defineStore({ this.order.customer.address.zipCode = null; this.order.customer.address.streetAddress = null; this.order.customer.address.streetAddress2 = null; + this.order.customer.companyCode = null; }, resetContactInfo() { diff --git a/src/store/store.spec.js b/src/store/store.spec.js index 7b9d4355..8cf40ee3 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -16,6 +16,7 @@ import coverageType from '@/constants/coverage-type'; import { getEnumName } from '@/helpers/unit-test-helper'; import { strictEqual } from 'assert'; import partNumberStrings from '@/constants/part-number-strings'; +import applicationConfig from '@/constants/application-config'; describe('Store', () => { let store; @@ -481,6 +482,42 @@ describe('Store', () => { expect(store.order.insuranceCoverage.coverageStatus).toBe(coverageStatuses.NO_COVERAGE); expect(store.order.insuranceCoverage.claimNumber).toBe(null); }); + + it('calls api with expected data', async () => { + // Arrange + const companyCode = getRandomString(6, 6); + const originalDeductible = { + replace: 500, + repair: 0 + }; + const currentDeductible = { + replace: 500, + repair: 0 + }; + store.order.originalDeductible = { + replace: originalDeductible.replace, + repair: originalDeductible.repair + }; + store.order.currentDeductible = { + replace: currentDeductible.replace, + repair: currentDeductible.repair + }; + store.order.customer.companyCode = companyCode; + globalMethods.callHttpClient = jest.fn().mockReturnValue(Promise.resolve({})); + + // Act + await store.registerClaim(); + + // Asserts + expect(globalMethods.callHttpClient).toHaveBeenCalledWith(expect.objectContaining({ + payload: expect.objectContaining({ + sourceSystem: applicationConfig.APPLICATION_NAME, + policyInfo: expect.objectContaining({ + company: companyCode + }) + }) + })); + }); }); describe('updateContactInfo method', () => { @@ -1299,6 +1336,7 @@ describe('Store', () => { const zipCode = getRandomString(6, 6); const firstName = getRandomString(6, 6); const lastName = getRandomString(6, 6); + const companyCode = getRandomString(6, 6); const vehicle = { id: '123' }; @@ -1313,7 +1351,8 @@ describe('Store', () => { state, zipCode, firstName, - lastName + lastName, + companyCode } ], vehicles: [ @@ -1335,6 +1374,7 @@ describe('Store', () => { await expect(store.order.customer.address.zipCode).toBe(zipCode); await expect(store.order.customer.firstName).toBe(firstName); await expect(store.order.customer.lastName).toBe(lastName); + await expect(store.order.customer.companyCode).toBe(companyCode) await expect(store.order.policy.vehicles).toStrictEqual([vehicle]); }); it('calls api with expected data', async () => { @@ -1404,7 +1444,8 @@ describe('Store', () => { lastName: getRandomString(6, 6), city: getRandomString(6, 6), state: getRandomString(6, 6), - zipCode: getRandomString(6, 6) + zipCode: getRandomString(6, 6), + companyCode: getRandomString(6, 6) }; const vehicles = [ { name: getRandomString(6, 6) }, @@ -1435,6 +1476,7 @@ describe('Store', () => { expect(store.order.customer.address.zipCode).toBe(insured.zipCode); expect(store.order.customer.firstName).toBe(insured.firstName); expect(store.order.customer.lastName).toBe(insured.lastName); + expect(store.order.customer.companyCode).toBe(insured.companyCode); expect(store.order.policy.vehicles).toEqual(vehicles); });