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 544888178cb09..86bd5735e6206 100644 Binary files a/x-pack/test/functional/es_archives/observability/alerts/data.json.gz and b/x-pack/test/functional/es_archives/observability/alerts/data.json.gz differ 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); }); });