import { cloneMessage } from "./globalChatboxUtils";
import type { Message } from "./GlobalChatbox.types";

describe("cloneMessage", () => {
  it("normalizes persisted question and todo arrays", () => {
    const message = {
      id: "assistant-1",
      role: "assistant",
      content: "需要补充信息",
      questions: [
        {
          requestId: "question-1",
          sessionId: "session-1",
          questions: [
            {
              header: "范围",
              question: "请选择分析范围",
            },
          ],
          createdAt: 1,
          status: "pending",
        },
      ],
      todos: {
        sessionId: "session-1",
        createdAt: 1,
      },
    } as unknown as Message;

    const cloned = cloneMessage(message);

    expect(cloned.questions?.[0]?.questions[0]?.options).toEqual([]);
    expect(cloned.todos?.todos).toEqual([]);
  });
});
