fix: unify chat process and reply presentation
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
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(<AgentToolProgress item={{ id: "tool", phase: "tool", status: "completed", title: "已完成", tool: { name: "mcp_tjwater_geocode", input: { address, radius: 500 } }, detail: "legacy secret summary" }} />);
|
||||
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(<AgentToolProgress item={{ id: "old", phase: "tool", status: "running", title: "正在调用 mcp_tjwater_query_nearby_elements", detail: "历史参数:radius=500" }} />);
|
||||
expect(screen.getByText("mcp_tjwater_query_nearby_elements")).toBeTruthy();
|
||||
expect(screen.getByText("历史参数:radius=500")).toBeTruthy();
|
||||
expect(container.querySelector("details")?.open).toBe(false);
|
||||
});
|
||||
Reference in New Issue
Block a user