import type { PublicMethodsOf } from '@osd/utility-types' ; import { OpenSearchDashboardsMigrator , OpenSearchDashboardsMigratorStatus , } from './opensearch_dashboards_migrator' ; import { buildActiveMappings } from '../core' ; const { mergeTypes } = jest . requireActual ( './opensearch_dashboards_migrator' ) ; import { SavedObjectsType } from '../../types' ; import { BehaviorSubject } from 'rxjs' ; const defaultSavedObjectTypes = [ { name : 'testtype' , hidden : false , namespaceType : 'single' , mappings : { properties : { name : { type : 'keyword' } , } , } , migrations : { } , } , ] ; const createMigrator = ( { types , } = { types : defaultSavedObjectTypes } ) => { const mockMigrator = { runMigrations : jest . fn ( ) , getActiveMappings : jest . fn ( ) , migrateDocument : jest . fn ( ) , getStatus$ : jest . fn ( ( ) => new BehaviorSubject < OpenSearchDashboardsMigratorStatus > ( { status : 'completed' , result : [ { status : 'migrated' , destIndex : '.test-opensearch-dashboards_2' , sourceIndex : '.test-opensearch-dashboards_1' , elapsedMs : 10 , } , ] , } ) ) , } ; mockMigrator . getActiveMappings . mockReturnValue ( buildActiveMappings ( mergeTypes ( types ) ) ) ; mockMigrator . migrateDocument . mockImplementation ( ( doc ) => doc ) ; return mockMigrator ; } ; export const mockOpenSearchDashboardsMigrator = { create : createMigrator , } ;