forked from Yara724/api
feat: route user claims by branch and align licence issue dates
Require the damaged party in user flows to select an active insurer branch and preserve branch access rules. Accept older licence issue dates, correct anniversary boundaries, and update Fanavaran audit documentation and regression coverage.
This commit is contained in:
@@ -471,7 +471,9 @@ describe("ExpertClaimService FileReviewer assignment", () => {
|
||||
const blameId = new Types.ObjectId();
|
||||
const claimId = new Types.ObjectId();
|
||||
|
||||
service.expireClaimWorkflowLockV2IfStale = jest.fn().mockResolvedValue(undefined);
|
||||
service.expireClaimWorkflowLockV2IfStale = jest
|
||||
.fn()
|
||||
.mockResolvedValue(undefined);
|
||||
service.claimCaseDbService = {
|
||||
findById: jest.fn().mockResolvedValue({
|
||||
_id: claimId,
|
||||
@@ -494,7 +496,9 @@ describe("ExpertClaimService FileReviewer assignment", () => {
|
||||
}),
|
||||
};
|
||||
service.fanavaranLocationService = {
|
||||
assertMakerReviewerBranchCompatible: jest.fn().mockResolvedValue(undefined),
|
||||
assertMakerReviewerBranchCompatible: jest
|
||||
.fn()
|
||||
.mockResolvedValue(undefined),
|
||||
};
|
||||
service.assertExpertActorOnClaim = jest.fn();
|
||||
|
||||
@@ -536,4 +540,32 @@ describe("ExpertClaimService branch-scoped claim views", () => {
|
||||
),
|
||||
).resolves.toEqual([inBranch, legacyUnscoped]);
|
||||
});
|
||||
it("denies direct access and assignment scope for an expert in another branch", async () => {
|
||||
const service = createService() as any;
|
||||
const branchId = new Types.ObjectId();
|
||||
const otherBranch = new Types.ObjectId();
|
||||
service.damageExpertDbService = {
|
||||
findById: jest.fn().mockResolvedValue({ branchId: otherBranch }),
|
||||
};
|
||||
await expect(
|
||||
service.assertActorBranchAccess(
|
||||
{ branchId },
|
||||
{ sub: V2_EXPERT_ID, role: RoleEnum.DAMAGE_EXPERT },
|
||||
),
|
||||
).rejects.toThrow();
|
||||
service.damageExpertDbService.findById.mockResolvedValue({ branchId });
|
||||
await expect(
|
||||
service.assertActorBranchAccess(
|
||||
{ branchId },
|
||||
{ sub: V2_EXPERT_ID, role: RoleEnum.DAMAGE_EXPERT },
|
||||
),
|
||||
).resolves.toBeUndefined();
|
||||
service.damageExpertDbService.findById.mockResolvedValue({});
|
||||
await expect(
|
||||
service.assertActorBranchAccess(
|
||||
{ branchId },
|
||||
{ sub: V2_EXPERT_ID, role: RoleEnum.DAMAGE_EXPERT },
|
||||
),
|
||||
).rejects.toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user