forked from Yara724/api
YARA-1258
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { buildInsurerFileReport } from "./case-expert-report.builder";
|
||||
import { PR } from "./persian-report-labels";
|
||||
import { toJalaliDateAndTime } from "../helpers/date-jalali";
|
||||
|
||||
describe("buildInsurerFileReport", () => {
|
||||
const getFieldValue = (
|
||||
@@ -18,9 +17,6 @@ describe("buildInsurerFileReport", () => {
|
||||
it("separates insurance blocks and exposes Fanavaran/timeline/evaluation data", () => {
|
||||
const fileCreatedAt = new Date("2026-08-10T09:53:23.588Z");
|
||||
const evaluationSubmittedAt = new Date("2026-08-10T12:30:45.000Z");
|
||||
const [fileDate, fileTime] = toJalaliDateAndTime(fileCreatedAt);
|
||||
const [evaluationDate, evaluationTime] =
|
||||
toJalaliDateAndTime(evaluationSubmittedAt);
|
||||
|
||||
const report = buildInsurerFileReport({
|
||||
overview: {
|
||||
@@ -152,6 +148,18 @@ describe("buildInsurerFileReport", () => {
|
||||
submittedAt: evaluationSubmittedAt,
|
||||
description: "نیاز به تعویض سپر جلو",
|
||||
actorDetail: { actorName: "کارشناس خسارت نمونه" },
|
||||
parts: [
|
||||
{
|
||||
partId: 12,
|
||||
carPartDamage: { label_fa: "سپر جلو" },
|
||||
typeOfDamage: "تعویض",
|
||||
price: 2_500_000,
|
||||
salary: 500_000,
|
||||
totalPayment: 3_000_000,
|
||||
factorNeeded: false,
|
||||
daghi: { option: "تحویل داغی" },
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -214,11 +222,11 @@ describe("buildInsurerFileReport", () => {
|
||||
);
|
||||
|
||||
expect(getFieldValue(report, PR.timelineSection, PR.fileRegisteredAt)).toBe(
|
||||
`${fileDate} ${fileTime}`,
|
||||
"1405/05/19 13:23",
|
||||
);
|
||||
expect(
|
||||
getFieldValue(report, PR.timelineSection, PR.evaluationRegisteredAt),
|
||||
).toBe(`${evaluationDate} ${evaluationTime}`);
|
||||
).toBe("1405/05/19 16:00");
|
||||
|
||||
expect(getFieldValue(report, PR.evaluationSection, PR.evaluationResult)).toBe(
|
||||
"تأیید شده",
|
||||
@@ -229,6 +237,91 @@ describe("buildInsurerFileReport", () => {
|
||||
expect(getFieldValue(report, PR.evaluationSection, PR.evaluationResponse)).toBe(
|
||||
"نیاز به تعویض سپر جلو",
|
||||
);
|
||||
expect(getFieldValue(report, "قیمت قطعات", "قطعه ۱ / نام قطعه")).toBe(
|
||||
"سپر جلو",
|
||||
);
|
||||
expect(getFieldValue(report, "قیمت قطعات", "قطعه ۱ / قیمت قطعه")).toBe(
|
||||
"۲٬۵۰۰٬۰۰۰ تومان",
|
||||
);
|
||||
expect(getFieldValue(report, "قیمت قطعات", "قطعه ۱ / مبلغ کل")).toBe(
|
||||
"۳٬۰۰۰٬۰۰۰ تومان",
|
||||
);
|
||||
});
|
||||
|
||||
it("localizes legacy English car-body environmental conditions", () => {
|
||||
const report = buildInsurerFileReport({
|
||||
overview: { publicId: "A00012" },
|
||||
blame: {
|
||||
type: "CAR_BODY",
|
||||
parties: [
|
||||
{
|
||||
role: "FIRST",
|
||||
person: { userId: "damaged", fullName: "بیمهگذار" },
|
||||
statement: {
|
||||
weatherCondition: "CLEAR",
|
||||
roadCondition: "wet",
|
||||
lightCondition: "LOW_LIGHT",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
expect(getFieldValue(report, PR.accidentSection, PR.weather)).toBe("صاف");
|
||||
expect(getFieldValue(report, PR.accidentSection, PR.road)).toBe("مرطوب");
|
||||
expect(getFieldValue(report, PR.accidentSection, PR.light)).toBe("کمنور");
|
||||
});
|
||||
|
||||
it("exposes the damage expert part-price result as a separate section", () => {
|
||||
const report = buildInsurerFileReport({
|
||||
overview: { publicId: "A00013" },
|
||||
claim: {
|
||||
claimStatus: "APPROVED",
|
||||
evaluation: {
|
||||
damageExpertReply: {
|
||||
description: "تعویض قطعه ضروری است",
|
||||
parts: [
|
||||
{
|
||||
carPartDamage: { label_fa: "چراغ جلو" },
|
||||
price: 4_000_000,
|
||||
totalPayment: 4_000_000,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(getFieldValue(report, "قیمت قطعات", "قطعه ۱ / نام قطعه")).toBe(
|
||||
"چراغ جلو",
|
||||
);
|
||||
expect(getFieldValue(report, "قیمت قطعات", "قطعه ۱ / قیمت قطعه")).toBe(
|
||||
"۴٬۰۰۰٬۰۰۰ تومان",
|
||||
);
|
||||
});
|
||||
|
||||
it("falls back to claim history for the evaluation submission time", () => {
|
||||
const report = buildInsurerFileReport({
|
||||
overview: { publicId: "A00014" },
|
||||
claim: {
|
||||
evaluation: {
|
||||
damageExpertReply: { description: "ارزیابی ثبت شد" },
|
||||
},
|
||||
history: [
|
||||
{
|
||||
type: "EXPERT_REPLY_SUBMITTED",
|
||||
timestamp: "2026-08-10T12:30:45.000Z",
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
expect(
|
||||
getFieldValue(report, PR.timelineSection, PR.evaluationRegisteredAt),
|
||||
).toBe("1405/05/19 16:00");
|
||||
expect(
|
||||
getFieldValue(report, PR.evaluationSection, PR.evaluationSubmittedAt),
|
||||
).toBe("1405/05/19 16:00");
|
||||
});
|
||||
|
||||
it("uses the stored V4 licence type for a driver who differs from the policyholder", () => {
|
||||
|
||||
Reference in New Issue
Block a user