@@ -5,6 +5,7 @@ import ToolsTab from "../ToolsTab";
5
5
import { Tool } from "@modelcontextprotocol/sdk/types.js" ;
6
6
import { Tabs } from "@/components/ui/tabs" ;
7
7
import { cacheToolOutputSchemas } from "@/utils/schemaUtils" ;
8
+ import { within } from "@testing-library/react" ;
8
9
9
10
describe ( "ToolsTab" , ( ) => {
10
11
beforeEach ( ( ) => {
@@ -556,4 +557,84 @@ describe("ToolsTab", () => {
556
557
expect ( mockOnReadResource ) . toHaveBeenCalledTimes ( 1 ) ;
557
558
} ) ;
558
559
} ) ;
560
+
561
+ describe ( "Meta Display" , ( ) => {
562
+ const toolWithMeta = {
563
+ name : "metaTool" ,
564
+ description : "Tool with meta" ,
565
+ inputSchema : {
566
+ type : "object" as const ,
567
+ properties : {
568
+ foo : { type : "string" as const } ,
569
+ } ,
570
+ } ,
571
+ _meta : {
572
+ author : "tester" ,
573
+ version : 1 ,
574
+ } ,
575
+ } as unknown as Tool ;
576
+
577
+ it ( "should display meta section when tool has _meta" , ( ) => {
578
+ renderToolsTab ( {
579
+ tools : [ toolWithMeta ] ,
580
+ selectedTool : toolWithMeta ,
581
+ } ) ;
582
+
583
+ expect ( screen . getByText ( "Meta:" ) ) . toBeInTheDocument ( ) ;
584
+ expect (
585
+ screen . getByRole ( "button" , { name : / e x p a n d / i } ) ,
586
+ ) . toBeInTheDocument ( ) ;
587
+ } ) ;
588
+
589
+ it ( "should toggle meta expansion" , ( ) => {
590
+ renderToolsTab ( {
591
+ tools : [ toolWithMeta ] ,
592
+ selectedTool : toolWithMeta ,
593
+ } ) ;
594
+
595
+ // There might be multiple Expand buttons (Output Schema, Meta). We need the one within Meta section
596
+ const metaHeading = screen . getByText ( "Meta:" ) ;
597
+ const metaContainer = metaHeading . closest ( "div" ) ;
598
+ expect ( metaContainer ) . toBeTruthy ( ) ;
599
+ const toggleButton = within ( metaContainer as HTMLElement ) . getByRole (
600
+ "button" ,
601
+ { name : / e x p a n d / i } ,
602
+ ) ;
603
+
604
+ // Expand Meta
605
+ fireEvent . click ( toggleButton ) ;
606
+ expect (
607
+ within ( metaContainer as HTMLElement ) . getByRole ( "button" , {
608
+ name : / c o l l a p s e / i,
609
+ } ) ,
610
+ ) . toBeInTheDocument ( ) ;
611
+
612
+ // Collapse Meta
613
+ fireEvent . click ( toggleButton ) ;
614
+ expect (
615
+ within ( metaContainer as HTMLElement ) . getByRole ( "button" , {
616
+ name : / e x p a n d / i,
617
+ } ) ,
618
+ ) . toBeInTheDocument ( ) ;
619
+ } ) ;
620
+ } ) ;
621
+
622
+ describe ( "ToolResults Meta" , ( ) => {
623
+ it ( "should display meta information when present in toolResult" , ( ) => {
624
+ const resultWithMeta = {
625
+ content : [ ] ,
626
+ _meta : { info : "details" , version : 2 } ,
627
+ } ;
628
+
629
+ renderToolsTab ( {
630
+ selectedTool : mockTools [ 0 ] ,
631
+ toolResult : resultWithMeta ,
632
+ } ) ;
633
+
634
+ // Only ToolResults meta should be present since selectedTool has no _meta
635
+ expect ( screen . getAllByText ( "Meta:" ) ) . toHaveLength ( 1 ) ;
636
+ expect ( screen . getByText ( / i n f o / i) ) . toBeInTheDocument ( ) ;
637
+ expect ( screen . getByText ( / v e r s i o n / i) ) . toBeInTheDocument ( ) ;
638
+ } ) ;
639
+ } ) ;
559
640
} ) ;
0 commit comments