fix: make user branch selection and signature completion reliable

This commit is contained in:
SepehrYahyaee
2026-11-16 10:40:09 +03:30
parent 775934c056
commit e5c4b740e7
10 changed files with 406 additions and 118 deletions
@@ -249,4 +249,20 @@ describe("user blame next action and claim eligibility", () => {
expect(response.parties[0].role).toBe("SECOND");
expect(JSON.stringify(response)).not.toContain("09120000001");
});
it("repairs interrupted signatures in the case list before calculating the next page", async () => {
const service = subject();
const record = blame({status:"WAITING_FOR_SIGNATURES",workflow:{currentStep:"WAITING_FOR_SIGNATURES"}});
service.blameRequestDbService = {
find: jest.fn().mockResolvedValue([record]),
findOneAndUpdate: jest.fn(async (filter,update) => {
expect(filter.status).toBe("WAITING_FOR_SIGNATURES");
expect(filter.$and).toHaveLength(2);
return {...record,status:update.$set.status,workflow:{currentStep:"COMPLETED"}};
}),
};
const response = await service.getAllBlameRequestsV2({sub:damagedId,role:RoleEnum.USER});
expect(response.list[0]).toMatchObject({status:"COMPLETED",nextAction:"CREATE_CLAIM"});
expect(service.blameRequestDbService.findOneAndUpdate).toHaveBeenCalledTimes(1);
});
});