From aa716e46a49365ca29fb0b547b059887965bc4d4 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Fri, 15 Jan 2021 18:41:32 +0100 Subject: [PATCH 01/15] wip --- .../uptime/public/state/api/alert_actions.ts | 29 ++++++++++++++++++- .../plugins/uptime/public/state/api/alerts.ts | 9 +++++- .../uptime/server/lib/alerts/status_check.ts | 1 - 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/uptime/public/state/api/alert_actions.ts b/x-pack/plugins/uptime/public/state/api/alert_actions.ts index 0e8781e5937dd..2a7b82eea908f 100644 --- a/x-pack/plugins/uptime/public/state/api/alert_actions.ts +++ b/x-pack/plugins/uptime/public/state/api/alert_actions.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { i18n } from '@kbn/i18n'; import { NewAlertParams } from './alerts'; import { AlertAction } from '../../../../triggers_actions_ui/public'; import { ACTION_GROUP_DEFINITIONS } from '../../../common/constants/alerts'; @@ -30,7 +31,12 @@ export const WEBHOOK_ACTION_ID: ActionTypeId = '.webhook'; const { MONITOR_STATUS } = ACTION_GROUP_DEFINITIONS; -export function populateAlertActions({ defaultActions, monitorId, monitorName }: NewAlertParams) { +export function populateAlertActions({ + defaultActions, + monitorId, + monitorName, + monitorUrl, +}: NewAlertParams) { const actions: AlertAction[] = []; defaultActions.forEach((aId) => { const action: AlertAction = { @@ -39,6 +45,22 @@ export function populateAlertActions({ defaultActions, monitorId, monitorName }: group: MONITOR_STATUS.id, params: {}, }; + + const recoveredAction: AlertAction = { + id: aId.id, + actionTypeId: aId.actionTypeId, + group: 'recovered', + params: { + message: i18n.translate('xpack.uptime.alerts.monitorStatus.recoveryMessage', { + defaultMessage: 'Monitor {monitor} with {url} has recovered with status Up', + values: { + monitor: monitorName || monitorId, + url: monitorUrl, + }, + }), + }, + }; + switch (aId.actionTypeId) { case PAGER_DUTY_ACTION_ID: action.params = getPagerDutyActionParams(monitorId); @@ -60,6 +82,11 @@ export function populateAlertActions({ defaultActions, monitorId, monitorName }: break; case SLACK_ACTION_ID: case TEAMS_ACTION_ID: + action.params = { + message: MonitorStatusTranslations.defaultActionMessage, + }; + actions.push(recoveredAction); + break; default: action.params = { message: MonitorStatusTranslations.defaultActionMessage, diff --git a/x-pack/plugins/uptime/public/state/api/alerts.ts b/x-pack/plugins/uptime/public/state/api/alerts.ts index dd78be5d08ea0..0609106ef2f42 100644 --- a/x-pack/plugins/uptime/public/state/api/alerts.ts +++ b/x-pack/plugins/uptime/public/state/api/alerts.ts @@ -24,6 +24,7 @@ export const fetchConnectors = async () => { export interface NewAlertParams extends AlertTypeParams { monitorId: string; + monitorUrl: string; monitorName?: string; defaultActions: ActionConnector[]; } @@ -46,8 +47,14 @@ export const createAlert = async ({ defaultActions, monitorId, monitorName, + monitorUrl, }: NewAlertParams): Promise => { - const actions: AlertAction[] = populateAlertActions({ defaultActions, monitorId, monitorName }); + const actions: AlertAction[] = populateAlertActions({ + defaultActions, + monitorId, + monitorName, + monitorUrl, + }); const data: NewMonitorStatusAlert = { actions, diff --git a/x-pack/plugins/uptime/server/lib/alerts/status_check.ts b/x-pack/plugins/uptime/server/lib/alerts/status_check.ts index 1bcad155bd0dc..6547cf80193f2 100644 --- a/x-pack/plugins/uptime/server/lib/alerts/status_check.ts +++ b/x-pack/plugins/uptime/server/lib/alerts/status_check.ts @@ -264,7 +264,6 @@ export const statusCheckAlertFactory: UptimeAlertTypeFactory = ( state, services: { alertInstanceFactory }, }, - dynamicSettings, uptimeEsClient, }) { const { From 65fbd89a6245bdd042147f1b2cb3a8a6472ae1e9 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Fri, 15 Jan 2021 21:20:27 +0100 Subject: [PATCH 02/15] wip --- .../components/monitor/monitor_title.tsx | 5 +-- .../monitor_list/columns/enable_alert.tsx | 7 ++-- .../overview/monitor_list/monitor_list.tsx | 2 +- .../uptime/public/state/api/alert_actions.ts | 37 +++++++++++++------ .../plugins/uptime/public/state/api/alerts.ts | 12 +++--- .../uptime/server/lib/alerts/status_check.ts | 4 +- 6 files changed, 37 insertions(+), 30 deletions(-) diff --git a/x-pack/plugins/uptime/public/components/monitor/monitor_title.tsx b/x-pack/plugins/uptime/public/components/monitor/monitor_title.tsx index cecef14298267..a850d84f87e0f 100644 --- a/x-pack/plugins/uptime/public/components/monitor/monitor_title.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/monitor_title.tsx @@ -48,10 +48,7 @@ export const MonitorPageTitle: React.FC = () => { - + ); diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/enable_alert.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/enable_alert.tsx index 8a5a72891c3e7..b7327135c5e39 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/enable_alert.tsx +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/enable_alert.tsx @@ -20,13 +20,14 @@ import { import { MONITOR_ROUTE } from '../../../../../common/constants'; import { DefineAlertConnectors } from './define_connectors'; import { DISABLE_STATUS_ALERT, ENABLE_STATUS_ALERT } from './translations'; +import { Ping } from '../../../../../common/runtime_types/ping'; interface Props { monitorId: string; - monitorName?: string; + selectedMonitor?: Ping; } -export const EnableMonitorAlert = ({ monitorId, monitorName }: Props) => { +export const EnableMonitorAlert = ({ monitorId, selectedMonitor }: Props) => { const [isLoading, setIsLoading] = useState(false); const { settings } = useSelector(selectDynamicSettings); @@ -65,7 +66,7 @@ export const EnableMonitorAlert = ({ monitorId, monitorName }: Props) => { createAlertAction.get({ defaultActions, monitorId, - monitorName, + selectedMonitor, }) ); setIsLoading(true); diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list.tsx index 10699dd34343e..25a52caf5f312 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list.tsx +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/monitor_list.tsx @@ -141,7 +141,7 @@ export const MonitorListComponent: ({ render: (item: MonitorSummary) => ( ), }, diff --git a/x-pack/plugins/uptime/public/state/api/alert_actions.ts b/x-pack/plugins/uptime/public/state/api/alert_actions.ts index 2a7b82eea908f..9f2d234a4655c 100644 --- a/x-pack/plugins/uptime/public/state/api/alert_actions.ts +++ b/x-pack/plugins/uptime/public/state/api/alert_actions.ts @@ -19,6 +19,7 @@ import { // eslint-disable-next-line @kbn/eslint/no-restricted-paths } from '../../../../actions/server'; import { ActionTypeId } from '../../components/settings/types'; +import { Ping } from '../../../common/runtime_types/ping'; export const SLACK_ACTION_ID: ActionTypeId = '.slack'; export const PAGER_DUTY_ACTION_ID: ActionTypeId = '.pagerduty'; @@ -31,11 +32,20 @@ export const WEBHOOK_ACTION_ID: ActionTypeId = '.webhook'; const { MONITOR_STATUS } = ACTION_GROUP_DEFINITIONS; +const getRecoveryMessage = (selectedMonitor: Ping) => { + return i18n.translate('xpack.uptime.alerts.monitorStatus.recoveryMessage', { + defaultMessage: 'Monitor {monitor} with url {url} has recovered with status Up', + values: { + monitor: selectedMonitor?.monitor?.name || selectedMonitor?.monitor?.id, + url: selectedMonitor?.url?.full, + }, + }); +}; + export function populateAlertActions({ defaultActions, monitorId, - monitorName, - monitorUrl, + selectedMonitor, }: NewAlertParams) { const actions: AlertAction[] = []; defaultActions.forEach((aId) => { @@ -51,19 +61,15 @@ export function populateAlertActions({ actionTypeId: aId.actionTypeId, group: 'recovered', params: { - message: i18n.translate('xpack.uptime.alerts.monitorStatus.recoveryMessage', { - defaultMessage: 'Monitor {monitor} with {url} has recovered with status Up', - values: { - monitor: monitorName || monitorId, - url: monitorUrl, - }, - }), + message: getRecoveryMessage(selectedMonitor), }, }; switch (aId.actionTypeId) { case PAGER_DUTY_ACTION_ID: - action.params = getPagerDutyActionParams(monitorId); + action.params = getPagerDutyActionParams(selectedMonitor); + recoveredAction.params = getPagerDutyActionParams(selectedMonitor, true); + actions.push(recoveredAction); break; case SERVER_LOG_ACTION_ID: action.params = getServerLogActionParams(); @@ -126,9 +132,16 @@ function getWebhookActionParams(): WebhookActionParams { }; } -function getPagerDutyActionParams(monitorId: string): PagerDutyActionParams { +function getPagerDutyActionParams(selectedMonitor: Ping, recover = false): PagerDutyActionParams { + if (recover) { + return { + dedupKey: selectedMonitor.monitor.id + MONITOR_STATUS.id, + eventAction: 'resolve', + summary: getRecoveryMessage(selectedMonitor), + }; + } return { - dedupKey: monitorId + MONITOR_STATUS.id, + dedupKey: selectedMonitor.monitor.id + MONITOR_STATUS.id, eventAction: 'trigger', severity: 'error', summary: MonitorStatusTranslations.defaultActionMessage, diff --git a/x-pack/plugins/uptime/public/state/api/alerts.ts b/x-pack/plugins/uptime/public/state/api/alerts.ts index 0609106ef2f42..885d440ab7c4c 100644 --- a/x-pack/plugins/uptime/public/state/api/alerts.ts +++ b/x-pack/plugins/uptime/public/state/api/alerts.ts @@ -15,6 +15,7 @@ import { Alert, AlertTypeParams } from '../../../../alerts/common'; import { AtomicStatusCheckParams } from '../../../common/runtime_types/alerts'; import { populateAlertActions } from './alert_actions'; +import { Ping } from '../../../common/runtime_types/ping'; const UPTIME_AUTO_ALERT = 'UPTIME_AUTO'; @@ -24,8 +25,7 @@ export const fetchConnectors = async () => { export interface NewAlertParams extends AlertTypeParams { monitorId: string; - monitorUrl: string; - monitorName?: string; + selectedMonitor: Ping; defaultActions: ActionConnector[]; } @@ -46,14 +46,12 @@ type NewMonitorStatusAlert = Omit< export const createAlert = async ({ defaultActions, monitorId, - monitorName, - monitorUrl, + selectedMonitor, }: NewAlertParams): Promise => { const actions: AlertAction[] = populateAlertActions({ defaultActions, monitorId, - monitorName, - monitorUrl, + selectedMonitor, }); const data: NewMonitorStatusAlert = { @@ -73,7 +71,7 @@ export const createAlert = async ({ schedule: { interval: '1m' }, notifyWhen: 'onActionGroupChange', tags: [UPTIME_AUTO_ALERT], - name: `${monitorName} (Simple status alert)`, + name: `${selectedMonitor?.monitor.name}(Simple status alert)`, enabled: true, throttle: null, }; diff --git a/x-pack/plugins/uptime/server/lib/alerts/status_check.ts b/x-pack/plugins/uptime/server/lib/alerts/status_check.ts index 6547cf80193f2..bb643356e08c3 100644 --- a/x-pack/plugins/uptime/server/lib/alerts/status_check.ts +++ b/x-pack/plugins/uptime/server/lib/alerts/status_check.ts @@ -282,9 +282,7 @@ export const statusCheckAlertFactory: UptimeAlertTypeFactory = ( const filterString = await formatFilterString(uptimeEsClient, filters, search, libs); const timerange = oldVersionTimeRange || { - from: isAutoGenerated - ? state.lastCheckedAt - : `now-${String(timerangeCount) + timerangeUnit}`, + from: `now-${String(timerangeCount) + timerangeUnit}`, to: 'now', }; From 63971795081ac13097465cc89c6018e78caf7886 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Tue, 26 Jan 2021 11:34:21 +0100 Subject: [PATCH 03/15] fix type --- x-pack/plugins/uptime/public/state/api/alerts.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/uptime/public/state/api/alerts.ts b/x-pack/plugins/uptime/public/state/api/alerts.ts index 885d440ab7c4c..3039ecdb0e342 100644 --- a/x-pack/plugins/uptime/public/state/api/alerts.ts +++ b/x-pack/plugins/uptime/public/state/api/alerts.ts @@ -71,7 +71,7 @@ export const createAlert = async ({ schedule: { interval: '1m' }, notifyWhen: 'onActionGroupChange', tags: [UPTIME_AUTO_ALERT], - name: `${selectedMonitor?.monitor.name}(Simple status alert)`, + name: `${selectedMonitor?.monitor.name || selectedMonitor?.url?.full}(Simple status alert)`, enabled: true, throttle: null, }; From 0f59cb4f3040a07129eeed0ed93200ffb328bc20 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Tue, 26 Jan 2021 12:04:53 +0100 Subject: [PATCH 04/15] implement recovery actions --- .../uptime/public/state/api/alert_actions.ts | 53 ++++++++++++++----- .../plugins/uptime/public/state/api/alerts.ts | 1 - 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/x-pack/plugins/uptime/public/state/api/alert_actions.ts b/x-pack/plugins/uptime/public/state/api/alert_actions.ts index 9f2d234a4655c..486430047dcd1 100644 --- a/x-pack/plugins/uptime/public/state/api/alert_actions.ts +++ b/x-pack/plugins/uptime/public/state/api/alert_actions.ts @@ -42,11 +42,7 @@ const getRecoveryMessage = (selectedMonitor: Ping) => { }); }; -export function populateAlertActions({ - defaultActions, - monitorId, - selectedMonitor, -}: NewAlertParams) { +export function populateAlertActions({ defaultActions, selectedMonitor }: NewAlertParams) { const actions: AlertAction[] = []; defaultActions.forEach((aId) => { const action: AlertAction = { @@ -72,19 +68,27 @@ export function populateAlertActions({ actions.push(recoveredAction); break; case SERVER_LOG_ACTION_ID: - action.params = getServerLogActionParams(); + action.params = getServerLogActionParams(selectedMonitor); + recoveredAction.params = getServerLogActionParams(selectedMonitor, true); + actions.push(recoveredAction); break; case INDEX_ACTION_ID: - action.params = getIndexActionParams(); + action.params = getIndexActionParams(selectedMonitor); + recoveredAction.params = getIndexActionParams(selectedMonitor, true); + actions.push(recoveredAction); break; case SERVICE_NOW_ACTION_ID: action.params = getServiceNowActionParams(); + // Recovery action for service now is not implemented yet break; case JIRA_ACTION_ID: action.params = getJiraActionParams(); + // Recovery action for Jira is not implemented yet break; case WEBHOOK_ACTION_ID: - action.params = getWebhookActionParams(); + action.params = getWebhookActionParams(selectedMonitor); + recoveredAction.params = getWebhookActionParams(selectedMonitor, true); + actions.push(recoveredAction); break; case SLACK_ACTION_ID: case TEAMS_ACTION_ID: @@ -105,7 +109,20 @@ export function populateAlertActions({ return actions; } -function getIndexActionParams(): IndexActionParams { +function getIndexActionParams(selectedMonitor: Ping, recovery = false): IndexActionParams { + if (recovery) { + return { + documents: [ + { + monitorName: '{{state.monitorName}}', + monitorUrl: '{{{state.monitorUrl}}}', + statusMessage: getRecoveryMessage(selectedMonitor), + latestErrorMessage: '', + observerLocation: '{{state.observerLocation}}', + }, + ], + }; + } return { documents: [ { @@ -119,21 +136,29 @@ function getIndexActionParams(): IndexActionParams { }; } -function getServerLogActionParams(): ServerLogActionParams { +function getServerLogActionParams(selectedMonitor: Ping, recovery = false): ServerLogActionParams { + if (recovery) { + return { + level: 'info', + message: getRecoveryMessage(selectedMonitor), + }; + } return { level: 'warn', message: MonitorStatusTranslations.defaultActionMessage, }; } -function getWebhookActionParams(): WebhookActionParams { +function getWebhookActionParams(selectedMonitor: Ping, recovery = false): WebhookActionParams { return { - body: MonitorStatusTranslations.defaultActionMessage, + body: recovery + ? getRecoveryMessage(selectedMonitor) + : MonitorStatusTranslations.defaultActionMessage, }; } -function getPagerDutyActionParams(selectedMonitor: Ping, recover = false): PagerDutyActionParams { - if (recover) { +function getPagerDutyActionParams(selectedMonitor: Ping, recovery = false): PagerDutyActionParams { + if (recovery) { return { dedupKey: selectedMonitor.monitor.id + MONITOR_STATUS.id, eventAction: 'resolve', diff --git a/x-pack/plugins/uptime/public/state/api/alerts.ts b/x-pack/plugins/uptime/public/state/api/alerts.ts index 3039ecdb0e342..d5b1d32762f0d 100644 --- a/x-pack/plugins/uptime/public/state/api/alerts.ts +++ b/x-pack/plugins/uptime/public/state/api/alerts.ts @@ -50,7 +50,6 @@ export const createAlert = async ({ }: NewAlertParams): Promise => { const actions: AlertAction[] = populateAlertActions({ defaultActions, - monitorId, selectedMonitor, }); From ae9eaa661359f7ea42e0742aa8f9f7a05a24b43b Mon Sep 17 00:00:00 2001 From: Shahzad Date: Tue, 26 Jan 2021 12:22:01 +0100 Subject: [PATCH 05/15] added test --- .../public/state/api/alert_actions.test.ts | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 x-pack/plugins/uptime/public/state/api/alert_actions.test.ts diff --git a/x-pack/plugins/uptime/public/state/api/alert_actions.test.ts b/x-pack/plugins/uptime/public/state/api/alert_actions.test.ts new file mode 100644 index 0000000000000..5d5dd45af9b04 --- /dev/null +++ b/x-pack/plugins/uptime/public/state/api/alert_actions.test.ts @@ -0,0 +1,75 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import { populateAlertActions } from './alert_actions'; + +const selectedMonitor = { + docId: 'X5dkPncBy0xTcvZ347hy', + timestamp: '2021-01-26T11:12:14.519Z', + '@timestamp': '2021-01-26T11:12:14.519Z', + url: { scheme: 'tcp', domain: 'localhost', port: 18278, full: 'tcp://localhost:18278' }, + error: { type: 'io', message: 'dial tcp 127.0.0.1:18278: connect: connection refused' }, + ecs: { version: '1.7.0' }, + resolve: { ip: '127.0.0.1', rtt: { us: 410 } }, + summary: { down: 1, up: 0 }, + monitor: { + ip: '127.0.0.1', + name: 'Always Down Local Port', + type: 'tcp', + timespan: { gte: '2021-01-26T11:12:14.519Z', lt: '2021-01-26T11:17:14.519Z' }, + id: 'always-down', + status: 'down', + duration: { us: 695 }, + check_group: 'a53b0003-5fc6-11eb-9241-42010a84000f', + }, + event: { dataset: 'uptime' }, + agent: { + ephemeral_id: '7d86e765-9f29-46e6-b1ec-047b09b4074e', + id: '7c9d2825-614f-4906-a13e-c9db1c6e5585', + name: 'gke-edge-oblt-edge-oblt-pool-c9faf257-m1ci', + type: 'heartbeat', + version: '8.0.0', + }, +}; + +describe('Alert Actions factory', () => { + it('generate expected action for slack', async () => { + const resp = populateAlertActions({ + selectedMonitor, + defaultActions: [ + { + id: '25b89830-5fc6-11eb-9c97-d1d4e807ea39', + notifyWhen: 'onActionGroupChange', + actions: [ + { + actionTypeId: '.pagerduty', + group: 'xpack.uptime.alerts.actionGroups.monitorStatus', + params: { + dedupKey: 'always-downxpack.uptime.alerts.actionGroups.monitorStatus', + eventAction: 'trigger', + severity: 'error', + summary: + 'Monitor {{state.monitorName}} with url {{{state.monitorUrl}}} is {{state.statusMessage}} from {{state.observerLocation}}. The latest error message is {{{state.latestErrorMessage}}}', + }, + id: 'f2a3b195-ed76-499a-805d-82d24d4eeba9', + }, + ], + }, + ], + }); + expect(resp).toEqual([ + { + actionTypeId: undefined, + group: 'xpack.uptime.alerts.actionGroups.monitorStatus', + id: '25b89830-5fc6-11eb-9c97-d1d4e807ea39', + params: { + message: + 'Monitor {{state.monitorName}} with url {{{state.monitorUrl}}} is {{state.statusMessage}} from {{state.observerLocation}}. The latest error message is {{{state.latestErrorMessage}}}', + }, + }, + ]); + }); +}); From e552d4eeeaf8e29fc077799cca2cd57e5614fc05 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Tue, 26 Jan 2021 13:28:54 +0100 Subject: [PATCH 06/15] fix types --- .../__snapshots__/enable_alert.test.tsx.snap | 17 ++++++- .../columns/enable_alert.test.tsx | 26 +++++++++-- .../public/state/api/alert_actions.test.ts | 46 +++++++++++-------- .../plugins/uptime/public/state/api/alerts.ts | 1 - 4 files changed, 64 insertions(+), 26 deletions(-) diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/__snapshots__/enable_alert.test.tsx.snap b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/__snapshots__/enable_alert.test.tsx.snap index 486414ab8a052..74956c5c0923a 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/__snapshots__/enable_alert.test.tsx.snap +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/__snapshots__/enable_alert.test.tsx.snap @@ -82,7 +82,22 @@ exports[`EnableAlertComponent shallow renders without errors for valid props 1`] > diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/enable_alert.test.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/enable_alert.test.tsx index dadb4a04c594c..5fe98eac41c9f 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/enable_alert.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/enable_alert.test.tsx @@ -15,6 +15,7 @@ import { import { EuiPopover, EuiText } from '@elastic/eui'; import { DYNAMIC_SETTINGS_DEFAULTS } from '../../../../../common/constants'; import { ReactRouterEuiLink } from '../../../common/react_router_helpers'; +import { makePing } from '../../../../../common/runtime_types/ping'; describe('EnableAlertComponent', () => { let defaultConnectors: string[] = []; @@ -45,14 +46,20 @@ describe('EnableAlertComponent', () => { it('shallow renders without errors for valid props', () => { const wrapper = shallowWithRouterRedux( - + ); expect(wrapper).toMatchSnapshot(); }); it('renders without errors for valid props', () => { const wrapper = renderWithRouterRedux( - + ); expect(wrapper).toMatchSnapshot(); }); @@ -60,7 +67,10 @@ describe('EnableAlertComponent', () => { it('displays define connectors when there is none', () => { defaultConnectors = []; const wrapper = mountWithRouterRedux( - + ); expect(wrapper.find(EuiPopover)).toHaveLength(1); wrapper.find('button').simulate('click'); @@ -98,7 +108,10 @@ describe('EnableAlertComponent', () => { it('does not displays define connectors when there is connector', () => { defaultConnectors = ['infra-slack-connector-id']; const wrapper = mountWithRouterRedux( - + ); expect(wrapper.find(EuiPopover)).toHaveLength(0); @@ -109,7 +122,10 @@ describe('EnableAlertComponent', () => { defaultConnectors = ['infra-slack-connector-id']; const wrapper = mountWithRouterRedux( - + ); expect(wrapper.find('button').prop('aria-label')).toBe('Disable status alert'); diff --git a/x-pack/plugins/uptime/public/state/api/alert_actions.test.ts b/x-pack/plugins/uptime/public/state/api/alert_actions.test.ts index 5d5dd45af9b04..42e91a0615fb8 100644 --- a/x-pack/plugins/uptime/public/state/api/alert_actions.test.ts +++ b/x-pack/plugins/uptime/public/state/api/alert_actions.test.ts @@ -41,32 +41,40 @@ describe('Alert Actions factory', () => { selectedMonitor, defaultActions: [ { - id: '25b89830-5fc6-11eb-9c97-d1d4e807ea39', - notifyWhen: 'onActionGroupChange', - actions: [ - { - actionTypeId: '.pagerduty', - group: 'xpack.uptime.alerts.actionGroups.monitorStatus', - params: { - dedupKey: 'always-downxpack.uptime.alerts.actionGroups.monitorStatus', - eventAction: 'trigger', - severity: 'error', - summary: - 'Monitor {{state.monitorName}} with url {{{state.monitorUrl}}} is {{state.statusMessage}} from {{state.observerLocation}}. The latest error message is {{{state.latestErrorMessage}}}', - }, - id: 'f2a3b195-ed76-499a-805d-82d24d4eeba9', - }, - ], + actionTypeId: '.pagerduty', + group: 'xpack.uptime.alerts.actionGroups.monitorStatus', + params: { + dedupKey: 'always-downxpack.uptime.alerts.actionGroups.monitorStatus', + eventAction: 'trigger', + severity: 'error', + summary: + 'Monitor {{state.monitorName}} with url {{{state.monitorUrl}}} is {{state.statusMessage}} from {{state.observerLocation}}. The latest error message is {{{state.latestErrorMessage}}}', + }, + id: 'f2a3b195-ed76-499a-805d-82d24d4eeba9', }, ], }); expect(resp).toEqual([ { - actionTypeId: undefined, + actionTypeId: '.pagerduty', + group: 'recovered', + id: 'f2a3b195-ed76-499a-805d-82d24d4eeba9', + params: { + dedupKey: 'always-downxpack.uptime.alerts.actionGroups.monitorStatus', + eventAction: 'resolve', + summary: + 'Monitor Always Down Local Port with url tcp://localhost:18278 has recovered with status Up', + }, + }, + { + actionTypeId: '.pagerduty', group: 'xpack.uptime.alerts.actionGroups.monitorStatus', - id: '25b89830-5fc6-11eb-9c97-d1d4e807ea39', + id: 'f2a3b195-ed76-499a-805d-82d24d4eeba9', params: { - message: + dedupKey: 'always-downxpack.uptime.alerts.actionGroups.monitorStatus', + eventAction: 'trigger', + severity: 'error', + summary: 'Monitor {{state.monitorName}} with url {{{state.monitorUrl}}} is {{state.statusMessage}} from {{state.observerLocation}}. The latest error message is {{{state.latestErrorMessage}}}', }, }, diff --git a/x-pack/plugins/uptime/public/state/api/alerts.ts b/x-pack/plugins/uptime/public/state/api/alerts.ts index d5b1d32762f0d..6b71a1063e0e8 100644 --- a/x-pack/plugins/uptime/public/state/api/alerts.ts +++ b/x-pack/plugins/uptime/public/state/api/alerts.ts @@ -24,7 +24,6 @@ export const fetchConnectors = async () => { }; export interface NewAlertParams extends AlertTypeParams { - monitorId: string; selectedMonitor: Ping; defaultActions: ActionConnector[]; } From feabbf3ee847bd79543b6bb84ae9564cb46f35cc Mon Sep 17 00:00:00 2001 From: Shahzad Date: Tue, 26 Jan 2021 15:23:52 +0100 Subject: [PATCH 07/15] fix type --- .../components/overview/monitor_list/columns/enable_alert.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/enable_alert.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/enable_alert.tsx index b7327135c5e39..0b40087a7a28f 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/enable_alert.tsx +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/enable_alert.tsx @@ -24,7 +24,7 @@ import { Ping } from '../../../../../common/runtime_types/ping'; interface Props { monitorId: string; - selectedMonitor?: Ping; + selectedMonitor: Ping; } export const EnableMonitorAlert = ({ monitorId, selectedMonitor }: Props) => { From bcc96b8922fcdf3ec3fd85ba7222136726a53368 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Tue, 26 Jan 2021 15:30:26 +0100 Subject: [PATCH 08/15] added tests --- .../public/state/api/alert_actions.test.ts | 52 +++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/uptime/public/state/api/alert_actions.test.ts b/x-pack/plugins/uptime/public/state/api/alert_actions.test.ts index 42e91a0615fb8..fd60e97ebbf26 100644 --- a/x-pack/plugins/uptime/public/state/api/alert_actions.test.ts +++ b/x-pack/plugins/uptime/public/state/api/alert_actions.test.ts @@ -5,6 +5,7 @@ */ import { populateAlertActions } from './alert_actions'; +import { ActionConnector } from '../alerts/alerts'; const selectedMonitor = { docId: 'X5dkPncBy0xTcvZ347hy', @@ -36,10 +37,10 @@ const selectedMonitor = { }; describe('Alert Actions factory', () => { - it('generate expected action for slack', async () => { + it('generate expected action for pager duty', async () => { const resp = populateAlertActions({ selectedMonitor, - defaultActions: [ + defaultActions: ([ { actionTypeId: '.pagerduty', group: 'xpack.uptime.alerts.actionGroups.monitorStatus', @@ -52,7 +53,52 @@ describe('Alert Actions factory', () => { }, id: 'f2a3b195-ed76-499a-805d-82d24d4eeba9', }, - ], + ] as unknown) as ActionConnector[], + }); + expect(resp).toEqual([ + { + actionTypeId: '.pagerduty', + group: 'recovered', + id: 'f2a3b195-ed76-499a-805d-82d24d4eeba9', + params: { + dedupKey: 'always-downxpack.uptime.alerts.actionGroups.monitorStatus', + eventAction: 'resolve', + summary: + 'Monitor Always Down Local Port with url tcp://localhost:18278 has recovered with status Up', + }, + }, + { + actionTypeId: '.pagerduty', + group: 'xpack.uptime.alerts.actionGroups.monitorStatus', + id: 'f2a3b195-ed76-499a-805d-82d24d4eeba9', + params: { + dedupKey: 'always-downxpack.uptime.alerts.actionGroups.monitorStatus', + eventAction: 'trigger', + severity: 'error', + summary: + 'Monitor {{state.monitorName}} with url {{{state.monitorUrl}}} is {{state.statusMessage}} from {{state.observerLocation}}. The latest error message is {{{state.latestErrorMessage}}}', + }, + }, + ]); + }); + + it('generate expected action for slack action connector', async () => { + const resp = populateAlertActions({ + selectedMonitor, + defaultActions: ([ + { + actionTypeId: '.pagerduty', + group: 'xpack.uptime.alerts.actionGroups.monitorStatus', + params: { + dedupKey: 'always-downxpack.uptime.alerts.actionGroups.monitorStatus', + eventAction: 'trigger', + severity: 'error', + summary: + 'Monitor {{state.monitorName}} with url {{{state.monitorUrl}}} is {{state.statusMessage}} from {{state.observerLocation}}. The latest error message is {{{state.latestErrorMessage}}}', + }, + id: 'f2a3b195-ed76-499a-805d-82d24d4eeba9', + }, + ] as unknown) as ActionConnector[], }); expect(resp).toEqual([ { From a1c982c2cfb8de209c7c243c3857a83fb6f87438 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Mon, 15 Feb 2021 23:23:05 +0100 Subject: [PATCH 09/15] update tests --- .../__snapshots__/enable_alert.test.tsx.snap | 104 ------------- .../columns/enable_alert.test.tsx | 144 +++++++----------- .../monitor_list/columns/enable_alert.tsx | 42 +++-- .../uptime/public/lib/helper/rtl_helpers.tsx | 1 + 4 files changed, 72 insertions(+), 219 deletions(-) delete mode 100644 x-pack/plugins/uptime/public/components/overview/monitor_list/columns/__snapshots__/enable_alert.test.tsx.snap diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/__snapshots__/enable_alert.test.tsx.snap b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/__snapshots__/enable_alert.test.tsx.snap deleted file mode 100644 index 74956c5c0923a..0000000000000 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/__snapshots__/enable_alert.test.tsx.snap +++ /dev/null @@ -1,104 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`EnableAlertComponent renders without errors for valid props 1`] = ` -
-
-
- -
-
-
-`; - -exports[`EnableAlertComponent shallow renders without errors for valid props 1`] = ` - - - - - -`; diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/enable_alert.test.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/enable_alert.test.tsx index e1c5ac38d067e..8aa63504df813 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/enable_alert.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/enable_alert.test.tsx @@ -7,128 +7,86 @@ import React from 'react'; import { EnableMonitorAlert } from './enable_alert'; -import * as redux from 'react-redux'; -import { - mountWithRouterRedux, - renderWithRouterRedux, - shallowWithRouterRedux, -} from '../../../../lib'; -import { EuiPopover, EuiText } from '@elastic/eui'; +import { fireEvent } from '@testing-library/dom'; + import { DYNAMIC_SETTINGS_DEFAULTS } from '../../../../../common/constants'; -import { ReactRouterEuiLink } from '../../../common/react_router_helpers'; import { makePing } from '../../../../../common/runtime_types/ping'; +import { render } from '../../../../lib/helper/rtl_helpers'; +import { DISABLE_STATUS_ALERT, ENABLE_STATUS_ALERT } from './translations'; +import { mockState } from '../../../../lib/__mocks__/uptime_store.mock'; +import { AlertsResult } from '../../../../state/actions/types'; describe('EnableAlertComponent', () => { - let defaultConnectors: string[] = []; - let alerts: any = []; - - beforeEach(() => { - jest.spyOn(redux, 'useDispatch').mockReturnValue(jest.fn()); - - jest.spyOn(redux, 'useSelector').mockImplementation((fn, d) => { - if (fn.name === 'selectDynamicSettings') { - return { - settings: Object.assign(DYNAMIC_SETTINGS_DEFAULTS, { - defaultConnectors, - }), - }; - } - if (fn.name === 'alertsSelector') { - return { - data: { - data: alerts, - }, - loading: false, - }; - } - return {}; - }); - }); - - it('shallow renders without errors for valid props', () => { - const wrapper = shallowWithRouterRedux( + it('it displays define connectors when there is none', () => { + const { getByTestId, getByLabelText, getByText } = render( ); - expect(wrapper).toMatchSnapshot(); - }); + expect(getByTestId('uptimeDisplayDefineConnector')); + expect(getByLabelText(ENABLE_STATUS_ALERT)); - it('renders without errors for valid props', () => { - const wrapper = renderWithRouterRedux( - - ); - expect(wrapper).toMatchSnapshot(); - }); + fireEvent.click(getByTestId('uptimeDisplayDefineConnector')); - it('displays define connectors when there is none', () => { - defaultConnectors = []; - const wrapper = mountWithRouterRedux( - + expect(getByTestId('uptimeSettingsLink')).toHaveAttribute( + 'href', + '/settings?focusConnectorField=true' ); - expect(wrapper.find(EuiPopover)).toHaveLength(1); - wrapper.find('button').simulate('click'); - expect(wrapper.find(EuiText).text()).toBe( - 'To start enabling alerts, please define a default alert action connector in Settings' + expect( + getByText('To start enabling alerts, please define a default alert action connector in') ); - expect(wrapper.find(ReactRouterEuiLink)).toMatchInlineSnapshot(` - - - - - Settings - - - - - `); }); it('does not displays define connectors when there is connector', () => { - defaultConnectors = ['infra-slack-connector-id']; - const wrapper = mountWithRouterRedux( + const defaultConnectors = ['infra-slack-connector-id']; + + const { getByTestId, getByLabelText } = render( + />, + { + state: { + dynamicSettings: { + settings: { ...DYNAMIC_SETTINGS_DEFAULTS, defaultConnectors }, + loading: false, + }, + }, + } ); - expect(wrapper.find(EuiPopover)).toHaveLength(0); + expect(getByTestId('uptimeEnableSimpleDownAlerttestMonitor')); + expect(getByLabelText(ENABLE_STATUS_ALERT)); }); it('displays disable when alert is there', () => { - alerts = [{ id: 'test-alert', params: { search: 'testMonitor' } }]; - defaultConnectors = ['infra-slack-connector-id']; + const alerts = [{ id: 'test-alert', params: { search: 'testMonitor' } }]; + const defaultConnectors = ['infra-slack-connector-id']; - const wrapper = mountWithRouterRedux( + const { getByTestId, getByLabelText } = render( + />, + { + state: { + dynamicSettings: { + settings: { ...DYNAMIC_SETTINGS_DEFAULTS, defaultConnectors }, + loading: false, + }, + alerts: { + ...mockState.alerts, + alerts: { + data: ({ data: alerts } as unknown) as AlertsResult, + loading: false, + }, + }, + }, + } ); - expect(wrapper.find('button').prop('aria-label')).toBe('Disable status alert'); + expect(getByTestId('uptimeDisableSimpleDownAlerttestMonitor')); + expect(getByLabelText(DISABLE_STATUS_ALERT)); }); }); diff --git a/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/enable_alert.tsx b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/enable_alert.tsx index b22d1a7facd3a..71ed222b6b023 100644 --- a/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/enable_alert.tsx +++ b/x-pack/plugins/uptime/public/components/overview/monitor_list/columns/enable_alert.tsx @@ -103,28 +103,26 @@ export const EnableMonitorAlert = ({ monitorId, selectedMonitor }: Props) => { return hasDefaultConnectors || hasAlert ? (
- { - - <> - {' '} - {showSpinner && } - - - } + + <> + {' '} + {showSpinner && } + +
) : ( diff --git a/x-pack/plugins/uptime/public/lib/helper/rtl_helpers.tsx b/x-pack/plugins/uptime/public/lib/helper/rtl_helpers.tsx index e02a2c6f9832f..f9c8690569577 100644 --- a/x-pack/plugins/uptime/public/lib/helper/rtl_helpers.tsx +++ b/x-pack/plugins/uptime/public/lib/helper/rtl_helpers.tsx @@ -110,6 +110,7 @@ export function render( ...mockState, ...state, }; + return reactTestLibRender( From 23a4754a389b9cc47582d053dee91b7d27abe556 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Tue, 16 Feb 2021 13:43:31 +0100 Subject: [PATCH 10/15] update lint --- x-pack/plugins/uptime/public/state/api/alert_actions.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/uptime/public/state/api/alert_actions.test.ts b/x-pack/plugins/uptime/public/state/api/alert_actions.test.ts index fd60e97ebbf26..15fb95f5d4a4d 100644 --- a/x-pack/plugins/uptime/public/state/api/alert_actions.test.ts +++ b/x-pack/plugins/uptime/public/state/api/alert_actions.test.ts @@ -1,7 +1,8 @@ /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. + * 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 { populateAlertActions } from './alert_actions'; From 1081330925e1da850e68adf067cb274d088fb0df Mon Sep 17 00:00:00 2001 From: Shahzad Date: Fri, 16 Apr 2021 10:49:05 +0200 Subject: [PATCH 11/15] update test --- .../functional_with_es_ssl/apps/uptime/simple_down_alert.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/x-pack/test/functional_with_es_ssl/apps/uptime/simple_down_alert.ts b/x-pack/test/functional_with_es_ssl/apps/uptime/simple_down_alert.ts index 302fb14012ade..33af94d949863 100644 --- a/x-pack/test/functional_with_es_ssl/apps/uptime/simple_down_alert.ts +++ b/x-pack/test/functional_with_es_ssl/apps/uptime/simple_down_alert.ts @@ -111,7 +111,9 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { it('disable simple status alert', async () => { await testSubjects.click('uptimeDisableSimpleDownAlert' + monitorId); await pageObjects.header.waitUntilLoadingHasFinished(); - await testSubjects.existOrFail('uptimeEnableSimpleDownAlert' + monitorId); + await retry.try(async ()=>{ + await testSubjects.existOrFail('uptimeEnableSimpleDownAlert' + monitorId); + }); }); }); }; From b293c2e1fc4462947987f68a39547e9dd3ec977b Mon Sep 17 00:00:00 2001 From: Shahzad Date: Fri, 16 Apr 2021 12:23:47 +0200 Subject: [PATCH 12/15] update --- x-pack/plugins/uptime/public/state/api/alert_actions.ts | 1 + .../functional_with_es_ssl/apps/uptime/simple_down_alert.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/uptime/public/state/api/alert_actions.ts b/x-pack/plugins/uptime/public/state/api/alert_actions.ts index 5f7ad29f7457e..fff5fa9a67804 100644 --- a/x-pack/plugins/uptime/public/state/api/alert_actions.ts +++ b/x-pack/plugins/uptime/public/state/api/alert_actions.ts @@ -122,6 +122,7 @@ function getIndexActionParams(selectedMonitor: Ping, recovery = false): IndexAct observerLocation: '{{state.observerLocation}}', }, ], + indexOverride: null, }; } return { diff --git a/x-pack/test/functional_with_es_ssl/apps/uptime/simple_down_alert.ts b/x-pack/test/functional_with_es_ssl/apps/uptime/simple_down_alert.ts index 33af94d949863..b15ce33148fdd 100644 --- a/x-pack/test/functional_with_es_ssl/apps/uptime/simple_down_alert.ts +++ b/x-pack/test/functional_with_es_ssl/apps/uptime/simple_down_alert.ts @@ -111,7 +111,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { it('disable simple status alert', async () => { await testSubjects.click('uptimeDisableSimpleDownAlert' + monitorId); await pageObjects.header.waitUntilLoadingHasFinished(); - await retry.try(async ()=>{ + await retry.try(async () => { await testSubjects.existOrFail('uptimeEnableSimpleDownAlert' + monitorId); }); }); From d2849b456fac2be0b3a575878c2fa2ed103a52b8 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Fri, 16 Apr 2021 19:31:53 +0200 Subject: [PATCH 13/15] update test --- .../overview/synthetics_callout.tsx | 1 + .../apps/uptime/simple_down_alert.ts | 45 +++++++++++-------- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/x-pack/plugins/uptime/public/components/overview/synthetics_callout.tsx b/x-pack/plugins/uptime/public/components/overview/synthetics_callout.tsx index 2772631363794..fa28e42d7d0c1 100644 --- a/x-pack/plugins/uptime/public/components/overview/synthetics_callout.tsx +++ b/x-pack/plugins/uptime/public/components/overview/synthetics_callout.tsx @@ -58,6 +58,7 @@ export const SyntheticsCallout = () => { { if (shouldShow) { hideSyntheticsCallout(); diff --git a/x-pack/test/functional_with_es_ssl/apps/uptime/simple_down_alert.ts b/x-pack/test/functional_with_es_ssl/apps/uptime/simple_down_alert.ts index b15ce33148fdd..52e602989afd3 100644 --- a/x-pack/test/functional_with_es_ssl/apps/uptime/simple_down_alert.ts +++ b/x-pack/test/functional_with_es_ssl/apps/uptime/simple_down_alert.ts @@ -16,6 +16,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const uptimeService = getService('uptime'); const retry = getService('retry'); const supertest = getService('supertest'); + const toasts = getService('toasts'); const testSubjects = getService('testSubjects'); @@ -46,6 +47,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { }); it('displays to define default connector', async () => { + await testSubjects.click('uptimeDismissSyntheticsCallout'); await hideErrorToast(); await testSubjects.click('uptimeDisplayDefineConnector'); await testSubjects.existOrFail('uptimeSettingsDefineConnector'); @@ -71,6 +73,8 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { }); it('displays relevant alert in list drawer', async () => { + await toasts.dismissAllToasts(); + await testSubjects.click(`xpack.uptime.monitorList.${monitorId}.expandMonitorDetail`); await pageObjects.header.waitUntilLoadingHasFinished(); await testSubjects.existOrFail('uptimeMonitorListDrawerAlert0'); @@ -87,25 +91,30 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { alert = alertsFromThisTest[0]; }); - const { actions, alertTypeId, consumer, id, tags } = alert ?? {}; - try { - expect(actions).to.eql([ - { - actionTypeId: '.slack', - group: 'xpack.uptime.alerts.actionGroups.monitorStatus', - id: 'my-slack1', - params: { - message: - 'Monitor {{state.monitorName}} with url {{{state.monitorUrl}}} is {{state.statusMessage}} from {{state.observerLocation}}. The latest error message is {{{state.latestErrorMessage}}}', - }, + const { actions, alertTypeId, consumer, tags } = alert ?? {}; + expect(actions).to.eql([ + { + actionTypeId: '.slack', + group: 'recovered', + params: { + message: + 'Monitor 0000-intermittent with url http://localhost:5678/pattern?r=200x5,500x1 has recovered with status Up', }, - ]); - expect(alertTypeId).to.eql('xpack.uptime.alerts.monitorStatus'); - expect(consumer).to.eql('uptime'); - expect(tags).to.eql(['UPTIME_AUTO']); - } catch (e) { - await supertest.delete(`/api/alerts/alert/${id}`).set('kbn-xsrf', 'true').expect(204); - } + id: 'my-slack1', + }, + { + actionTypeId: '.slack', + group: 'xpack.uptime.alerts.actionGroups.monitorStatus', + params: { + message: + 'Monitor {{state.monitorName}} with url {{{state.monitorUrl}}} is {{state.statusMessage}} from {{state.observerLocation}}. The latest error message is {{{state.latestErrorMessage}}}', + }, + id: 'my-slack1', + }, + ]); + expect(alertTypeId).to.eql('xpack.uptime.alerts.monitorStatus'); + expect(consumer).to.eql('uptime'); + expect(tags).to.eql(['UPTIME_AUTO']); }); it('disable simple status alert', async () => { From 1d99c4e2d635bc28d09e4920e13719fbb22903e4 Mon Sep 17 00:00:00 2001 From: Shahzad Date: Fri, 16 Apr 2021 22:28:14 +0200 Subject: [PATCH 14/15] snapshot --- .../public/components/overview/synthetics_callout.test.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x-pack/plugins/uptime/public/components/overview/synthetics_callout.test.tsx b/x-pack/plugins/uptime/public/components/overview/synthetics_callout.test.tsx index b5933fa51b398..5f6f9d7a7207e 100644 --- a/x-pack/plugins/uptime/public/components/overview/synthetics_callout.test.tsx +++ b/x-pack/plugins/uptime/public/components/overview/synthetics_callout.test.tsx @@ -55,6 +55,7 @@ describe('SyntheticsCallout', () => { grow={false} > { grow={false} > Date: Tue, 27 Apr 2021 14:27:34 +0200 Subject: [PATCH 15/15] lint --- .../uptime/public/components/monitor/monitor_title.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/x-pack/plugins/uptime/public/components/monitor/monitor_title.tsx b/x-pack/plugins/uptime/public/components/monitor/monitor_title.tsx index 5b19a61b713e3..eebd3d8aeb14d 100644 --- a/x-pack/plugins/uptime/public/components/monitor/monitor_title.tsx +++ b/x-pack/plugins/uptime/public/components/monitor/monitor_title.tsx @@ -89,10 +89,7 @@ export const MonitorPageTitle: React.FC = () => { - +