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

Fixing Failing test: Chrome X-Pack UI Functional Tests.x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alert_create_flyout·ts - Actions and Triggers app create alert should successfully test valid es_query alert #114917

Merged
merged 10 commits into from
Nov 4, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import expect from '@kbn/expect';
import { asyncForEach } from '@kbn/std';
import { omit } from 'lodash';
import { FtrProviderContext } from '../../ftr_provider_context';
import { generateUniqueKey } from '../../lib/get_test_data';

Expand Down Expand Up @@ -103,8 +104,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await testSubjects.click('test.always-firing-SelectOption');
}

// FLAKY https://github.com/elastic/kibana/issues/112749
describe.skip('create alert', function () {
describe('create alert', function () {
before(async () => {
await pageObjects.common.navigateToApp('triggersActions');
await testSubjects.click('rulesTab');
Expand Down Expand Up @@ -154,14 +154,13 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
expect(toastTitle).to.eql(`Created rule "${alertName}"`);
await pageObjects.triggersActionsUI.searchAlerts(alertName);
const searchResultsAfterSave = await pageObjects.triggersActionsUI.getAlertsList();
expect(searchResultsAfterSave).to.eql([
{
name: alertName,
tagsText: '',
alertType: 'Index threshold',
interval: '1m',
},
]);
const searchResultAfterSave = searchResultsAfterSave[0];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These tests should have been updated with this PR but were missed since this test suite was skipped at the time.

expect(omit(searchResultAfterSave, 'duration')).to.eql({
name: `${alertName}Index threshold`,
tags: '',
interval: '1 min',
});
expect(searchResultAfterSave.duration).to.match(/\d{2}:\d{2}:\d{2}.\d{3}/);

// clean up created alert
const alertsToDelete = await getAlertsByName(alertName);
Expand Down Expand Up @@ -205,14 +204,12 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
expect(toastTitle).to.eql(`Created rule "${alertName}"`);
await pageObjects.triggersActionsUI.searchAlerts(alertName);
const searchResultsAfterSave = await pageObjects.triggersActionsUI.getAlertsList();
expect(searchResultsAfterSave).to.eql([
{
name: alertName,
tagsText: '',
alertType: 'Always Firing',
interval: '1m',
},
]);
const searchResultAfterSave = searchResultsAfterSave[0];
expect(omit(searchResultAfterSave, 'duration')).to.eql({
name: `${alertName}Always Firing`,
tags: '',
interval: '1 min',
});

// clean up created alert
const alertsToDelete = await getAlertsByName(alertName);
Expand All @@ -239,14 +236,12 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await new Promise((resolve) => setTimeout(resolve, 1000));
await pageObjects.triggersActionsUI.searchAlerts(alertName);
const searchResultsAfterSave = await pageObjects.triggersActionsUI.getAlertsList();
expect(searchResultsAfterSave).to.eql([
{
name: alertName,
tagsText: '',
alertType: 'Always Firing',
interval: '1m',
},
]);
const searchResultAfterSave = searchResultsAfterSave[0];
expect(omit(searchResultAfterSave, 'duration')).to.eql({
name: `${alertName}Always Firing`,
tags: '',
interval: '1 min',
});

// clean up created alert
const alertsToDelete = await getAlertsByName(alertName);
Expand Down Expand Up @@ -278,6 +273,15 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
await testSubjects.existOrFail('testQuerySuccess');
await testSubjects.missingOrFail('testQueryError');

await testSubjects.click('cancelSaveAlertButton');
await testSubjects.existOrFail('confirmAlertCloseModal');
await testSubjects.click('confirmAlertCloseModal > confirmModalConfirmButton');
});

it('should show error when es_query is invalid', async () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the test that I split into 2 tests.

const alertName = generateUniqueKey();
await defineEsQueryAlert(alertName);

// Invalid query
await testSubjects.setValue('queryJsonEditor', '{"query":{"foo":{}}}', {
clearWithKeyboard: true,
Expand Down