import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import { afterEach, expect, it, vi } from "vitest";
import { AgentToolProgress } from "./agent-tool-progress";
vi.mock("use-stick-to-bottom", () => ({ useStickToBottomContext: () => ({ scrollRef: { current: null }, stopScroll: vi.fn() }) }));
afterEach(cleanup);
it("keeps full structured parameters collapsed until the tool row opens", () => {
const address = "完整地址".repeat(70);
const { container } = render();
const details = container.querySelector("details")!;
expect(details.open).toBe(false);
expect(screen.getByText("mcp_tjwater_geocode")).toBeTruthy();
expect(container.querySelector("pre")?.textContent).toContain(address);
expect(screen.queryByText("legacy secret summary")).toBeNull();
fireEvent.click(container.querySelector("summary")!);
expect(details.open).toBe(true);
});
it("retains historical details and removes the old status text from the tool label", () => {
const { container } = render();
expect(screen.getByText("mcp_tjwater_query_nearby_elements")).toBeTruthy();
expect(screen.getByText("历史参数:radius=500")).toBeTruthy();
expect(container.querySelector("details")?.open).toBe(false);
});