forked from Yara724/api
fix(fanavaran): honor supplied submission payload fields
Apply every supplied JSON field over generated defaults, preserving IDs, nested values and explicit nulls across base, damage and expertise submits. Validate manual hull payloads without rewriting their values or premium, and derive an empty replacement flag for old hull licences.
This commit is contained in:
@@ -187,4 +187,28 @@ describe("hull live lookup submission checks", () => {
|
||||
ActualPremium: 123456,
|
||||
});
|
||||
});
|
||||
it("validates a manual payload without normalizing values or refreshing the supplied premium", async () => {
|
||||
const service = setup();
|
||||
const ids = {
|
||||
cities: 801, "accident-report-type": 802, "accident-causes": 803,
|
||||
"vehicle-hull-accident-types": 804, "vehicle-hull-accident-culprit-type": 805,
|
||||
"detection-accident-culprits": 806, "driving-licence-types": 807, "vehicle-use-types": 808,
|
||||
};
|
||||
service.fanavaranLookupService.fetchFromFanavaran.mockImplementation(async (_client, url) => [
|
||||
{ Id: ids[url.split("/").at(-1)], IsActive: 1 },
|
||||
]);
|
||||
service.fanavaranLookupService.bodyPolicyById = jest.fn().mockResolvedValue({ TotalPremium: 123456 });
|
||||
const payload = {
|
||||
PolicyId: 1, ActualPremium: 12, AccidentCityId: "801", AccidentReportTypeId: 802,
|
||||
AccidentCauseId: 803, AccidentTypeId: 804, CulpritTypeId: 805,
|
||||
AuthorityCulpritId: 806, CulpritLicenceTypeId: 807, AccidentVehicleUsedId: 808,
|
||||
IsLicenseReplaced: null,
|
||||
};
|
||||
const original = JSON.parse(JSON.stringify(payload));
|
||||
await service.postFanavaranJson("https://example.test/car/vehicle-hull-claims", payload, "parsian", undefined, undefined, true);
|
||||
expect(payload).toEqual(original);
|
||||
expect(service.httpService.post).toHaveBeenCalledWith(expect.any(String), original, expect.any(Object));
|
||||
expect(service.fanavaranLookupService.bodyPolicyById).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user