From d798b739d3c5326d1607fbd35224b54f136a3860 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 4 Nov 2021 15:06:29 -0400 Subject: [PATCH] =?UTF-8?q?Fixing=20Failing=20test:=20Chrome=20X-Pack=20UI?= =?UTF-8?q?=20Functional=20Tests.x-pack/test/functional=5Fwith=5Fes=5Fssl/?= =?UTF-8?q?apps/triggers=5Factions=5Fui/alert=5Fcreate=5Fflyout=C2=B7ts=20?= =?UTF-8?q?-=20Actions=20and=20Triggers=20app=20create=20alert=20should=20?= =?UTF-8?q?successfully=20test=20valid=20es=5Fquery=20alert=20(#114917)=20?= =?UTF-8?q?(#117566)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Unskipping test * Commenting out fix and fixing another test * Fixing functional test * Fixing functional test agaaaiiinn * Fixing the actual flake * Splitting into two tests * Maybe this time Co-authored-by: ymao1 --- .../alert_create_flyout.ts | 56 ++++++++++--------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alert_create_flyout.ts b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alert_create_flyout.ts index fa144bd5bf9f6..51a70026339c9 100644 --- a/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alert_create_flyout.ts +++ b/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/alert_create_flyout.ts @@ -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'; @@ -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'); @@ -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]; + 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); @@ -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); @@ -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); @@ -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 () => { + const alertName = generateUniqueKey(); + await defineEsQueryAlert(alertName); + // Invalid query await testSubjects.setValue('queryJsonEditor', '{"query":{"foo":{}}}', { clearWithKeyboard: true,