@@ -1962,73 +1962,6 @@ describe('useGeminiStream', () => {
19621962 } ) ;
19631963 } ) ;
19641964
1965- describe ( 'MCP Discovery State' , ( ) => {
1966- it ( 'should block non-slash command queries when discovery is in progress and servers exist' , async ( ) => {
1967- const mockMcpClientManager = {
1968- getDiscoveryState : vi
1969- . fn ( )
1970- . mockReturnValue ( MCPDiscoveryState . IN_PROGRESS ) ,
1971- getMcpServerCount : vi . fn ( ) . mockReturnValue ( 1 ) ,
1972- } ;
1973- mockConfig . getMcpClientManager = ( ) => mockMcpClientManager as any ;
1974-
1975- const { result } = renderTestHook ( ) ;
1976-
1977- await act ( async ( ) => {
1978- await result . current . submitQuery ( 'test query' ) ;
1979- } ) ;
1980-
1981- expect ( coreEvents . emitFeedback ) . toHaveBeenCalledWith (
1982- 'info' ,
1983- 'Waiting for MCP servers to initialize... Slash commands are still available.' ,
1984- ) ;
1985- expect ( mockSendMessageStream ) . not . toHaveBeenCalled ( ) ;
1986- } ) ;
1987-
1988- it ( 'should NOT block queries when discovery is NOT_STARTED but there are no servers' , async ( ) => {
1989- const mockMcpClientManager = {
1990- getDiscoveryState : vi
1991- . fn ( )
1992- . mockReturnValue ( MCPDiscoveryState . NOT_STARTED ) ,
1993- getMcpServerCount : vi . fn ( ) . mockReturnValue ( 0 ) ,
1994- } ;
1995- mockConfig . getMcpClientManager = ( ) => mockMcpClientManager as any ;
1996-
1997- const { result } = renderTestHook ( ) ;
1998-
1999- await act ( async ( ) => {
2000- await result . current . submitQuery ( 'test query' ) ;
2001- } ) ;
2002-
2003- expect ( coreEvents . emitFeedback ) . not . toHaveBeenCalledWith (
2004- 'info' ,
2005- 'Waiting for MCP servers to initialize... Slash commands are still available.' ,
2006- ) ;
2007- expect ( mockSendMessageStream ) . toHaveBeenCalled ( ) ;
2008- } ) ;
2009-
2010- it ( 'should NOT block slash commands even when discovery is in progress' , async ( ) => {
2011- const mockMcpClientManager = {
2012- getDiscoveryState : vi
2013- . fn ( )
2014- . mockReturnValue ( MCPDiscoveryState . IN_PROGRESS ) ,
2015- getMcpServerCount : vi . fn ( ) . mockReturnValue ( 1 ) ,
2016- } ;
2017- mockConfig . getMcpClientManager = ( ) => mockMcpClientManager as any ;
2018-
2019- const { result } = renderTestHook ( ) ;
2020-
2021- await act ( async ( ) => {
2022- await result . current . submitQuery ( '/help' ) ;
2023- } ) ;
2024-
2025- expect ( coreEvents . emitFeedback ) . not . toHaveBeenCalledWith (
2026- 'info' ,
2027- 'Waiting for MCP servers to initialize... Slash commands are still available.' ,
2028- ) ;
2029- } ) ;
2030- } ) ;
2031-
20321965 describe ( 'handleFinishedEvent' , ( ) => {
20331966 it ( 'should add info message for MAX_TOKENS finish reason' , async ( ) => {
20341967 // Setup mock to return a stream with MAX_TOKENS finish reason
@@ -3182,68 +3115,4 @@ describe('useGeminiStream', () => {
31823115 } ) ;
31833116 } ) ;
31843117 } ) ;
3185-
3186- describe ( 'MCP Server Initialization' , ( ) => {
3187- it ( 'should allow slash commands to run while MCP servers are initializing' , async ( ) => {
3188- const mockMcpClientManager = {
3189- getDiscoveryState : vi
3190- . fn ( )
3191- . mockReturnValue ( MCPDiscoveryState . IN_PROGRESS ) ,
3192- getMcpServerCount : vi . fn ( ) . mockReturnValue ( 1 ) ,
3193- } ;
3194- mockConfig . getMcpClientManager = ( ) => mockMcpClientManager as any ;
3195-
3196- const { result } = renderTestHook ( ) ;
3197-
3198- await act ( async ( ) => {
3199- await result . current . submitQuery ( '/help' ) ;
3200- } ) ;
3201-
3202- // Slash command should be handled, and no Gemini call should be made.
3203- expect ( mockHandleSlashCommand ) . toHaveBeenCalledWith ( '/help' ) ;
3204- expect ( coreEvents . emitFeedback ) . not . toHaveBeenCalled ( ) ;
3205- } ) ;
3206-
3207- it ( 'should block normal prompts and provide feedback while MCP servers are initializing' , async ( ) => {
3208- const mockMcpClientManager = {
3209- getDiscoveryState : vi
3210- . fn ( )
3211- . mockReturnValue ( MCPDiscoveryState . IN_PROGRESS ) ,
3212- getMcpServerCount : vi . fn ( ) . mockReturnValue ( 1 ) ,
3213- } ;
3214- mockConfig . getMcpClientManager = ( ) => mockMcpClientManager as any ;
3215- const { result } = renderTestHook ( ) ;
3216-
3217- await act ( async ( ) => {
3218- await result . current . submitQuery ( 'a normal prompt' ) ;
3219- } ) ;
3220-
3221- // No slash command, no Gemini call, but feedback should be emitted.
3222- expect ( mockHandleSlashCommand ) . not . toHaveBeenCalled ( ) ;
3223- expect ( mockSendMessageStream ) . not . toHaveBeenCalled ( ) ;
3224- expect ( coreEvents . emitFeedback ) . toHaveBeenCalledWith (
3225- 'info' ,
3226- 'Waiting for MCP servers to initialize... Slash commands are still available.' ,
3227- ) ;
3228- } ) ;
3229-
3230- it ( 'should allow normal prompts to run when MCP servers are finished initializing' , async ( ) => {
3231- const mockMcpClientManager = {
3232- getDiscoveryState : vi . fn ( ) . mockReturnValue ( MCPDiscoveryState . COMPLETED ) ,
3233- getMcpServerCount : vi . fn ( ) . mockReturnValue ( 1 ) ,
3234- } ;
3235- mockConfig . getMcpClientManager = ( ) => mockMcpClientManager as any ;
3236-
3237- const { result } = renderTestHook ( ) ;
3238-
3239- await act ( async ( ) => {
3240- await result . current . submitQuery ( 'a normal prompt' ) ;
3241- } ) ;
3242-
3243- // Prompt should be sent to Gemini.
3244- expect ( mockHandleSlashCommand ) . not . toHaveBeenCalled ( ) ;
3245- expect ( mockSendMessageStream ) . toHaveBeenCalled ( ) ;
3246- expect ( coreEvents . emitFeedback ) . not . toHaveBeenCalled ( ) ;
3247- } ) ;
3248- } ) ;
32493118} ) ;
0 commit comments