add UI spec

This commit is contained in:
Greg Saab 2025-10-08 13:04:57 -04:00
commit 6dd62d3a6d

View file

@ -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;