@@ -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 : / n u l l / 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 : / r u n t o o l / 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