Trim whitespace from command on blur

This commit is contained in:
Richard Michael 2025-08-14 00:14:30 -07:00
commit 8d8af870ba
2 changed files with 33 additions and 0 deletions

View file

@ -268,6 +268,7 @@ const Sidebar = ({
placeholder="Command"
value={command}
onChange={(e) => setCommand(e.target.value)}
onBlur={(e) => setCommand(e.target.value.trim())}
className="font-mono"
/>
</div>

View file

@ -878,4 +878,36 @@ describe("Sidebar Environment Variables", () => {
expect(mockClipboardWrite).toHaveBeenCalledWith(expectedConfig);
});
});
describe("Command and arguments", () => {
it("should trim whitespace from command input on blur", () => {
const setCommand = jest.fn();
renderSidebar({ command: " node server.js ", setCommand });
const commandInput = screen.getByLabelText("Command");
fireEvent.blur(commandInput);
expect(setCommand).toHaveBeenLastCalledWith("node server.js");
});
it("should handle whitespace-only command input on blur", () => {
const setCommand = jest.fn();
renderSidebar({ command: " ", setCommand });
const commandInput = screen.getByLabelText("Command");
fireEvent.blur(commandInput);
expect(setCommand).toHaveBeenLastCalledWith("");
});
it("should not affect command without surrounding whitespace", () => {
const setCommand = jest.fn();
renderSidebar({ command: "node", setCommand });
const commandInput = screen.getByLabelText("Command");
fireEvent.blur(commandInput);
expect(setCommand).toHaveBeenLastCalledWith("node");
});
});
});