@@ -6,10 +6,13 @@ import { ObservabilityManager } from '@microsoft/agents-a365-observability/src/O
66import { ObservabilityConfiguration } from '@microsoft/agents-a365-observability/src/configuration/ObservabilityConfiguration' ;
77import { DefaultConfigurationProvider } from '@microsoft/agents-a365-runtime' ;
88
9- // Capture Agent365Exporter constructor options without performing network calls.
9+ // Capture Agent365Exporter constructor args without performing network calls.
1010jest . mock ( '@microsoft/agents-a365-observability/src/tracing/exporter/Agent365Exporter' , ( ) => ( {
1111 Agent365Exporter : class {
12- constructor ( opts : any ) { ( global as any ) . __capturedOpts = opts ; }
12+ constructor ( opts : any , configProvider ?: any ) {
13+ ( global as any ) . __capturedOpts = opts ;
14+ ( global as any ) . __capturedConfigProvider = configProvider ;
15+ }
1316 export ( ) { /* no-op */ }
1417 shutdown ( ) { /* no-op */ }
1518 forceFlush ( ) { /* no-op */ }
@@ -30,11 +33,13 @@ const makeProvider = (exporterEnabled?: boolean) =>
3033 } ) ) ;
3134
3235const capturedOpts = ( ) => ( global as any ) . __capturedOpts as any | undefined ;
36+ const capturedConfigProvider = ( ) => ( global as any ) . __capturedConfigProvider as any | undefined ;
3337
3438describe ( 'ObservabilityBuilder configProvider' , ( ) => {
3539 beforeEach ( ( ) => {
3640 delete process . env . ENABLE_A365_OBSERVABILITY_EXPORTER ;
3741 delete ( global as any ) . __capturedOpts ;
42+ delete ( global as any ) . __capturedConfigProvider ;
3843 capturedLogger = null ;
3944 jest . spyOn ( console , 'log' ) . mockImplementation ( ( ) => { } ) ;
4045 jest . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
@@ -44,6 +49,10 @@ describe('ObservabilityBuilder configProvider', () => {
4449 afterEach ( async ( ) => {
4550 delete process . env . ENABLE_A365_OBSERVABILITY_EXPORTER ;
4651 await ObservabilityManager . shutdown ( ) ;
52+ const actualLogging = jest . requireActual ( '@microsoft/agents-a365-observability/src/utils/logging' ) as any ;
53+ if ( typeof actualLogging . resetLogger === 'function' ) {
54+ actualLogging . resetLogger ( ) ;
55+ }
4756 jest . restoreAllMocks ( ) ;
4857 } ) ;
4958
@@ -61,7 +70,8 @@ describe('ObservabilityBuilder configProvider', () => {
6170 . build ( ) ;
6271
6372 expect ( capturedOpts ( ) ) . toBeDefined ( ) ;
64- expect ( capturedOpts ( ) . configProvider ) . toBe ( provider ) ;
73+ expect ( capturedConfigProvider ( ) ) . toBe ( provider ) ;
74+ expect ( capturedOpts ( ) . configProvider ) . toBeUndefined ( ) ;
6575 expect ( capturedOpts ( ) . maxQueueSize ) . toBe ( 42 ) ;
6676 expect ( capturedOpts ( ) . tokenResolver ( 'a' , 'b' ) ) . toBe ( 'tok' ) ;
6777 } ) ;
@@ -90,12 +100,12 @@ describe('ObservabilityBuilder configProvider', () => {
90100 process . env . ENABLE_A365_OBSERVABILITY_EXPORTER = 'true' ;
91101 new ObservabilityBuilder ( ) . withTokenResolver ( ( ) => 't' ) . build ( ) ;
92102 expect ( capturedOpts ( ) ) . toBeDefined ( ) ;
93- expect ( capturedOpts ( ) . configProvider ) . toBeUndefined ( ) ;
103+ expect ( capturedConfigProvider ( ) ) . toBeUndefined ( ) ;
94104 } ) ;
95105
96106 it ( 'ObservabilityManager.start() passes configProvider through to exporter' , ( ) => {
97107 const provider = makeProvider ( true ) ;
98108 ObservabilityManager . start ( { serviceName : 'svc' , tokenResolver : ( ) => 't' , configProvider : provider } ) ;
99- expect ( capturedOpts ( ) ?. configProvider ) . toBe ( provider ) ;
109+ expect ( capturedConfigProvider ( ) ) . toBe ( provider ) ;
100110 } ) ;
101111} ) ;
0 commit comments