Merge pull request #1157 from Safelite/feature/kroell/INSR-8546

INSR-8546: fix recal logic
This commit is contained in:
katiekroell 2026-04-03 10:50:24 -04:00 committed by GitHub
commit 07d8945c5b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 37 additions and 4 deletions

View file

@ -11,7 +11,7 @@ export function isRecalPartOrHasChildRecalPart(glassPart) {
const isGlassPartRecalPart = isRecalPart(glassPart);
if (!isGlassPartRecalPart && glassPart.childParts && glassPart.childParts.length > 0) {
return glassPart.childParts.filter((cp) => isRecalPartOrHasChildRecalPart(cp));
return glassPart.childParts.some((cp) => isRecalPartOrHasChildRecalPart(cp));
}
return isGlassPartRecalPart;
@ -52,3 +52,24 @@ export function getRecalPartNumbers(glassPartsArray) {
}
}
export function containsRecalParts(lineItems) {
if (!lineItems) {
return false;
}
if (Array.isArray(lineItems)) {
return lineItems.some((li) => isRecalPartOrHasChildRecalPart(li));
} else {
// complex object form -- flatten and re-call.
const flattened = [
...(lineItems.glassParts ?? []),
...(lineItems.supportingItems ?? []),
...(lineItems.otherParts ?? []),
...(lineItems.feeItems ?? []),
...(lineItems.vaps ?? []),
];
return flattened.some((li) => isRecalPartOrHasChildRecalPart(li));
}
}

View file

@ -32,6 +32,12 @@ jest.mock('@/helpers/text-helper', () => ({
formatAmountInDollars: jest.fn()
}));
jest.mock('@/helpers/recal-helper.js', () => ({
containsRecalParts: jest.fn()
}));
import { containsRecalParts } from '@/helpers/recal-helper.js';
const SAFELITE_PROVIDER = 'Safelite';
const CANCEL_CLAIM_REF_NAME = 'CancelClaimModal';
@ -337,15 +343,17 @@ describe('coverageStatement.vue', () => {
// Assert
expect(result).toBeFalsy();
});
test('returns true when a part in glassParts require recalibration', () => {
test('returns true when a part in glassParts require recalibration and recalibration has been added to order', () => {
// Arrange
containsRecalParts.mockReturnValue(true);
const mainInitialState = {
order: {
lineItems: {
glassParts: [
{
partNumber: 123,
requiresRecalibration: true
requiresRecalibration: true,
partType: 'RECALIBRATION'
},
{
partNumber: 111,

View file

@ -147,6 +147,7 @@ import { getPriceOfLineItems } from '@/helpers/price-calculator';
import coverageStatuses from '@/constants/coverage-statuses';
import coverageType from '@/constants/coverage-type';
import oemEndorsementModal from '@/layouts/coverage-statement/oem-endorsement-modal/oem-endorsement-modal.vue';
import { containsRecalParts } from '@/helpers/recal-helper';
const RECAL_MODAL_REF_NAME = 'RecalModal';
const CANCEL_CLAIM_REF_NAME = 'CancelClaimModal';
@ -305,9 +306,11 @@ export default {
},
isADAS() {
const { glassParts } = useMainStore().order.lineItems;
const orderContainsRecalPart = containsRecalParts(glassParts);
return (
glassParts !== null
&& !!glassParts.find((part) => part.requiresRecalibration)
&& orderContainsRecalPart
);
},
totalServicePrice() {

View file

@ -23,6 +23,7 @@ import partTypeStrings from '@/constants/part-type-strings';
import { useMainStore } from '@/store';
import { getPriceOfLineItem } from '@/helpers/price-calculator';
import { shallowRef } from 'vue';
import { containsRecalParts } from '@/helpers/recal-helper';
const glassLocations = damageLocationsSelected;
@ -100,7 +101,7 @@ export default {
return modifiedAnswers;
},
isRecalibrationOnOrder() {
return this.mainStore.hasRecalibrationPart;
return this.mainStore.hasRecalibrationPart && containsRecalParts(this.mainStore.order.lineItems);
},
frontWipersApplicableForTierTwo() {
const frontWipersAreAvailable = this.lineItemsContainsPartType(partTypeStrings.FRONT_WIPER);