From 07844b95d45e9e7dfc05091da16993bb3a56fea5 Mon Sep 17 00:00:00 2001 From: Gidi Meir Morris Date: Thu, 13 Feb 2020 10:21:48 +1300 Subject: [PATCH] [Alerting] make actionGroup name's i18n-able (#57404) We want to make the Action Group i18n-able for display in the AlertDetails page, so instead of just a list of ids, the AlertType now registers an object where key is the id and value is the human readable, and translatable, value. --- x-pack/legacy/plugins/alerting/README.md | 2 +- .../server/alert_type_registry.test.ts | 13 +++++++- .../alerting/server/alerts_client.test.ts | 8 ++--- .../plugins/alerting/server/alerts_client.ts | 5 +-- .../create_execution_handler.test.ts | 5 ++- .../task_runner/create_execution_handler.ts | 4 ++- .../server/task_runner/task_runner.test.ts | 2 +- .../task_runner/task_runner_factory.test.ts | 2 +- .../legacy/plugins/alerting/server/types.ts | 7 +++- .../server/alerts/license_expiration.test.ts | 2 +- .../server/alerts/license_expiration.ts | 10 +++++- .../signals/signal_rule_alert_type.ts | 10 +++++- .../public/application/lib/alert_api.test.ts | 2 +- .../sections/alert_add/alert_form.tsx | 17 ++++++---- .../components/alert_details.test.tsx | 32 +++++++++---------- .../triggers_actions_ui/public/types.ts | 6 +++- .../common/fixtures/plugins/alerts/index.ts | 12 +++++-- .../tests/alerting/list_alert_types.ts | 1 + .../tests/alerting/list_alert_types.ts | 1 + .../fixtures/plugins/alerts/index.ts | 7 ++-- 20 files changed, 103 insertions(+), 45 deletions(-) diff --git a/x-pack/legacy/plugins/alerting/README.md b/x-pack/legacy/plugins/alerting/README.md index eb9df042f9254..2a10c41f12b85 100644 --- a/x-pack/legacy/plugins/alerting/README.md +++ b/x-pack/legacy/plugins/alerting/README.md @@ -85,7 +85,7 @@ The following table describes the properties of the `options` object. |---|---|---| |id|Unique identifier for the alert type. For convention purposes, ids starting with `.` are reserved for built in alert types. We recommend using a convention like `.mySpecialAlert` for your alert types to avoid conflicting with another plugin.|string| |name|A user-friendly name for the alert type. These will be displayed in dropdowns when choosing alert types.|string| -|actionGroups|An explicit list of groups the alert type may schedule actions for. Alert `actions` validation will use this array to ensure groups are valid.|string[]| +|actionGroups|An explicit list of groups the alert type may schedule actions for, each specifying the ActionGroup's unique ID and human readable name. Alert `actions` validation will use this configuartion to ensure groups are valid. We highly encourage using `kbn-i18n` to translate the names of actionGroup when registering the AlertType. |Array<{id:string, name:string}>| |validate.params|When developing an alert type, you can choose to accept a series of parameters. You may also have the parameters validated before they are passed to the `executor` function or created as an alert saved object. In order to do this, provide a `@kbn/config-schema` schema that we will use to validate the `params` attribute.|@kbn/config-schema| |executor|This is where the code of the alert type lives. This is a function to be called when executing an alert on an interval basis. For full details, see executor section below.|Function| diff --git a/x-pack/legacy/plugins/alerting/server/alert_type_registry.test.ts b/x-pack/legacy/plugins/alerting/server/alert_type_registry.test.ts index e1a05d6460e25..976bed884cd43 100644 --- a/x-pack/legacy/plugins/alerting/server/alert_type_registry.test.ts +++ b/x-pack/legacy/plugins/alerting/server/alert_type_registry.test.ts @@ -118,13 +118,24 @@ describe('list()', () => { registry.register({ id: 'test', name: 'Test', - actionGroups: [], + actionGroups: [ + { + id: 'testActionGroup', + name: 'Test Action Group', + }, + ], executor: jest.fn(), }); const result = registry.list(); expect(result).toMatchInlineSnapshot(` Array [ Object { + "actionGroups": Array [ + Object { + "id": "testActionGroup", + "name": "Test Action Group", + }, + ], "id": "test", "name": "Test", }, diff --git a/x-pack/legacy/plugins/alerting/server/alerts_client.test.ts b/x-pack/legacy/plugins/alerting/server/alerts_client.test.ts index 38521eea20481..1555a0537158a 100644 --- a/x-pack/legacy/plugins/alerting/server/alerts_client.test.ts +++ b/x-pack/legacy/plugins/alerting/server/alerts_client.test.ts @@ -86,7 +86,7 @@ describe('create()', () => { alertTypeRegistry.get.mockReturnValue({ id: '123', name: 'Test', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], async executor() {}, }); }); @@ -1884,7 +1884,7 @@ describe('update()', () => { alertTypeRegistry.get.mockReturnValue({ id: '123', name: 'Test', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], async executor() {}, }); }); @@ -2414,7 +2414,7 @@ describe('update()', () => { alertTypeRegistry.get.mockReturnValueOnce({ id: '123', name: 'Test', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], validate: { params: schema.object({ param1: schema.string(), @@ -2646,7 +2646,7 @@ describe('update()', () => { alertTypeRegistry.get.mockReturnValueOnce({ id: '123', name: 'Test', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], async executor() {}, }); savedObjectsClient.bulkGet.mockResolvedValueOnce({ diff --git a/x-pack/legacy/plugins/alerting/server/alerts_client.ts b/x-pack/legacy/plugins/alerting/server/alerts_client.ts index 334eacc05c771..eef6f662a20a2 100644 --- a/x-pack/legacy/plugins/alerting/server/alerts_client.ts +++ b/x-pack/legacy/plugins/alerting/server/alerts_client.ts @@ -5,7 +5,7 @@ */ import Boom from 'boom'; -import { omit, isEqual } from 'lodash'; +import { omit, isEqual, pluck } from 'lodash'; import { i18n } from '@kbn/i18n'; import { Logger, @@ -639,8 +639,9 @@ export class AlertsClient { private validateActions(alertType: AlertType, actions: NormalizedAlertAction[]): void { const { actionGroups: alertTypeActionGroups } = alertType; const usedAlertActionGroups = actions.map(action => action.group); + const availableAlertTypeActionGroups = new Set(pluck(alertTypeActionGroups, 'id')); const invalidActionGroups = usedAlertActionGroups.filter( - group => !alertTypeActionGroups.includes(group) + group => !availableAlertTypeActionGroups.has(group) ); if (invalidActionGroups.length) { throw Boom.badRequest( diff --git a/x-pack/legacy/plugins/alerting/server/task_runner/create_execution_handler.test.ts b/x-pack/legacy/plugins/alerting/server/task_runner/create_execution_handler.test.ts index d86a06767c9d1..02fa09ba97a65 100644 --- a/x-pack/legacy/plugins/alerting/server/task_runner/create_execution_handler.test.ts +++ b/x-pack/legacy/plugins/alerting/server/task_runner/create_execution_handler.test.ts @@ -11,7 +11,10 @@ import { loggingServiceMock } from '../../../../../../src/core/server/mocks'; const alertType: AlertType = { id: 'test', name: 'Test', - actionGroups: ['default', 'other-group'], + actionGroups: [ + { id: 'default', name: 'Default' }, + { id: 'other-group', name: 'Other Group' }, + ], executor: jest.fn(), }; diff --git a/x-pack/legacy/plugins/alerting/server/task_runner/create_execution_handler.ts b/x-pack/legacy/plugins/alerting/server/task_runner/create_execution_handler.ts index 6b4b47b87b300..737f86a881c1f 100644 --- a/x-pack/legacy/plugins/alerting/server/task_runner/create_execution_handler.ts +++ b/x-pack/legacy/plugins/alerting/server/task_runner/create_execution_handler.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { pluck } from 'lodash'; import { AlertAction, State, Context, AlertType } from '../types'; import { Logger } from '../../../../../../src/core/server'; import { transformActionParams } from './transform_action_params'; @@ -35,8 +36,9 @@ export function createExecutionHandler({ apiKey, alertType, }: CreateExecutionHandlerOptions) { + const alertTypeActionGroups = new Set(pluck(alertType.actionGroups, 'id')); return async ({ actionGroup, context, state, alertInstanceId }: ExecutionHandlerOptions) => { - if (!alertType.actionGroups.includes(actionGroup)) { + if (!alertTypeActionGroups.has(actionGroup)) { logger.error(`Invalid action group "${actionGroup}" for alert "${alertType.id}".`); return; } diff --git a/x-pack/legacy/plugins/alerting/server/task_runner/task_runner.test.ts b/x-pack/legacy/plugins/alerting/server/task_runner/task_runner.test.ts index 394c13e1bd24f..b6dd4b3435fcb 100644 --- a/x-pack/legacy/plugins/alerting/server/task_runner/task_runner.test.ts +++ b/x-pack/legacy/plugins/alerting/server/task_runner/task_runner.test.ts @@ -19,7 +19,7 @@ import { const alertType = { id: 'test', name: 'My test alert', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], executor: jest.fn(), }; let fakeTimer: sinon.SinonFakeTimers; diff --git a/x-pack/legacy/plugins/alerting/server/task_runner/task_runner_factory.test.ts b/x-pack/legacy/plugins/alerting/server/task_runner/task_runner_factory.test.ts index 543b9e7d32e12..7474fcfb4baaa 100644 --- a/x-pack/legacy/plugins/alerting/server/task_runner/task_runner_factory.test.ts +++ b/x-pack/legacy/plugins/alerting/server/task_runner/task_runner_factory.test.ts @@ -16,7 +16,7 @@ import { const alertType = { id: 'test', name: 'My test alert', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], executor: jest.fn(), }; let fakeTimer: sinon.SinonFakeTimers; diff --git a/x-pack/legacy/plugins/alerting/server/types.ts b/x-pack/legacy/plugins/alerting/server/types.ts index 5e8adadf74ac0..95a96fa384c2c 100644 --- a/x-pack/legacy/plugins/alerting/server/types.ts +++ b/x-pack/legacy/plugins/alerting/server/types.ts @@ -42,13 +42,18 @@ export interface AlertExecutorOptions { updatedBy: string | null; } +export interface ActionGroup { + id: string; + name: string; +} + export interface AlertType { id: string; name: string; validate?: { params?: { validate: (object: any) => any }; }; - actionGroups: string[]; + actionGroups: ActionGroup[]; executor: ({ services, params, state }: AlertExecutorOptions) => Promise; } diff --git a/x-pack/legacy/plugins/monitoring/server/alerts/license_expiration.test.ts b/x-pack/legacy/plugins/monitoring/server/alerts/license_expiration.test.ts index ec00ece9e6ee2..38b4e6c60ca48 100644 --- a/x-pack/legacy/plugins/monitoring/server/alerts/license_expiration.test.ts +++ b/x-pack/legacy/plugins/monitoring/server/alerts/license_expiration.test.ts @@ -102,7 +102,7 @@ describe('getLicenseExpiration', () => { it('should have the right id and actionGroups', () => { const alert = getLicenseExpiration(server, getMonitoringCluster, getLogger, ccrEnabled); expect(alert.id).toBe(ALERT_TYPE_LICENSE_EXPIRATION); - expect(alert.actionGroups).toEqual(['default']); + expect(alert.actionGroups).toEqual([{ id: 'default', name: 'Default' }]); }); it('should return the state if no license is provided', async () => { diff --git a/x-pack/legacy/plugins/monitoring/server/alerts/license_expiration.ts b/x-pack/legacy/plugins/monitoring/server/alerts/license_expiration.ts index 197c5c9cdcbc7..8688a2b08efc4 100644 --- a/x-pack/legacy/plugins/monitoring/server/alerts/license_expiration.ts +++ b/x-pack/legacy/plugins/monitoring/server/alerts/license_expiration.ts @@ -8,6 +8,7 @@ import moment from 'moment-timezone'; import { get } from 'lodash'; import { Legacy } from 'kibana'; import { Logger } from 'src/core/server'; +import { i18n } from '@kbn/i18n'; import { ALERT_TYPE_LICENSE_EXPIRATION, INDEX_PATTERN_ELASTICSEARCH } from '../../common/constants'; import { AlertType } from '../../../alerting'; import { fetchLicenses } from '../lib/alerts/fetch_licenses'; @@ -45,7 +46,14 @@ export const getLicenseExpiration = ( return { id: ALERT_TYPE_LICENSE_EXPIRATION, name: 'Monitoring Alert - License Expiration', - actionGroups: ['default'], + actionGroups: [ + { + id: 'default', + name: i18n.translate('xpack.monitoring.alerts.licenseExpiration.actionGroups.default', { + defaultMessage: 'Default', + }), + }, + ], async executor({ services, params, diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts index cd28f348a27c3..79337aa91b1fe 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts @@ -7,6 +7,7 @@ import { schema } from '@kbn/config-schema'; import { Logger } from 'src/core/server'; import moment from 'moment'; +import { i18n } from '@kbn/i18n'; import { SIGNALS_ID, DEFAULT_MAX_SIGNALS, @@ -32,7 +33,14 @@ export const signalRulesAlertType = ({ return { id: SIGNALS_ID, name: 'SIEM Signals', - actionGroups: ['default'], + actionGroups: [ + { + id: 'default', + name: i18n.translate('xpack.siem.detectionEngine.signalRuleAlert.actionGroups.default', { + defaultMessage: 'Default', + }), + }, + ], validate: { params: schema.object({ description: schema.string(), diff --git a/x-pack/plugins/triggers_actions_ui/public/application/lib/alert_api.test.ts b/x-pack/plugins/triggers_actions_ui/public/application/lib/alert_api.test.ts index 9c6f4daccc705..93a46862f4cd2 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/lib/alert_api.test.ts +++ b/x-pack/plugins/triggers_actions_ui/public/application/lib/alert_api.test.ts @@ -39,7 +39,7 @@ describe('loadAlertTypes', () => { id: 'test', name: 'Test', actionVariables: ['var1'], - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], }, ]; http.get.mockResolvedValueOnce(resolvedValue); diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_add/alert_form.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_add/alert_form.tsx index 90b84e11fccd2..1c64f599721d5 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_add/alert_form.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_add/alert_form.tsx @@ -40,6 +40,7 @@ import { ActionTypeIndex, ActionConnector, AlertTypeIndex, + ActionGroup, } from '../../../types'; import { SectionLoading } from '../../components/section_loading'; import { ConnectorAddModal } from '../action_connector_form/connector_add_modal'; @@ -118,7 +119,7 @@ export const AlertForm = ({ const [alertThrottleUnit, setAlertThrottleUnit] = useState('m'); const [isAddActionPanelOpen, setIsAddActionPanelOpen] = useState(true); const [connectors, setConnectors] = useState([]); - const [defaultActionGroup, setDefaultActionGroup] = useState(undefined); + const [defaultActionGroup, setDefaultActionGroup] = useState(undefined); const [activeActionItem, setActiveActionItem] = useState( undefined ); @@ -158,7 +159,11 @@ export const AlertForm = ({ // temp hack of API result alertTypes.push({ id: 'threshold', - actionGroups: ['Alert', 'Warning', 'If unacknowledged'], + actionGroups: [ + { id: 'alert', name: 'Alert' }, + { id: 'warning', name: 'Warning' }, + { id: 'ifUnacknowledged', name: 'If unacknowledged' }, + ], name: 'threshold', actionVariables: ['ctx.metadata.name', 'ctx.metadata.test'], }); @@ -261,7 +266,7 @@ export const AlertForm = ({ alert.actions.push({ id: '', actionTypeId: actionTypeModel.id, - group: defaultActionGroup ?? 'Alert', + group: defaultActionGroup?.id ?? 'Alert', params: {}, }); setActionProperty('id', freeConnectors[0].id, alert.actions.length - 1); @@ -273,7 +278,7 @@ export const AlertForm = ({ alert.actions.push({ id: '', actionTypeId: actionTypeModel.id, - group: defaultActionGroup ?? 'Alert', + group: defaultActionGroup?.id ?? 'Alert', params: {}, }); setActionProperty('id', alert.actions.length, alert.actions.length - 1); @@ -351,7 +356,7 @@ export const AlertForm = ({ id, })); const actionTypeRegisterd = actionTypeRegistry.get(actionConnector.actionTypeId); - if (actionTypeRegisterd === null || actionItem.group !== defaultActionGroup) return null; + if (actionTypeRegisterd === null || actionItem.group !== defaultActionGroup?.id) return null; const ParamsFieldsComponent = actionTypeRegisterd.actionParamsFields; const actionParamsErrors: { errors: IErrorObject } = Object.keys(actionsErrors).length > 0 ? actionsErrors[actionItem.id] : { errors: {} }; @@ -474,7 +479,7 @@ export const AlertForm = ({ ? actionTypesIndex[actionItem.actionTypeId].name : actionItem.actionTypeId; const actionTypeRegisterd = actionTypeRegistry.get(actionItem.actionTypeId); - if (actionTypeRegisterd === null || actionItem.group !== defaultActionGroup) return null; + if (actionTypeRegisterd === null || actionItem.group !== defaultActionGroup?.id) return null; return ( { const alertType = { id: '.noop', name: 'No Op', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], actionVariables: [], }; @@ -64,7 +64,7 @@ describe('alert_details', () => { const alertType = { id: '.noop', name: 'No Op', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], actionVariables: [], }; @@ -91,7 +91,7 @@ describe('alert_details', () => { const alertType = { id: '.noop', name: 'No Op', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], actionVariables: [], }; @@ -140,7 +140,7 @@ describe('alert_details', () => { const alertType = { id: '.noop', name: 'No Op', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], actionVariables: [], }; const actionTypes: ActionType[] = [ @@ -190,7 +190,7 @@ describe('alert_details', () => { const alertType = { id: '.noop', name: 'No Op', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], actionVariables: [], }; @@ -214,7 +214,7 @@ describe('alert_details', () => { const alertType = { id: '.noop', name: 'No Op', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], actionVariables: [], }; @@ -238,7 +238,7 @@ describe('alert_details', () => { const alertType = { id: '.noop', name: 'No Op', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], actionVariables: [], }; @@ -267,7 +267,7 @@ describe('enable button', () => { const alertType = { id: '.noop', name: 'No Op', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], actionVariables: [], }; @@ -292,7 +292,7 @@ describe('enable button', () => { const alertType = { id: '.noop', name: 'No Op', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], actionVariables: [], }; @@ -317,7 +317,7 @@ describe('enable button', () => { const alertType = { id: '.noop', name: 'No Op', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], actionVariables: [], }; @@ -351,7 +351,7 @@ describe('enable button', () => { const alertType = { id: '.noop', name: 'No Op', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], actionVariables: [], }; @@ -388,7 +388,7 @@ describe('mute button', () => { const alertType = { id: '.noop', name: 'No Op', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], actionVariables: [], }; @@ -414,7 +414,7 @@ describe('mute button', () => { const alertType = { id: '.noop', name: 'No Op', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], actionVariables: [], }; @@ -440,7 +440,7 @@ describe('mute button', () => { const alertType = { id: '.noop', name: 'No Op', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], actionVariables: [], }; @@ -475,7 +475,7 @@ describe('mute button', () => { const alertType = { id: '.noop', name: 'No Op', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], actionVariables: [], }; @@ -510,7 +510,7 @@ describe('mute button', () => { const alertType = { id: '.noop', name: 'No Op', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], actionVariables: [], }; diff --git a/x-pack/plugins/triggers_actions_ui/public/types.ts b/x-pack/plugins/triggers_actions_ui/public/types.ts index 30718f702c9cb..86853e88a81cd 100644 --- a/x-pack/plugins/triggers_actions_ui/public/types.ts +++ b/x-pack/plugins/triggers_actions_ui/public/types.ts @@ -70,10 +70,14 @@ export interface ActionConnectorTableItem extends ActionConnector { actionType: ActionType['name']; } +export interface ActionGroup { + id: string; + name: string; +} export interface AlertType { id: string; name: string; - actionGroups: string[]; + actionGroups: ActionGroup[]; actionVariables: string[]; } diff --git a/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts/index.ts b/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts/index.ts index f7f3d0fa91fff..0cc45a624bc1a 100644 --- a/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts/index.ts +++ b/x-pack/test/alerting_api_integration/common/fixtures/plugins/alerts/index.ts @@ -202,7 +202,10 @@ export default function(kibana: any) { const alwaysFiringAlertType: AlertType = { id: 'test.always-firing', name: 'Test: Always Firing', - actionGroups: ['default', 'other'], + actionGroups: [ + { id: 'default', name: 'Default' }, + { id: 'other', name: 'Other' }, + ], async executor(alertExecutorOptions: AlertExecutorOptions) { const { services, @@ -253,7 +256,10 @@ export default function(kibana: any) { const cumulativeFiringAlertType: AlertType = { id: 'test.cumulative-firing', name: 'Test: Cumulative Firing', - actionGroups: ['default', 'other'], + actionGroups: [ + { id: 'default', name: 'Default' }, + { id: 'other', name: 'Other' }, + ], async executor(alertExecutorOptions: AlertExecutorOptions) { const { services, state } = alertExecutorOptions; const group = 'default'; @@ -383,7 +389,7 @@ export default function(kibana: any) { const noopAlertType: AlertType = { id: 'test.noop', name: 'Test: Noop', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], async executor({ services, params, state }: AlertExecutorOptions) {}, }; server.plugins.alerting.setup.registerType(alwaysFiringAlertType); diff --git a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/list_alert_types.ts b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/list_alert_types.ts index fde4d0e880a81..517a60f77849e 100644 --- a/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/list_alert_types.ts +++ b/x-pack/test/alerting_api_integration/security_and_spaces/tests/alerting/list_alert_types.ts @@ -40,6 +40,7 @@ export default function listAlertTypes({ getService }: FtrProviderContext) { (alertType: any) => alertType.id === 'test.noop' ); expect(fixtureAlertType).to.eql({ + actionGroups: [{ id: 'default', name: 'Default' }], id: 'test.noop', name: 'Test: Noop', }); diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/list_alert_types.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/list_alert_types.ts index 479b6621d3fcd..55570744f6af9 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/list_alert_types.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/list_alert_types.ts @@ -20,6 +20,7 @@ export default function listAlertTypes({ getService }: FtrProviderContext) { expect(response.statusCode).to.eql(200); const fixtureAlertType = response.body.find((alertType: any) => alertType.id === 'test.noop'); expect(fixtureAlertType).to.eql({ + actionGroups: [{ id: 'default', name: 'Default' }], id: 'test.noop', name: 'Test: Noop', }); diff --git a/x-pack/test/functional_with_es_ssl/fixtures/plugins/alerts/index.ts b/x-pack/test/functional_with_es_ssl/fixtures/plugins/alerts/index.ts index 15d1baadf7806..d7551345203b4 100644 --- a/x-pack/test/functional_with_es_ssl/fixtures/plugins/alerts/index.ts +++ b/x-pack/test/functional_with_es_ssl/fixtures/plugins/alerts/index.ts @@ -22,7 +22,7 @@ function createNoopAlertType(setupContract: any) { const noopAlertType: AlertType = { id: 'test.noop', name: 'Test: Noop', - actionGroups: ['default'], + actionGroups: [{ id: 'default', name: 'Default' }], async executor() {}, }; setupContract.registerType(noopAlertType); @@ -33,7 +33,10 @@ function createAlwaysFiringAlertType(setupContract: any) { const alwaysFiringAlertType: any = { id: 'test.always-firing', name: 'Always Firing', - actionGroups: ['default', 'other'], + actionGroups: [ + { id: 'default', name: 'Default' }, + { id: 'other', name: 'Other' }, + ], async executor(alertExecutorOptions: any) { const { services, state, params } = alertExecutorOptions;