Skip to content

Commit

Permalink
pr review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mgiota committed Sep 29, 2021
1 parent 7c45c7b commit 6aa828b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
47 changes: 26 additions & 21 deletions x-pack/test/functional/services/observability/alerts/pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,68 +7,68 @@

import { FtrProviderContext } from '../../../ftr_provider_context';

const ALERTS_ROWS_PER_PAGE_SELECTOR = 'tablePaginationPopoverButton';
const ALERTS_PAGINATION_BUTTON_PREVIOUS = 'pagination-button-previous';
const ALERTS_PAGINATION_BUTTON_NEXT = 'pagination-button-next';
const ALERTS_PAGINATION_TEN_ROWS = 'tablePagination-10-rows';
const ALERTS_PAGINATION_TWENTY_FIVE_ROWS = 'tablePagination-25-rows';
const ALERTS_PAGINATION_FIFTY_ROWS = 'tablePagination-50-rows';
const ALERTS_PAGINATION_BUTTON_ONE = 'pagination-button-0';
const ALERTS_PAGINATION_BUTTON_TWO = 'pagination-button-1';
const ROWS_PER_PAGE_SELECTOR = 'tablePaginationPopoverButton';
const PREV_BUTTON_SELECTOR = 'pagination-button-previous';
const NEXT_BUTTON_SELECTOR = 'pagination-button-next';
const TEN_ROWS_SELECTOR = 'tablePagination-10-rows';
const TWENTY_FIVE_ROWS_SELECTOR = 'tablePagination-25-rows';
const FIFTY_ROWS_SELECTOR = 'tablePagination-50-rows';
const BUTTON_ONE_SELECTOR = 'pagination-button-0';
const BUTTON_TWO_SELECTOR = 'pagination-button-1';

export function ObservabilityAlertsPaginationProvider({ getService }: FtrProviderContext) {
const testSubjects = getService('testSubjects');

const getPageSizeSelector = async () => {
return await testSubjects.find(ALERTS_ROWS_PER_PAGE_SELECTOR);
return await testSubjects.find(ROWS_PER_PAGE_SELECTOR);
};

const getPageSizeSelectorOrFail = async () => {
return await testSubjects.existOrFail(ALERTS_ROWS_PER_PAGE_SELECTOR);
return await testSubjects.existOrFail(ROWS_PER_PAGE_SELECTOR);
};

const missingPageSizeSelectorOrFail = async () => {
return await testSubjects.missingOrFail(ALERTS_ROWS_PER_PAGE_SELECTOR);
return await testSubjects.missingOrFail(ROWS_PER_PAGE_SELECTOR);
};

const getTenRowsPageSelector = async () => {
return await testSubjects.find(ALERTS_PAGINATION_TEN_ROWS);
return await testSubjects.find(TEN_ROWS_SELECTOR);
};

const getTwentyFiveRowsPageSelector = async () => {
return await testSubjects.find(ALERTS_PAGINATION_TWENTY_FIVE_ROWS);
return await testSubjects.find(TWENTY_FIVE_ROWS_SELECTOR);
};

const getFiftyRowsPageSelector = async () => {
return await testSubjects.find(ALERTS_PAGINATION_FIFTY_ROWS);
return await testSubjects.find(FIFTY_ROWS_SELECTOR);
};

const getPrevPageButton = async () => {
return await testSubjects.find(ALERTS_PAGINATION_BUTTON_PREVIOUS);
return await testSubjects.find(PREV_BUTTON_SELECTOR);
};

const getPrevPageButtonOrFail = async () => {
return await testSubjects.existOrFail(ALERTS_PAGINATION_BUTTON_PREVIOUS);
return await testSubjects.existOrFail(PREV_BUTTON_SELECTOR);
};

const missingPrevPageButtonOrFail = async () => {
return await testSubjects.missingOrFail(ALERTS_ROWS_PER_PAGE_SELECTOR);
return await testSubjects.missingOrFail(PREV_BUTTON_SELECTOR);
};

const getNextPageButton = async () => {
return await testSubjects.find(ALERTS_PAGINATION_BUTTON_NEXT, 20000);
return await testSubjects.find(NEXT_BUTTON_SELECTOR, 20000);
};

const getNextPageButtonOrFail = async () => {
return await testSubjects.existOrFail(ALERTS_PAGINATION_BUTTON_NEXT);
return await testSubjects.existOrFail(NEXT_BUTTON_SELECTOR);
};

const getPaginationButtonOne = async () => {
return await testSubjects.find(ALERTS_PAGINATION_BUTTON_ONE);
return await testSubjects.find(BUTTON_ONE_SELECTOR);
};

const getPaginationButtonTwo = async () => {
return await testSubjects.find(ALERTS_PAGINATION_BUTTON_TWO);
return await testSubjects.find(BUTTON_TWO_SELECTOR);
};

const goToNextPage = async () => {
Expand All @@ -87,6 +87,10 @@ export function ObservabilityAlertsPaginationProvider({ getService }: FtrProvide
return await (await getPrevPageButton()).getAttribute('disabled');
};

const getNextButtonDisabledValue = async () => {
return await (await getNextPageButton()).getAttribute('disabled');
};

return {
getPageSizeSelector,
getPageSizeSelectorOrFail,
Expand All @@ -105,5 +109,6 @@ export function ObservabilityAlertsPaginationProvider({ getService }: FtrProvide
goToPrevPage,
goToFirstPage,
getPrevButtonDisabledValue,
getNextButtonDisabledValue,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default ({ getService }: FtrProviderContext) => {
it('Next page button is disabled', async () => {
await (await observability.alerts.pagination.getPaginationButtonTwo()).click();
const nextButtonDisabledValue =
await observability.alerts.pagination.getPrevButtonDisabledValue();
await observability.alerts.pagination.getNextButtonDisabledValue();
expect(nextButtonDisabledValue).to.be('true');
});
});
Expand Down

0 comments on commit 6aa828b

Please sign in to comment.