forked from Yara724/api
fix: harden claim review and inquiry workflows
Preserve damage history and current vehicle price, restore depreciation mapping, normalize inquiry/report output, and support resumable expert review with paginated case retrieval.
This commit is contained in:
@@ -5,6 +5,9 @@ import { RoleEnum } from "src/Types&Enums/role.enum";
|
||||
import { CreationMethod } from "./entities/schema/request-management.schema";
|
||||
import { PartyRole } from "./entities/schema/partyRole.enum";
|
||||
import { RequestManagementService } from "./request-management.service";
|
||||
import { CaseStatus } from "src/Types&Enums/blame-request-management/caseStatus.enum";
|
||||
import { ClaimCaseStatus } from "src/Types&Enums/claim-request-management/claim-case-status.enum";
|
||||
import { ClaimWorkflowStep } from "src/Types&Enums/claim-request-management/claim-workflow-steps.enum";
|
||||
|
||||
describe("RequestManagementService V4 FileMaker workflow", () => {
|
||||
it("persists FIRST_INITIAL_FORM after the first party OTP is verified", async () => {
|
||||
@@ -216,4 +219,138 @@ describe("RequestManagementService V4 FileMaker workflow", () => {
|
||||
WorkflowStep.FIRST_VIDEO,
|
||||
);
|
||||
});
|
||||
|
||||
it.each([false, true])(
|
||||
"resumes V4/V5 FileMaker work from the linked claim during partial document upload (approval=%s)",
|
||||
async (requiresFileMakerApproval) => {
|
||||
const fileMakerId = new Types.ObjectId();
|
||||
const blameId = new Types.ObjectId();
|
||||
const claimId = new Types.ObjectId();
|
||||
const request = {
|
||||
_id: blameId,
|
||||
publicId: "BL-FILE-MAKER-RESUME",
|
||||
requestNo: "BL-RESUME",
|
||||
type: BlameRequestType.THIRD_PARTY,
|
||||
status: CaseStatus.OPEN,
|
||||
isMadeByFileMaker: true,
|
||||
initiatedByFieldExpertId: fileMakerId,
|
||||
requiresFileMakerApproval,
|
||||
parties: [],
|
||||
workflow: {
|
||||
currentStep: WorkflowStep.SECOND_COMPLETED,
|
||||
nextStep: WorkflowStep.WAITING_FOR_GUILT_DECISION,
|
||||
completedSteps: [
|
||||
WorkflowStep.FIRST_COMPLETED,
|
||||
WorkflowStep.SECOND_COMPLETED,
|
||||
],
|
||||
},
|
||||
};
|
||||
const claim = {
|
||||
_id: claimId,
|
||||
blameRequestId: blameId,
|
||||
status: ClaimCaseStatus.UPLOADING_REQUIRED_DOCUMENTS,
|
||||
workflow: {
|
||||
currentStep: ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS,
|
||||
nextStep: ClaimWorkflowStep.SELECT_OUTER_PARTS,
|
||||
completedSteps: [ClaimWorkflowStep.CLAIM_CREATED],
|
||||
},
|
||||
};
|
||||
const service =
|
||||
new (RequestManagementService as any)() as RequestManagementService;
|
||||
(service as any).blameRequestDbService = {
|
||||
findById: jest.fn().mockResolvedValue(request),
|
||||
find: jest.fn().mockResolvedValue([request]),
|
||||
};
|
||||
(service as any).claimCaseDbService = {
|
||||
findOne: jest.fn().mockResolvedValue(claim),
|
||||
find: jest.fn().mockResolvedValue([claim]),
|
||||
};
|
||||
|
||||
const reopened = await service.getMyFileMakerFileDetail(
|
||||
{ sub: String(fileMakerId), role: RoleEnum.FILE_MAKER },
|
||||
String(blameId),
|
||||
);
|
||||
|
||||
expect(reopened.status).toBe(CaseStatus.OPEN);
|
||||
expect(reopened.claimStatus).toBe(
|
||||
ClaimCaseStatus.UPLOADING_REQUIRED_DOCUMENTS,
|
||||
);
|
||||
expect(reopened.fileMakerResume).toEqual({
|
||||
action: "UPLOAD_REQUIRED_DOCUMENTS",
|
||||
entity: "CLAIM",
|
||||
entityId: String(claimId),
|
||||
status: ClaimCaseStatus.UPLOADING_REQUIRED_DOCUMENTS,
|
||||
currentStep: ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS,
|
||||
nextStep: ClaimWorkflowStep.SELECT_OUTER_PARTS,
|
||||
});
|
||||
|
||||
const list = await service.getMyFileMakerFiles({
|
||||
sub: String(fileMakerId),
|
||||
role: RoleEnum.FILE_MAKER,
|
||||
});
|
||||
expect(list.list[0]).toEqual(
|
||||
expect.objectContaining({
|
||||
linkedClaimId: String(claimId),
|
||||
claimStatus: ClaimCaseStatus.UPLOADING_REQUIRED_DOCUMENTS,
|
||||
fileMakerResume: expect.objectContaining({
|
||||
action: "UPLOAD_REQUIRED_DOCUMENTS",
|
||||
entityId: String(claimId),
|
||||
}),
|
||||
}),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it("does not leave the blame narrative before all required signatures", async () => {
|
||||
const fileMakerId = new Types.ObjectId();
|
||||
const blameId = new Types.ObjectId();
|
||||
const claimId = new Types.ObjectId();
|
||||
const request = {
|
||||
_id: blameId,
|
||||
publicId: "BL-FILE-MAKER-NARRATIVE",
|
||||
requestNo: "BL-NARRATIVE",
|
||||
type: BlameRequestType.THIRD_PARTY,
|
||||
status: CaseStatus.OPEN,
|
||||
isMadeByFileMaker: true,
|
||||
initiatedByFieldExpertId: fileMakerId,
|
||||
parties: [],
|
||||
workflow: {
|
||||
currentStep: WorkflowStep.FIRST_DESCRIPTION,
|
||||
nextStep: WorkflowStep.FIRST_SIGN,
|
||||
completedSteps: [WorkflowStep.FIRST_VOICE],
|
||||
},
|
||||
};
|
||||
const claim = {
|
||||
_id: claimId,
|
||||
blameRequestId: blameId,
|
||||
status: ClaimCaseStatus.UPLOADING_REQUIRED_DOCUMENTS,
|
||||
workflow: {
|
||||
currentStep: ClaimWorkflowStep.UPLOAD_REQUIRED_DOCUMENTS,
|
||||
nextStep: ClaimWorkflowStep.SELECT_OUTER_PARTS,
|
||||
completedSteps: [ClaimWorkflowStep.CLAIM_CREATED],
|
||||
},
|
||||
};
|
||||
const service =
|
||||
new (RequestManagementService as any)() as RequestManagementService;
|
||||
(service as any).blameRequestDbService = {
|
||||
findById: jest.fn().mockResolvedValue(request),
|
||||
};
|
||||
(service as any).claimCaseDbService = {
|
||||
findOne: jest.fn().mockResolvedValue(claim),
|
||||
};
|
||||
|
||||
const reopened = await service.getMyFileMakerFileDetail(
|
||||
{ sub: String(fileMakerId), role: RoleEnum.FILE_MAKER },
|
||||
String(blameId),
|
||||
);
|
||||
|
||||
expect(reopened.fileMakerResume).toEqual(
|
||||
expect.objectContaining({
|
||||
action: "CONTINUE_BLAME",
|
||||
entity: "BLAME",
|
||||
entityId: String(blameId),
|
||||
currentStep: WorkflowStep.FIRST_DESCRIPTION,
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user