Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ export const AutoApproveSettings = ({
<Button
key={index}
variant="secondary"
className="bg-red-500/20 text-red-500 hover:bg-red-500/30"
data-testid={`remove-denied-command-${index}`}
onClick={() => {
const newCommands = (deniedCommands ?? []).filter((_, i) => i !== index)
Expand All @@ -384,7 +385,7 @@ export const AutoApproveSettings = ({
}}>
<div className="flex flex-row items-center gap-1">
<div>{cmd}</div>
<X className="text-foreground scale-75" />
<X className="text-red-500 scale-75" />
</div>
</Button>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -714,3 +714,65 @@ describe("SettingsView - Duplicate Commands", () => {
)
})
})

describe("SettingsView - Denied Commands", () => {
beforeEach(() => {
vi.clearAllMocks()
})

it("renders denied commands with red styling", () => {
const { activateTab, getSettingsContent } = renderSettingsView()

// Activate the autoApprove tab
activateTab("autoApprove")

const content = getSettingsContent()
// Enable always allow execute to show command sections
const executeCheckbox = within(content).getByTestId("always-allow-execute-toggle")
fireEvent.click(executeCheckbox)

// Add a denied command
const deniedInput = within(content).getByTestId("denied-command-input")
fireEvent.change(deniedInput, { target: { value: "rm -rf" } })
const addDeniedButton = within(content).getByTestId("add-denied-command-button")
fireEvent.click(addDeniedButton)

// Verify the denied command button has red styling classes
const deniedButton = within(content).getByTestId("remove-denied-command-0")
expect(deniedButton).toHaveClass("bg-red-500/20", "text-red-500")
})

it("adds and removes denied commands", () => {
const { activateTab, getSettingsContent } = renderSettingsView()

activateTab("autoApprove")

const content = getSettingsContent()
const executeCheckbox = within(content).getByTestId("always-allow-execute-toggle")
fireEvent.click(executeCheckbox)

// Add a denied command
const deniedInput = within(content).getByTestId("denied-command-input")
fireEvent.change(deniedInput, { target: { value: "rm" } })
const addDeniedButton = within(content).getByTestId("add-denied-command-button")
fireEvent.click(addDeniedButton)

// Verify command was added
expect(within(content).getByText("rm")).toBeInTheDocument()

// Verify VSCode message was sent
expect(vscode.postMessage).toHaveBeenCalledWith({
type: "updateSettings",
updatedSettings: {
deniedCommands: ["rm"],
},
})

// Remove the denied command
const removeButton = within(content).getByTestId("remove-denied-command-0")
fireEvent.click(removeButton)

// Verify command was removed
expect(within(content).queryByTestId("remove-denied-command-0")).not.toBeInTheDocument()
})
})
Loading