import { describe, expect, it, vi } from "vitest"; import { buildAssistantAddressLaneResponseRuntimeInput } from "../src/services/assistantAddressLaneResponseRuntimeInputBuilder"; function buildInput(overrides: Record = {}) { return { sessionId: "asst-1", userMessage: "where is settlement tail", effectiveAddressUserMessage: "where is settlement tail for Org A", addressLane: { reply_text: "address reply", reply_type: "factual_with_explanation", debug: {} }, carryoverMeta: { previousReplyType: "partial_coverage" }, llmPreDecomposeMeta: { mode: "supported", confidence: "high" }, knownOrganizations: ["Org A"], activeOrganization: "Org A", sanitizeOutgoingAssistantText: vi.fn((value: unknown, fallback = "") => { const text = String(value ?? "").trim(); return text || fallback; }), buildAddressDebugPayload: vi.fn(() => ({})), buildAddressFollowupOffer: vi.fn(() => null), mergeKnownOrganizations: vi.fn((values: string[]) => values), toNonEmptyString: vi.fn((value: unknown) => typeof value === "string" && value.trim().length > 0 ? value.trim() : null ), appendItem: vi.fn(), getSession: vi.fn(), persistSession: vi.fn(), cloneConversation: vi.fn((items: unknown[]) => items), logEvent: vi.fn(), messageIdFactory: vi.fn(() => "msg-1"), ...overrides } as any; } describe("assistant address lane response runtime input builder", () => { it("maps lane-response fields into runtime input", () => { const runtimeInput = buildAssistantAddressLaneResponseRuntimeInput(buildInput()); expect(runtimeInput.sessionId).toBe("asst-1"); expect(runtimeInput.effectiveAddressUserMessage).toBe("where is settlement tail for Org A"); expect(runtimeInput.knownOrganizations).toEqual(["Org A"]); expect(runtimeInput.carryoverMeta).toEqual({ previousReplyType: "partial_coverage" }); expect(runtimeInput.llmPreDecomposeMeta).toEqual({ mode: "supported", confidence: "high" }); }); });