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:
2026-09-18 16:04:33 +03:30
parent a84d83a135
commit 7d1a50db7b
38 changed files with 2345 additions and 370 deletions
+21 -21
View File
@@ -43,36 +43,36 @@ describe("resolveSelectedPartByPartId", () => {
});
it("resolves catalog id from outer catalog when not on claim", () => {
const hit = resolveCatalogPartByPartId(201, ClaimVehicleTypeV2.HATCHBACK);
expect(hit?.id).toBe(201);
expect(hit?.side).toBe("left");
expect(hit?.catalogKey).toBe("left_backfender");
const hit = resolveCatalogPartByPartId(36, ClaimVehicleTypeV2.HATCHBACK);
expect(hit?.id).toBe(36);
expect(hit?.side).toBe("");
expect(hit?.catalogKey).toBe("36");
});
it("resolvePartForExpertReply uses catalog for new expert line", () => {
const hit = resolvePartForExpertReply(
201,
36,
[],
ClaimVehicleTypeV2.HATCHBACK,
);
expect(hit?.id).toBe(201);
expect(hit?.id).toBe(36);
});
it("sanitize fixes Persian side and re-hydrates from catalog id", () => {
const fixed = sanitizeDamageSelectedPartV2(
{
id: 201,
name: "گلگیر عقب (چپ)",
id: 36,
name: "گلگير عقب سمت راننده",
side: "چپ",
label_fa: "",
catalogKey: "چپ",
},
ClaimVehicleTypeV2.HATCHBACK,
);
expect(fixed.side).toBe("left");
expect(fixed.name).toBe("backfender");
expect(fixed.catalogKey).toBe("left_backfender");
expect(catalogPartIdFromSelectedPart(fixed)).toBe(201);
expect(fixed.side).toBe("");
expect(fixed.name).toBe("36");
expect(fixed.catalogKey).toBe("36");
expect(catalogPartIdFromSelectedPart(fixed)).toBe(36);
});
it("internal parts have null catalog partId", () => {
@@ -90,30 +90,30 @@ describe("resolveSelectedPartByPartId", () => {
const fixed = sanitizeDamageSelectedPartV2(
{
id: null,
name: "گلگیر عقب (چپ)",
name: "گلگير عقب سمت راننده",
side: "internal",
label_fa: "گلگیر عقب (چپ)",
label_fa: "گلگير عقب سمت راننده",
},
ClaimVehicleTypeV2.HATCHBACK,
);
expect(fixed.id).toBe(201);
expect(fixed.side).toBe("left");
expect(fixed.name).toBe("backfender");
expect(fixed.catalogKey).toBe("left_backfender");
expect(fixed.id).toBe(36);
expect(fixed.side).toBe("");
expect(fixed.name).toBe("36");
expect(fixed.catalogKey).toBe("36");
});
it("price drop resolves catalog id when claim row is corrupt", () => {
const corrupt: DamageSelectedPartV2[] = [
{
id: null,
name: "گلگیر عقب (چپ)",
name: "گلگير عقب سمت راننده",
side: "internal",
label_fa: "گلگیر عقب (چپ)",
label_fa: "گلگير عقب سمت راننده",
},
];
const { coefficients, errors } = buildCoefficientsFromPartSeverities(
corrupt,
[{ partId: 201, severity: "Minor" }],
[{ partId: 36, severity: "Minor" }],
ClaimVehicleTypeV2.HATCHBACK,
);
expect(errors).toHaveLength(0);