File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -173,12 +173,13 @@ const ToolsTab = ({
173
173
name = { key }
174
174
placeholder = { prop . description }
175
175
value = { ( params [ key ] as string ) ?? "" }
176
- onChange = { ( e ) =>
176
+ onChange = { ( e ) => {
177
+ const value = e . target . value ;
177
178
setParams ( {
178
179
...params ,
179
- [ key ] : Number ( e . target . value ) ,
180
- } )
181
- }
180
+ [ key ] : value === "" ? "" : Number ( value ) ,
181
+ } ) ;
182
+ } }
182
183
className = "mt-1"
183
184
/>
184
185
) : (
Original file line number Diff line number Diff line change @@ -111,6 +111,27 @@ describe("ToolsTab", () => {
111
111
} ) ;
112
112
} ) ;
113
113
114
+ it ( "should allow typing negative numbers" , async ( ) => {
115
+ renderToolsTab ( {
116
+ selectedTool : mockTools [ 0 ] ,
117
+ } ) ;
118
+
119
+ const input = screen . getByRole ( "spinbutton" ) as HTMLInputElement ;
120
+
121
+ // Complete the negative number
122
+ fireEvent . change ( input , { target : { value : "-42" } } ) ;
123
+ expect ( input . value ) . toBe ( "-42" ) ;
124
+
125
+ const submitButton = screen . getByRole ( "button" , { name : / r u n t o o l / i } ) ;
126
+ await act ( async ( ) => {
127
+ fireEvent . click ( submitButton ) ;
128
+ } ) ;
129
+
130
+ expect ( defaultProps . callTool ) . toHaveBeenCalledWith ( mockTools [ 0 ] . name , {
131
+ num : - 42 ,
132
+ } ) ;
133
+ } ) ;
134
+
114
135
it ( "should disable button and change text while tool is running" , async ( ) => {
115
136
// Create a promise that we can resolve later
116
137
let resolvePromise : ( ( value : unknown ) => void ) | undefined ;
You can’t perform that action at this time.
0 commit comments