forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added functional test for alerts list filters by status, alert type a…
…nd action type. Did a code refactoring and splitting for alerts tests. (elastic#81422) (elastic#81794) * Added functional test for alerts list filters by status, alert type and action type. Did a code refactoring and splitting for alerts tests. * - * fixed failing tests * fixed type checks * minor naming fixes
- Loading branch information
1 parent
41206e1
commit f3e6671
Showing
11 changed files
with
393 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alert_create_flyout.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
/* | ||
* 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 uuid from 'uuid'; | ||
import expect from '@kbn/expect'; | ||
import { FtrProviderContext } from '../../ftr_provider_context'; | ||
|
||
function generateUniqueKey() { | ||
return uuid.v4().replace(/-/g, ''); | ||
} | ||
|
||
export default ({ getPageObjects, getService }: FtrProviderContext) => { | ||
const testSubjects = getService('testSubjects'); | ||
const pageObjects = getPageObjects(['common', 'triggersActionsUI', 'header']); | ||
const supertest = getService('supertest'); | ||
const find = getService('find'); | ||
const retry = getService('retry'); | ||
|
||
async function getAlertsByName(name: string) { | ||
const { | ||
body: { data: alerts }, | ||
} = await supertest.get(`/api/alerts/_find?search=${name}&search_fields=name`).expect(200); | ||
|
||
return alerts; | ||
} | ||
|
||
async function deleteAlerts(alertIds: string[]) { | ||
alertIds.forEach(async (alertId: string) => { | ||
await supertest.delete(`/api/alerts/alert/${alertId}`).set('kbn-xsrf', 'foo').expect(204, ''); | ||
}); | ||
} | ||
|
||
async function defineAlert(alertName: string) { | ||
await pageObjects.triggersActionsUI.clickCreateAlertButton(); | ||
await testSubjects.setValue('alertNameInput', alertName); | ||
await testSubjects.click('.index-threshold-SelectOption'); | ||
await testSubjects.click('selectIndexExpression'); | ||
const comboBox = await find.byCssSelector('#indexSelectSearchBox'); | ||
await comboBox.click(); | ||
await comboBox.type('k'); | ||
const filterSelectItem = await find.byCssSelector(`.euiFilterSelectItem`); | ||
await filterSelectItem.click(); | ||
await testSubjects.click('thresholdAlertTimeFieldSelect'); | ||
await retry.try(async () => { | ||
const fieldOptions = await find.allByCssSelector('#thresholdTimeField option'); | ||
expect(fieldOptions[1]).not.to.be(undefined); | ||
await fieldOptions[1].click(); | ||
}); | ||
await testSubjects.click('closePopover'); | ||
// need this two out of popup clicks to close them | ||
const nameInput = await testSubjects.find('alertNameInput'); | ||
await nameInput.click(); | ||
} | ||
|
||
describe('create alert', function () { | ||
before(async () => { | ||
await pageObjects.common.navigateToApp('triggersActions'); | ||
await testSubjects.click('alertsTab'); | ||
}); | ||
|
||
it('should create an alert', async () => { | ||
const alertName = generateUniqueKey(); | ||
await defineAlert(alertName); | ||
|
||
await testSubjects.click('.slack-ActionTypeSelectOption'); | ||
await testSubjects.click('addNewActionConnectorButton-.slack'); | ||
const slackConnectorName = generateUniqueKey(); | ||
await testSubjects.setValue('nameInput', slackConnectorName); | ||
await testSubjects.setValue('slackWebhookUrlInput', 'https://test'); | ||
await find.clickByCssSelector('[data-test-subj="saveActionButtonModal"]:not(disabled)'); | ||
const createdConnectorToastTitle = await pageObjects.common.closeToast(); | ||
expect(createdConnectorToastTitle).to.eql(`Created '${slackConnectorName}'`); | ||
await testSubjects.setValue('messageTextArea', 'test message '); | ||
await testSubjects.click('messageAddVariableButton'); | ||
await testSubjects.click('variableMenuButton-0'); | ||
const messageTextArea = await find.byCssSelector('[data-test-subj="messageTextArea"]'); | ||
expect(await messageTextArea.getAttribute('value')).to.eql('test message {{alertId}}'); | ||
await messageTextArea.type(' some additional text '); | ||
|
||
await testSubjects.click('messageAddVariableButton'); | ||
await testSubjects.click('variableMenuButton-1'); | ||
|
||
expect(await messageTextArea.getAttribute('value')).to.eql( | ||
'test message {{alertId}} some additional text {{alertInstanceId}}' | ||
); | ||
|
||
await testSubjects.click('saveAlertButton'); | ||
const toastTitle = await pageObjects.common.closeToast(); | ||
expect(toastTitle).to.eql(`Created alert "${alertName}"`); | ||
await pageObjects.triggersActionsUI.searchAlerts(alertName); | ||
const searchResultsAfterSave = await pageObjects.triggersActionsUI.getAlertsList(); | ||
expect(searchResultsAfterSave).to.eql([ | ||
{ | ||
name: alertName, | ||
tagsText: '', | ||
alertType: 'Index threshold', | ||
interval: '1m', | ||
}, | ||
]); | ||
|
||
// clean up created alert | ||
const alertsToDelete = await getAlertsByName(alertName); | ||
await deleteAlerts(alertsToDelete.map((alertItem: { id: string }) => alertItem.id)); | ||
}); | ||
|
||
it('should show save confirmation before creating alert with no actions', async () => { | ||
const alertName = generateUniqueKey(); | ||
await defineAlert(alertName); | ||
|
||
await testSubjects.click('saveAlertButton'); | ||
await testSubjects.existOrFail('confirmAlertSaveModal'); | ||
await testSubjects.click('confirmAlertSaveModal > confirmModalCancelButton'); | ||
await testSubjects.missingOrFail('confirmAlertSaveModal'); | ||
await find.existsByCssSelector('[data-test-subj="saveAlertButton"]:not(disabled)'); | ||
|
||
await testSubjects.click('saveAlertButton'); | ||
await testSubjects.existOrFail('confirmAlertSaveModal'); | ||
await testSubjects.click('confirmAlertSaveModal > confirmModalConfirmButton'); | ||
await testSubjects.missingOrFail('confirmAlertSaveModal'); | ||
|
||
const toastTitle = await pageObjects.common.closeToast(); | ||
expect(toastTitle).to.eql(`Created alert "${alertName}"`); | ||
await pageObjects.triggersActionsUI.searchAlerts(alertName); | ||
const searchResultsAfterSave = await pageObjects.triggersActionsUI.getAlertsList(); | ||
expect(searchResultsAfterSave).to.eql([ | ||
{ | ||
name: alertName, | ||
tagsText: '', | ||
alertType: 'Index threshold', | ||
interval: '1m', | ||
}, | ||
]); | ||
|
||
// clean up created alert | ||
const alertsToDelete = await getAlertsByName(alertName); | ||
await deleteAlerts(alertsToDelete.map((alertItem: { id: string }) => alertItem.id)); | ||
}); | ||
}); | ||
}; |
Oops, something went wrong.