diff --git a/src/expert-insurer/helper/timeline-fa-labels.spec.ts b/src/expert-insurer/helper/timeline-fa-labels.spec.ts index 86895f9..7eff8be 100644 --- a/src/expert-insurer/helper/timeline-fa-labels.spec.ts +++ b/src/expert-insurer/helper/timeline-fa-labels.spec.ts @@ -89,4 +89,49 @@ describe("insurer timeline Persian labels", () => { captureKey: "front", }); }); + + it("localizes the auto-resolved first-party confession reason", () => { + expect( + localizeTimelineMetadata({ + type: "AUTO_CONFESSION_SKIPPED", + metadata: { + reason: + "IN_PERSON expert-initiated: first party is always guilty; confession auto-resolved", + stepKey: "FIRST_BLAME_CONFESSION", + advancedTo: "FIRST_VIDEO", + }, + }), + ).toEqual({ + reason: + "در پرونده حضوری ایجادشده توسط کارشناس، طرف اول همیشه مقصر است؛ بنابراین مرحله اقرار به‌صورت خودکار تعیین تکلیف شد.", + stepKey: "FIRST_BLAME_CONFESSION", + advancedTo: "FIRST_VIDEO", + }); + }); + + it("localizes the call-center auto-confession reason", () => { + expect( + localizeTimelineMetadata({ + type: "AUTO_CONFESSION_SKIPPED", + metadata: { + reason: + "V6 call-center initiated: first party is always guilty; confession auto-resolved", + advancedTo: "FIRST_VIDEO", + }, + }), + ).toEqual({ + reason: + "در پرونده ایجادشده توسط مرکز تماس، طرف اول همیشه مقصر است؛ بنابراین مرحله اقرار به‌صورت خودکار تعیین تکلیف شد.", + advancedTo: "FIRST_VIDEO", + }); + }); + + it("preserves user-entered reasons that are not system messages", () => { + expect( + localizeTimelineMetadata({ + type: "V5_FILE_MAKER_REJECTED", + metadata: { reason: "تصویر کارت خودرو خوانا نیست" }, + }), + ).toEqual({ reason: "تصویر کارت خودرو خوانا نیست" }); + }); }); diff --git a/src/expert-insurer/helper/timeline-fa-labels.ts b/src/expert-insurer/helper/timeline-fa-labels.ts index 2bf59ae..c95cd0c 100644 --- a/src/expert-insurer/helper/timeline-fa-labels.ts +++ b/src/expert-insurer/helper/timeline-fa-labels.ts @@ -190,6 +190,13 @@ export const STEP_KEY_FA_LABELS: Record = { const GENERIC_EVENT_FA_LABEL = "رویداد پرونده"; const GENERIC_EVENT_FA_DESCRIPTION = "رویدادی در روند پرونده ثبت شد."; +const SYSTEM_REASON_FA_TRANSLATIONS: Record = { + "IN_PERSON expert-initiated: first party is always guilty; confession auto-resolved": + "در پرونده حضوری ایجادشده توسط کارشناس، طرف اول همیشه مقصر است؛ بنابراین مرحله اقرار به‌صورت خودکار تعیین تکلیف شد.", + "V6 call-center initiated: first party is always guilty; confession auto-resolved": + "در پرونده ایجادشده توسط مرکز تماس، طرف اول همیشه مقصر است؛ بنابراین مرحله اقرار به‌صورت خودکار تعیین تکلیف شد.", +}; + /** * Persian descriptions for workflow-step events. These are deliberately * complete sentences because the insurer timeline exposes them as the event @@ -276,10 +283,15 @@ export function localizeTimelineMetadata(event: { }): Record | null { if (!event.metadata) return null; + const reason = event.metadata.reason; + const localizedReason = + typeof reason === "string" ? SYSTEM_REASON_FA_TRANSLATIONS[reason] : null; + return { ...event.metadata, ...(Object.prototype.hasOwnProperty.call(event.metadata, "description") ? { description: getEventFaDescription(event) } : {}), + ...(localizedReason ? { reason: localizedReason } : {}), }; }