import assert from "node:assert/strict"; import test from "node:test"; import { DO_NOT_CONTACT_RECHECK_MS, FOLLOW_UP_DUE_DELAY_MS, getManualSalesStatusLabel, getFollowUpPromptState, getDoNotContactRecheckState, shouldCreateFollowUpDraftAfterSend, } from "../lib/outreach-follow-up"; test("manual sales statuses expose the German MVP labels", () => { assert.equal(getManualSalesStatusLabel("reply_received"), "Antwort erhalten"); assert.equal(getManualSalesStatusLabel("not_interested"), "Kein Interesse"); assert.equal(getManualSalesStatusLabel("later"), "Später wieder melden"); assert.equal(getManualSalesStatusLabel("meeting_scheduled"), "Gespräch vereinbart"); assert.equal(getManualSalesStatusLabel("proposal_requested"), "Angebot angefragt"); assert.equal(getManualSalesStatusLabel("proposal_sent"), "Angebot gesendet"); assert.equal(getManualSalesStatusLabel("won"), "Auftrag gewonnen"); assert.equal(getManualSalesStatusLabel("lost"), "Auftrag verloren"); assert.equal(getManualSalesStatusLabel("do_not_pursue"), "Nicht weiter verfolgen"); assert.equal(getManualSalesStatusLabel("follow_up_planned"), "Follow-up geplant"); assert.equal(getManualSalesStatusLabel("follow_up_sent"), "Follow-up gesendet"); }); test("initial send creates exactly one pending follow-up window", () => { const sentAt = Date.UTC(2026, 5, 5); assert.equal( shouldCreateFollowUpDraftAfterSend({ existingFollowUpOutreachCount: 0, followUpDraft: "Kurze Nachfrage", salesStatus: "follow_up_planned", sendStatus: "sent", }), true, ); assert.equal( getFollowUpPromptState({ followUpDueAt: sentAt + FOLLOW_UP_DUE_DELAY_MS, responseStatus: "none", salesStatus: "follow_up_planned", now: sentAt + FOLLOW_UP_DUE_DELAY_MS, }), "due", ); }); test("answers and no-interest statuses suppress pending follow-up prompts", () => { const dueAt = Date.UTC(2026, 5, 12); for (const salesStatus of ["reply_received", "not_interested"] as const) { assert.equal( getFollowUpPromptState({ followUpDueAt: dueAt, responseStatus: "none", salesStatus, now: dueAt + 1, }), "suppressed", ); } assert.equal( getFollowUpPromptState({ followUpDueAt: dueAt, responseStatus: "manual_reply_recorded", salesStatus: "follow_up_planned", now: dueAt + 1, }), "suppressed", ); }); test("do-not-contact blocks outreach for twelve months before recheck", () => { const markedAt = Date.UTC(2026, 0, 1); const recheckAt = markedAt + DO_NOT_CONTACT_RECHECK_MS; assert.deepEqual( getDoNotContactRecheckState({ doNotContactUntil: recheckAt, now: recheckAt - 1, }), { status: "blocked", label: "Nicht erneut kontaktieren" }, ); assert.deepEqual( getDoNotContactRecheckState({ doNotContactUntil: recheckAt, now: recheckAt, }), { status: "recheck", label: "Erneut prüfen" }, ); });