Skip to content

Commit

Permalink
Updating functional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ymao1 committed Nov 4, 2020
1 parent dc4b4da commit 3d2c08b
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ export const alertInstancesTableColumns = (
render: (value: AlertInstanceListItemStatus, instance: AlertInstanceListItem) => {
return (
<EuiHealth color={value.healthColor}>
{value.label} {value.actionGroup ? `(${value.actionGroup})` : null}
{value.label}
{value.actionGroup ? ` (${value.actionGroup})` : null}
</EuiHealth>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -226,6 +262,7 @@ export default function createGetAlertInstanceSummaryTests({ getService }: FtrPr
instanceA: {
status: 'Active',
muted: false,
actionGroupId: 'default',
activeStartDate: actualInstances.instanceA.activeStartDate,
},
instanceB: {
Expand All @@ -235,6 +272,7 @@ export default function createGetAlertInstanceSummaryTests({ getService }: FtrPr
instanceC: {
status: 'Active',
muted: true,
actionGroupId: 'default',
activeStartDate: actualInstances.instanceC.activeStartDate,
},
instanceD: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down

0 comments on commit 3d2c08b

Please sign in to comment.