From 6aa828b5db72dd42bc3faadeaf3a035762009172 Mon Sep 17 00:00:00 2001 From: mgiota Date: Wed, 29 Sep 2021 11:28:33 +0200 Subject: [PATCH] pr review comments --- .../observability/alerts/pagination.ts | 47 ++++++++++--------- .../apps/observability/alerts/pagination.ts | 2 +- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/x-pack/test/functional/services/observability/alerts/pagination.ts b/x-pack/test/functional/services/observability/alerts/pagination.ts index b403ef7b02d68..4d2bbefb60632 100644 --- a/x-pack/test/functional/services/observability/alerts/pagination.ts +++ b/x-pack/test/functional/services/observability/alerts/pagination.ts @@ -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 () => { @@ -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, @@ -105,5 +109,6 @@ export function ObservabilityAlertsPaginationProvider({ getService }: FtrProvide goToPrevPage, goToFirstPage, getPrevButtonDisabledValue, + getNextButtonDisabledValue, }; } 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 a4703d9fd5b73..c4b56bc89c3f5 100644 --- a/x-pack/test/observability_functional/apps/observability/alerts/pagination.ts +++ b/x-pack/test/observability_functional/apps/observability/alerts/pagination.ts @@ -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'); }); });