Skip to content

Commit 6dd62d3

Browse files
committed
add UI spec
1 parent 6facce3 commit 6dd62d3

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

client/src/components/__tests__/ToolsTab.test.tsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ describe("ToolsTab", () => {
4444
},
4545
},
4646
},
47+
{
48+
name: "tool4",
49+
description: "Tool with nullable field",
50+
inputSchema: {
51+
type: "object" as const,
52+
properties: {
53+
num: { type: ["number", "null"] as const },
54+
},
55+
},
56+
},
4757
];
4858

4959
const defaultProps = {
@@ -135,6 +145,38 @@ describe("ToolsTab", () => {
135145
});
136146
});
137147

148+
it("should allow specifying null value", async () => {
149+
const mockCallTool = jest.fn();
150+
const toolWithNullableField = mockTools[3];
151+
152+
renderToolsTab({
153+
tools: [toolWithNullableField],
154+
selectedTool: toolWithNullableField,
155+
callTool: mockCallTool,
156+
});
157+
158+
const nullToggleButton = screen.getByRole("checkbox", { name: /null/i });
159+
expect(nullToggleButton).toBeInTheDocument();
160+
161+
await act(async () => {
162+
fireEvent.click(nullToggleButton);
163+
});
164+
165+
expect(screen.getByRole("toolinputwrapper").classList).toContain(
166+
"pointer-events-none",
167+
);
168+
169+
const runButton = screen.getByRole("button", { name: /run tool/i });
170+
await act(async () => {
171+
fireEvent.click(runButton);
172+
});
173+
174+
// Tool should have been called with null value
175+
expect(mockCallTool).toHaveBeenCalledWith(toolWithNullableField.name, {
176+
num: null,
177+
});
178+
});
179+
138180
it("should disable button and change text while tool is running", async () => {
139181
// Create a promise that we can resolve later
140182
let resolvePromise: ((value: unknown) => void) | undefined;

0 commit comments

Comments
 (0)