import { describe, expect, it } from "vitest";
import { countPendingAgentInputs, hasPendingAgentInput } from "./message-state";
import type { AgentChatMessage } from "./types";

describe("Agent message state", () => {
  it("counts pending and failed operator inputs from one shared rule", () => {
    const messages = [
      {
        id: "assistant-1",
        role: "assistant",
        content: "",
        permissions: [
          { status: "pending" },
          { status: "approved_once" }
        ],
        questions: [
          { status: "error" },
          { status: "answered" }
        ]
      }
    ] as AgentChatMessage[];

    expect(countPendingAgentInputs(messages)).toBe(2);
    expect(hasPendingAgentInput(messages)).toBe(true);
    expect(hasPendingAgentInput([])).toBe(false);
  });
});
