diff --git a/e2e/core/infinite-scrolling.e2e.ts b/e2e/core/infinite-scrolling.e2e.ts index bd29a0c18f..3aacd5769f 100644 --- a/e2e/core/infinite-scrolling.e2e.ts +++ b/e2e/core/infinite-scrolling.e2e.ts @@ -17,6 +17,9 @@ import { LoginPage } from '../pages/adf/loginPage'; import { ContentServicesPage } from '../pages/adf/contentServicesPage'; +import { InfinitePaginationPage } from '../pages/adf/core/infinitePaginationPage'; +import { ConfigEditorPage } from '../pages/adf/configEditorPage'; +import { NavigationBarPage } from '../pages/adf/navigationBarPage'; import { AcsUserModel } from '../models/ACS/acsUserModel'; import { FolderModel } from '../models/ACS/folderModel'; @@ -29,14 +32,19 @@ import { UploadActions } from '../actions/ACS/upload.actions'; describe('Enable infinite scrolling', () => { - let loginPage = new LoginPage(); - let contentServicesPage = new ContentServicesPage(); + const loginPage = new LoginPage(); + const contentServicesPage = new ContentServicesPage(); + const infinitePaginationPage = new InfinitePaginationPage(); + const configEditorPage = new ConfigEditorPage(); + const navigationBarPage = new NavigationBarPage(); let acsUser = new AcsUserModel(); let folderModel = new FolderModel({ 'name': 'folderOne' }); - let fileNames = [], nrOfFiles = 21, deleteFileNames = [], nrOfDeletedFiles = 22; + let fileNames = [], nrOfFiles = 30, deleteFileNames = [], nrOfDeletedFiles = 22; let deleteUploaded; + let pageSize = 20; + let emptyFolderModel; let files = { base: 'newFile', @@ -63,6 +71,7 @@ describe('Enable infinite scrolling', () => { await this.alfrescoJsApi.login(acsUser.id, acsUser.password); let folderUploadedModel = await uploadActions.createFolder(this.alfrescoJsApi, folderModel.name, '-my-'); + emptyFolderModel = await uploadActions.createFolder(this.alfrescoJsApi, 'emptyFolder', '-my-'); await uploadActions.createEmptyFiles(this.alfrescoJsApi, fileNames, folderUploadedModel.entry.id); @@ -74,14 +83,15 @@ describe('Enable infinite scrolling', () => { }); beforeEach(async (done) => { - contentServicesPage.goToDocumentList(); + navigationBarPage.clickContentServicesButton(); + contentServicesPage.checkAcsContainer(); done(); }); it('[C260484] Should be possible to enable infinite scrolling', () => { contentServicesPage.doubleClickRow(folderModel.name); contentServicesPage.enableInfiniteScrolling(); - contentServicesPage.clickLoadMoreButton(); + infinitePaginationPage.clickLoadMoreButton(); for (let i = 0; i < nrOfFiles; i++) { contentServicesPage.checkContentIsDisplayed(fileNames[i]); } @@ -92,7 +102,7 @@ describe('Enable infinite scrolling', () => { contentServicesPage.checkAcsContainer(); contentServicesPage.waitForTableBody(); contentServicesPage.enableInfiniteScrolling(); - contentServicesPage.clickLoadMoreButton(); + infinitePaginationPage.clickLoadMoreButton(); for (let i = 0; i < nrOfDeletedFiles; i++) { contentServicesPage.checkContentIsDisplayed(deleteFileNames[i]); } @@ -106,4 +116,43 @@ describe('Enable infinite scrolling', () => { } }); + it('[C299201] Should use default pagination settings for infinite pagination', () => { + navigationBarPage.clickContentServicesButton(); + contentServicesPage.checkAcsContainer(); + contentServicesPage.doubleClickRow(folderModel.name); + + contentServicesPage.enableInfiniteScrolling(); + expect(contentServicesPage.numberOfResultsDisplayed()).toBe(pageSize); + infinitePaginationPage.clickLoadMoreButton(); + expect(contentServicesPage.numberOfResultsDisplayed()).toBe(nrOfFiles); + + infinitePaginationPage.checkLoadMoreButtonIsNotDisplayed(); + }); + + it('[C299202] Should not display load more button when all the files are already displayed', () => { + navigationBarPage.clickConfigEditorButton(); + configEditorPage.clickInfinitePaginationConfiguration(); + configEditorPage.clickClearButton(); + configEditorPage.enterConfiguration('30'); + configEditorPage.clickSaveButton(); + + navigationBarPage.clickContentServicesButton(); + contentServicesPage.checkAcsContainer(); + contentServicesPage.doubleClickRow(folderModel.name); + + contentServicesPage.enableInfiniteScrolling(); + expect(contentServicesPage.numberOfResultsDisplayed()).toBe(nrOfFiles); + + infinitePaginationPage.checkLoadMoreButtonIsNotDisplayed(); + }); + + it('[C299203] Should not display load more button when a folder is empty', () => { + navigationBarPage.clickContentServicesButton(); + contentServicesPage.checkAcsContainer(); + + contentServicesPage.doubleClickRow(emptyFolderModel.entry.name); + + infinitePaginationPage.checkLoadMoreButtonIsNotDisplayed(); + }); + }); diff --git a/e2e/pages/adf/configEditorPage.ts b/e2e/pages/adf/configEditorPage.ts index 932d93711f..f77e165655 100644 --- a/e2e/pages/adf/configEditorPage.ts +++ b/e2e/pages/adf/configEditorPage.ts @@ -90,4 +90,11 @@ export class ConfigEditorPage { Util.waitUntilElementIsClickable(button); return button.click(); } + + clickInfinitePaginationConfiguration() { + let button = element(by.id('adf-infinite-pagination-conf')); + Util.waitUntilElementIsVisible(button); + Util.waitUntilElementIsClickable(button); + return button.click(); + } } diff --git a/e2e/pages/adf/contentServicesPage.ts b/e2e/pages/adf/contentServicesPage.ts index 684e7c5e7a..c95a4a7c98 100644 --- a/e2e/pages/adf/contentServicesPage.ts +++ b/e2e/pages/adf/contentServicesPage.ts @@ -45,7 +45,6 @@ export class ContentServicesPage { uploadMultipleFileButton = element(by.css('input[data-automation-id="upload-multiple-files"]')); uploadFolderButton = element(by.css('input[data-automation-id="uploadFolder"]')); errorSnackBar = element(by.css('simple-snack-bar[class*="mat-simple-snackbar"]')); - loadMoreButton = element(by.css('button[data-automation-id="adf-infinite-pagination-button"]')); emptyPagination = element(by.css('adf-pagination[class*="adf-pagination__empty"]')); dragAndDrop = element.all(by.css('adf-upload-drag-area div')).first(); nameHeader = element(by.css('div[data-automation-id="auto_id_name"] > span')); @@ -504,13 +503,6 @@ export class ContentServicesPage { return this; } - clickLoadMoreButton() { - Util.waitUntilElementIsVisible(this.loadMoreButton); - Util.waitUntilElementIsClickable(this.loadMoreButton); - this.loadMoreButton.click(); - return this; - } - checkPaginationIsNotDisplayed() { Util.waitUntilElementIsVisible(this.emptyPagination); } diff --git a/e2e/pages/adf/core/infinitePaginationPage.ts b/e2e/pages/adf/core/infinitePaginationPage.ts new file mode 100644 index 0000000000..cb03fce84e --- /dev/null +++ b/e2e/pages/adf/core/infinitePaginationPage.ts @@ -0,0 +1,48 @@ +/*! + * @license + * Copyright 2019 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { element, by } from 'protractor'; +import { ElementFinder } from 'protractor/built/element'; + +import { Util } from '../../../util/util'; + +export class InfinitePaginationPage { + + rootElement: ElementFinder; + loadMoreButton; + + constructor(rootElement: ElementFinder = element.all(by.css('adf-infinite-pagination')).first()) { + this.rootElement = rootElement; + this.loadMoreButton = this.rootElement.element(by.css('button[data-automation-id="adf-infinite-pagination-button"]')); + } + + clickLoadMoreButton() { + Util.waitUntilElementIsVisible(this.loadMoreButton); + Util.waitUntilElementIsClickable(this.loadMoreButton); + this.loadMoreButton.click(); + return this; + } + + checkLoadMoreButtonIsDisplayed() { + return Util.waitUntilElementIsVisible(this.loadMoreButton); + } + + checkLoadMoreButtonIsNotDisplayed() { + return Util.waitUntilElementIsNotOnPage(this.loadMoreButton); + } + +}