Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Alerting] Reload the Alerts List when alerts are deleted #73715

Merged
merged 8 commits into from
Aug 5, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -400,17 +400,8 @@ export const AlertsList: React.FunctionComponent = () => {
<section data-test-subj="alertsList">
<DeleteModalConfirmation
onDeleted={(deleted: string[]) => {
if (selectedIds.length === 0 || selectedIds.length === deleted.length) {
const updatedAlerts = alertsState.data.filter(
(alert) => alert.id && !alertsToDelete.includes(alert.id)
);
setAlertsState({
isLoading: false,
data: updatedAlerts,
totalItemCount: alertsState.totalItemCount - deleted.length,
});
setSelectedIds([]);
}
loadAlertsData();
setSelectedIds([]);
setAlertsToDelete([]);
}}
onErrors={async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import uuid from 'uuid';
import { times } from 'lodash';
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';

Expand Down Expand Up @@ -361,11 +362,22 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
});

it('should delete all selection', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Seems like testing for this could be covered in a unit test instead of end to end.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can test the implementation of the fix in a unit test, but you can't test the actual behaviour as it relies on hooks and calls being made inside of other components (including EUI).
You could never be sure it's working correctly with just a unit test...

I have a real fear that we're compromising on test quality instead of addressing the scaling issues in our infrastructure. :/

const createdAlert = await createAlert();
const namePrefix = generateUniqueKey();
let count = 0;
const createdAlertsFirstPage = await Promise.all(
times(10, () => createAlert({ name: `${namePrefix}-0${count++}` }))
);

const createdAlertsSecondPage = await Promise.all(
times(2, () => createAlert({ name: `${namePrefix}-1${count++}` }))
);

await pageObjects.common.navigateToApp('triggersActions');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
await pageObjects.triggersActionsUI.searchAlerts(namePrefix);

await testSubjects.click(`checkboxSelectRow-${createdAlert.id}`);
for (const createdAlert of createdAlertsFirstPage) {
await testSubjects.click(`checkboxSelectRow-${createdAlert.id}`);
}

await testSubjects.click('bulkAction');

Expand All @@ -377,9 +389,11 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await pageObjects.common.closeToast();

await pageObjects.common.navigateToApp('triggersActions');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
await pageObjects.triggersActionsUI.searchAlerts(namePrefix);
const searchResultsAfterDelete = await pageObjects.triggersActionsUI.getAlertsList();
expect(searchResultsAfterDelete.length).to.eql(0);
expect(searchResultsAfterDelete).to.have.length(2);
expect(searchResultsAfterDelete[0].name).to.eql(createdAlertsSecondPage[0].name);
expect(searchResultsAfterDelete[1].name).to.eql(createdAlertsSecondPage[1].name);
});
});
};