forked from Yara724/api
Fixed FileMaker and FileReviewer access to COMPLETED files
This commit is contained in:
59
src/claim-request-management/claim-details-access.v2.spec.ts
Normal file
59
src/claim-request-management/claim-details-access.v2.spec.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
import { ForbiddenException } from "@nestjs/common";
|
||||
import { ClaimRequestManagementService } from "./claim-request-management.service";
|
||||
import { RoleEnum } from "src/Types&Enums/role.enum";
|
||||
|
||||
describe("V2 claim-detail access for split file roles", () => {
|
||||
const makerId = "maker-id";
|
||||
const reviewerId = "reviewer-id";
|
||||
|
||||
const createService = (blame: Record<string, unknown>) => {
|
||||
const service = Object.create(
|
||||
ClaimRequestManagementService.prototype,
|
||||
) as ClaimRequestManagementService;
|
||||
(service as any).blameRequestDbService = {
|
||||
findById: jest.fn().mockResolvedValue(blame),
|
||||
};
|
||||
return service;
|
||||
};
|
||||
|
||||
const claim = { blameRequestId: "blame-id" };
|
||||
|
||||
it("allows the FileMaker who created a completed V4/V5 file", async () => {
|
||||
const service = createService({
|
||||
isMadeByFileMaker: true,
|
||||
expertInitiated: true,
|
||||
creationMethod: "IN_PERSON",
|
||||
initiatedByFieldExpertId: makerId,
|
||||
});
|
||||
|
||||
await expect(
|
||||
(service as any).assertActorCanViewClaimV2(claim, makerId, {
|
||||
sub: makerId,
|
||||
role: RoleEnum.FILE_MAKER,
|
||||
}),
|
||||
).resolves.toBeUndefined();
|
||||
});
|
||||
|
||||
it("allows only the assigned FileReviewer", async () => {
|
||||
const service = createService({
|
||||
isMadeByFileMaker: true,
|
||||
expertInitiated: true,
|
||||
creationMethod: "IN_PERSON",
|
||||
assignedFileReviewerId: reviewerId,
|
||||
});
|
||||
|
||||
await expect(
|
||||
(service as any).assertActorCanViewClaimV2(claim, reviewerId, {
|
||||
sub: reviewerId,
|
||||
role: RoleEnum.FILE_REVIEWER,
|
||||
}),
|
||||
).resolves.toBeUndefined();
|
||||
|
||||
await expect(
|
||||
(service as any).assertActorCanViewClaimV2(claim, "other-reviewer", {
|
||||
sub: "other-reviewer",
|
||||
role: RoleEnum.FILE_REVIEWER,
|
||||
}),
|
||||
).rejects.toBeInstanceOf(ForbiddenException);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user