import { applyDeprecations , configDeprecationFactory } from '@osd/config' ; import { config } from './opensearch_dashboards_config' ; const DEFAULT_CONFIG_PATH = 'opensearchDashboards' ; const LEGACY_CONFIG_PATH = 'kibana' ; const applyOpenSearchDashboardsDeprecations = ( settings = { } , path = DEFAULT_CONFIG_PATH ) => { const deprecations = config . deprecations ! ( configDeprecationFactory ) ; const deprecationMessages = [ ] ; const _config = { } ; _config [ path ] = settings ; const migrated = applyDeprecations ( _config , deprecations . map ( ( deprecation ) => ( { deprecation , path , } ) ) , ( msg ) => deprecationMessages . push ( msg ) ) ; return { messages : deprecationMessages , migrated , } ; } ; const applyLegacyDeprecations = ( settings = { } ) => { return applyOpenSearchDashboardsDeprecations ( settings , LEGACY_CONFIG_PATH ) ; } ; describe ( 'deprecations' , ( ) => { it ( 'logs a warning if kibana.enabled is set and opensearchDashboards.enabled is not' , ( ) => { const { messages } = applyLegacyDeprecations ( { enabled : true } ) ; expect ( messages ) . toMatchInlineSnapshot ( `
        Array [
          "\\"kibana.enabled\\" is deprecated and has been replaced by \\"opensearchDashboards.enabled\\"",
        ]
      ` ) ; } ) ; it ( 'logs a warning if kibana.index is set and opensearchDashboards.index is not' , ( ) => { const { messages } = applyLegacyDeprecations ( { index : '' } ) ; expect ( messages ) . toMatchInlineSnapshot ( `
        Array [
          "\\"kibana.index\\" is deprecated and has been replaced by \\"opensearchDashboards.index\\"",
        ]
      ` ) ; } ) ; it ( 'logs a warning if kibana.autocompleteTerminateAfter is set and opensearchDashboards.autocompleteTerminateAfter is not' , ( ) => { const { messages } = applyLegacyDeprecations ( { autocompleteTerminateAfter : 100 } ) ; expect ( messages ) . toMatchInlineSnapshot ( `
        Array [
          "\\"kibana.autocompleteTerminateAfter\\" is deprecated and has been replaced by \\"opensearchDashboards.autocompleteTerminateAfter\\"",
        ]
      ` ) ; } ) ; it ( 'logs a warning if kibana.autocompleteTimeout is set and opensearchDashboards.autocompleteTimeout is not' , ( ) => { const { messages } = applyLegacyDeprecations ( { autocompleteTimeout : 100 } ) ; expect ( messages ) . toMatchInlineSnapshot ( `
        Array [
          "\\"kibana.autocompleteTimeout\\" is deprecated and has been replaced by \\"opensearchDashboards.autocompleteTimeout\\"",
        ]
      ` ) ; } ) ; } ) ;