@@ -3,15 +3,12 @@ import type { Collection } from "mongodb";
33import  { 
44    databaseCollectionInvalidArgs , 
55    databaseCollectionParameters , 
6-     defaultDriverOptions , 
7-     defaultTestConfig , 
86    getDataFromUntrustedContent , 
97    getResponseContent , 
10-     setupIntegrationTest , 
118    validateThrowsForInvalidArguments , 
129    validateToolMetadata , 
1310}  from  "../../../helpers.js" ; 
14- import  {  describeWithMongoDB ,   setupMongoDBIntegrationTest  }  from  "../mongodbHelpers.js" ; 
11+ import  {  defaultTestSuiteConfig ,   describeWithMongoDB  }  from  "../mongodbHelpers.js" ; 
1512import  {  createMockElicitInput  }  from  "../../../../utils/elicitationMocks.js" ; 
1613import  {  Elicitation  }  from  "../../../../../src/elicitation.js" ; 
1714
@@ -113,69 +110,71 @@ describeWithMongoDB("drop-index tool", (integration) => {
113110    } ) ; 
114111} ) ; 
115112
116- describe ( "drop-index tool - when invoked via an elicitation enabled client" ,  ( )  =>  { 
117-     const  mockElicitInput  =  createMockElicitInput ( ) ; 
118-     const  mdbIntegration  =  setupMongoDBIntegrationTest ( ) ; 
119-     const  integration  =  setupIntegrationTest ( 
120-         ( )  =>  defaultTestConfig , 
121-         ( )  =>  defaultDriverOptions , 
122-         {  elicitInput : mockElicitInput  } 
123-     ) ; 
124-     let  moviesCollection : Collection ; 
125-     let  indexName : string ; 
113+ const  mockElicitInput  =  createMockElicitInput ( ) ; 
126114
127-     beforeEach ( async  ( )  =>  { 
128-         moviesCollection  =  mdbIntegration . mongoClient ( ) . db ( "mflix" ) . collection ( "movies" ) ; 
129-         await  moviesCollection . insertMany ( [ 
130-             {  name : "Movie1" ,  year : 1994  } , 
131-             {  name : "Movie2" ,  year : 2001  } , 
132-         ] ) ; 
133-         indexName  =  await  moviesCollection . createIndex ( {  year : 1  } ) ; 
134-         await  integration . mcpClient ( ) . callTool ( { 
135-             name : "connect" , 
136-             arguments : { 
137-                 connectionString : mdbIntegration . connectionString ( ) , 
138-             } , 
139-         } ) ; 
140-     } ) ; 
141- 
142-     afterEach ( async  ( )  =>  { 
143-         await  moviesCollection . drop ( ) ; 
144-     } ) ; 
115+ describeWithMongoDB ( 
116+     "drop-index tool - when invoked via an elicitation enabled client" , 
117+     ( integration )  =>  { 
118+         let  moviesCollection : Collection ; 
119+         let  indexName : string ; 
145120
146-     it ( "should ask for confirmation before proceeding with tool call" ,  async  ( )  =>  { 
147-         expect ( await  moviesCollection . listIndexes ( ) . toArray ( ) ) . toHaveLength ( 2 ) ; 
148-         mockElicitInput . confirmYes ( ) ; 
149-         await  integration . mcpClient ( ) . callTool ( { 
150-             name : "drop-index" , 
151-             arguments : {  database : "mflix" ,  collection : "movies" ,  indexName } , 
121+         beforeEach ( async  ( )  =>  { 
122+             moviesCollection  =  integration . mongoClient ( ) . db ( "mflix" ) . collection ( "movies" ) ; 
123+             await  moviesCollection . insertMany ( [ 
124+                 {  name : "Movie1" ,  year : 1994  } , 
125+                 {  name : "Movie2" ,  year : 2001  } , 
126+             ] ) ; 
127+             indexName  =  await  moviesCollection . createIndex ( {  year : 1  } ) ; 
128+             await  integration . mcpClient ( ) . callTool ( { 
129+                 name : "connect" , 
130+                 arguments : { 
131+                     connectionString : integration . connectionString ( ) , 
132+                 } , 
133+             } ) ; 
152134        } ) ; 
153-         expect ( mockElicitInput . mock ) . toHaveBeenCalledTimes ( 1 ) ; 
154-         expect ( mockElicitInput . mock ) . toHaveBeenCalledWith ( { 
155-             // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment 
156-             message : expect . stringContaining ( 
157-                 "You are about to drop the `year_1` index from the `mflix.movies` namespace" 
158-             ) , 
159-             requestedSchema : Elicitation . CONFIRMATION_SCHEMA , 
135+ 
136+         afterEach ( async  ( )  =>  { 
137+             await  moviesCollection . drop ( ) ; 
160138        } ) ; 
161-         expect ( await  moviesCollection . listIndexes ( ) . toArray ( ) ) . toHaveLength ( 1 ) ; 
162-     } ) ; 
163139
164-     it ( "should not drop the index if the confirmation was not provided" ,  async  ( )  =>  { 
165-         expect ( await  moviesCollection . listIndexes ( ) . toArray ( ) ) . toHaveLength ( 2 ) ; 
166-         mockElicitInput . confirmNo ( ) ; 
167-         await  integration . mcpClient ( ) . callTool ( { 
168-             name : "drop-index" , 
169-             arguments : {  database : "mflix" ,  collection : "movies" ,  indexName } , 
140+         it ( "should ask for confirmation before proceeding with tool call" ,  async  ( )  =>  { 
141+             expect ( await  moviesCollection . listIndexes ( ) . toArray ( ) ) . toHaveLength ( 2 ) ; 
142+             mockElicitInput . confirmYes ( ) ; 
143+             await  integration . mcpClient ( ) . callTool ( { 
144+                 name : "drop-index" , 
145+                 arguments : {  database : "mflix" ,  collection : "movies" ,  indexName } , 
146+             } ) ; 
147+             expect ( mockElicitInput . mock ) . toHaveBeenCalledTimes ( 1 ) ; 
148+             expect ( mockElicitInput . mock ) . toHaveBeenCalledWith ( { 
149+                 // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment 
150+                 message : expect . stringContaining ( 
151+                     "You are about to drop the `year_1` index from the `mflix.movies` namespace" 
152+                 ) , 
153+                 requestedSchema : Elicitation . CONFIRMATION_SCHEMA , 
154+             } ) ; 
155+             expect ( await  moviesCollection . listIndexes ( ) . toArray ( ) ) . toHaveLength ( 1 ) ; 
170156        } ) ; 
171-         expect ( mockElicitInput . mock ) . toHaveBeenCalledTimes ( 1 ) ; 
172-         expect ( mockElicitInput . mock ) . toHaveBeenCalledWith ( { 
173-             // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment 
174-             message : expect . stringContaining ( 
175-                 "You are about to drop the `year_1` index from the `mflix.movies` namespace" 
176-             ) , 
177-             requestedSchema : Elicitation . CONFIRMATION_SCHEMA , 
157+ 
158+         it ( "should not drop the index if the confirmation was not provided" ,  async  ( )  =>  { 
159+             expect ( await  moviesCollection . listIndexes ( ) . toArray ( ) ) . toHaveLength ( 2 ) ; 
160+             mockElicitInput . confirmNo ( ) ; 
161+             await  integration . mcpClient ( ) . callTool ( { 
162+                 name : "drop-index" , 
163+                 arguments : {  database : "mflix" ,  collection : "movies" ,  indexName } , 
164+             } ) ; 
165+             expect ( mockElicitInput . mock ) . toHaveBeenCalledTimes ( 1 ) ; 
166+             expect ( mockElicitInput . mock ) . toHaveBeenCalledWith ( { 
167+                 // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment 
168+                 message : expect . stringContaining ( 
169+                     "You are about to drop the `year_1` index from the `mflix.movies` namespace" 
170+                 ) , 
171+                 requestedSchema : Elicitation . CONFIRMATION_SCHEMA , 
172+             } ) ; 
173+             expect ( await  moviesCollection . listIndexes ( ) . toArray ( ) ) . toHaveLength ( 2 ) ; 
178174        } ) ; 
179-         expect ( await  moviesCollection . listIndexes ( ) . toArray ( ) ) . toHaveLength ( 2 ) ; 
180-     } ) ; 
181- } ) ; 
175+     } , 
176+     { 
177+         ...defaultTestSuiteConfig , 
178+         getMockElicitationInput : ( )  =>  mockElicitInput , 
179+     } 
180+ ) ; 
0 commit comments