forked from Yara724/api
Fixed Car_Body inquiry for Parsian
This commit is contained in:
@@ -32,6 +32,7 @@ describe("SandHubService inquiry mocks", () => {
|
|||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks();
|
jest.clearAllMocks();
|
||||||
delete process.env.CLIENT_ID;
|
delete process.env.CLIENT_ID;
|
||||||
|
delete process.env.FANAVARAN_CLIENT;
|
||||||
service = new SandHubService(
|
service = new SandHubService(
|
||||||
httpService as any,
|
httpService as any,
|
||||||
sandHubDbService as any,
|
sandHubDbService as any,
|
||||||
@@ -107,6 +108,28 @@ describe("SandHubService inquiry mocks", () => {
|
|||||||
expect(httpService.post).not.toHaveBeenCalled();
|
expect(httpService.post).not.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("uses the processed CAR_BODY lookup when the active Fanavaran client is Parsian", async () => {
|
||||||
|
process.env.FANAVARAN_CLIENT = "parsian";
|
||||||
|
externalInquirySettings.isInquiryLive.mockResolvedValue(true);
|
||||||
|
lookupsService.findLastProcessedCarPolicy.mockResolvedValue({
|
||||||
|
policy: { CINumber: "70019846985" },
|
||||||
|
customer: {},
|
||||||
|
vehicle: {},
|
||||||
|
});
|
||||||
|
const tejarat = jest
|
||||||
|
.spyOn(service, "getTejaratCarBodyInquiry")
|
||||||
|
.mockResolvedValue({ raw: { mocked: true }, mapped: {} });
|
||||||
|
|
||||||
|
const result = await service.getCarBodyInquiry(userDetail);
|
||||||
|
|
||||||
|
expect(lookupsService.findLastProcessedCarPolicy).toHaveBeenCalledWith(
|
||||||
|
"car-body",
|
||||||
|
expect.objectContaining({ nationalCode: "1234567890" }),
|
||||||
|
);
|
||||||
|
expect(tejarat).not.toHaveBeenCalled();
|
||||||
|
expect(result.raw).not.toEqual({ mocked: true });
|
||||||
|
});
|
||||||
|
|
||||||
it("keeps ESG car-body inquiry in mock mode when the per-client toggle is off", async () => {
|
it("keeps ESG car-body inquiry in mock mode when the per-client toggle is off", async () => {
|
||||||
process.env.CLIENT_ID = "8";
|
process.env.CLIENT_ID = "8";
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,15 @@ export class SandHubService {
|
|||||||
return String(process.env.CLIENT_ID ?? "") === "8";
|
return String(process.env.CLIENT_ID ?? "") === "8";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The processed Fanavaran CAR_BODY lookup belongs only to the Parsian
|
||||||
|
* Fanavaran profile. Do not use the deployment-wide ESG selector here:
|
||||||
|
* `FANAVARAN_CLIENT=parsian` is valid even when CLIENT_ID is not 8.
|
||||||
|
*/
|
||||||
|
private shouldUseParsianCarBodyLookup(): boolean {
|
||||||
|
return resolveFanavaranClientKey() === "parsian";
|
||||||
|
}
|
||||||
|
|
||||||
/** Fixed plate/insurance inquiry payload used everywhere we mock block-inquiry style APIs. */
|
/** Fixed plate/insurance inquiry payload used everywhere we mock block-inquiry style APIs. */
|
||||||
private buildMockPlateInquiryRaw(
|
private buildMockPlateInquiryRaw(
|
||||||
ctx: MockInquiryCompanyContext,
|
ctx: MockInquiryCompanyContext,
|
||||||
@@ -857,7 +866,7 @@ export class SandHubService {
|
|||||||
raw: any;
|
raw: any;
|
||||||
mapped: Record<string, unknown>;
|
mapped: Record<string, unknown>;
|
||||||
}> {
|
}> {
|
||||||
if (!this.shouldUseEsgInquiryProvider()) {
|
if (!this.shouldUseParsianCarBodyLookup()) {
|
||||||
const result = await this.getTejaratCarBodyInquiry(
|
const result = await this.getTejaratCarBodyInquiry(
|
||||||
userDetail as SandHubDetailDto,
|
userDetail as SandHubDetailDto,
|
||||||
options,
|
options,
|
||||||
|
|||||||
Reference in New Issue
Block a user