mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
xpack_main legacy plugin pre-removal cleanup (#76257)
* cleanup xpack_main legacy plugin, remove capabilities mixin * fix test env * delete injectXpackSignature and related tests
This commit is contained in:
parent
e7966e9d46
commit
d802bf03f7
20 changed files with 35 additions and 828 deletions
|
@ -4,23 +4,30 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
import { coreMock, savedObjectsServiceMock } from 'src/core/server/mocks';
|
||||
|
||||
import { Plugin } from './plugin';
|
||||
const initContext = coreMock.createPluginInitializerContext();
|
||||
const coreSetup = coreMock.createSetup();
|
||||
const coreStart = coreMock.createStart();
|
||||
const typeRegistry = savedObjectsServiceMock.createTypeRegistryMock();
|
||||
typeRegistry.getVisibleTypes.mockReturnValue([
|
||||
{
|
||||
name: 'foo',
|
||||
hidden: false,
|
||||
mappings: { properties: {} },
|
||||
namespaceType: 'single' as 'single',
|
||||
},
|
||||
]);
|
||||
coreStart.savedObjects.getTypeRegistry.mockReturnValue(typeRegistry);
|
||||
|
||||
describe('Features Plugin', () => {
|
||||
let initContext: ReturnType<typeof coreMock.createPluginInitializerContext>;
|
||||
let coreSetup: ReturnType<typeof coreMock.createSetup>;
|
||||
let coreStart: ReturnType<typeof coreMock.createStart>;
|
||||
let typeRegistry: ReturnType<typeof savedObjectsServiceMock.createTypeRegistryMock>;
|
||||
|
||||
beforeEach(() => {
|
||||
initContext = coreMock.createPluginInitializerContext();
|
||||
coreSetup = coreMock.createSetup();
|
||||
coreStart = coreMock.createStart();
|
||||
typeRegistry = savedObjectsServiceMock.createTypeRegistryMock();
|
||||
typeRegistry.getVisibleTypes.mockReturnValue([
|
||||
{
|
||||
name: 'foo',
|
||||
hidden: false,
|
||||
mappings: { properties: {} },
|
||||
namespaceType: 'single' as 'single',
|
||||
},
|
||||
]);
|
||||
coreStart.savedObjects.getTypeRegistry.mockReturnValue(typeRegistry);
|
||||
});
|
||||
|
||||
it('returns OSS + registered features', async () => {
|
||||
const plugin = new Plugin(initContext);
|
||||
const { registerFeature } = await plugin.setup(coreSetup, {});
|
||||
|
@ -88,4 +95,12 @@ describe('Features Plugin', () => {
|
|||
expect(soTypes.includes('foo')).toBe(true);
|
||||
expect(soTypes.includes('bar')).toBe(false);
|
||||
});
|
||||
|
||||
it('registers a capabilities provider', async () => {
|
||||
const plugin = new Plugin(initContext);
|
||||
await plugin.setup(coreSetup, {});
|
||||
|
||||
expect(coreSetup.capabilities.registerProvider).toHaveBeenCalledTimes(1);
|
||||
expect(coreSetup.capabilities.registerProvider).toHaveBeenCalledWith(expect.any(Function));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -61,10 +61,15 @@ export class Plugin {
|
|||
featureRegistry: this.featureRegistry,
|
||||
});
|
||||
|
||||
const getFeaturesUICapabilities = () =>
|
||||
uiCapabilitiesForFeatures(this.featureRegistry.getAll());
|
||||
|
||||
core.capabilities.registerProvider(getFeaturesUICapabilities);
|
||||
|
||||
return deepFreeze({
|
||||
registerFeature: this.featureRegistry.register.bind(this.featureRegistry),
|
||||
getFeatures: this.featureRegistry.getAll.bind(this.featureRegistry),
|
||||
getFeaturesUICapabilities: () => uiCapabilitiesForFeatures(this.featureRegistry.getAll()),
|
||||
getFeaturesUICapabilities,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue