@@ -648,6 +648,144 @@ describe("Sidebar Environment Variables", () => {
648648 } ) ;
649649 } ) ;
650650
651+ describe ( "Headers Operations" , ( ) => {
652+ const openHeadersSection = ( ) => {
653+ const button = screen . getByTestId ( "headers-button" ) ;
654+ fireEvent . click ( button ) ;
655+ } ;
656+
657+ it ( "should add a new header" , ( ) => {
658+ const setConfig = jest . fn ( ) ;
659+ renderSidebar ( { config : DEFAULT_INSPECTOR_CONFIG , setConfig } ) ;
660+
661+ openHeadersSection ( ) ;
662+
663+ const addButton = screen . getByTestId ( "add-header-button" ) ;
664+ fireEvent . click ( addButton ) ;
665+
666+ expect ( setConfig ) . toHaveBeenCalledWith (
667+ expect . objectContaining ( {
668+ MCP_CUSTOM_HEADERS : {
669+ label : "Custom Headers" ,
670+ description : "Custom headers for authentication with the MCP server (stored as JSON array)" ,
671+ value : '[{"name":"","value":""}]' ,
672+ is_session_item : true ,
673+ } ,
674+ } ) ,
675+ ) ;
676+ } ) ;
677+
678+ it ( "should update header name" , ( ) => {
679+ const setConfig = jest . fn ( ) ;
680+ const config = {
681+ ...DEFAULT_INSPECTOR_CONFIG ,
682+ MCP_CUSTOM_HEADERS : {
683+ ...DEFAULT_INSPECTOR_CONFIG . MCP_CUSTOM_HEADERS ,
684+ value : '[{"name":"","value":""}]' ,
685+ } ,
686+ } ;
687+
688+ renderSidebar ( { config, setConfig } ) ;
689+
690+ openHeadersSection ( ) ;
691+
692+ const headerNameInput = screen . getByTestId ( "header-name-0" ) ;
693+
694+ fireEvent . change ( headerNameInput , { target : { value : "X-API-Key" } } ) ;
695+
696+ expect ( setConfig ) . toHaveBeenCalledWith (
697+ expect . objectContaining ( {
698+ MCP_CUSTOM_HEADERS : {
699+ label : "Custom Headers" ,
700+ description : "Custom headers for authentication with the MCP server (stored as JSON array)" ,
701+ value : '[{"name":"X-API-Key","value":""}]' ,
702+ is_session_item : true ,
703+ } ,
704+ } ) ,
705+ ) ;
706+ } ) ;
707+
708+ it ( "should update header value" , ( ) => {
709+ const setConfig = jest . fn ( ) ;
710+ const config = {
711+ ...DEFAULT_INSPECTOR_CONFIG ,
712+ MCP_CUSTOM_HEADERS : {
713+ ...DEFAULT_INSPECTOR_CONFIG . MCP_CUSTOM_HEADERS ,
714+ value : '[{"name":"","value":""}]' ,
715+ } ,
716+ } ;
717+
718+ renderSidebar ( { config, setConfig } ) ;
719+
720+ openHeadersSection ( ) ;
721+
722+ const headerValueInput = screen . getByTestId ( "header-value-0" ) ;
723+
724+ fireEvent . change ( headerValueInput , { target : { value : "secret-key-123" } } ) ;
725+
726+ expect ( setConfig ) . toHaveBeenCalledWith (
727+ expect . objectContaining ( {
728+ MCP_CUSTOM_HEADERS : {
729+ label : "Custom Headers" ,
730+ description : "Custom headers for authentication with the MCP server (stored as JSON array)" ,
731+ value : '[{"name":"","value":"secret-key-123"}]' ,
732+ is_session_item : true ,
733+ } ,
734+ } ) ,
735+ ) ;
736+ } ) ;
737+
738+ it ( "should remove a header" , ( ) => {
739+ const setConfig = jest . fn ( ) ;
740+ const config = {
741+ ...DEFAULT_INSPECTOR_CONFIG ,
742+ MCP_CUSTOM_HEADERS : {
743+ ...DEFAULT_INSPECTOR_CONFIG . MCP_CUSTOM_HEADERS ,
744+ value : '[{"name":"X-API-Key","value":"secret-key-123"}]' ,
745+ } ,
746+ } ;
747+
748+ renderSidebar ( { config, setConfig } ) ;
749+
750+ openHeadersSection ( ) ;
751+
752+ const removeButton = screen . getByTestId ( "remove-header-0" ) ;
753+ fireEvent . click ( removeButton ) ;
754+
755+ expect ( setConfig ) . toHaveBeenCalledWith (
756+ expect . objectContaining ( {
757+ MCP_CUSTOM_HEADERS : {
758+ label : "Custom Headers" ,
759+ description : "Custom headers for authentication with the MCP server (stored as JSON array)" ,
760+ value : "[]" ,
761+ is_session_item : true ,
762+ } ,
763+ } ) ,
764+ ) ;
765+ } ) ;
766+
767+ it ( "should handle multiple headers" , ( ) => {
768+ const setConfig = jest . fn ( ) ;
769+ const config = {
770+ ...DEFAULT_INSPECTOR_CONFIG ,
771+ MCP_CUSTOM_HEADERS : {
772+ ...DEFAULT_INSPECTOR_CONFIG . MCP_CUSTOM_HEADERS ,
773+ value : '[{"name":"X-API-Key","value":"key1"},{"name":"Authorization","value":"Bearer token"}]' ,
774+ } ,
775+ } ;
776+
777+ renderSidebar ( { config, setConfig } ) ;
778+
779+ openHeadersSection ( ) ;
780+
781+ // Verify both headers are displayed
782+ expect ( screen . getByTestId ( "header-name-0" ) ) . toHaveValue ( "X-API-Key" ) ;
783+ expect ( screen . getByTestId ( "header-value-0" ) ) . toHaveValue ( "key1" ) ;
784+ expect ( screen . getByTestId ( "header-name-1" ) ) . toHaveValue ( "Authorization" ) ;
785+ expect ( screen . getByTestId ( "header-value-1" ) ) . toHaveValue ( "Bearer token" ) ;
786+ } ) ;
787+ } ) ;
788+
651789 describe ( "Copy Configuration Features" , ( ) => {
652790 beforeEach ( ( ) => {
653791 jest . clearAllMocks ( ) ;
0 commit comments