* Adding preconfigured alert history index * Adding functions to build alert history document * Adding functions to build alert history document * Moving index template creation to plugin start * Adding unit tests * Adding unit tests * Adding unit tests * Simplifying * Revert "Merge branch 'master' of https://github.com/elastic/kibana into alerting/default-es-index-schema" This reverts commit957c333aa4
, reversing changes made to4b1b78761e
. * Reverting some changes * Reverting some changes * Adding index override * Updating UI with index override * Only allow indexOverride for preconfigured alert history connector * Handling preconfigured connector id clashes * Cleanup * UI unit tests * Fixing default schema shown in UI * Fixing functional tests * Adding functional test * Fixing functional tests * Adding docs and link to docs * Adding config to docker allowlist * Fixing wrong typescript operator * Changing default for config to false * Cleanup * Adding note about index privileges to docs * Fixing i18n * PR fixes * PR fixes * PR fixes * PR fixes - wording * PR fixes * Fixing unit and functional tests * Fixing types check * ES -> Elasticsearch * Moving files * Adding kibana- to beginning of prefix * Namespacing alert data within schema with kibana * Fix i18n * Updating docs * Fixing unit tests * Fixing doc links * Fixing types check * PR fixes Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
67 lines
2.1 KiB
TypeScript
67 lines
2.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 { actionsClientMock } from './actions_client.mock';
|
|
import { PluginSetupContract, PluginStartContract, renderActionParameterTemplates } from './plugin';
|
|
import { Services } from './types';
|
|
import {
|
|
elasticsearchServiceMock,
|
|
savedObjectsClientMock,
|
|
} from '../../../../src/core/server/mocks';
|
|
import { actionsAuthorizationMock } from './authorization/actions_authorization.mock';
|
|
export { actionsAuthorizationMock };
|
|
export { actionsClientMock };
|
|
|
|
const createSetupMock = () => {
|
|
const mock: jest.Mocked<PluginSetupContract> = {
|
|
registerType: jest.fn(),
|
|
};
|
|
return mock;
|
|
};
|
|
|
|
const createStartMock = () => {
|
|
const mock: jest.Mocked<PluginStartContract> = {
|
|
isActionTypeEnabled: jest.fn(),
|
|
isActionExecutable: jest.fn(),
|
|
getActionsClientWithRequest: jest.fn().mockResolvedValue(actionsClientMock.create()),
|
|
getActionsAuthorizationWithRequest: jest
|
|
.fn()
|
|
.mockReturnValue(actionsAuthorizationMock.create()),
|
|
preconfiguredActions: [],
|
|
renderActionParameterTemplates: jest.fn(),
|
|
};
|
|
return mock;
|
|
};
|
|
|
|
// this is a default renderer that escapes nothing
|
|
export function renderActionParameterTemplatesDefault<RecordType>(
|
|
actionTypeId: string,
|
|
actionId: string,
|
|
params: Record<string, unknown>,
|
|
variables: Record<string, unknown>
|
|
) {
|
|
return renderActionParameterTemplates(undefined, actionTypeId, actionId, params, variables);
|
|
}
|
|
|
|
const createServicesMock = () => {
|
|
const mock: jest.Mocked<
|
|
Services & {
|
|
savedObjectsClient: ReturnType<typeof savedObjectsClientMock.create>;
|
|
}
|
|
> = {
|
|
savedObjectsClient: savedObjectsClientMock.create(),
|
|
scopedClusterClient: elasticsearchServiceMock.createScopedClusterClient().asCurrentUser,
|
|
};
|
|
return mock;
|
|
};
|
|
|
|
export const actionsMock = {
|
|
createServices: createServicesMock,
|
|
createSetup: createSetupMock,
|
|
createStart: createStartMock,
|
|
};
|