fix(chat): clarify approval mode and verify permission prompts
This commit is contained in:
@@ -79,7 +79,7 @@ const approvalModeOptions: ReadonlyArray<{
|
|||||||
{
|
{
|
||||||
value: "always",
|
value: "always",
|
||||||
label: "始终允许",
|
label: "始终允许",
|
||||||
description: "除明确禁止项外自动放行",
|
description: "常规权限自动放行,敏感路径仍需确认",
|
||||||
icon: WarningAmberRounded,
|
icon: WarningAmberRounded,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
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<HTMLDivElement>) => (
|
||||||
|
<div {...props}>{children}</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
describe("PermissionRequestGroup", () => {
|
||||||
|
it("shows an external path approval request and forwards the user's decision", () => {
|
||||||
|
const onReply = jest.fn();
|
||||||
|
render(
|
||||||
|
<ThemeProvider theme={createTheme()}>
|
||||||
|
<PermissionRequestGroup
|
||||||
|
permissions={[
|
||||||
|
{
|
||||||
|
requestId: "external-1",
|
||||||
|
sessionId: "session-1",
|
||||||
|
permission: "external_directory",
|
||||||
|
patterns: ["/app/private/*"],
|
||||||
|
target: "/app/private/report.json",
|
||||||
|
always: ["/app/private/*"],
|
||||||
|
createdAt: 1,
|
||||||
|
status: "pending",
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
isRunning
|
||||||
|
onReply={onReply}
|
||||||
|
/>
|
||||||
|
</ThemeProvider>,
|
||||||
|
);
|
||||||
|
|
||||||
|
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");
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user