import { getEventFaDescription, getEventFaLabel, localizeTimelineMetadata, } from "./timeline-fa-labels"; describe("insurer timeline Persian labels", () => { it("localizes the user-submission detail shown to insurers", () => { const event = { type: "STEP_COMPLETED", metadata: { stepKey: "USER_SUBMISSION_COMPLETE", description: "User submission complete. Claim ready for damage expert review.", }, }; expect(getEventFaLabel(event)).toBe("ارسال اطلاعات توسط کاربر"); expect(getEventFaDescription(event)).toBe( "ثبت اطلاعات کاربر تکمیل شد و پرونده آماده بررسی کارشناس خسارت است.", ); }); it("never returns an English event type as the description fallback", () => { expect(getEventFaDescription({ type: "UNRECOGNIZED_EVENT" })).toBe( "رویدادی در روند پرونده ثبت شد.", ); }); it.each([ ["FIRST_INITIAL_FORM_SUBMITTED", "فرم اولیه طرف اول ثبت شد"], ["FIRST_LOCATION_SUBMITTED", "موقعیت مکانی طرف اول ثبت شد"], ["FIRST_VOICE_UPLOADED", "صدای طرف اول بارگذاری شد"], ["FIRST_DESCRIPTION_SUBMITTED", "توضیحات طرف اول ثبت شد"], ["EXPERT_REPLY_SUBMITTED", "پاسخ کارشناس ثبت شد"], ])("localizes sample timeline event %s", (type, expectedLabel) => { expect(getEventFaLabel({ type })).toBe(expectedLabel); }); it("uses a Persian faLabel fallback for an unknown event type", () => { expect(getEventFaLabel({ type: "UNRECOGNIZED_EVENT" })).toBe( "رویداد پرونده", ); }); it("preserves human-readable assignment metadata exactly", () => { expect( localizeTimelineMetadata({ type: "CLAIM_ASSIGNED", metadata: { note: "Expert assigned via review assign endpoint" }, }), ).toEqual({ note: "Expert assigned via review assign endpoint", }); }); it("preserves Fanavaran metadata keys and values exactly", () => { expect( localizeTimelineMetadata({ type: "FANAVARAN_EXPERTISE_AUTO_SUBMIT_FAILED", metadata: { clientKey: "parsian", error: "Fanavaran expertise payload is not ready.", }, }), ).toEqual({ clientKey: "parsian", error: "Fanavaran expertise payload is not ready.", }); }); it("does not add fields to existing metadata", () => { expect( localizeTimelineMetadata({ type: "STEP_COMPLETED", metadata: { role: "FIRST", stepKey: "USER_SUBMISSION_COMPLETE", carType: "sedan", captureType: "angle", captureKey: "front", }, }), ).toEqual({ role: "FIRST", stepKey: "USER_SUBMISSION_COMPLETE", carType: "sedan", captureType: "angle", 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: "تصویر کارت خودرو خوانا نیست" }); }); });