@@ -12,6 +12,7 @@ vi.mock("@src/i18n/TranslationContext", () => ({
1212 "mcp:tool.alwaysAllow" : "Always allow" ,
1313 "mcp:tool.parameters" : "Parameters" ,
1414 "mcp:tool.noDescription" : "No description" ,
15+ "mcp:tool.togglePromptInclusion" : "Toggle prompt inclusion" ,
1516 }
1617 return translations [ key ] || key
1718 } ,
@@ -48,6 +49,7 @@ describe("McpToolRow", () => {
4849 name : "test-tool" ,
4950 description : "A test tool" ,
5051 alwaysAllow : false ,
52+ enabledForPrompt : true ,
5153 }
5254
5355 beforeEach ( ( ) => {
@@ -141,4 +143,48 @@ describe("McpToolRow", () => {
141143 expect ( screen . getByText ( "First parameter" ) ) . toBeInTheDocument ( )
142144 expect ( screen . getByText ( "Second parameter" ) ) . toBeInTheDocument ( )
143145 } )
146+
147+ it ( "shows eye button when serverName is provided and not in chat context" , ( ) => {
148+ render ( < McpToolRow tool = { mockTool } serverName = "test-server" /> )
149+
150+ const eyeButton = screen . getByRole ( "button" , { name : "Toggle prompt inclusion" } )
151+ expect ( eyeButton ) . toBeInTheDocument ( )
152+ } )
153+
154+ it ( "hides eye button when isInChatContext is true" , ( ) => {
155+ render ( < McpToolRow tool = { mockTool } serverName = "test-server" isInChatContext = { true } /> )
156+
157+ const eyeButton = screen . queryByRole ( "button" , { name : "Toggle prompt inclusion" } )
158+ expect ( eyeButton ) . not . toBeInTheDocument ( )
159+ } )
160+
161+ it ( "shows correct eye icon based on enabledForPrompt state" , ( ) => {
162+ // Test when enabled (should show eye-closed icon)
163+ const { rerender } = render ( < McpToolRow tool = { mockTool } serverName = "test-server" /> )
164+
165+ let eyeIcon = screen . getByRole ( "button" , { name : "Toggle prompt inclusion" } ) . querySelector ( "span" )
166+ expect ( eyeIcon ) . toHaveClass ( "codicon-eye-closed" )
167+
168+ // Test when disabled (should show eye icon)
169+ const disabledTool = { ...mockTool , enabledForPrompt : false }
170+ rerender ( < McpToolRow tool = { disabledTool } serverName = "test-server" /> )
171+
172+ eyeIcon = screen . getByRole ( "button" , { name : "Toggle prompt inclusion" } ) . querySelector ( "span" )
173+ expect ( eyeIcon ) . toHaveClass ( "codicon-eye" )
174+ } )
175+
176+ it ( "sends message to toggle enabledForPrompt when eye button is clicked" , ( ) => {
177+ render ( < McpToolRow tool = { mockTool } serverName = "test-server" /> )
178+
179+ const eyeButton = screen . getByRole ( "button" , { name : "Toggle prompt inclusion" } )
180+ fireEvent . click ( eyeButton )
181+
182+ expect ( vscode . postMessage ) . toHaveBeenCalledWith ( {
183+ type : "toggleToolEnabledForPrompt" ,
184+ serverName : "test-server" ,
185+ source : "global" ,
186+ toolName : "test-tool" ,
187+ isEnabled : false ,
188+ } )
189+ } )
144190} )
0 commit comments