forked from Yara724/api
Extend durable image assessments with explicit Persian vehicle names, deployment severity settings and advisory market prices normalized to rials. Preserve case access and retry boundaries, and remove the retired OpenAI pricing module and routes.
87 lines
2.9 KiB
TypeScript
87 lines
2.9 KiB
TypeScript
import { SuperAdminController } from "src/super-admin/super-admin.controller";
|
|
import { ForbiddenException } from "@nestjs/common";
|
|
import { ExpertClaimV2Controller } from "src/expert-claim/expert-claim.v2.controller";
|
|
import { ExpertInsurerController } from "src/expert-insurer/expert-insurer.controller";
|
|
|
|
describe("AI analysis file access", () => {
|
|
const actor = { sub: "actor", clientKey: "tenant" };
|
|
it.each(["getAiAnalysis", "retryAiAnalysis", "estimateAiAnalysis"])(
|
|
"expert %s uses the existing file access gate before reading results or scheduling work",
|
|
async (method) => {
|
|
const service = {
|
|
getClaimDetailV2: jest.fn().mockRejectedValue(new ForbiddenException()),
|
|
};
|
|
const ai = { list: jest.fn(), retry: jest.fn() },
|
|
db = { findById: jest.fn() };
|
|
const controller = new ExpertClaimV2Controller(
|
|
service as any,
|
|
ai as any,
|
|
db as any,
|
|
{} as any,
|
|
);
|
|
await expect(controller[method]("other-tenant", actor)).rejects.toThrow(
|
|
ForbiddenException,
|
|
);
|
|
expect(db.findById).not.toHaveBeenCalled();
|
|
expect(ai.list).not.toHaveBeenCalled();
|
|
expect(ai.retry).not.toHaveBeenCalled();
|
|
},
|
|
);
|
|
it.each(["getAiAnalysis", "retryAiAnalysis"])(
|
|
"insurer %s validates its public file identifier before resolving a claim",
|
|
async (method) => {
|
|
const service = {
|
|
retrieveFileDetailsByPublicId: jest
|
|
.fn()
|
|
.mockRejectedValue(new ForbiddenException()),
|
|
};
|
|
const ai = { list: jest.fn(), retry: jest.fn() },
|
|
db = { findById: jest.fn() };
|
|
const controller = new ExpertInsurerController(
|
|
service as any,
|
|
{} as any,
|
|
ai as any,
|
|
db as any,
|
|
);
|
|
await expect(controller[method](actor, "other-tenant")).rejects.toThrow(
|
|
ForbiddenException,
|
|
);
|
|
expect(service.retrieveFileDetailsByPublicId).toHaveBeenCalledWith(
|
|
"tenant",
|
|
"other-tenant",
|
|
);
|
|
expect(db.findById).not.toHaveBeenCalled();
|
|
},
|
|
);
|
|
});
|
|
|
|
describe("admin AI tenant selection", () => {
|
|
it.each(["getAiAnalysis", "retryAiAnalysis"])(
|
|
"%s resolves the file inside the selected tenant before reading AI results",
|
|
async (method) => {
|
|
const insurer = {
|
|
retrieveFileDetailsByPublicId: jest
|
|
.fn()
|
|
.mockRejectedValue(new ForbiddenException()),
|
|
};
|
|
const ai = { list: jest.fn(), retry: jest.fn() },
|
|
db = { findById: jest.fn() };
|
|
const controller = new SuperAdminController(
|
|
{} as any,
|
|
{} as any,
|
|
insurer as any,
|
|
ai as any,
|
|
db as any,
|
|
);
|
|
await expect(
|
|
controller[method]("selected-client", "other-client-file"),
|
|
).rejects.toThrow(ForbiddenException);
|
|
expect(insurer.retrieveFileDetailsByPublicId).toHaveBeenCalledWith(
|
|
"selected-client",
|
|
"other-client-file",
|
|
);
|
|
expect(db.findById).not.toHaveBeenCalled();
|
|
},
|
|
);
|
|
});
|