99import { BehaviorSubject , Observable } from 'rxjs' ;
1010import { first , take } from 'rxjs/operators' ;
1111
12- import { mockApplyDeprecations } from './config_service.test.mocks' ;
12+ import { mockApplyDeprecations , mockedChangedPaths } from './config_service.test.mocks' ;
1313import { rawConfigServiceMock } from './raw/raw_config_service.mock' ;
1414
1515import { schema } from '@kbn/config-schema' ;
@@ -420,7 +420,7 @@ test('logs deprecation warning during validation', async () => {
420420 const addDeprecation = createAddDeprecation ! ( '' ) ;
421421 addDeprecation ( { message : 'some deprecation message' } ) ;
422422 addDeprecation ( { message : 'another deprecation message' } ) ;
423- return config ;
423+ return { config, changedPaths : mockedChangedPaths } ;
424424 } ) ;
425425
426426 loggerMock . clear ( logger ) ;
@@ -446,12 +446,12 @@ test('does not log warnings for silent deprecations during validation', async ()
446446 const addDeprecation = createAddDeprecation ! ( '' ) ;
447447 addDeprecation ( { message : 'some deprecation message' , silent : true } ) ;
448448 addDeprecation ( { message : 'another deprecation message' } ) ;
449- return config ;
449+ return { config, changedPaths : mockedChangedPaths } ;
450450 } )
451451 . mockImplementationOnce ( ( config , deprecations , createAddDeprecation ) => {
452452 const addDeprecation = createAddDeprecation ! ( '' ) ;
453453 addDeprecation ( { message : 'I am silent' , silent : true } ) ;
454- return config ;
454+ return { config, changedPaths : mockedChangedPaths } ;
455455 } ) ;
456456
457457 loggerMock . clear ( logger ) ;
@@ -521,7 +521,7 @@ describe('getHandledDeprecatedConfigs', () => {
521521 const addDeprecation = createAddDeprecation ! ( deprecation . path ) ;
522522 addDeprecation ( { message : `some deprecation message` , documentationUrl : 'some-url' } ) ;
523523 } ) ;
524- return config ;
524+ return { config, changedPaths : mockedChangedPaths } ;
525525 } ) ;
526526
527527 await configService . validate ( ) ;
@@ -541,3 +541,18 @@ describe('getHandledDeprecatedConfigs', () => {
541541 ` ) ;
542542 } ) ;
543543} ) ;
544+
545+ describe ( 'getDeprecatedConfigPath$' , ( ) => {
546+ it ( 'returns all config paths changes during deprecation' , async ( ) => {
547+ const rawConfig$ = new BehaviorSubject < Record < string , any > > ( { key : 'value' } ) ;
548+ const rawConfigProvider = rawConfigServiceMock . create ( { rawConfig$ } ) ;
549+
550+ const configService = new ConfigService ( rawConfigProvider , defaultEnv , logger ) ;
551+ await configService . setSchema ( 'key' , schema . string ( ) ) ;
552+ await configService . validate ( ) ;
553+
554+ const deprecatedConfigPath$ = configService . getDeprecatedConfigPath$ ( ) ;
555+ const deprecatedConfigPath = await deprecatedConfigPath$ . pipe ( first ( ) ) . toPromise ( ) ;
556+ expect ( deprecatedConfigPath ) . toEqual ( mockedChangedPaths ) ;
557+ } ) ;
558+ } ) ;
0 commit comments