Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed type and mock issue
  • Loading branch information
clintandrewhall committed Jan 19, 2022
commit f1bba3b31ffbc3d205d088fabaf7210198566287
25 changes: 25 additions & 0 deletions src/plugins/engagement/public/mocks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { EngagementPluginSetup, EngagementPluginStart } from './types';

function createEngagementPluginSetup(): jest.Mocked<EngagementPluginSetup> {
const mock: jest.Mocked<EngagementPluginSetup> = {};
return mock;
}

function createEngagementPluginStart(): jest.Mocked<EngagementPluginStart> {
return {
ContextProvider: jest.fn(),
};
}

export const engagementMock = {
createSetup: createEngagementPluginSetup,
createStart: createEngagementPluginStart,
};
2 changes: 1 addition & 1 deletion src/plugins/engagement/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class EngagementPlugin
const drift = config?.drift || _config.drift || { enabled: false };

return {
ServicesContext: ({ children }) => (
ContextProvider: ({ children }) => (
<sharedUX.ServicesContext>
<ServicesProvider drift={drift}>{children}</ServicesProvider>
</sharedUX.ServicesContext>
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/engagement/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export interface EngagementPluginStart {
/**
* A React component that provides a pre-wired `React.Context` which connects components to Engagement services.
*/
ServicesContext: FC<{}>;
ContextProvider: FC<{}>;
}

/** @internal */
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/fleet/public/applications/integrations/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export const IntegrationsAppContext: React.FC<{
<UIExtensionsContext.Provider value={extensions}>
<FleetStatusProvider>
<startServices.customIntegrations.ContextProvider>
<startServices.engagement.ServicesContext>
<startServices.engagement.ContextProvider>
<Router history={history}>
<AgentPolicyContextProvider>
<PackageInstallProvider
Expand All @@ -87,7 +87,7 @@ export const IntegrationsAppContext: React.FC<{
</PackageInstallProvider>
</AgentPolicyContextProvider>
</Router>
</startServices.engagement.ServicesContext>
</startServices.engagement.ContextProvider>
</startServices.customIntegrations.ContextProvider>
</FleetStatusProvider>
</UIExtensionsContext.Provider>
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/fleet/public/mock/plugin_dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { homePluginMock } from '../../../../../src/plugins/home/public/mocks';
import { navigationPluginMock } from '../../../../../src/plugins/navigation/public/mocks';
import { customIntegrationsMock } from '../../../../../src/plugins/custom_integrations/public/mocks';
import { sharePluginMock } from '../../../../../src/plugins/share/public/mocks';
import { engagementMock } from '../../../../../src/plugins/engagement/public/mocks';

import type { MockedFleetSetupDeps, MockedFleetStartDeps } from './types';

Expand All @@ -29,5 +30,6 @@ export const createStartDepsMock = (): MockedFleetStartDeps => {
navigation: navigationPluginMock.createStartContract(),
customIntegrations: customIntegrationsMock.createStart(),
share: sharePluginMock.createStartContract(),
engagement: engagementMock.createStart(),
};
};