@@ -78,10 +78,11 @@ describe('ChatPlugin', () => {
7878 } ) ;
7979
8080 describe ( 'start' , ( ) => {
81- it ( 'should initialize chat service with configured AG-UI URL ' , ( ) => {
81+ it ( 'should initialize chat service when enabled ' , ( ) => {
8282 plugin . start ( mockCoreStart , mockDeps ) ;
8383
84- expect ( ChatService ) . toHaveBeenCalledWith ( 'http://test-ag-ui:3000' ) ;
84+ // ChatService is called without arguments (uses proxy endpoint)
85+ expect ( ChatService ) . toHaveBeenCalledWith ( ) ;
8586 } ) ;
8687
8788 it ( 'should register chat button in header nav controls' , ( ) => {
@@ -100,14 +101,17 @@ describe('ChatPlugin', () => {
100101 expect ( startContract . chatService ) . toBeInstanceOf ( ChatService ) ;
101102 } ) ;
102103
103- it ( 'should handle missing AG-UI URL configuration' , ( ) => {
104+ it ( 'should initialize chat service even without agUiUrl config' , ( ) => {
105+ // agUiUrl is server-side config only; client doesn't need it
104106 mockInitializerContext . config . get = jest . fn ( ) . mockReturnValue ( { enabled : true } ) ;
107+ const testPlugin = new ChatPlugin ( mockInitializerContext ) ;
105108
106- const startContract = plugin . start ( mockCoreStart , mockDeps ) ;
109+ const startContract = testPlugin . start ( mockCoreStart , mockDeps ) ;
107110
108- expect ( ChatService ) . not . toHaveBeenCalled ( ) ;
109- expect ( startContract . chatService ) . toBeUndefined ( ) ;
110- expect ( mockCoreStart . chrome . navControls . registerRight ) . not . toHaveBeenCalled ( ) ;
111+ // ChatService should still be created (uses proxy endpoint)
112+ expect ( ChatService ) . toHaveBeenCalledWith ( ) ;
113+ expect ( startContract . chatService ) . toBeInstanceOf ( ChatService ) ;
114+ expect ( mockCoreStart . chrome . navControls . registerRight ) . toHaveBeenCalled ( ) ;
111115 } ) ;
112116
113117 it ( 'should not initialize when plugin is disabled' , ( ) => {
@@ -272,19 +276,22 @@ describe('ChatPlugin', () => {
272276 { enabled : true , agUiUrl : 'http://localhost:3000' } ,
273277 { enabled : true , agUiUrl : 'https://remote-server:8080' } ,
274278 { enabled : false , agUiUrl : 'http://localhost:3000' } ,
275- { enabled : true } , // Missing agUiUrl
279+ { enabled : true } , // Missing agUiUrl (still works with proxy)
276280 { } , // Missing both enabled and agUiUrl
277281 ] ;
278282
279- configs . forEach ( ( config ) => {
283+ configs . forEach ( ( config , index ) => {
284+ jest . clearAllMocks ( ) ;
280285 mockInitializerContext . config . get = jest . fn ( ) . mockReturnValue ( config ) ;
281286 const testPlugin = new ChatPlugin ( mockInitializerContext ) ;
282287
283288 expect ( ( ) => testPlugin . start ( mockCoreStart , mockDeps ) ) . not . toThrow ( ) ;
284289
285- // Only first two configs should initialize the service
286- if ( config . enabled && config . agUiUrl ) {
287- expect ( ChatService ) . toHaveBeenCalledWith ( config . agUiUrl ) ;
290+ // ChatService is initialized whenever enabled is true (regardless of agUiUrl)
291+ if ( config . enabled ) {
292+ expect ( ChatService ) . toHaveBeenCalledWith ( ) ;
293+ } else {
294+ expect ( ChatService ) . not . toHaveBeenCalled ( ) ;
288295 }
289296 } ) ;
290297 } ) ;
0 commit comments