From 0eadb898c774ee603c77ed90f3b8dcf223911a51 Mon Sep 17 00:00:00 2001 From: Ersin Erdal <92688503+ersin-erdal@users.noreply.github.com> Date: Wed, 1 Dec 2021 12:58:18 +0100 Subject: [PATCH] [RAC] fix failing alerts table pagination functional tests (#119985) * [RAC] fix failing alerts table pagination functional tests --- .../observability/alerts/data.json.gz | Bin 3909 -> 4051 bytes .../services/observability/alerts/common.ts | 33 +++++++++++++++- .../observability/alerts/pagination.ts | 6 +++ .../apps/observability/alerts/index.ts | 4 +- .../apps/observability/alerts/pagination.ts | 37 +++++++++++------- 5 files changed, 63 insertions(+), 17 deletions(-) diff --git a/x-pack/test/functional/es_archives/observability/alerts/data.json.gz b/x-pack/test/functional/es_archives/observability/alerts/data.json.gz index 544888178cb092cd9e71f1b82f7dd8967ac77d48..86bd5735e6206b8762d8a2188269b18cc33af6c4 100644 GIT binary patch literal 4051 zcmV;^4=nH>iwFpm8m3_Y17u-zVJ>QOZ*BnXom+1sxs}J?=Tis<0?aJJ3hx&^EOrs> z0s(e_V0ZG8bYSr6R$5khb#bS6FyDO-OLqGv$wj*)m!xWUH!Ky4#p31v;~@{pUw;^l zE|%YJ;>CD$5o&+&`~1bNov!jXzrqLjI0^Zxc1pMu4e~Sz#1;JJte41PO+zr=M8lff z^BuDg|Cw*9CbMOn&+N3a(>Px)Q0*3Rerw%iI$3_J?9KK4g%FcnO_vDgKjc25MZKE) zhorza|F)c5$HmfK-{klyrUVg;i1~$xF~wu1E5*%U@9u~2@ixwumG#R>Jt7(n`RZbF1&MvQ`eowm%&yZ|h1J~VXsXo$!V+Q>F&t96IdsgqxDLPkJdcad^)x?1 zyc+sG_ZhAfRoX~nguQBSdVUEhkC$<37t4u9 zzD8+YL&?m-<>%${2F>IDt{_vJ4~y|1{_yqd*Xk~CHetS*_N03rbud79)mZK!ik(j3&^mg%3DcAD!KnS5VL9 z%a_d#<1r_d5aO@f?^`x)=0)p!66`*O1xoWgim&zjOPbbSFCQLR-^AIA(2E;*QO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{9Ep++^}hNnF$^y$$ITP6)932~8E z58x!h6Oa-m&V+W(8R17UT_vxY1zO0%Y?`fc&z|`$=8Xqt{0Oli6wTvpy~hs3V@F; diff --git a/x-pack/test/functional/services/observability/alerts/common.ts b/x-pack/test/functional/services/observability/alerts/common.ts index dd7d49af4fe5a..8c6352fff9864 100644 --- a/x-pack/test/functional/services/observability/alerts/common.ts +++ b/x-pack/test/functional/services/observability/alerts/common.ts @@ -6,6 +6,11 @@ */ import { chunk } from 'lodash'; +import { + ALERT_STATUS_ACTIVE, + ALERT_STATUS_RECOVERED, + AlertStatus, +} from '@kbn/rule-data-utils/alerts_as_data_status'; import { FtrProviderContext } from '../../../ftr_provider_context'; import { WebElementWrapper } from '../../../../../../test/functional/services/lib/web_element_wrapper'; @@ -192,7 +197,6 @@ export function ObservabilityAlertsCommonProvider({ const viewRuleDetailsLinkClick = async () => { return await (await testSubjects.find(VIEW_RULE_DETAILS_FLYOUT_SELECTOR)).click(); }; - // Workflow status const setWorkflowStatusForRow = async (rowIndex: number, workflowStatus: WorkflowStatus) => { await openActionsMenuForRow(rowIndex); @@ -220,6 +224,30 @@ export function ObservabilityAlertsCommonProvider({ return await selectedWorkflowStatusButton.getVisibleText(); }; + // Alert status + const setAlertStatusFilter = async (alertStatus?: AlertStatus) => { + let buttonSubject = 'alert-status-filter-show-all-button'; + if (alertStatus === ALERT_STATUS_ACTIVE) { + buttonSubject = 'alert-status-filter-active-button'; + } + if (alertStatus === ALERT_STATUS_RECOVERED) { + buttonSubject = 'alert-status-filter-recovered-button'; + } + const buttonGroupButton = await testSubjects.find(buttonSubject); + await buttonGroupButton.click(); + }; + + const alertDataIsBeingLoaded = async () => { + return testSubjects.existOrFail('events-container-loading-true'); + }; + + const alertDataHasLoaded = async () => { + await retry.waitFor( + 'Alert Table is loaded', + async () => await testSubjects.exists('events-container-loading-false', { timeout: 2500 }) + ); + }; + // Date picker const getTimeRange = async () => { const isAbsoluteRange = await testSubjects.exists('superDatePickerstartDatePopoverButton'); @@ -266,6 +294,9 @@ export function ObservabilityAlertsCommonProvider({ setWorkflowStatusForRow, setWorkflowStatusFilter, getWorkflowStatusFilterValue, + setAlertStatusFilter, + alertDataIsBeingLoaded, + alertDataHasLoaded, submitQuery, typeInQueryBar, openActionsMenuForRow, diff --git a/x-pack/test/functional/services/observability/alerts/pagination.ts b/x-pack/test/functional/services/observability/alerts/pagination.ts index 6bffcf3596e2d..e9e7b7c7d5ca2 100644 --- a/x-pack/test/functional/services/observability/alerts/pagination.ts +++ b/x-pack/test/functional/services/observability/alerts/pagination.ts @@ -83,6 +83,11 @@ export function ObservabilityAlertsPaginationProvider({ getService }: FtrProvide await (await getPaginationButtonOne()).click(); }; + const goToNthPage = async (page: number) => { + const pageButton = await testSubjects.find(`pagination-button-${page - 1}`); + await pageButton.click(); + }; + const getPrevButtonDisabledValue = async () => { return await (await getPrevPageButton()).getAttribute('disabled'); }; @@ -105,5 +110,6 @@ export function ObservabilityAlertsPaginationProvider({ getService }: FtrProvide goToPrevPage, goToFirstPage, getPrevButtonDisabledValue, + goToNthPage, }; } diff --git a/x-pack/test/observability_functional/apps/observability/alerts/index.ts b/x-pack/test/observability_functional/apps/observability/alerts/index.ts index 048c007dcb6a4..3abf04ed29e67 100644 --- a/x-pack/test/observability_functional/apps/observability/alerts/index.ts +++ b/x-pack/test/observability_functional/apps/observability/alerts/index.ts @@ -15,14 +15,14 @@ async function asyncForEach(array: T[], callback: (item: T, index: number) => } const ACTIVE_ALERTS_CELL_COUNT = 78; -const RECOVERED_ALERTS_CELL_COUNT = 100; +const RECOVERED_ALERTS_CELL_COUNT = 120; const TOTAL_ALERTS_CELL_COUNT = 165; export default ({ getService }: FtrProviderContext) => { const esArchiver = getService('esArchiver'); const find = getService('find'); - describe('Observability alerts 1', function () { + describe('Observability alerts', function () { this.tags('includeFirefox'); const testSubjects = getService('testSubjects'); diff --git a/x-pack/test/observability_functional/apps/observability/alerts/pagination.ts b/x-pack/test/observability_functional/apps/observability/alerts/pagination.ts index a00fbe2a77f34..8fe91d686c59c 100644 --- a/x-pack/test/observability_functional/apps/observability/alerts/pagination.ts +++ b/x-pack/test/observability_functional/apps/observability/alerts/pagination.ts @@ -6,6 +6,7 @@ */ import expect from '@kbn/expect'; +import { ALERT_STATUS_ACTIVE } from '@kbn/rule-data-utils/alerts_as_data_status'; import { FtrProviderContext } from '../../../ftr_provider_context'; const ROWS_NEEDED_FOR_PAGINATION = 10; @@ -15,7 +16,7 @@ export default ({ getService }: FtrProviderContext) => { const esArchiver = getService('esArchiver'); // FAILING: https://github.com/elastic/kibana/issues/113486 - describe.skip('Observability alerts pagination', function () { + describe('Observability alerts pagination', function () { this.tags('includeFirefox'); const retry = getService('retry'); @@ -23,21 +24,25 @@ export default ({ getService }: FtrProviderContext) => { before(async () => { await esArchiver.load('x-pack/test/functional/es_archives/observability/alerts'); + await esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs'); + await observability.alerts.common.navigateToTimeWithData(); }); after(async () => { await esArchiver.unload('x-pack/test/functional/es_archives/observability/alerts'); + await esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs'); }); describe(`When less than ${ROWS_NEEDED_FOR_PAGINATION} alerts are found`, () => { before(async () => { - // current archiver has 3 closed alerts - await observability.alerts.common.setWorkflowStatusFilter('closed'); + // current archiver has 8 active alerts + await observability.alerts.common.setAlertStatusFilter(ALERT_STATUS_ACTIVE); }); after(async () => { - await observability.alerts.common.setWorkflowStatusFilter('open'); + // current archiver has 33 alerts + await observability.alerts.common.setAlertStatusFilter(); }); it('Does not render page size selector', async () => { @@ -50,11 +55,6 @@ export default ({ getService }: FtrProviderContext) => { }); describe(`When ${ROWS_NEEDED_FOR_PAGINATION} alerts are found`, () => { - before(async () => { - // current archiver has 12 open alerts - await observability.alerts.common.setWorkflowStatusFilter('open'); - }); - describe('Page size selector', () => { it('Renders page size selector', async () => { await observability.alerts.pagination.getPageSizeSelectorOrFail(); @@ -92,12 +92,11 @@ export default ({ getService }: FtrProviderContext) => { before(async () => { await (await observability.alerts.pagination.getPageSizeSelector()).click(); await (await observability.alerts.pagination.getTenRowsPageSelector()).click(); - }); - beforeEach(async () => { await observability.alerts.pagination.goToFirstPage(); }); it('Renders previous page button', async () => { + await observability.alerts.common.alertDataHasLoaded(); await observability.alerts.pagination.getPrevPageButtonOrFail(); }); @@ -111,17 +110,27 @@ export default ({ getService }: FtrProviderContext) => { expect(prevButtonDisabledValue).to.be('true'); }); + it('Goes to nth page', async () => { + await observability.alerts.pagination.goToNthPage(3); + await observability.alerts.common.alertDataIsBeingLoaded(); + await observability.alerts.common.alertDataHasLoaded(); + const tableRows = await observability.alerts.common.getTableCellsInRows(); + expect(tableRows.length).to.be(10); + }); + it('Goes to next page', async () => { await observability.alerts.pagination.goToNextPage(); + await observability.alerts.common.alertDataIsBeingLoaded(); + await observability.alerts.common.alertDataHasLoaded(); const tableRows = await observability.alerts.common.getTableCellsInRows(); - expect(tableRows.length).to.be(2); + expect(tableRows.length).to.be(3); }); it('Goes to previous page', async () => { - await (await observability.alerts.pagination.getPaginationButtonTwo()).click(); await observability.alerts.pagination.goToPrevPage(); + await observability.alerts.common.alertDataIsBeingLoaded(); + await observability.alerts.common.alertDataHasLoaded(); const tableRows = await observability.alerts.common.getTableCellsInRows(); - expect(tableRows.length).to.be(10); }); });