Merge pull request #1310 from Safelite/feature/humphries/INSR-523

INSR-523: Move claim registration to just before work order submission for USAA
This commit is contained in:
AHumphriesSL 2026-07-23 15:48:21 -04:00 committed by GitHub
commit d94bd6ebe0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 183 additions and 11 deletions

View file

@ -37,6 +37,15 @@ export async function saveSession({ shouldAwaitSaveSessionQueue = false, submitA
export async function submitWorkOrder({ submitType }) {
const store = useMainStore();
store.resetSubmittedOrder();
const shouldRegisterClaim = store.isPolicyLookupSuccessful
&& store.vehicle.policyVehicleId != null
&& store.vehicle.policyVehicleId >= 0
&& store.isClaimRegistrationRequired
&& store.issConfig.callClaimRegistrationAtEnd
&& !store.isNoComp;
if (shouldRegisterClaim) {
await store.registerClaim();
}
await saveSession({
shouldAwaitSaveSessionQueue: true,
submitAfterSave: true,

View file

@ -0,0 +1,157 @@
import coverageType from '@/constants/coverage-type';
import { submitWorkOrder } from '@/helpers/order-helper';
import { createTestingPinia } from '@pinia/testing';
import { getDefaultState, useMainStore } from '@/store';
let store;
describe('order-helper.js', () => {
describe('submitWorkOrder', () => {
beforeEach(() => {
const testingPinia = createTestingPinia({
initialState: {
main: getDefaultState()
}
});
store = useMainStore(testingPinia);
store.resetSubmittedOrder = jest.fn();
store.createSubmittedOrder = jest.fn(() => Promise.resolve());
store.registerClaim = jest.fn(() => Promise.resolve());
store.saveSession = jest.fn(() => Promise.resolve({ data: { referralNumber: 'REF-001' } }));
store.setSaveSessionInfo = jest.fn();
store.setSaveSessionPromise = jest.fn((promise) => {
store.applicationUser.saveSessionPromise = promise;
});
store.order.referralNumber = null;
store.order.vehicle.policyVehicleId = null;
store.order.insuranceCoverage.coverageType = coverageType.NONE;
store.issConfig.isClaimRegistrationRequired = false;
store.issConfig.callClaimRegistrationAtEnd = false;
jest.clearAllMocks();
});
test('Resets order, saves session, and creates submitted order with submit type', async () => {
// Arrange
const submitType = 'SUBMIT';
// Act
await submitWorkOrder({ submitType });
// Assert
expect(store.resetSubmittedOrder).toHaveBeenCalledTimes(1);
expect(store.saveSession).toHaveBeenCalledTimes(1);
expect(store.saveSession).toHaveBeenCalledWith({
submitAfterSave: true,
createWorkOrderNumberForPIA: false,
bailoutOnError: true
});
expect(store.setSaveSessionPromise).toHaveBeenCalledTimes(1);
expect(store.setSaveSessionInfo).toHaveBeenCalledWith({ referralNumber: 'REF-001' });
expect(store.createSubmittedOrder).toHaveBeenCalledTimes(1);
expect(store.createSubmittedOrder).toHaveBeenCalledWith(submitType);
});
test('Registers claim when all claim registration conditions are met', async () => {
// Arrange
store.order.insuranceCoverage.coverageType = coverageType.Deductible;
store.order.vehicle.policyVehicleId = 42;
store.issConfig.isClaimRegistrationRequired = true;
store.issConfig.callClaimRegistrationAtEnd = true;
// Act
await submitWorkOrder({ submitType: 'SUBMIT' });
// Assert
expect(store.registerClaim).toHaveBeenCalledTimes(1);
});
test('Does not register claim when policy lookup is not successful', async () => {
// Arrange
store.order.insuranceCoverage.coverageType = coverageType.NONE;
store.order.vehicle.policyVehicleId = 42;
store.issConfig.isClaimRegistrationRequired = true;
store.issConfig.callClaimRegistrationAtEnd = true;
// Act
await submitWorkOrder({ submitType: 'SUBMIT' });
// Assert
expect(store.registerClaim).not.toHaveBeenCalled();
});
test('Does not register claim when policyVehicleId is null', async () => {
// Arrange
store.order.insuranceCoverage.coverageType = coverageType.Deductible;
store.order.vehicle.policyVehicleId = null;
store.issConfig.isClaimRegistrationRequired = true;
store.issConfig.callClaimRegistrationAtEnd = true;
// Act
await submitWorkOrder({ submitType: 'SUBMIT' });
// Assert
expect(store.registerClaim).not.toHaveBeenCalled();
});
test('Does not register claim when policyVehicleId is negative', async () => {
// Arrange
store.order.insuranceCoverage.coverageType = coverageType.Deductible;
store.order.vehicle.policyVehicleId = -1;
store.issConfig.isClaimRegistrationRequired = true;
store.issConfig.callClaimRegistrationAtEnd = true;
// Act
await submitWorkOrder({ submitType: 'SUBMIT' });
// Assert
expect(store.registerClaim).not.toHaveBeenCalled();
});
test('Does not register claim when claim registration is not required', async () => {
// Arrange
store.order.insuranceCoverage.coverageType = coverageType.Deductible;
store.order.vehicle.policyVehicleId = 42;
store.issConfig.isClaimRegistrationRequired = false;
store.issConfig.callClaimRegistrationAtEnd = true;
// Act
await submitWorkOrder({ submitType: 'SUBMIT' });
// Assert
expect(store.registerClaim).not.toHaveBeenCalled();
});
test('Does not register claim when claim registration is disabled in config', async () => {
// Arrange
store.order.insuranceCoverage.coverageType = coverageType.Deductible;
store.order.vehicle.policyVehicleId = 42;
store.issConfig.isClaimRegistrationRequired = true;
store.issConfig.callClaimRegistrationAtEnd = false;
// Act
await submitWorkOrder({ submitType: 'SUBMIT' });
// Assert
expect(store.registerClaim).not.toHaveBeenCalled();
});
test('Does not register claim when coverage type is NoComp', async () => {
// Arrange
store.order.insuranceCoverage.coverageType = coverageType.NO_COMP;
store.order.vehicle.policyVehicleId = 42;
store.issConfig.isClaimRegistrationRequired = true;
store.issConfig.callClaimRegistrationAtEnd = true;
// Act
await submitWorkOrder({ submitType: 'SUBMIT' });
// Assert
expect(store.registerClaim).not.toHaveBeenCalled();
});
});
});

View file

@ -406,23 +406,26 @@ describe('coverageStatement.vue', () => {
});
});
describe.each([
[false, false, true, true, 0],
[false, true, false, true, 0],
[false, true, true, false, 0],
[false, true, true, true, -1],
[false, true, true, true, null],
[true, true, true, true, 0]
[false, false, true, true, 0, false],
[false, true, false, true, 0, false],
[false, true, true, false, 0, false],
[false, true, true, true, -1, false],
[false, true, true, true, null, false],
[false, true, true, true, 0, true],
[true, true, true, true, 0, false]
])('shouldRegisterClaim', (
expected,
isClaimRegistrationRequired,
isPolicyLookupSuccessful,
isPendingClaimRegistration,
policyVehicleId
policyVehicleId,
callClaimRegistrationAtEnd
) => {
test(`returns ${expected} when isClaimRegistrationRequired is ${isClaimRegistrationRequired} `
+ `and isPolicyLookupSuccessful is ${isPolicyLookupSuccessful} `
+ `and isPendingClaimRegistration is ${isPendingClaimRegistration} `
+ `and policyVehicleId is ${(policyVehicleId == null ? 'NULL' : policyVehicleId)}`, () => {
+ `and policyVehicleId is ${(policyVehicleId == null ? 'NULL' : policyVehicleId)} `
+ `and callClaimRegistrationAtEnd is ${callClaimRegistrationAtEnd}`, () => {
// Arrange
const mainInitialState = {
order: {
@ -435,7 +438,8 @@ describe('coverageStatement.vue', () => {
}
},
issConfig: {
isClaimRegistrationRequired
isClaimRegistrationRequired,
callClaimRegistrationAtEnd
}
};

View file

@ -331,7 +331,8 @@ export default {
vehicle,
isClaimRegistrationRequired,
isPolicyLookupSuccessful,
isPendingClaimRegistration
isPendingClaimRegistration,
issConfig
} = useMainStore();
const { policyVehicleId } = vehicle;
return (
@ -340,6 +341,7 @@ export default {
&& policyVehicleId >= 0
&& isClaimRegistrationRequired
&& isPendingClaimRegistration
&& !issConfig.callClaimRegistrationAtEnd
);
},
isRepair() {
@ -453,7 +455,7 @@ export default {
async initializeComponent() {
if (this.shouldRegisterClaim) {
await this.mainStore.registerClaim();
} else if (!this.mainStore.isClaimRegistrationRequired && this.mainStore.order.insuranceCoverage.coverageType !== coverageType.NONE) {
} else if ((!this.mainStore.isClaimRegistrationRequired || this.mainStore.issConfig.callClaimRegistrationAtEnd) && this.mainStore.order.insuranceCoverage.coverageType !== coverageType.NONE) {
this.mainStore.updateCoverageStatus(coverageStatuses.VERIFIED);
}