Skip to content

Commit

Permalink
[RAC] fix failing alerts table pagination functional tests (#119985) (#…
Browse files Browse the repository at this point in the history
…120220)

* [RAC] fix failing alerts table pagination functional tests
  • Loading branch information
ersin-erdal authored Dec 2, 2021
1 parent f2e3762 commit e829d98
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 17 deletions.
Binary file not shown.
33 changes: 32 additions & 1 deletion x-pack/test/functional/services/observability/alerts/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -266,6 +294,9 @@ export function ObservabilityAlertsCommonProvider({
setWorkflowStatusForRow,
setWorkflowStatusFilter,
getWorkflowStatusFilterValue,
setAlertStatusFilter,
alertDataIsBeingLoaded,
alertDataHasLoaded,
submitQuery,
typeInQueryBar,
openActionsMenuForRow,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
};
Expand All @@ -105,5 +110,6 @@ export function ObservabilityAlertsPaginationProvider({ getService }: FtrProvide
goToPrevPage,
goToFirstPage,
getPrevButtonDisabledValue,
goToNthPage,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ async function asyncForEach<T>(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');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -15,29 +16,33 @@ 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');
const observability = getService('observability');

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 () => {
Expand All @@ -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();
Expand Down Expand Up @@ -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();
});

Expand All @@ -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);
});
});
Expand Down

0 comments on commit e829d98

Please sign in to comment.