Skip to content

Commit

Permalink
Fix alerting UI flaky tests (#62817) (#63615)
Browse files Browse the repository at this point in the history
* Use of testSubjects.setValue

* Add waitForEditAlertFlyout

* Fix some extra flakiness

* Test half second sleep to confirm cause of flakiness

* Revert 0241796

* Try clearWithKeyboard

* Fix test failures

* Fix uptime tests

* Revert uptime changes

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
mikecote and elasticmachine authored May 14, 2020
1 parent 5a7cefb commit 9d1274a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ export const IndexThresholdAlertTypeExpression: React.FunctionComponent<IndexThr
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonIcon
data-test-subj="closePopover"
iconType="cross"
color="danger"
aria-label={i18n.translate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ export const ActionForm = ({
labelAppend={
<EuiButtonEmpty
size="xs"
data-test-subj="createActionConnectorButton"
onClick={() => {
setActiveActionItem({ actionTypeId: actionItem.actionTypeId, index });
setAddModalVisibility(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const pageObjects = getPageObjects(['common', 'triggersActionsUI', 'header']);
const supertest = getService('supertest');
const find = getService('find');
const retry = getService('retry');

async function createAlert(overwrites: Record<string, any> = {}) {
const { body: createdAlert } = await supertest
Expand Down Expand Up @@ -47,10 +48,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
it('should create an alert', async () => {
const alertName = generateUniqueKey();
await pageObjects.triggersActionsUI.clickCreateAlertButton();
const nameInput = await testSubjects.find('alertNameInput');
await nameInput.click();
await nameInput.clearValue();
await nameInput.type(alertName);
await testSubjects.setValue('alertNameInput', alertName);
await testSubjects.click('.index-threshold-SelectOption');
await testSubjects.click('selectIndexExpression');
const comboBox = await find.byCssSelector('#indexSelectSearchBox');
Expand All @@ -59,30 +57,28 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const filterSelectItem = await find.byCssSelector(`.euiFilterSelectItem`);
await filterSelectItem.click();
await testSubjects.click('thresholdAlertTimeFieldSelect');
const fieldOptions = await find.allByCssSelector('#thresholdTimeField option');
await fieldOptions[1].click();
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();

await testSubjects.click('.slack-ActionTypeSelectOption');
await testSubjects.click('createActionConnectorButton');
const connectorNameInput = await testSubjects.find('nameInput');
await connectorNameInput.click();
await connectorNameInput.clearValue();
const connectorName = generateUniqueKey();
await connectorNameInput.type(connectorName);
const slackWebhookUrlInput = await testSubjects.find('slackWebhookUrlInput');
await slackWebhookUrlInput.click();
await slackWebhookUrlInput.clearValue();
await slackWebhookUrlInput.type('https://test');
const slackConnectorName = generateUniqueKey();
await testSubjects.setValue('nameInput', slackConnectorName);
await testSubjects.setValue('slackWebhookUrlInput', 'https://test');
await find.clickByCssSelector('[data-test-subj="saveActionButtonModal"]:not(disabled)');
const loggingMessageInput = await testSubjects.find('slackMessageTextArea');
await loggingMessageInput.click();
await loggingMessageInput.clearValue();
await loggingMessageInput.type('test message');
const createdConnectorToastTitle = await pageObjects.common.closeToast();
expect(createdConnectorToastTitle).to.eql(`Created '${slackConnectorName}'`);
await testSubjects.setValue('slackMessageTextArea', 'test message');
await testSubjects.click('messageAddVariableButton');
const variableMenuButton = await testSubjects.find('variableMenuButton-0');
await variableMenuButton.click();
await testSubjects.click('variableMenuButton-0');

await testSubjects.click('saveAlertButton');
const toastTitle = await pageObjects.common.closeToast();
expect(toastTitle).to.eql(`Saved '${alertName}'`);
Expand Down Expand Up @@ -133,7 +129,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
it('should edit an alert', async () => {
const createdAlert = await createAlert({
alertTypeId: '.index-threshold',
name: 'new alert',
name: generateUniqueKey(),
params: {
aggType: 'count',
termSize: 5,
Expand Down Expand Up @@ -161,11 +157,8 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const editLink = await testSubjects.findAll('alertsTableCell-editLink');
await editLink[0].click();

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

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

Expand Down Expand Up @@ -218,10 +211,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const editLink = await testSubjects.findAll('alertsTableCell-editLink');
await editLink[0].click();

const throttleInputToSetInitialValue = await testSubjects.find('throttleInput');
await throttleInputToSetInitialValue.click();
await throttleInputToSetInitialValue.clearValue();
await throttleInputToSetInitialValue.type('1');
await testSubjects.setValue('throttleInput', '1', { clearWithKeyboard: true });

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

Expand Down Expand Up @@ -309,11 +299,8 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
const editLink = await testSubjects.findAll('alertsTableCell-editLink');
await editLink[0].click();

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

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

0 comments on commit 9d1274a

Please sign in to comment.