import { useContext } from 'react' ; import type { ScopedHistory } from 'kibana/public' ; import { coreMock , themeServiceMock } from '../../../../../../src/core/public/mocks' ; import { dataPluginMock } from '../../../../../../src/plugins/data/public/mocks' ; import { savedObjectsPluginMock } from '../../../../../../src/plugins/saved_objects/public/mocks' ; import { SharePluginStart } from '../../../../../../src/plugins/share/public' ; import { Storage } from '../../../../../../src/plugins/kibana_utils/public' ; import type { AppDependencies } from '../app_dependencies' ; import { MlSharedContext } from './shared_context' ; import type { GetMlSharedImportsReturnType } from '../../shared_imports' ; import type { TriggersAndActionsUIPublicPluginStart } from '../../../../triggers_actions_ui/public' ; const coreSetup = coreMock . createSetup ( ) ; const coreStart = coreMock . createStart ( ) ; const dataStart = dataPluginMock . createStartContract ( ) ; coreStart . savedObjects . client . find = jest . fn ( ) . mockResolvedValue ( { savedObjects : [ ] } ) ; const appDependencies = { application : coreStart . application , chrome : coreStart . chrome , data : dataStart , docLinks : coreStart . docLinks , i18n : coreStart . i18n , notifications : coreSetup . notifications , uiSettings : coreStart . uiSettings , savedObjects : coreStart . savedObjects , storage : { get : jest . fn ( ) } as unknown as Storage , overlays : coreStart . overlays , theme : themeServiceMock . createStartContract ( ) , http : coreSetup . http , history : { } as ScopedHistory , savedObjectsPlugin : savedObjectsPluginMock . createStartContract ( ) , share : { urlGenerators : { getUrlGenerator : jest . fn ( ) } } as unknown as SharePluginStart , ml : { } as GetMlSharedImportsReturnType , triggersActionsUi : { } as jest . Mocked < TriggersAndActionsUIPublicPluginStart > , } ; export const useAppDependencies = ( ) => { const ml = useContext ( MlSharedContext ) ; return { ... appDependencies , ml } ; } ; export const useToastNotifications = ( ) => { return { ... coreSetup . notifications , addDanger : jest . fn ( ) } ; } ;