[Alerting UI] Fixed flaky alerting e2e tests (#79533)
* Removed skip on alerting e2e tests * Reduced alerting tests execution time by removing page reload for each test. Added server side cleanup fo each test with createAlert. Removed long waiting toast method for reduce flakiness. * Added additional cleanup and retry method for delete single alert
This commit is contained in:
parent
0a02ac1327
commit
4996020087
|
@ -40,8 +40,21 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
return createdAlert;
|
||||
}
|
||||
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/77401
|
||||
describe.skip('alerts', function () {
|
||||
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, '');
|
||||
});
|
||||
}
|
||||
|
||||
describe('alerts', function () {
|
||||
before(async () => {
|
||||
await pageObjects.common.navigateToApp('triggersActions');
|
||||
await testSubjects.click('alertsTab');
|
||||
|
@ -104,15 +117,18 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
interval: '1m',
|
||||
},
|
||||
]);
|
||||
|
||||
// clean up created alert
|
||||
const alertsToDelete = await getAlertsByName(alertName);
|
||||
await deleteAlerts(alertsToDelete.map((alertItem: { id: string }) => alertItem.id));
|
||||
});
|
||||
|
||||
it('should display alerts in alphabetical order', async () => {
|
||||
const uniqueKey = generateUniqueKey();
|
||||
await createAlert({ name: 'b', tags: [uniqueKey] });
|
||||
await createAlert({ name: 'c', tags: [uniqueKey] });
|
||||
await createAlert({ name: 'a', tags: [uniqueKey] });
|
||||
const a = await createAlert({ name: 'b', tags: [uniqueKey] });
|
||||
const b = await createAlert({ name: 'c', tags: [uniqueKey] });
|
||||
const c = await createAlert({ name: 'a', tags: [uniqueKey] });
|
||||
|
||||
await pageObjects.common.navigateToApp('triggersActions');
|
||||
await pageObjects.triggersActionsUI.searchAlerts(uniqueKey);
|
||||
|
||||
const searchResults = await pageObjects.triggersActionsUI.getAlertsList();
|
||||
|
@ -120,11 +136,12 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
expect(searchResults[0].name).to.eql('a');
|
||||
expect(searchResults[1].name).to.eql('b');
|
||||
expect(searchResults[2].name).to.eql('c');
|
||||
|
||||
await deleteAlerts([a.id, b.id, c.id]);
|
||||
});
|
||||
|
||||
it('should search for alert', async () => {
|
||||
const createdAlert = await createAlert();
|
||||
await pageObjects.common.navigateToApp('triggersActions');
|
||||
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
|
||||
|
||||
const searchResults = await pageObjects.triggersActionsUI.getAlertsList();
|
||||
|
@ -136,11 +153,11 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
interval: '1m',
|
||||
},
|
||||
]);
|
||||
await deleteAlerts([createdAlert.id]);
|
||||
});
|
||||
|
||||
it('should search for tags', async () => {
|
||||
const createdAlert = await createAlert();
|
||||
await pageObjects.common.navigateToApp('triggersActions');
|
||||
await pageObjects.triggersActionsUI.searchAlerts(`${createdAlert.name} foo`);
|
||||
|
||||
const searchResults = await pageObjects.triggersActionsUI.getAlertsList();
|
||||
|
@ -152,10 +169,10 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
interval: '1m',
|
||||
},
|
||||
]);
|
||||
await deleteAlerts([createdAlert.id]);
|
||||
});
|
||||
|
||||
it('should display an empty list when search removes all alerts', async () => {
|
||||
await pageObjects.common.navigateToApp('triggersActions');
|
||||
it('should display an empty list when search did not return any alerts', async () => {
|
||||
await pageObjects.triggersActionsUI.searchAlerts(`An Alert That For Sure Doesn't Exist!`);
|
||||
|
||||
expect(await pageObjects.triggersActionsUI.isAlertsListDisplayed()).to.eql(true);
|
||||
|
@ -163,7 +180,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
|
||||
it('should disable single alert', async () => {
|
||||
const createdAlert = await createAlert();
|
||||
await pageObjects.common.navigateToApp('triggersActions');
|
||||
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
|
||||
|
||||
await testSubjects.click('collapsedItemActions');
|
||||
|
@ -177,11 +193,11 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
const disableSwitchAfterDisable = await testSubjects.find('disableSwitch');
|
||||
const isChecked = await disableSwitchAfterDisable.getAttribute('aria-checked');
|
||||
expect(isChecked).to.eql('true');
|
||||
await deleteAlerts([createdAlert.id]);
|
||||
});
|
||||
|
||||
it('should re-enable single alert', async () => {
|
||||
const createdAlert = await createAlert();
|
||||
await pageObjects.common.navigateToApp('triggersActions');
|
||||
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
|
||||
|
||||
await testSubjects.click('collapsedItemActions');
|
||||
|
@ -201,11 +217,11 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
const disableSwitchAfterReEnable = await testSubjects.find('disableSwitch');
|
||||
const isChecked = await disableSwitchAfterReEnable.getAttribute('aria-checked');
|
||||
expect(isChecked).to.eql('false');
|
||||
await deleteAlerts([createdAlert.id]);
|
||||
});
|
||||
|
||||
it('should mute single alert', async () => {
|
||||
const createdAlert = await createAlert();
|
||||
await pageObjects.common.navigateToApp('triggersActions');
|
||||
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
|
||||
|
||||
await testSubjects.click('collapsedItemActions');
|
||||
|
@ -219,11 +235,11 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
const muteSwitchAfterMute = await testSubjects.find('muteSwitch');
|
||||
const isChecked = await muteSwitchAfterMute.getAttribute('aria-checked');
|
||||
expect(isChecked).to.eql('true');
|
||||
await deleteAlerts([createdAlert.id]);
|
||||
});
|
||||
|
||||
it('should unmute single alert', async () => {
|
||||
const createdAlert = await createAlert();
|
||||
await pageObjects.common.navigateToApp('triggersActions');
|
||||
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
|
||||
|
||||
await testSubjects.click('collapsedItemActions');
|
||||
|
@ -243,13 +259,13 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
const muteSwitchAfterUnmute = await testSubjects.find('muteSwitch');
|
||||
const isChecked = await muteSwitchAfterUnmute.getAttribute('aria-checked');
|
||||
expect(isChecked).to.eql('false');
|
||||
await deleteAlerts([createdAlert.id]);
|
||||
});
|
||||
|
||||
it('should delete single alert', async () => {
|
||||
await createAlert();
|
||||
const createdAlert = await createAlert();
|
||||
await pageObjects.common.navigateToApp('triggersActions');
|
||||
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
|
||||
const firstAlert = await createAlert();
|
||||
const secondAlert = await createAlert();
|
||||
await pageObjects.triggersActionsUI.searchAlerts(secondAlert.name);
|
||||
|
||||
await testSubjects.click('collapsedItemActions');
|
||||
|
||||
|
@ -258,17 +274,19 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
await testSubjects.click('deleteIdsConfirmation > confirmModalConfirmButton');
|
||||
await testSubjects.missingOrFail('deleteIdsConfirmation');
|
||||
|
||||
const toastTitle = await pageObjects.common.closeToast();
|
||||
expect(toastTitle).to.eql('Deleted 1 alert');
|
||||
await pageObjects.common.navigateToApp('triggersActions');
|
||||
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
|
||||
await retry.try(async () => {
|
||||
const toastTitle = await pageObjects.common.closeToast();
|
||||
expect(toastTitle).to.eql('Deleted 1 alert');
|
||||
});
|
||||
|
||||
await pageObjects.triggersActionsUI.searchAlerts(secondAlert.name);
|
||||
const searchResultsAfterDelete = await pageObjects.triggersActionsUI.getAlertsList();
|
||||
expect(searchResultsAfterDelete.length).to.eql(0);
|
||||
await deleteAlerts([firstAlert.id]);
|
||||
});
|
||||
|
||||
it('should mute all selection', async () => {
|
||||
const createdAlert = await createAlert();
|
||||
await pageObjects.common.navigateToApp('triggersActions');
|
||||
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
|
||||
|
||||
await testSubjects.click(`checkboxSelectRow-${createdAlert.id}`);
|
||||
|
@ -287,11 +305,11 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
const muteSwitch = await testSubjects.find('muteSwitch');
|
||||
const isChecked = await muteSwitch.getAttribute('aria-checked');
|
||||
expect(isChecked).to.eql('true');
|
||||
await deleteAlerts([createdAlert.id]);
|
||||
});
|
||||
|
||||
it('should unmute all selection', async () => {
|
||||
const createdAlert = await createAlert();
|
||||
await pageObjects.common.navigateToApp('triggersActions');
|
||||
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
|
||||
|
||||
await testSubjects.click(`checkboxSelectRow-${createdAlert.id}`);
|
||||
|
@ -312,11 +330,11 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
const muteSwitch = await testSubjects.find('muteSwitch');
|
||||
const isChecked = await muteSwitch.getAttribute('aria-checked');
|
||||
expect(isChecked).to.eql('false');
|
||||
await deleteAlerts([createdAlert.id]);
|
||||
});
|
||||
|
||||
it('should disable all selection', async () => {
|
||||
const createdAlert = await createAlert();
|
||||
await pageObjects.common.navigateToApp('triggersActions');
|
||||
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
|
||||
|
||||
await testSubjects.click(`checkboxSelectRow-${createdAlert.id}`);
|
||||
|
@ -335,11 +353,11 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
const disableSwitch = await testSubjects.find('disableSwitch');
|
||||
const isChecked = await disableSwitch.getAttribute('aria-checked');
|
||||
expect(isChecked).to.eql('true');
|
||||
await deleteAlerts([createdAlert.id]);
|
||||
});
|
||||
|
||||
it('should enable all selection', async () => {
|
||||
const createdAlert = await createAlert();
|
||||
await pageObjects.common.navigateToApp('triggersActions');
|
||||
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
|
||||
|
||||
await testSubjects.click(`checkboxSelectRow-${createdAlert.id}`);
|
||||
|
@ -360,6 +378,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
const disableSwitch = await testSubjects.find('disableSwitch');
|
||||
const isChecked = await disableSwitch.getAttribute('aria-checked');
|
||||
expect(isChecked).to.eql('false');
|
||||
await deleteAlerts([createdAlert.id]);
|
||||
});
|
||||
|
||||
it('should delete all selection', async () => {
|
||||
|
@ -373,7 +392,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
times(2, () => createAlert({ name: `${namePrefix}-1${count++}` }))
|
||||
);
|
||||
|
||||
await pageObjects.common.navigateToApp('triggersActions');
|
||||
await pageObjects.triggersActionsUI.searchAlerts(namePrefix);
|
||||
|
||||
for (const createdAlert of createdAlertsFirstPage) {
|
||||
|
@ -392,12 +410,13 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
|
|||
expect(toastTitle).to.eql('Deleted 10 alerts');
|
||||
});
|
||||
|
||||
await pageObjects.common.navigateToApp('triggersActions');
|
||||
await pageObjects.triggersActionsUI.searchAlerts(namePrefix);
|
||||
const searchResultsAfterDelete = await pageObjects.triggersActionsUI.getAlertsList();
|
||||
expect(searchResultsAfterDelete).to.have.length(2);
|
||||
expect(searchResultsAfterDelete[0].name).to.eql(createdAlertsSecondPage[0].name);
|
||||
expect(searchResultsAfterDelete[1].name).to.eql(createdAlertsSecondPage[1].name);
|
||||
|
||||
await deleteAlerts([createdAlertsSecondPage[0].id, createdAlertsSecondPage[1].id]);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue