forked from Yara724/api
fix(reports): localize Persian reports and resolve person display names
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
import {
|
||||
PR,
|
||||
persianFieldPath,
|
||||
persianReportValue,
|
||||
persianStatus,
|
||||
} from "./persian-report-labels";
|
||||
import { buildInsurerFileReport } from "./case-expert-report.builder";
|
||||
import { ClaimCaseStatus } from "src/Types&Enums/claim-request-management/claim-case-status.enum";
|
||||
import { CaseStatus } from "src/Types&Enums/blame-request-management/caseStatus.enum";
|
||||
|
||||
describe("Persian report presentation", () => {
|
||||
it.each([...Object.values(ClaimCaseStatus), ...Object.values(CaseStatus)])(
|
||||
"translates persisted status %s",
|
||||
(status) => expect(persianStatus(status)).not.toMatch(/[a-z]/i),
|
||||
);
|
||||
it("uses meaningful Persian labels and suppresses unknown provider field keys", () => {
|
||||
expect(persianFieldPath("party.vehicle.vin")).toBe(
|
||||
"خودرو / شماره شناسایی خودرو",
|
||||
);
|
||||
expect(
|
||||
persianFieldPath("party.vehicle.inquiry.unmappedProviderField"),
|
||||
).toBe("");
|
||||
expect(persianReportValue("vehicle.expedited", true)).toBe("فوری");
|
||||
expect(persianReportValue("vehicle.carType", "sedan")).toBe("سواری");
|
||||
expect(persianReportValue("vehicle.status", "NEW_UNKNOWN_STATUS")).toBe(
|
||||
"وضعیت نامشخص",
|
||||
);
|
||||
});
|
||||
it("keeps factual identifiers intact, uses phones for unnamed users and keeps driver/owner identities separate", () => {
|
||||
const vin = "IR1ABC23456789012";
|
||||
const report = buildInsurerFileReport({
|
||||
overview: { publicId: "QA-1" },
|
||||
blame: {
|
||||
type: "CAR_BODY",
|
||||
status: "COMPLETED",
|
||||
parties: [
|
||||
{
|
||||
role: "FIRST",
|
||||
person: {
|
||||
userId: "650000000000000000000001",
|
||||
fullName: "1234567890",
|
||||
phoneNumber: "09120000000",
|
||||
driverIsInsurer: false,
|
||||
nationalCodeOfDriver: "1111111111",
|
||||
driverLicense: "987654321",
|
||||
},
|
||||
participants: [
|
||||
{
|
||||
participantId: "driver",
|
||||
fullName: "حسن احمدی",
|
||||
nationalCode: "1111111111",
|
||||
birthday: "1370/01/01",
|
||||
},
|
||||
],
|
||||
participantRoles: { driver: "driver" },
|
||||
vehicle: {
|
||||
vin,
|
||||
carType: "sedan",
|
||||
unknownProviderField: "DO_NOT_SHOW",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
claim: {
|
||||
owner: { userId: "650000000000000000000001" },
|
||||
evaluation: {
|
||||
damageExpertReply: {
|
||||
parts: [
|
||||
{
|
||||
carPartDamage: { label_fa: "گلگیر جلو" },
|
||||
typeOfDamage: "تعویض",
|
||||
price: "2000000",
|
||||
totalPayment: "3000000",
|
||||
factorNeeded: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
const fields = report.sections.flatMap((section) => section.fields);
|
||||
expect(fields.every((field) => !/[a-z]/i.test(field.label))).toBe(true);
|
||||
expect(fields.some((field) => field.value === vin)).toBe(true);
|
||||
expect(fields.some((field) => field.value === "DO_NOT_SHOW")).toBe(false);
|
||||
expect(
|
||||
report.sections
|
||||
.find((section) => section.title === PR.ownerSection)
|
||||
?.fields.find((field) => field.label === PR.name)?.value,
|
||||
).toBe("09120000000");
|
||||
const driver = report.sections.find(
|
||||
(section) => section.title === PR.driverSection,
|
||||
);
|
||||
expect(driver?.fields.find((field) => field.label === PR.name)?.value).toBe(
|
||||
"حسن احمدی",
|
||||
);
|
||||
expect(
|
||||
driver?.fields.find((field) => field.label === PR.licenseDate),
|
||||
).toBeUndefined();
|
||||
expect(fields.some((field) => field.value === "۲٬۰۰۰٬۰۰۰ ریال")).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user