11import { render , screen , fireEvent } from "@testing-library/react" ;
22import { describe , it , beforeEach , jest } from "@jest/globals" ;
33import Sidebar from "../Sidebar" ;
4- import { DEFAULT_INSPECTOR_CONFIG } from "../../lib/constants" ;
5- import { InspectorConfig } from "../../lib/configurationTypes" ;
4+ import { DEFAULT_INSPECTOR_CONFIG } from "@/lib/constants" ;
5+ import { InspectorConfig } from "@/lib/configurationTypes" ;
6+ import { TooltipProvider } from "@/components/ui/tooltip" ;
67
78// Mock theme hook
89jest . mock ( "../../lib/useTheme" , ( ) => ( {
@@ -36,11 +37,15 @@ describe("Sidebar Environment Variables", () => {
3637 } ;
3738
3839 const renderSidebar = ( props = { } ) => {
39- return render ( < Sidebar { ...defaultProps } { ...props } /> ) ;
40+ return render (
41+ < TooltipProvider >
42+ < Sidebar { ...defaultProps } { ...props } />
43+ </ TooltipProvider > ,
44+ ) ;
4045 } ;
4146
4247 const openEnvVarsSection = ( ) => {
43- const button = screen . getByText ( "Environment Variables ") ;
48+ const button = screen . getByTestId ( "env-vars-button ") ;
4449 fireEvent . click ( button ) ;
4550 } ;
4651
@@ -216,7 +221,11 @@ describe("Sidebar Environment Variables", () => {
216221 const updatedEnv = setEnv . mock . calls [ 0 ] [ 0 ] as Record < string , string > ;
217222
218223 // Rerender with the updated env
219- rerender ( < Sidebar { ...defaultProps } env = { updatedEnv } setEnv = { setEnv } /> ) ;
224+ rerender (
225+ < TooltipProvider >
226+ < Sidebar { ...defaultProps } env = { updatedEnv } setEnv = { setEnv } />
227+ </ TooltipProvider > ,
228+ ) ;
220229
221230 // Second key edit
222231 const secondKeyInput = screen . getByDisplayValue ( "SECOND_KEY" ) ;
@@ -247,7 +256,11 @@ describe("Sidebar Environment Variables", () => {
247256 fireEvent . change ( keyInput , { target : { value : "NEW_KEY" } } ) ;
248257
249258 // Rerender with updated env
250- rerender ( < Sidebar { ...defaultProps } env = { { NEW_KEY : "test_value" } } /> ) ;
259+ rerender (
260+ < TooltipProvider >
261+ < Sidebar { ...defaultProps } env = { { NEW_KEY : "test_value" } } />
262+ </ TooltipProvider > ,
263+ ) ;
251264
252265 // Value should still be visible
253266 const updatedValueInput = screen . getByDisplayValue ( "test_value" ) ;
@@ -312,7 +325,7 @@ describe("Sidebar Environment Variables", () => {
312325
313326 describe ( "Configuration Operations" , ( ) => {
314327 const openConfigSection = ( ) => {
315- const button = screen . getByText ( "Configuration ") ;
328+ const button = screen . getByTestId ( "config-button ") ;
316329 fireEvent . click ( button ) ;
317330 } ;
318331
@@ -327,12 +340,14 @@ describe("Sidebar Environment Variables", () => {
327340 ) ;
328341 fireEvent . change ( timeoutInput , { target : { value : "5000" } } ) ;
329342
330- expect ( setConfig ) . toHaveBeenCalledWith ( {
331- MCP_SERVER_REQUEST_TIMEOUT : {
332- description : "Timeout for requests to the MCP server (ms)" ,
333- value : 5000 ,
334- } ,
335- } ) ;
343+ expect ( setConfig ) . toHaveBeenCalledWith (
344+ expect . objectContaining ( {
345+ MCP_SERVER_REQUEST_TIMEOUT : {
346+ description : "Timeout for requests to the MCP server (ms)" ,
347+ value : 5000 ,
348+ } ,
349+ } ) ,
350+ ) ;
336351 } ) ;
337352
338353 it ( "should handle invalid timeout values entered by user" , ( ) => {
@@ -346,12 +361,14 @@ describe("Sidebar Environment Variables", () => {
346361 ) ;
347362 fireEvent . change ( timeoutInput , { target : { value : "abc1" } } ) ;
348363
349- expect ( setConfig ) . toHaveBeenCalledWith ( {
350- MCP_SERVER_REQUEST_TIMEOUT : {
351- description : "Timeout for requests to the MCP server (ms)" ,
352- value : 0 ,
353- } ,
354- } ) ;
364+ expect ( setConfig ) . toHaveBeenCalledWith (
365+ expect . objectContaining ( {
366+ MCP_SERVER_REQUEST_TIMEOUT : {
367+ description : "Timeout for requests to the MCP server (ms)" ,
368+ value : 0 ,
369+ } ,
370+ } ) ,
371+ ) ;
355372 } ) ;
356373
357374 it ( "should maintain configuration state after multiple updates" , ( ) => {
@@ -362,7 +379,6 @@ describe("Sidebar Environment Variables", () => {
362379 } ) ;
363380
364381 openConfigSection ( ) ;
365-
366382 // First update
367383 const timeoutInput = screen . getByTestId (
368384 "MCP_SERVER_REQUEST_TIMEOUT-input" ,
@@ -374,11 +390,13 @@ describe("Sidebar Environment Variables", () => {
374390
375391 // Rerender with the updated config
376392 rerender (
377- < Sidebar
378- { ...defaultProps }
379- config = { updatedConfig }
380- setConfig = { setConfig }
381- /> ,
393+ < TooltipProvider >
394+ < Sidebar
395+ { ...defaultProps }
396+ config = { updatedConfig }
397+ setConfig = { setConfig }
398+ />
399+ </ TooltipProvider > ,
382400 ) ;
383401
384402 // Second update
@@ -388,12 +406,14 @@ describe("Sidebar Environment Variables", () => {
388406 fireEvent . change ( updatedTimeoutInput , { target : { value : "3000" } } ) ;
389407
390408 // Verify the final state matches what we expect
391- expect ( setConfig ) . toHaveBeenLastCalledWith ( {
392- MCP_SERVER_REQUEST_TIMEOUT : {
393- description : "Timeout for requests to the MCP server (ms)" ,
394- value : 3000 ,
395- } ,
396- } ) ;
409+ expect ( setConfig ) . toHaveBeenLastCalledWith (
410+ expect . objectContaining ( {
411+ MCP_SERVER_REQUEST_TIMEOUT : {
412+ description : "Timeout for requests to the MCP server (ms)" ,
413+ value : 3000 ,
414+ } ,
415+ } ) ,
416+ ) ;
397417 } ) ;
398418 } ) ;
399419} ) ;
0 commit comments