Skip to content

Commit

Permalink
Remove edit alert button from alerts list
Browse files Browse the repository at this point in the history
  • Loading branch information
mikecote committed Apr 28, 2020
1 parent 4d3e60b commit 698c6e8
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 216 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,25 @@ describe('alert_form', () => {
const alertTypeSelectOptions = wrapper.find('[data-test-subj="selectedAlertTypeTitle"]');
expect(alertTypeSelectOptions.exists()).toBeTruthy();
});

it('should update throttle value', async () => {
const newThrottle = 17;
await setup();
const throttleField = wrapper.find('[data-test-subj="throttleInput"]');
expect(throttleField.exists()).toBeTruthy();
throttleField.at(1).simulate('change', { target: { value: newThrottle.toString() } });
const throttleFieldAfterUpdate = wrapper.find('[data-test-subj="throttleInput"]');
expect(throttleFieldAfterUpdate.at(1).prop('value')).toEqual(newThrottle);
});

it('should unset throttle value', async () => {
const newThrottle = '';
await setup();
const throttleField = wrapper.find('[data-test-subj="throttleInput"]');
expect(throttleField.exists()).toBeTruthy();
throttleField.at(1).simulate('change', { target: { value: newThrottle } });
const throttleFieldAfterUpdate = wrapper.find('[data-test-subj="throttleInput"]');
expect(throttleFieldAfterUpdate.at(1).prop('value')).toEqual(newThrottle);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,6 @@ describe('alerts_list component with items', () => {
expect(wrapper.find('EuiBasicTable')).toHaveLength(1);
expect(wrapper.find('EuiTableRow')).toHaveLength(2);
});
it('renders edit button for registered alert types', async () => {
await setup();
expect(wrapper.find('[data-test-subj="alertsTableCell-editLink"]').length).toBeGreaterThan(0);
});
});

describe('alerts_list component empty with show only capability', () => {
Expand Down Expand Up @@ -442,8 +438,4 @@ describe('alerts_list with show only capability', () => {
expect(wrapper.find('EuiTableRow')).toHaveLength(2);
// TODO: check delete button
});
it('not renders edit button for non registered alert types', async () => {
await setup();
expect(wrapper.find('[data-test-subj="alertsTableCell-editLink"]').length).toBe(0);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -219,27 +219,6 @@ export const AlertsList: React.FunctionComponent = () => {
truncateText: false,
'data-test-subj': 'alertsTableCell-interval',
},
{
name: '',
width: '50px',
render(item: AlertTableItem) {
if (!canSave || !alertTypeRegistry.has(item.alertTypeId)) {
return;
}
return (
<EuiLink
data-test-subj="alertsTableCell-editLink"
color="primary"
onClick={() => editItem(item)}
>
<FormattedMessage
defaultMessage="Edit"
id="xpack.triggersActionsUI.sections.alertsList.alertsListTable.columns.editLinkTitle"
/>
</EuiLink>
);
},
},
{
name: '',
width: '40px',
Expand Down
187 changes: 0 additions & 187 deletions x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alerts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,193 +126,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
]);
});

it('should edit an alert', async () => {
const createdAlert = await createAlert({
alertTypeId: '.index-threshold',
name: generateUniqueKey(),
params: {
aggType: 'count',
termSize: 5,
thresholdComparator: '>',
timeWindowSize: 5,
timeWindowUnit: 'm',
groupBy: 'all',
threshold: [1000, 5000],
index: ['.kibana_1'],
timeField: 'alert',
},
});
await pageObjects.common.navigateToApp('triggersActions');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);

const searchResults = await pageObjects.triggersActionsUI.getAlertsList();
expect(searchResults).to.eql([
{
name: createdAlert.name,
tagsText: 'foo, bar',
alertType: 'Index threshold',
interval: '1m',
},
]);
const editLink = await testSubjects.findAll('alertsTableCell-editLink');
await editLink[0].click();

const updatedAlertName = `Changed Alert Name ${generateUniqueKey()}`;
await testSubjects.setValue('alertNameInput', updatedAlertName, { clearWithKeyboard: true });

await find.clickByCssSelector('[data-test-subj="saveEditedAlertButton"]:not(disabled)');

const toastTitle = await pageObjects.common.closeToast();
expect(toastTitle).to.eql(`Updated '${updatedAlertName}'`);
await pageObjects.common.navigateToApp('triggersActions');
await pageObjects.triggersActionsUI.searchAlerts(updatedAlertName);

const searchResultsAfterEdit = await pageObjects.triggersActionsUI.getAlertsList();
expect(searchResultsAfterEdit).to.eql([
{
name: updatedAlertName,
tagsText: 'foo, bar',
alertType: 'Index threshold',
interval: '1m',
},
]);
});

