forked from Yara724/api
fix: harden claim review and inquiry workflows
Preserve damage history and current vehicle price, restore depreciation mapping, normalize inquiry/report output, and support resumable expert review with paginated case retrieval.
This commit is contained in:
51
src/common/utils/inquiry-error.spec.ts
Normal file
51
src/common/utils/inquiry-error.spec.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import {
|
||||
getInquiryErrorMessage,
|
||||
isInquiryFailurePayload,
|
||||
} from "./inquiry-error";
|
||||
|
||||
describe("inquiry error messages", () => {
|
||||
it("turns ESG not-found responses into a contextual plate message", () => {
|
||||
expect(
|
||||
getInquiryErrorMessage(
|
||||
{ success: false, message: "موردی یافت نشد" },
|
||||
"thirdPartyPlate",
|
||||
),
|
||||
).toBe("بیمهنامه شخص ثالثی مطابق پلاک و کد ملی واردشده یافت نشد.");
|
||||
});
|
||||
|
||||
it("distinguishes VIN and car-body not-found failures", () => {
|
||||
expect(getInquiryErrorMessage({ status: 404 }, "thirdPartyVin")).toContain(
|
||||
"شماره شاسی (VIN)",
|
||||
);
|
||||
expect(
|
||||
getInquiryErrorMessage(
|
||||
new Error("No active policy found"),
|
||||
"carBodyPlate",
|
||||
),
|
||||
).toBe("بیمهنامه بدنه فعالی مطابق پلاک و کد ملی واردشده یافت نشد.");
|
||||
});
|
||||
|
||||
it("preserves a specific Persian provider message", () => {
|
||||
expect(
|
||||
getInquiryErrorMessage(
|
||||
{ message: "کد ملی واردشده صحیح نیست" },
|
||||
"personalIdentity",
|
||||
),
|
||||
).toBe("کد ملی واردشده صحیح نیست");
|
||||
});
|
||||
|
||||
it("does not expose transport or authentication details", () => {
|
||||
expect(
|
||||
getInquiryErrorMessage(
|
||||
{ response: { status: 401 }, message: "ESG authentication failed" },
|
||||
"thirdPartyPlate",
|
||||
),
|
||||
).toBe("سرویس استعلام در دسترس نیست. لطفاً کمی بعد دوباره تلاش کنید.");
|
||||
});
|
||||
|
||||
it("recognizes provider failure envelopes", () => {
|
||||
expect(isInquiryFailurePayload({ success: false })).toBe(true);
|
||||
expect(isInquiryFailurePayload({ HasError: true })).toBe(true);
|
||||
expect(isInquiryFailurePayload({ success: true, data: {} })).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user