forked from Yara724/api
Route inquiries by participant role
This commit is contained in:
@@ -176,12 +176,39 @@ describe("SandHubService inquiry mocks", () => {
|
||||
});
|
||||
|
||||
await expect(
|
||||
service.getPolicyByChassisInquiry("NAAR03HFFRDE07024", {
|
||||
enforceDeploymentClientMatch: true,
|
||||
}),
|
||||
service.getPolicyByChassisInquiry(
|
||||
{
|
||||
nationalCode: "1234567890",
|
||||
chassis: "NAAR03HFFRDE07024",
|
||||
},
|
||||
{ enforceDeploymentClientMatch: true },
|
||||
),
|
||||
).rejects.toBeInstanceOf(ForbiddenException);
|
||||
});
|
||||
|
||||
it("sends the policyholder national code with the VIN inquiry", async () => {
|
||||
externalInquirySettings.isInquiryLive.mockResolvedValue(true);
|
||||
const esg = jest.spyOn(service as any, "makeEsgRequest").mockResolvedValue({
|
||||
success: true,
|
||||
data: { CmpCod: "8", CmpNam: "بیمه پارسیان" },
|
||||
});
|
||||
|
||||
await service.getPolicyByChassisInquiry({
|
||||
nationalCode: "0012345678",
|
||||
chassis: "NAAR03HFFRDE07024",
|
||||
});
|
||||
|
||||
expect(esg).toHaveBeenCalledWith(
|
||||
expect.stringContaining("/inquiry/policyByChassis"),
|
||||
{
|
||||
nationalCode: "0012345678",
|
||||
chassis: "NAAR03HFFRDE07024",
|
||||
},
|
||||
"vinChassis",
|
||||
undefined,
|
||||
);
|
||||
});
|
||||
|
||||
it("does not accept a policy when CLIENT_ID is not configured", async () => {
|
||||
delete process.env.CLIENT_ID;
|
||||
externalInquirySettings.isInquiryLive.mockResolvedValue(true);
|
||||
@@ -295,6 +322,47 @@ describe("SandHubService inquiry mocks", () => {
|
||||
expect(result.source).toBe("ESG_CAR_BODY_VIN_INQUIRY");
|
||||
});
|
||||
|
||||
it("uses the tenant Fanavaran VIN lookup for non-Parsian car-body inquiries", async () => {
|
||||
process.env.CLIENT_ID = "15";
|
||||
process.env.FANAVARAN_CLIENT = "tejaratno";
|
||||
externalInquirySettings.isInquiryLive.mockResolvedValue(true);
|
||||
lookupsService.findLastProcessedCarPolicy.mockResolvedValue({
|
||||
policy: { CINumber: "BODY-15" },
|
||||
customer: {},
|
||||
vehicle: { VIN: "NAAR03HFFRDE07024" },
|
||||
});
|
||||
const tejarat = jest.spyOn(service, "getTejaratCarBodyInquiry");
|
||||
|
||||
const result = await service.getCarBodyInquiry({
|
||||
nationalCodeOfInsurer: "0012345678",
|
||||
plate: "NAAR03HFFRDE07024",
|
||||
});
|
||||
|
||||
expect(lookupsService.findLastProcessedCarPolicy).toHaveBeenCalledWith(
|
||||
"car-body",
|
||||
{ nationalCode: "0012345678", vin: "NAAR03HFFRDE07024" },
|
||||
);
|
||||
expect(tejarat).not.toHaveBeenCalled();
|
||||
expect(result.source).toBe("TEJARAT_CAR_BODY_VIN_INQUIRY");
|
||||
});
|
||||
|
||||
it("returns a VIN-shaped car-body mock without invoking a plate adapter", async () => {
|
||||
process.env.CLIENT_ID = "15";
|
||||
process.env.FANAVARAN_CLIENT = "tejaratno";
|
||||
const tejarat = jest.spyOn(service, "getTejaratCarBodyInquiry");
|
||||
|
||||
const result = await service.getCarBodyInquiry({
|
||||
nationalCodeOfInsurer: "0012345678",
|
||||
plate: "NAAR03HFFRDE07024",
|
||||
});
|
||||
|
||||
expect(tejarat).not.toHaveBeenCalled();
|
||||
expect(lookupsService.findLastProcessedCarPolicy).not.toHaveBeenCalled();
|
||||
expect(result.source).toBe("TEJARAT_CAR_BODY_VIN_INQUIRY");
|
||||
expect(result.mapped.VinNumberField).toBe("NAAR03HFFRDE07024");
|
||||
expect(result.mapped.insurerNationalCode).toBe("0012345678");
|
||||
});
|
||||
|
||||
it("uses car-body mock shape in Tejarat helper when inquiry is off", async () => {
|
||||
const raw = await (service as any).makeTejaratRequest(
|
||||
"http://example/block-inquiry-tejarat/badane",
|
||||
|
||||
Reference in New Issue
Block a user