it('should set an alert throttle', async () => {
const alertName = `edit throttle ${generateUniqueKey()}`;
const createdAlert = await createAlert({
alertTypeId: '.index-threshold',
name: alertName,
params: {
aggType: 'count',
termSize: 5,
thresholdComparator: '>',
timeWindowSize: 5,
timeWindowUnit: 'm',
groupBy: 'all',
threshold: [1000, 5000],
index: ['.kibana_1'],
timeField: 'alert',
},
});
await pageObjects.common.navigateToApp('triggersActions');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);

const searchResults = await pageObjects.triggersActionsUI.getAlertsList();
expect(searchResults).to.eql([
{
name: createdAlert.name,
tagsText: 'foo, bar',
alertType: 'Index threshold',
interval: '1m',
},
]);

const editLink = await testSubjects.findAll('alertsTableCell-editLink');
await editLink[0].click();

await testSubjects.setValue('throttleInput', '1', { clearWithKeyboard: true });

await find.clickByCssSelector('[data-test-subj="saveEditedAlertButton"]:not(disabled)');

expect(await pageObjects.common.closeToast()).to.eql(`Updated '${createdAlert.name}'`);

await pageObjects.common.navigateToApp('triggersActions');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
await (await testSubjects.findAll('alertsTableCell-editLink'))[0].click();
const throttleInput = await testSubjects.find('throttleInput');
expect(await throttleInput.getAttribute('value')).to.eql('1');
});

it('should unset an alert throttle', async () => {
const alertName = `edit throttle ${generateUniqueKey()}`;
const createdAlert = await createAlert({
alertTypeId: '.index-threshold',
name: alertName,
throttle: '10m',
params: {
aggType: 'count',
termSize: 5,
thresholdComparator: '>',
timeWindowSize: 5,
timeWindowUnit: 'm',
groupBy: 'all',
threshold: [1000, 5000],
index: ['.kibana_1'],
timeField: 'alert',
},
});
await pageObjects.common.navigateToApp('triggersActions');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);

const searchResults = await pageObjects.triggersActionsUI.getAlertsList();
expect(searchResults).to.eql([
{
name: createdAlert.name,
tagsText: 'foo, bar',
alertType: 'Index threshold',
interval: '1m',
},
]);

const editLink = await testSubjects.findAll('alertsTableCell-editLink');
await editLink[0].click();

const throttleInputToUnsetValue = await testSubjects.find('throttleInput');

expect(await throttleInputToUnsetValue.getAttribute('value')).to.eql('10');
await throttleInputToUnsetValue.click();
await throttleInputToUnsetValue.clearValueWithKeyboard();

expect(await throttleInputToUnsetValue.getAttribute('value')).to.eql('');

await find.clickByCssSelector('[data-test-subj="saveEditedAlertButton"]:not(disabled)');

expect(await pageObjects.common.closeToast()).to.eql(`Updated '${createdAlert.name}'`);

await pageObjects.common.navigateToApp('triggersActions');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);
await (await testSubjects.findAll('alertsTableCell-editLink'))[0].click();
const throttleInput = await testSubjects.find('throttleInput');
expect(await throttleInput.getAttribute('value')).to.eql('');
});

it('should reset alert when canceling an edit', async () => {
const createdAlert = await createAlert({
alertTypeId: '.index-threshold',
name: generateUniqueKey(),
params: {
aggType: 'count',
termSize: 5,
thresholdComparator: '>',
timeWindowSize: 5,
timeWindowUnit: 'm',
groupBy: 'all',
threshold: [1000, 5000],
index: ['.kibana_1'],
timeField: 'alert',
},
});
await pageObjects.common.navigateToApp('triggersActions');
await pageObjects.triggersActionsUI.searchAlerts(createdAlert.name);

const editLink = await testSubjects.findAll('alertsTableCell-editLink');
await editLink[0].click();

const updatedAlertName = `Changed Alert Name ${generateUniqueKey()}`;
await testSubjects.setValue('alertNameInput', updatedAlertName);

await testSubjects.click('cancelSaveEditedAlertButton');
await find.waitForDeletedByCssSelector('[data-test-subj="cancelSaveEditedAlertButton"]');

const editLinkPostCancel = await testSubjects.findAll('alertsTableCell-editLink');
await editLinkPostCancel[0].click();

const nameInputAfterCancel = await testSubjects.find('alertNameInput');
const textAfterCancel = await nameInputAfterCancel.getAttribute('value');
expect(textAfterCancel).to.eql(createdAlert.name);
});

it('should search for tags', async () => {
const createdAlert = await createAlert();
await pageObjects.common.navigateToApp('triggersActions');
Expand Down

0 comments on commit 698c6e8

Please sign in to comment.