From 6dd62d3a6d1a1c3b013fbed691d6b30d7e6554e6 Mon Sep 17 00:00:00 2001 From: Greg Saab Date: Wed, 8 Oct 2025 13:04:57 -0400 Subject: [PATCH] add UI spec --- .../components/__tests__/ToolsTab.test.tsx | 42 +++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/client/src/components/__tests__/ToolsTab.test.tsx b/client/src/components/__tests__/ToolsTab.test.tsx index a50f62df..a1d8f605 100644 --- a/client/src/components/__tests__/ToolsTab.test.tsx +++ b/client/src/components/__tests__/ToolsTab.test.tsx @@ -44,6 +44,16 @@ describe("ToolsTab", () => { }, }, }, + { + name: "tool4", + description: "Tool with nullable field", + inputSchema: { + type: "object" as const, + properties: { + num: { type: ["number", "null"] as const }, + }, + }, + }, ]; const defaultProps = { @@ -135,6 +145,38 @@ describe("ToolsTab", () => { }); }); + it("should allow specifying null value", async () => { + const mockCallTool = jest.fn(); + const toolWithNullableField = mockTools[3]; + + renderToolsTab({ + tools: [toolWithNullableField], + selectedTool: toolWithNullableField, + callTool: mockCallTool, + }); + + const nullToggleButton = screen.getByRole("checkbox", { name: /null/i }); + expect(nullToggleButton).toBeInTheDocument(); + + await act(async () => { + fireEvent.click(nullToggleButton); + }); + + expect(screen.getByRole("toolinputwrapper").classList).toContain( + "pointer-events-none", + ); + + const runButton = screen.getByRole("button", { name: /run tool/i }); + await act(async () => { + fireEvent.click(runButton); + }); + + // Tool should have been called with null value + expect(mockCallTool).toHaveBeenCalledWith(toolWithNullableField.name, { + num: null, + }); + }); + it("should disable button and change text while tool is running", async () => { // Create a promise that we can resolve later let resolvePromise: ((value: unknown) => void) | undefined;