import React from "react"; import { fireEvent, render, screen } from "@testing-library/react"; import { ThemeProvider, createTheme } from "@mui/material/styles"; import { PermissionRequestGroup } from "./AgentPermissionRequests"; jest.mock("framer-motion", () => ({ AnimatePresence: ({ children }: { children: React.ReactNode }) => <>{children}, motion: { div: ({ children, ...props }: React.HTMLAttributes) => (
{children}
), }, })); describe("PermissionRequestGroup", () => { it("shows an external path approval request and forwards the user's decision", () => { const onReply = jest.fn(); render( , ); expect(screen.getByText("访问工作区外目录")).toBeInTheDocument(); expect(screen.getByText("/app/private/report.json")).toBeInTheDocument(); fireEvent.click(screen.getByRole("button", { name: "允许一次" })); expect(onReply).toHaveBeenCalledWith("external-1", "once"); fireEvent.click(screen.getByRole("button", { name: "保存授权" })); expect(onReply).toHaveBeenCalledWith("external-1", "always"); }); });