Enforce claim beneficiary access and retire unused legacy APIs

This commit is contained in:
SepehrYahyaee
2026-10-05 14:39:51 +03:30
parent 0735333467
commit a3f9aab8fb
104 changed files with 6864 additions and 13223 deletions
@@ -141,6 +141,30 @@ describe("user blame next action and claim eligibility", () => {
expect(service.claimCaseDbService.findOne).not.toHaveBeenCalled();
});
it("shows an existing claim as actionable only to its beneficiary", async () => {
const service = subject();
for (const [viewer, nextAction] of [
[guiltyId, "VIEW_RESULT"],
[damagedId, "CONTINUE_CLAIM"],
]) {
const hint = await service.computeClaimCreationHintForViewer(
blame(),
{ sub: viewer },
{ _id: blameId },
);
expect(resolveBlameUserNextAction("COMPLETED", {}, hint)).toBe(
nextAction,
);
}
const unknown = blame({ expert: { decision: { guiltyPartyId: blameId } } });
const hint = await service.computeClaimCreationHintForViewer(
unknown,
{ sub: damagedId },
null,
);
expect(hint.shouldGuideToCreateClaim).toBe(false);
});
it("permits a completed body-insurance claim only for its own party", async () => {
const service = subject();
const body = blame({
@@ -172,15 +196,13 @@ describe("user blame next action and claim eligibility", () => {
it("keeps identity filters working but omits private/search-only fields in list responses", async () => {
const service = subject();
service.blameRequestDbService = {
find: jest
.fn()
.mockResolvedValue([
blame({
__v: 42,
inquiries: { raw: "private" },
initiatedByFieldExpertId: guiltyId,
}),
]),
find: jest.fn().mockResolvedValue([
blame({
__v: 42,
inquiries: { raw: "private" },
initiatedByFieldExpertId: guiltyId,
}),
]),
};
const response = await service.getAllBlameRequestsV2(
{ sub: damagedId, role: RoleEnum.USER },