@@ -40,7 +40,10 @@ function setupBaseMocks() {
4040}
4141
4242describe ( 'McpConnectionManager' , ( ) => {
43- let manager : { connect : Function ; dispose : Function } | null = null
43+ let manager : {
44+ connect : ( ...args : unknown [ ] ) => Promise < { supportsListChanged : boolean } >
45+ dispose : ( ) => void
46+ } | null = null
4447
4548 afterEach ( ( ) => {
4649 manager ?. dispose ( )
@@ -72,17 +75,14 @@ describe('McpConnectionManager', () => {
7275
7376 const config = serverConfig ( 'server-1' )
7477
75- // Fire two concurrent connect() calls for the same server
7678 const p1 = mgr . connect ( config , 'user-1' , 'ws-1' )
7779 const p2 = mgr . connect ( config , 'user-1' , 'ws-1' )
7880
7981 deferred . resolve ( )
8082 const [ r1 , r2 ] = await Promise . all ( [ p1 , p2 ] )
8183
82- // Only one McpClient should have been instantiated
8384 expect ( instances ) . toHaveLength ( 1 )
8485 expect ( r1 . supportsListChanged ) . toBe ( true )
85- // Second call hits the connectingServers guard and returns false
8686 expect ( r2 . supportsListChanged ) . toBe ( false )
8787 } )
8888
@@ -109,11 +109,9 @@ describe('McpConnectionManager', () => {
109109
110110 const config = serverConfig ( 'server-2' )
111111
112- // First connect — server doesn't support listChanged, disconnects immediately
113112 const r1 = await mgr . connect ( config , 'user-1' , 'ws-1' )
114113 expect ( r1 . supportsListChanged ) . toBe ( false )
115114
116- // connectingServers cleaned up via finally, so second connect proceeds
117115 const r2 = await mgr . connect ( config , 'user-1' , 'ws-1' )
118116 expect ( r2 . supportsListChanged ) . toBe ( false )
119117
@@ -148,11 +146,9 @@ describe('McpConnectionManager', () => {
148146
149147 const config = serverConfig ( 'server-3' )
150148
151- // First connect fails
152149 const r1 = await mgr . connect ( config , 'user-1' , 'ws-1' )
153150 expect ( r1 . supportsListChanged ) . toBe ( false )
154151
155- // Second connect should NOT be blocked by a stale connectingServers entry
156152 const r2 = await mgr . connect ( config , 'user-1' , 'ws-1' )
157153 expect ( r2 . supportsListChanged ) . toBe ( true )
158154 expect ( instances ) . toHaveLength ( 2 )
0 commit comments