import "@testing-library/jest-dom"; import { fireEvent, render, screen } from "@testing-library/react"; import { AgentActivityTimeline } from "./AgentActivityTimeline"; describe("AgentActivityTimeline", () => { it("shows only the first lines of a long tool command until expanded", () => { const target = [ "cd /app/data/conversation-workspaces/conversation-example", "python3 - <<'EOF'", "import json, glob", "print('fourth line')", "EOF", ].join("\n"); render( , ); fireEvent.click(screen.getByRole("button", { name: "展开分析过程" })); expect(screen.getByText(/import json, glob/u)).toBeInTheDocument(); expect(screen.queryByText(/fourth line/u)).not.toBeInTheDocument(); expect(screen.getByText("help data")).toBeInTheDocument(); expect(screen.getByRole("button", { name: "展开完整内容" })).toHaveAttribute( "aria-expanded", "false", ); fireEvent.click(screen.getByRole("button", { name: "展开完整内容" })); expect(screen.getByText(/fourth line/u)).toBeInTheDocument(); expect(screen.getByRole("button", { name: "收起内容" })).toHaveAttribute( "aria-expanded", "true", ); fireEvent.click(screen.getByRole("button", { name: "收起内容" })); expect(screen.queryByText(/fourth line/u)).not.toBeInTheDocument(); }); });