From 3d2c08b9ad7e5c1adfe500a0af603d1f050608fe Mon Sep 17 00:00:00 2001 From: Ying Mao Date: Wed, 4 Nov 2020 13:20:43 -0500 Subject: [PATCH] Updating functional tests --- .../components/alert_instances.tsx | 3 +- .../spaces_only/tests/alerting/event_log.ts | 2 +- .../alerting/get_alert_instance_summary.ts | 38 +++++++++++++++++++ .../apps/triggers_actions_ui/details.ts | 6 +-- 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_instances.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_instances.tsx index 6b33235162c69..f368066f3c69e 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_instances.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/alert_details/components/alert_instances.tsx @@ -57,7 +57,8 @@ export const alertInstancesTableColumns = ( render: (value: AlertInstanceListItemStatus, instance: AlertInstanceListItem) => { return ( - {value.label} {value.actionGroup ? `(${value.actionGroup})` : null} + {value.label} + {value.actionGroup ? ` (${value.actionGroup})` : null} ); }, diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/event_log.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/event_log.ts index a5dff437283ae..dbf8eb162fca7 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/event_log.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/event_log.ts @@ -134,7 +134,7 @@ export default function eventLogTests({ getService }: FtrProviderContext) { validateInstanceEvent(event, `resolved instance: 'instance'`); break; case 'active-instance': - validateInstanceEvent(event, `active instance: 'instance'`); + validateInstanceEvent(event, `active instance: 'instance' in actionGroup: 'default'`); break; // this will get triggered as we add new event actions default: diff --git a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/get_alert_instance_summary.ts b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/get_alert_instance_summary.ts index 563127e028a62..37be74e915faf 100644 --- a/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/get_alert_instance_summary.ts +++ b/x-pack/test/alerting_api_integration/spaces_only/tests/alerting/get_alert_instance_summary.ts @@ -173,6 +173,42 @@ export default function createGetAlertInstanceSummaryTests({ getService }: FtrPr }); }); + it('handles muted instances that are active', async () => { + const pattern = { + instanceA: [true, true, true, true], + }; + + const { body: createdAlert } = await supertest + .post(`${getUrlPrefix(Spaces.space1.id)}/api/alerts/alert`) + .set('kbn-xsrf', 'foo') + .send( + getTestAlertData({ + alertTypeId: 'test.patternFiring', + params: { pattern }, + schedule: { interval: '1s' }, + }) + ) + .expect(200); + objectRemover.add(Spaces.space1.id, createdAlert.id, 'alert', 'alerts'); + await alertUtils.muteInstance(createdAlert.id, 'instanceA'); + + await waitForEvents(createdAlert.id, ['active-instance']); + const response = await supertest.get( + `${getUrlPrefix(Spaces.space1.id)}/api/alerts/alert/${createdAlert.id}/_instance_summary` + ); + + const actualInstances = response.body.instances; + const expectedInstances = { + instanceA: { + status: 'Active', + muted: true, + actionGroupId: 'default', + activeStartDate: actualInstances.instanceA.activeStartDate, + }, + }; + expect(actualInstances).to.eql(expectedInstances); + }); + it('handles alert errors', async () => { const dateNow = Date.now(); const { body: createdAlert } = await supertest @@ -226,6 +262,7 @@ export default function createGetAlertInstanceSummaryTests({ getService }: FtrPr instanceA: { status: 'Active', muted: false, + actionGroupId: 'default', activeStartDate: actualInstances.instanceA.activeStartDate, }, instanceB: { @@ -235,6 +272,7 @@ export default function createGetAlertInstanceSummaryTests({ getService }: FtrPr instanceC: { status: 'Active', muted: true, + actionGroupId: 'default', activeStartDate: actualInstances.instanceC.activeStartDate, }, instanceD: { diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/details.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/details.ts index 4c97c8556d7df..9e4006681dc8d 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/details.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/details.ts @@ -392,21 +392,21 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { expect(instancesList.map((instance) => omit(instance, 'duration'))).to.eql([ { instance: 'us-central', - status: 'Active', + status: 'Active (Default)', start: moment(dateOnAllInstancesFromApiResponse['us-central']) .utc() .format('D MMM YYYY @ HH:mm:ss'), }, { instance: 'us-east', - status: 'Active', + status: 'Active (Default)', start: moment(dateOnAllInstancesFromApiResponse['us-east']) .utc() .format('D MMM YYYY @ HH:mm:ss'), }, { instance: 'us-west', - status: 'Active', + status: 'Active (Default)', start: moment(dateOnAllInstancesFromApiResponse['us-west']) .utc() .format('D MMM YYYY @ HH:mm:ss'),