mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
## Summary - Avoid constructing the capabilities passed to core's capability provider for each request - Add proper *explicit* lock mechanism to the feature registry - Some other minor cleanup, probably #### Before: (look at the `getFeatureUICapabilities` block) <img width="1629" alt="CleanShot 2023-03-26 at 09 55 45@2x" src="https://user-images.githubusercontent.com/1532934/227951476-1edbd2bc-f60b-4529-8c22-ff0d9511b2b8.png"> #### After <img width="1640" alt="CleanShot 2023-03-27 at 14 58 31@2x" src="https://user-images.githubusercontent.com/1532934/227951533-dbe675c3-7089-4b36-86a9-584a3e97c860.png">
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
/*
|
|
* 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; you may not use this file except in compliance with the Elastic License
|
|
* 2.0.
|
|
*/
|
|
|
|
import { PluginSetupContract, PluginStartContract } from './plugin';
|
|
import {
|
|
featurePrivilegeIterator,
|
|
subFeaturePrivilegeIterator,
|
|
} from './feature_privilege_iterator';
|
|
|
|
const createSetup = (): jest.Mocked<PluginSetupContract> => {
|
|
return {
|
|
getKibanaFeatures: jest.fn(),
|
|
getElasticsearchFeatures: jest.fn(),
|
|
registerKibanaFeature: jest.fn(),
|
|
registerElasticsearchFeature: jest.fn(),
|
|
enableReportingUiCapabilities: jest.fn(),
|
|
featurePrivilegeIterator: jest.fn().mockImplementation(featurePrivilegeIterator),
|
|
subFeaturePrivilegeIterator: jest.fn().mockImplementation(subFeaturePrivilegeIterator),
|
|
};
|
|
};
|
|
|
|
const createStart = (): jest.Mocked<PluginStartContract> => {
|
|
return {
|
|
getKibanaFeatures: jest.fn(),
|
|
getElasticsearchFeatures: jest.fn(),
|
|
};
|
|
};
|
|
|
|
export const featuresPluginMock = {
|
|
createSetup,
|
|
createStart,
|
|
};
|