Merge pull request #235 from olaservo/add-tests

Add failing test to repro issue 154
This commit is contained in:
Cliff Hall
2025-04-01 12:23:55 -04:00
committed by GitHub

View File

@@ -16,6 +16,16 @@ describe("ToolsTab", () => {
}, },
}, },
}, },
{
name: "tool3",
description: "Integer tool",
inputSchema: {
type: "object" as const,
properties: {
count: { type: "integer" as const },
},
},
},
{ {
name: "tool2", name: "tool2",
description: "Second tool", description: "Second tool",
@@ -61,7 +71,7 @@ describe("ToolsTab", () => {
// Switch to second tool // Switch to second tool
rerender( rerender(
<Tabs defaultValue="tools"> <Tabs defaultValue="tools">
<ToolsTab {...defaultProps} selectedTool={mockTools[1]} /> <ToolsTab {...defaultProps} selectedTool={mockTools[2]} />
</Tabs>, </Tabs>,
); );
@@ -69,4 +79,24 @@ describe("ToolsTab", () => {
const newInput = screen.getByRole("spinbutton") as HTMLInputElement; const newInput = screen.getByRole("spinbutton") as HTMLInputElement;
expect(newInput.value).toBe(""); expect(newInput.value).toBe("");
}); });
it("should handle integer type inputs", () => {
renderToolsTab({
selectedTool: mockTools[1], // Use the tool with integer type
});
const input = screen.getByRole("spinbutton", {
name: /count/i,
}) as HTMLInputElement;
expect(input).toHaveProperty("type", "number");
fireEvent.change(input, { target: { value: "42" } });
expect(input.value).toBe("42");
const submitButton = screen.getByRole("button", { name: /run tool/i });
fireEvent.click(submitButton);
expect(defaultProps.callTool).toHaveBeenCalledWith(mockTools[1].name, {
count: 42,
});
});
}); });