forked from Yara724/api
fix claim validation and expert branch scoping
This commit is contained in:
@@ -515,6 +515,9 @@ describe("ExpertClaimService FileReviewer assignment", () => {
|
||||
],
|
||||
}),
|
||||
};
|
||||
service.fanavaranLocationService = {
|
||||
assertMakerReviewerBranchCompatible: jest.fn().mockResolvedValue(undefined),
|
||||
};
|
||||
service.assertExpertActorOnClaim = jest.fn();
|
||||
|
||||
await expect(
|
||||
@@ -531,3 +534,28 @@ describe("ExpertClaimService FileReviewer assignment", () => {
|
||||
expect(service.assertExpertActorOnClaim).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("ExpertClaimService branch-scoped claim views", () => {
|
||||
it("shows branch-scoped claims only to damage experts in that branch", async () => {
|
||||
const service = createService() as any;
|
||||
const branchId = new Types.ObjectId();
|
||||
const otherBranchId = new Types.ObjectId();
|
||||
service.damageExpertDbService = {
|
||||
findById: jest.fn().mockResolvedValue({ branchId }),
|
||||
};
|
||||
service.blameRequestDbService = {
|
||||
find: jest.fn().mockResolvedValue([]),
|
||||
};
|
||||
|
||||
const inBranch = { _id: "in-branch", branchId };
|
||||
const otherBranch = { _id: "other-branch", branchId: otherBranchId };
|
||||
const legacyUnscoped = { _id: "legacy-unscoped" };
|
||||
|
||||
await expect(
|
||||
service.filterDamageExpertClaimsByBranch(
|
||||
[inBranch, otherBranch, legacyUnscoped],
|
||||
{ sub: V2_EXPERT_ID, role: RoleEnum.DAMAGE_EXPERT },
|
||||
),
|
||||
).resolves.toEqual([inBranch, legacyUnscoped]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user