forked from Yara724/api
Better error handling and validation and min/max prices added for expert submit
This commit is contained in:
@@ -95,4 +95,45 @@ describe("ExpertClaimService expert-reply pricing", () => {
|
||||
|
||||
expect(findByIdAndUpdate).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("returns a Persian, field-specific error when a V2 price is below the minimum", async () => {
|
||||
const service = createService() as any;
|
||||
const findByIdAndUpdate = jest.fn();
|
||||
service.claimCaseDbService = {
|
||||
findById: jest.fn().mockResolvedValue({
|
||||
status: ClaimCaseStatus.EXPERT_REVIEWING,
|
||||
workflow: { locked: true, lockedBy: { actorId: "expert-1" } },
|
||||
}),
|
||||
findByIdAndUpdate,
|
||||
};
|
||||
service.assertExpertActorOnClaim = jest.fn().mockResolvedValue(undefined);
|
||||
|
||||
await expect(
|
||||
service.submitExpertReplyV2(
|
||||
"v2-claim",
|
||||
{
|
||||
description: "Damage assessment",
|
||||
parts: [
|
||||
{
|
||||
partId: 201,
|
||||
typeOfDamage: TypeOfDamage.Repair,
|
||||
price: "99,999",
|
||||
salary: "100000",
|
||||
totalPayment: "100000",
|
||||
factorNeeded: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
{ sub: "expert-1", role: RoleEnum.FIELD_EXPERT },
|
||||
),
|
||||
).rejects.toMatchObject({
|
||||
response: {
|
||||
code: "EXPERT_REPLY_VALIDATION_ERROR",
|
||||
field: "parts[0].price",
|
||||
message: expect.stringContaining("حداقل"),
|
||||
},
|
||||
});
|
||||
|
||||
expect(findByIdAndUpdate).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user