From 4b2c0dfab78d077c1c88e4e884c00a42fd2897f2 Mon Sep 17 00:00:00 2001 From: suzanadirla Date: Fri, 24 Nov 2017 11:36:06 +0200 Subject: [PATCH 01/19] [ACA-1029] Move action does not work for items in Favorites (#81) -fix move on favorites -ensure translation of 'Undo' from notification bar -add '' to file name displayed on destination picker's title --- .../directives/node-copy.directive.spec.ts | 18 +++++++------- .../common/directives/node-copy.directive.ts | 2 +- .../directives/node-move.directive.spec.ts | 24 +++++++++---------- .../common/directives/node-move.directive.ts | 4 ++-- .../common/services/node-actions.service.ts | 2 +- 5 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/app/common/directives/node-copy.directive.spec.ts b/src/app/common/directives/node-copy.directive.spec.ts index 9e70237da..933ca54c3 100644 --- a/src/app/common/directives/node-copy.directive.spec.ts +++ b/src/app/common/directives/node-copy.directive.spec.ts @@ -92,7 +92,7 @@ describe('NodeCopyDirective', () => { expect(service.copyNodes).toHaveBeenCalled(); expect(notificationService.openSnackMessageAction).toHaveBeenCalledWith( - 'APP.MESSAGES.INFO.NODE_COPY.SINGULAR', 'Undo', 10000 + 'APP.MESSAGES.INFO.NODE_COPY.SINGULAR', 'APP.ACTIONS.UNDO', 10000 ); }); @@ -112,7 +112,7 @@ describe('NodeCopyDirective', () => { expect(service.copyNodes).toHaveBeenCalled(); expect(notificationService.openSnackMessageAction).toHaveBeenCalledWith( - 'APP.MESSAGES.INFO.NODE_COPY.PLURAL', 'Undo', 10000 + 'APP.MESSAGES.INFO.NODE_COPY.PLURAL', 'APP.ACTIONS.UNDO', 10000 ); }); @@ -131,7 +131,7 @@ describe('NodeCopyDirective', () => { expect(service.copyNodes).toHaveBeenCalled(); expect(notificationService.openSnackMessageAction).toHaveBeenCalledWith( - 'APP.MESSAGES.INFO.NODE_COPY.PARTIAL_SINGULAR', 'Undo', 10000 + 'APP.MESSAGES.INFO.NODE_COPY.PARTIAL_SINGULAR', 'APP.ACTIONS.UNDO', 10000 ); }); @@ -152,7 +152,7 @@ describe('NodeCopyDirective', () => { expect(service.copyNodes).toHaveBeenCalled(); expect(notificationService.openSnackMessageAction).toHaveBeenCalledWith( - 'APP.MESSAGES.INFO.NODE_COPY.PARTIAL_PLURAL', 'Undo', 10000 + 'APP.MESSAGES.INFO.NODE_COPY.PARTIAL_PLURAL', 'APP.ACTIONS.UNDO', 10000 ); }); @@ -255,7 +255,7 @@ describe('NodeCopyDirective', () => { expect(service.copyNodes).toHaveBeenCalled(); expect(notificationService.openSnackMessageAction).toHaveBeenCalledWith( - 'APP.MESSAGES.INFO.NODE_COPY.SINGULAR', 'Undo', 10000 + 'APP.MESSAGES.INFO.NODE_COPY.SINGULAR', 'APP.ACTIONS.UNDO', 10000 ); expect(nodesApiService.deleteNode).toHaveBeenCalledWith(createdItems[0].entry.id, { permanent: true }); @@ -279,7 +279,7 @@ describe('NodeCopyDirective', () => { expect(service.copyNodes).toHaveBeenCalled(); expect(notificationService.openSnackMessageAction).toHaveBeenCalledWith( - 'APP.MESSAGES.INFO.NODE_COPY.PLURAL', 'Undo', 10000 + 'APP.MESSAGES.INFO.NODE_COPY.PLURAL', 'APP.ACTIONS.UNDO', 10000 ); expect(spyOnDeleteNode).toHaveBeenCalled(); @@ -300,7 +300,7 @@ describe('NodeCopyDirective', () => { expect(service.copyNodes).toHaveBeenCalled(); expect(nodesApiService.deleteNode).toHaveBeenCalled(); expect(notificationService.openSnackMessageAction['calls'].allArgs()) - .toEqual([['APP.MESSAGES.INFO.NODE_COPY.SINGULAR', 'Undo', 10000], + .toEqual([['APP.MESSAGES.INFO.NODE_COPY.SINGULAR', 'APP.ACTIONS.UNDO', 10000], ['APP.MESSAGES.ERRORS.GENERIC', '', 3000]]); }); @@ -317,7 +317,7 @@ describe('NodeCopyDirective', () => { expect(service.copyNodes).toHaveBeenCalled(); expect(nodesApiService.deleteNode).toHaveBeenCalled(); expect(notificationService.openSnackMessageAction['calls'].allArgs()) - .toEqual([['APP.MESSAGES.INFO.NODE_COPY.SINGULAR', 'Undo', 10000], + .toEqual([['APP.MESSAGES.INFO.NODE_COPY.SINGULAR', 'APP.ACTIONS.UNDO', 10000], ['APP.MESSAGES.ERRORS.GENERIC', '', 3000]]); }); @@ -334,7 +334,7 @@ describe('NodeCopyDirective', () => { expect(service.copyNodes).toHaveBeenCalled(); expect(nodesApiService.deleteNode).toHaveBeenCalled(); expect(notificationService.openSnackMessageAction['calls'].allArgs()) - .toEqual([['APP.MESSAGES.INFO.NODE_COPY.SINGULAR', 'Undo', 10000], + .toEqual([['APP.MESSAGES.INFO.NODE_COPY.SINGULAR', 'APP.ACTIONS.UNDO', 10000], ['APP.MESSAGES.ERRORS.PERMISSION', '', 3000]]); }); }); diff --git a/src/app/common/directives/node-copy.directive.ts b/src/app/common/directives/node-copy.directive.ts index b1f66aa5b..e6a711afa 100644 --- a/src/app/common/directives/node-copy.directive.ts +++ b/src/app/common/directives/node-copy.directive.ts @@ -96,7 +96,7 @@ export class NodeCopyDirective { } catch (err) { /* Do nothing, keep the original message */ } } - const undo = (numberOfCopiedItems > 0) ? 'Undo' : ''; + const undo = (numberOfCopiedItems > 0) ? this.translation.translate.instant('APP.ACTIONS.UNDO') : ''; const withUndo = (numberOfCopiedItems > 0) ? '_WITH_UNDO' : ''; this.translation.get(i18nMessageString, { success: numberOfCopiedItems, failed: failedItems }).subscribe(message => { diff --git a/src/app/common/directives/node-move.directive.spec.ts b/src/app/common/directives/node-move.directive.spec.ts index 4a5422df9..9476e6734 100644 --- a/src/app/common/directives/node-move.directive.spec.ts +++ b/src/app/common/directives/node-move.directive.spec.ts @@ -107,7 +107,7 @@ describe('NodeMoveDirective', () => { expect(service.moveNodes).toHaveBeenCalled(); expect(notificationService.openSnackMessageAction).toHaveBeenCalledWith( - 'APP.MESSAGES.INFO.NODE_MOVE.SINGULAR', 'Undo', 10000 + 'APP.MESSAGES.INFO.NODE_MOVE.SINGULAR', 'APP.ACTIONS.UNDO', 10000 ); }); @@ -132,7 +132,7 @@ describe('NodeMoveDirective', () => { expect(service.moveNodes).toHaveBeenCalled(); expect(notificationService.openSnackMessageAction).toHaveBeenCalledWith( - 'APP.MESSAGES.INFO.NODE_MOVE.PLURAL', 'Undo', 10000 + 'APP.MESSAGES.INFO.NODE_MOVE.PLURAL', 'APP.ACTIONS.UNDO', 10000 ); }); @@ -155,7 +155,7 @@ describe('NodeMoveDirective', () => { expect(service.moveNodes).toHaveBeenCalled(); expect(notificationService.openSnackMessageAction).toHaveBeenCalledWith( - 'APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.SINGULAR', 'Undo', 10000 + 'APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.SINGULAR', 'APP.ACTIONS.UNDO', 10000 ); }); @@ -180,7 +180,7 @@ describe('NodeMoveDirective', () => { expect(service.moveNodes).toHaveBeenCalled(); expect(notificationService.openSnackMessageAction).toHaveBeenCalledWith( - 'APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.PLURAL', 'Undo', 10000 + 'APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.PLURAL', 'APP.ACTIONS.UNDO', 10000 ); }); @@ -204,7 +204,7 @@ describe('NodeMoveDirective', () => { expect(service.moveNodes).toHaveBeenCalled(); expect(notificationService.openSnackMessageAction).toHaveBeenCalledWith( - 'APP.MESSAGES.INFO.NODE_MOVE.SINGULAR APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.FAIL', 'Undo', 10000 + 'APP.MESSAGES.INFO.NODE_MOVE.SINGULAR APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.FAIL', 'APP.ACTIONS.UNDO', 10000 ); }); @@ -228,7 +228,7 @@ describe('NodeMoveDirective', () => { expect(service.moveNodes).toHaveBeenCalled(); expect(notificationService.openSnackMessageAction).toHaveBeenCalledWith( - 'APP.MESSAGES.INFO.NODE_MOVE.SINGULAR APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.SINGULAR', 'Undo', 10000 + 'APP.MESSAGES.INFO.NODE_MOVE.SINGULAR APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.SINGULAR', 'APP.ACTIONS.UNDO', 10000 ); }); @@ -348,7 +348,7 @@ describe('NodeMoveDirective', () => { expect(service.moveNodeAction) .toHaveBeenCalledWith(movedItems.succeeded[0].itemMoved.entry, movedItems.succeeded[0].initialParentId); expect(notificationService.openSnackMessageAction) - .toHaveBeenCalledWith('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR', 'Undo', 10000); + .toHaveBeenCalledWith('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR', 'APP.ACTIONS.UNDO', 10000); }); it('should move node back to initial parent, after succeeded move of a single file', () => { @@ -370,7 +370,7 @@ describe('NodeMoveDirective', () => { expect(service.moveNodeAction).toHaveBeenCalledWith(node.entry, initialParent); expect(notificationService.openSnackMessageAction) - .toHaveBeenCalledWith('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR', 'Undo', 10000); + .toHaveBeenCalledWith('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR', 'APP.ACTIONS.UNDO', 10000); }); it('should restore deleted folder back to initial parent, after succeeded moving all its files', () => { @@ -396,7 +396,7 @@ describe('NodeMoveDirective', () => { expect(nodesApiService.restoreNode).toHaveBeenCalled(); expect(notificationService.openSnackMessageAction) - .toHaveBeenCalledWith('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR', 'Undo', 10000); + .toHaveBeenCalledWith('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR', 'APP.ACTIONS.UNDO', 10000); }); it('should notify when error occurs on Undo Move action', () => { @@ -422,7 +422,7 @@ describe('NodeMoveDirective', () => { expect(nodesApiService.restoreNode).toHaveBeenCalled(); expect(notificationService.openSnackMessageAction) - .toHaveBeenCalledWith('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR', 'Undo', 10000); + .toHaveBeenCalledWith('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR', 'APP.ACTIONS.UNDO', 10000); expect(notificationService.openSnackMessage) .toHaveBeenCalledWith('APP.MESSAGES.ERRORS.GENERIC', 3000); }); @@ -449,7 +449,7 @@ describe('NodeMoveDirective', () => { expect(nodesApiService.restoreNode).toHaveBeenCalled(); expect(notificationService.openSnackMessageAction) - .toHaveBeenCalledWith('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR', 'Undo', 10000); + .toHaveBeenCalledWith('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR', 'APP.ACTIONS.UNDO', 10000); expect(notificationService.openSnackMessage) .toHaveBeenCalledWith('APP.MESSAGES.ERRORS.GENERIC', 3000); }); @@ -477,7 +477,7 @@ describe('NodeMoveDirective', () => { expect(service.moveNodes).toHaveBeenCalled(); expect(nodesApiService.restoreNode).toHaveBeenCalled(); expect(notificationService.openSnackMessageAction) - .toHaveBeenCalledWith('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR', 'Undo', 10000); + .toHaveBeenCalledWith('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR', 'APP.ACTIONS.UNDO', 10000); expect(notificationService.openSnackMessage) .toHaveBeenCalledWith('APP.MESSAGES.ERRORS.PERMISSION', 3000); }); diff --git a/src/app/common/directives/node-move.directive.ts b/src/app/common/directives/node-move.directive.ts index 60196eaa9..081f2ae8a 100644 --- a/src/app/common/directives/node-move.directive.ts +++ b/src/app/common/directives/node-move.directive.ts @@ -46,7 +46,7 @@ export class NodeMoveDirective { ) {} moveSelected() { - const permissionForMove: string = 'delete'; + const permissionForMove = '!'; Observable.zip( this.nodeActionsService.moveNodes(this.selection, permissionForMove), @@ -110,7 +110,7 @@ export class NodeMoveDirective { errorMessage = this.getErrorMessage(info); } - const undo = (succeeded + partiallySucceeded > 0) ? 'Undo' : ''; + const undo = (succeeded + partiallySucceeded > 0) ? this.translation.translate.instant('APP.ACTIONS.UNDO') : ''; const withUndo = errorMessage ? '' : '_WITH_UNDO'; failedMessage = errorMessage ? errorMessage : failedMessage; diff --git a/src/app/common/services/node-actions.service.ts b/src/app/common/services/node-actions.service.ts index 72a41394d..927e584cc 100644 --- a/src/app/common/services/node-actions.service.ts +++ b/src/app/common/services/node-actions.service.ts @@ -170,7 +170,7 @@ export class NodeActionsService { let nodeEntryName = ''; if (contentEntities.length === 1 && contentEntities[0].entry.name) { - nodeEntryName = `${contentEntities[0].entry.name} `; + nodeEntryName = `'${contentEntities[0].entry.name}' `; } const data: ContentNodeSelectorComponentData = { From ac6c9e961d09525fdc36fc2a9de57bf619d7447b Mon Sep 17 00:00:00 2001 From: Cilibiu Bogdan Date: Fri, 24 Nov 2017 11:49:58 +0200 Subject: [PATCH 02/19] render condition (#80) --- .../favorites/favorites.component.html | 1 + .../favorites/favorites.component.spec.ts | 50 +++++++++++++++++++ .../favorites/favorites.component.ts | 6 ++- 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/app/components/favorites/favorites.component.html b/src/app/components/favorites/favorites.component.html index 0a1fe1a3f..d1d736a99 100644 --- a/src/app/components/favorites/favorites.component.html +++ b/src/app/components/favorites/favorites.component.html @@ -23,6 +23,7 @@ @@ -95,5 +94,6 @@ + diff --git a/yarn.lock b/yarn.lock index 2e9892fea..00dd32fe0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,11 +2,11 @@ # yarn lockfile v1 -"@alfresco/adf-content-services@2.0.0-beta2": - version "2.0.0-beta2" - resolved "https://registry.yarnpkg.com/@alfresco/adf-content-services/-/adf-content-services-2.0.0-beta2.tgz#7b587278b7bef852f6d543e1b667f9be5eaf3308" +"@alfresco/adf-content-services@2.0.0-c968fbcdacb90946dc00bca3d7b663de94d5a9ad": + version "2.0.0-c968fbcdacb90946dc00bca3d7b663de94d5a9ad" + resolved "https://registry.yarnpkg.com/@alfresco/adf-content-services/-/adf-content-services-2.0.0-c968fbcdacb90946dc00bca3d7b663de94d5a9ad.tgz#4d189cf2df9ff155c439805ad9ccea92181dc5b1" dependencies: - "@alfresco/adf-core" "2.0.0-beta2" + "@alfresco/adf-core" "2.0.0-c968fbcdacb90946dc00bca3d7b663de94d5a9ad" "@angular/animations" "5.0.0" "@angular/cdk" "5.0.0-rc0" "@angular/common" "5.0.0" @@ -21,7 +21,7 @@ "@angular/platform-browser-dynamic" "5.0.0" "@angular/router" "5.0.0" "@ngx-translate/core" "8.0.0" - alfresco-js-api "2.0.0-beta1" + alfresco-js-api "2.0.0-2e4554a3d3a1265d058795c924d55d570dd46de2" chart.js "2.5.0" core-js "2.4.1" hammerjs "2.0.8" @@ -35,9 +35,9 @@ systemjs "0.19.27" zone.js "0.8.14" -"@alfresco/adf-core@2.0.0-beta2": - version "2.0.0-beta2" - resolved "https://registry.yarnpkg.com/@alfresco/adf-core/-/adf-core-2.0.0-beta2.tgz#3b38b8fa9339d94bde48d8866e797bb0e4d5cc24" +"@alfresco/adf-core@2.0.0-c968fbcdacb90946dc00bca3d7b663de94d5a9ad": + version "2.0.0-c968fbcdacb90946dc00bca3d7b663de94d5a9ad" + resolved "https://registry.yarnpkg.com/@alfresco/adf-core/-/adf-core-2.0.0-c968fbcdacb90946dc00bca3d7b663de94d5a9ad.tgz#bbf289ed254049f7db0406efd94276fa53a9fbf0" dependencies: "@angular/animations" "5.0.0" "@angular/cdk" "5.0.0-rc0" @@ -53,7 +53,7 @@ "@angular/platform-browser-dynamic" "5.0.0" "@angular/router" "5.0.0" "@ngx-translate/core" "8.0.0" - alfresco-js-api "2.0.0-beta1" + alfresco-js-api "2.0.0-2e4554a3d3a1265d058795c924d55d570dd46de2" chart.js "2.5.0" core-js "2.4.1" hammerjs "2.0.8" @@ -364,6 +364,13 @@ ajv@^5.0.0, ajv@^5.1.0, ajv@^5.1.5: fast-json-stable-stringify "^2.0.0" json-schema-traverse "^0.3.0" +alfresco-js-api@2.0.0-2e4554a3d3a1265d058795c924d55d570dd46de2: + version "2.0.0-2e4554a3d3a1265d058795c924d55d570dd46de2" + resolved "https://registry.yarnpkg.com/alfresco-js-api/-/alfresco-js-api-2.0.0-2e4554a3d3a1265d058795c924d55d570dd46de2.tgz#9b4cafb16eef618ed449c2d69055cb032cbe9087" + dependencies: + event-emitter "0.3.4" + superagent "3.7.0" + alfresco-js-api@2.0.0-beta1: version "2.0.0-beta1" resolved "https://registry.yarnpkg.com/alfresco-js-api/-/alfresco-js-api-2.0.0-beta1.tgz#f52f8dfb82e3516efd71868f06cf91c62e4fa71e" @@ -3797,14 +3804,20 @@ mkdirp@0.5.x, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkd dependencies: minimist "0.0.8" +moment-es6@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/moment-es6/-/moment-es6-1.0.0.tgz#552fcf405d62565b0a1fe84e6c1e697ac79332df" + dependencies: + moment "*" + +moment@*, moment@^2.10.6: + version "2.19.2" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.19.2.tgz#8a7f774c95a64550b4c7ebd496683908f9419dbe" + moment@2.15.2: version "2.15.2" resolved "https://registry.yarnpkg.com/moment/-/moment-2.15.2.tgz#1bfdedf6a6e345f322fe956d5df5bd08a8ce84dc" -moment@^2.10.6: - version "2.19.2" - resolved "https://registry.yarnpkg.com/moment/-/moment-2.19.2.tgz#8a7f774c95a64550b4c7ebd496683908f9419dbe" - moment@~2.18.0: version "2.18.1" resolved "https://registry.yarnpkg.com/moment/-/moment-2.18.1.tgz#c36193dd3ce1c2eed2adb7c802dbbc77a81b1c0f" From 1dade550a1586e3f07639a6abb77809e126d632e Mon Sep 17 00:00:00 2001 From: suzanadirla Date: Tue, 28 Nov 2017 12:12:09 +0200 Subject: [PATCH 16/19] [ACA-902] fix bug: Personal Files - toolbar actions reloads to first page (#94) --- src/app/components/files/files.component.ts | 42 ++++++++++++++++----- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/src/app/components/files/files.component.ts b/src/app/components/files/files.component.ts index 651271e02..5946bc86a 100644 --- a/src/app/components/files/files.component.ts +++ b/src/app/components/files/files.component.ts @@ -79,12 +79,12 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy { this.subscriptions = this.subscriptions.concat([ nodeActionsService.contentCopied.subscribe((nodes) => this.onContentCopied(nodes)), - contentService.folderCreate.subscribe(() => this.load()), - contentService.folderEdit.subscribe(() => this.load()), - contentManagementService.deleteNode.subscribe(() => this.load()), - contentManagementService.moveNode.subscribe(() => this.load()), - contentManagementService.restoreNode.subscribe(() => this.load()), - contentManagementService.toggleFavorite.subscribe(() => this.load()), + contentService.folderCreate.subscribe(() => this.load(false, this.pagination)), + contentService.folderEdit.subscribe(() => this.load(false, this.pagination)), + contentManagementService.deleteNode.subscribe(() => this.load(false, this.pagination)), + contentManagementService.moveNode.subscribe(() => this.load(false, this.pagination)), + contentManagementService.restoreNode.subscribe(() => this.load(false, this.pagination)), + contentManagementService.toggleFavorite.subscribe(() => this.load(false, this.pagination)), uploadService.fileUploadComplete.subscribe(file => this.onFileUploadedEvent(file)), uploadService.fileUploadDeleted.subscribe((file) => this.onFileUploadedEvent(file)) ]); @@ -140,7 +140,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy { onFileUploadedEvent(event: FileUploadEvent) { if (event && event.file.options.parentId === this.getParentNodeId()) { - this.load(); + this.load(false, this.pagination); } } @@ -150,7 +150,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy { return node && node.entry && node.entry.parentId === this.getParentNodeId(); }); if (newNode) { - this.load(); + this.load(false, this.pagination); } } @@ -167,12 +167,36 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy { this.fetchNodes(this.getParentNodeId(), pagination) .subscribe( - (page) => this.onPageLoaded(page), + (page) => { + if (this.isCurrentPageEmpty(page) && this.isNotFirstPage(page)) { + const newSkipCount = pagination.skipCount - pagination.maxItems; + + this.fetchNodes(this.getParentNodeId(), {skipCount: newSkipCount, maxItems: pagination.maxItems}) + .subscribe( + (previousPage) => this.onPageLoaded(previousPage), + error => this.onFetchError(error) + ); + } else { + this.onPageLoaded(page); + } + }, error => this.onFetchError(error), () => this.changeDetector.detectChanges() ); } + isCurrentPageEmpty(page): boolean { + return !this.hasPageEntries(page); + } + + hasPageEntries(page): boolean { + return page && page.list && page.list.entries && page.list.entries.length > 0; + } + + isNotFirstPage(page): boolean { + return (page.list.pagination.skipCount >= page.list.pagination.maxItems); + } + // todo: review this approach once 5.2.3 is out private async updateCurrentNode(node: MinimalNodeEntryEntity) { this.nodePath = null; From 79f8ec33a9c1589e964efa6a0bf10f2198d5ba7f Mon Sep 17 00:00:00 2001 From: Adina Parpalita Date: Tue, 28 Nov 2017 22:02:47 +0200 Subject: [PATCH 17/19] [ACA-990] framework improvements (#96) * refactoring * e2e API improvements * forgot one file --- e2e/components/data-table/data-table.ts | 16 ++--- e2e/components/menu/menu.ts | 6 +- e2e/pages/page.ts | 2 +- e2e/suites/actions/create-folder.test.ts | 32 ++++----- e2e/suites/actions/edit-folder.test.ts | 32 ++++----- e2e/suites/actions/permanently-delete.test.ts | 44 ++++--------- e2e/suites/actions/restore.test.ts | 37 ++++------- .../toolbar-multiple-selection.test.ts | 2 +- .../actions/toolbar-single-selection.test.ts | 65 ++++++++++--------- e2e/suites/list-views/empty-list.test.ts | 2 - e2e/suites/list-views/personal-files.test.ts | 4 +- e2e/suites/pagination/pagination.test.ts | 12 ++-- .../apis/favorites/favorites-api.ts | 6 ++ .../repo-client/apis/nodes/nodes-api.ts | 23 +++---- .../apis/shared-links/shared-links-api.ts | 6 ++ .../repo-client/apis/sites/sites-api.ts | 21 +++++- .../repo-client/apis/trashcan/trashcan-api.ts | 20 ++++++ protractor.conf.js | 5 ++ 18 files changed, 184 insertions(+), 151 deletions(-) diff --git a/e2e/components/data-table/data-table.ts b/e2e/components/data-table/data-table.ts index 59df39a48..9192147e3 100644 --- a/e2e/components/data-table/data-table.ts +++ b/e2e/components/data-table/data-table.ts @@ -34,6 +34,7 @@ export class DataTable extends Component { row: 'tr', selectedRow: 'tr.is-selected', cell: 'td', + nameCell: 'td.app-name-column', emptyListContainer: 'td.adf-no-content-container', emptyFolderDragAndDrop: '.adf-empty-list_template .adf-empty-folder', @@ -44,7 +45,6 @@ export class DataTable extends Component { head: ElementFinder = this.component.element(by.css(DataTable.selectors.head)); body: ElementFinder = this.component.element(by.css(DataTable.selectors.body)); - cell = by.css(DataTable.selectors.cell); emptyList: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyListContainer)); emptyFolderDragAndDrop: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyFolderDragAndDrop)); emptyListTitle: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyListTitle)); @@ -113,18 +113,16 @@ export class DataTable extends Component { } // Navigation/selection methods - doubleClickOnRowByContainingText(text: string): promise.Promise { - const row = this.getRowByContainingText(text); - const dblClick = browser.actions().mouseMove(row).click().click(); + doubleClickOnItemName(name: string): promise.Promise { + const locator = by.cssContainingText(DataTable.selectors.nameCell, name); + const dblClick = browser.actions().mouseMove(this.body.element(locator)).click().click(); return dblClick.perform(); } - clickOnRowByContainingText(text: string): promise.Promise { - const row = this.getRowByContainingText(text); - const click = browser.actions().mouseMove(row).click(); - - return click.perform(); + clickOnItemName(name: string): promise.Promise { + const locator = by.cssContainingText(DataTable.selectors.nameCell, name); + return this.body.element(locator).click(); } selectMultipleItems(names: string[]): promise.Promise { diff --git a/e2e/components/menu/menu.ts b/e2e/components/menu/menu.ts index 536e4b05e..d5d9a3bed 100644 --- a/e2e/components/menu/menu.ts +++ b/e2e/components/menu/menu.ts @@ -47,7 +47,11 @@ export class Menu extends Component { return this.getItemByLabel(label).getAttribute('title'); } - clicktNthItem(nth: number): promise.Promise { + getItemsCount(): promise.Promise { + return this.items.count(); + } + + clickNthItem(nth: number): promise.Promise { return this.getNthItem(nth).click(); } diff --git a/e2e/pages/page.ts b/e2e/pages/page.ts index 0867bfa45..7b30f62b8 100644 --- a/e2e/pages/page.ts +++ b/e2e/pages/page.ts @@ -19,7 +19,7 @@ import { browser, element, by, ElementFinder, promise, ExpectedConditions as EC import { BROWSER_WAIT_TIMEOUT } from './../configs'; export abstract class Page { - private static USE_HASH_STRATEGY = false; + private static USE_HASH_STRATEGY = true; private locators = { app: by.css('app-root'), diff --git a/e2e/suites/actions/create-folder.test.ts b/e2e/suites/actions/create-folder.test.ts index f5639049e..1e3dd6c34 100644 --- a/e2e/suites/actions/create-folder.test.ts +++ b/e2e/suites/actions/create-folder.test.ts @@ -87,7 +87,7 @@ describe('Create folder', () => { }); it('option is enabled when having enough permissions', () => { - personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent) + personalFilesPage.dataTable.doubleClickOnItemName(parent) .then(() => personalFilesPage.sidenav.openNewMenu() .then((menu) => { const isEnabled = menu.getItemByLabel('Create folder').getWebElement().isEnabled(); @@ -98,7 +98,7 @@ describe('Create folder', () => { }); it('creates new folder with name', () => { - personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent) + personalFilesPage.dataTable.doubleClickOnItemName(parent) .then(() => openCreateDialog() .then(() => createDialog.enterName(folderName1).clickCreate()) .then(() => createDialog.waitForDialogToClose()) @@ -111,7 +111,7 @@ describe('Create folder', () => { }); it('creates new folder with name and description', () => { - personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent) + personalFilesPage.dataTable.doubleClickOnItemName(parent) .then(() => openCreateDialog() .then(() => { createDialog @@ -133,7 +133,7 @@ describe('Create folder', () => { }); it('enabled option tooltip', () => { - personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent) + personalFilesPage.dataTable.doubleClickOnItemName(parent) .then(() => personalFilesPage.sidenav.openNewMenu() .then(menu => { const action = browser.actions().mouseMove(menu.getItemByLabel('Create folder')); @@ -152,8 +152,8 @@ describe('Create folder', () => { const fileLibrariesPage = new BrowsingPage(APP_ROUTES.FILE_LIBRARIES); fileLibrariesPage.sidenav.navigateToLinkByLabel('File Libraries') - .then(() => fileLibrariesPage.dataTable.doubleClickOnRowByContainingText(siteName)) - .then(() => fileLibrariesPage.dataTable.doubleClickOnRowByContainingText(folderName1)) + .then(() => fileLibrariesPage.dataTable.doubleClickOnItemName(siteName)) + .then(() => fileLibrariesPage.dataTable.doubleClickOnItemName(folderName1)) .then(() => fileLibrariesPage.sidenav.openNewMenu()) .then(menu => { const isEnabled = menu.getItemByLabel('Create folder').getWebElement().isEnabled(); @@ -165,8 +165,8 @@ describe('Create folder', () => { const fileLibrariesPage = new BrowsingPage(APP_ROUTES.FILE_LIBRARIES); fileLibrariesPage.sidenav.navigateToLinkByLabel('File Libraries') - .then(() => fileLibrariesPage.dataTable.doubleClickOnRowByContainingText(siteName)) - .then(() => fileLibrariesPage.dataTable.doubleClickOnRowByContainingText(folderName1)) + .then(() => fileLibrariesPage.dataTable.doubleClickOnItemName(siteName)) + .then(() => fileLibrariesPage.dataTable.doubleClickOnItemName(folderName1)) .then(() => fileLibrariesPage.sidenav.openNewMenu()) .then(menu => { const action = browser.actions().mouseMove(menu.getItemByLabel('Create folder')); @@ -179,7 +179,7 @@ describe('Create folder', () => { }); it('dialog UI elements', () => { - personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent) + personalFilesPage.dataTable.doubleClickOnItemName(parent) .then(() => openCreateDialog().then(() => { const dialogTitle = createDialog.getTitle(); const isFolderNameDisplayed = createDialog.nameInput.getWebElement().isDisplayed(); @@ -197,7 +197,7 @@ describe('Create folder', () => { }); it('with empty folder name', () => { - personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent) + personalFilesPage.dataTable.doubleClickOnItemName(parent) .then(() => openCreateDialog() .then(() => { createDialog.deleteNameWithBackspace(); @@ -213,7 +213,7 @@ describe('Create folder', () => { }); it('with folder name ending with a dot "."', () => { - personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent) + personalFilesPage.dataTable.doubleClickOnItemName(parent) .then(() => openCreateDialog() .then(() => createDialog.enterName('folder-name.')) .then((dialog) => { @@ -229,7 +229,7 @@ describe('Create folder', () => { it('with folder name containing special characters', () => { const namesWithSpecialChars = [ 'a*a', 'a"a', 'aa', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a' ]; - personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent) + personalFilesPage.dataTable.doubleClickOnItemName(parent) .then(() => openCreateDialog() .then(() => { namesWithSpecialChars.forEach(name => { @@ -246,7 +246,7 @@ describe('Create folder', () => { }); it('with folder name containing only spaces', () => { - personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent) + personalFilesPage.dataTable.doubleClickOnItemName(parent) .then(() => openCreateDialog() .then(() => createDialog.enterName(' ')) .then((dialog) => { @@ -260,7 +260,7 @@ describe('Create folder', () => { }); it('cancel folder creation', () => { - personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent) + personalFilesPage.dataTable.doubleClickOnItemName(parent) .then(() => openCreateDialog() .then(() => { createDialog @@ -273,7 +273,7 @@ describe('Create folder', () => { }); it('duplicate folder name', () => { - personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent) + personalFilesPage.dataTable.doubleClickOnItemName(parent) .then(() => openCreateDialog() .then(() => createDialog.enterName(duplicateFolderName).clickCreate()) .then(() => { @@ -287,7 +287,7 @@ describe('Create folder', () => { }); it('trim ending spaces from folder name', () => { - personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent) + personalFilesPage.dataTable.doubleClickOnItemName(parent) .then(() => openCreateDialog() .then(() => createDialog.enterName(nameWithSpaces).clickCreate()) .then(() => createDialog.waitForDialogToClose()) diff --git a/e2e/suites/actions/edit-folder.test.ts b/e2e/suites/actions/edit-folder.test.ts index 2e58b4d07..fb830f5c1 100644 --- a/e2e/suites/actions/edit-folder.test.ts +++ b/e2e/suites/actions/edit-folder.test.ts @@ -87,8 +87,8 @@ describe('Edit folder', () => { }); it('dialog UI defaults', () => { - personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent) - .then(() => dataTable.clickOnRowByContainingText(folderName) + personalFilesPage.dataTable.doubleClickOnItemName(parent) + .then(() => dataTable.clickOnItemName(folderName) .then(() => editButton.click()) .then(() => { expect(editDialog.getTitle()).toBe('Edit folder'); @@ -101,8 +101,8 @@ describe('Edit folder', () => { }); it('properties are modified when pressing OK', () => { - personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent) - .then(() => dataTable.clickOnRowByContainingText(folderNameToEdit) + personalFilesPage.dataTable.doubleClickOnItemName(parent) + .then(() => dataTable.clickOnItemName(folderNameToEdit) .then(() => editButton.click()) .then(() => { editDialog @@ -126,8 +126,8 @@ describe('Edit folder', () => { }); it('with empty folder name', () => { - personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent) - .then(() => dataTable.clickOnRowByContainingText(folderName) + personalFilesPage.dataTable.doubleClickOnItemName(parent) + .then(() => dataTable.clickOnItemName(folderName) .then(() => editButton.click()) .then(() => { editDialog.deleteNameWithBackspace(); @@ -142,8 +142,8 @@ describe('Edit folder', () => { it('with name with special characters', () => { const namesWithSpecialChars = [ 'a*a', 'a"a', 'aa', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a' ]; - personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent) - .then(() => dataTable.clickOnRowByContainingText(folderName) + personalFilesPage.dataTable.doubleClickOnItemName(parent) + .then(() => dataTable.clickOnItemName(folderName) .then(() => editButton.click()) .then(() => { namesWithSpecialChars.forEach(name => { @@ -157,8 +157,8 @@ describe('Edit folder', () => { }); it('with name ending with a dot', () => { - personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent) - .then(() => dataTable.clickOnRowByContainingText(folderName) + personalFilesPage.dataTable.doubleClickOnItemName(parent) + .then(() => dataTable.clickOnItemName(folderName) .then(() => editButton.click()) .then(() => editDialog.nameInput.sendKeys('.')) .then(() => { @@ -169,8 +169,8 @@ describe('Edit folder', () => { }); it('Cancel button', () => { - personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent) - .then(() => dataTable.clickOnRowByContainingText(folderName) + personalFilesPage.dataTable.doubleClickOnItemName(parent) + .then(() => dataTable.clickOnItemName(folderName) .then(() => editButton.click()) .then(() => editDialog.clickCancel()) .then(() => { @@ -180,8 +180,8 @@ describe('Edit folder', () => { }); it('with duplicate folder name', () => { - personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent) - .then(() => dataTable.clickOnRowByContainingText(folderName) + personalFilesPage.dataTable.doubleClickOnItemName(parent) + .then(() => dataTable.clickOnItemName(folderName) .then(() => editButton.click()) .then(() => editDialog.enterName(duplicateFolderName).clickUpdate()) .then(() => { @@ -195,8 +195,8 @@ describe('Edit folder', () => { }); it('trim ending spaces', () => { - personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent) - .then(() => dataTable.clickOnRowByContainingText(folderName) + personalFilesPage.dataTable.doubleClickOnItemName(parent) + .then(() => dataTable.clickOnItemName(folderName) .then(() => editButton.click()) .then(() => editDialog.nameInput.sendKeys(' ')) .then(() => editDialog.clickUpdate()) diff --git a/e2e/suites/actions/permanently-delete.test.ts b/e2e/suites/actions/permanently-delete.test.ts index e169c3840..cde2d9bec 100644 --- a/e2e/suites/actions/permanently-delete.test.ts +++ b/e2e/suites/actions/permanently-delete.test.ts @@ -25,14 +25,12 @@ describe('Permanently delete from Trash', () => { const username = `user-${Utils.random()}`; const file1 = `file-${Utils.random()}.txt`; - let file1Id; const file2 = `file-${Utils.random()}.txt`; - let file2Id; + let filesIds; const folder1 = `folder-${Utils.random()}`; - let folder1Id; const folder2 = `folder-${Utils.random()}`; - let folder2Id; + let foldersIds; const apis = { admin: new RepoClient(), @@ -47,15 +45,13 @@ describe('Permanently delete from Trash', () => { beforeAll(done => { apis.admin.people.createUser(username) - .then(() => apis.user.nodes.createFiles([ file1 ]).then(resp => file1Id = resp.data.entry.id)) - .then(() => apis.user.nodes.createFiles([ file2 ]).then(resp => file2Id = resp.data.entry.id)) - .then(() => apis.user.nodes.createFolders([ folder1 ]).then(resp => folder1Id = resp.data.entry.id)) - .then(() => apis.user.nodes.createFolders([ folder2 ]).then(resp => folder2Id = resp.data.entry.id)) + .then(() => apis.user.nodes.createFiles([ file1, file2 ])) + .then(resp => filesIds = resp.data.list.entries.map(entries => entries.entry.id)) + .then(() => apis.user.nodes.createFolders([ folder1, folder2 ])) + .then(resp => foldersIds = resp.data.list.entries.map(entries => entries.entry.id)) - .then(() => apis.user.nodes.deleteNodeById(file1Id, false)) - .then(() => apis.user.nodes.deleteNodeById(file2Id, false)) - .then(() => apis.user.nodes.deleteNodeById(folder1Id, false)) - .then(() => apis.user.nodes.deleteNodeById(folder2Id, false)) + .then(() => apis.user.nodes.deleteNodesById(filesIds, false)) + .then(() => apis.user.nodes.deleteNodesById(foldersIds, false)) .then(() => loginPage.load()) .then(() => loginPage.loginWith(username)) @@ -70,21 +66,15 @@ describe('Permanently delete from Trash', () => { afterAll(done => { Promise.all([ - apis.user.trashcan.permanentlyDelete(file1Id), - apis.user.trashcan.permanentlyDelete(file2Id), - apis.user.trashcan.permanentlyDelete(folder1Id), - apis.user.trashcan.permanentlyDelete(folder2Id), + apis.user.trashcan.emptyTrash(), logoutPage.load() ]) .then(done); }); it('delete file', () => { - dataTable.clickOnRowByContainingText(file1) - .then(() => { - const button = toolbar.actions.getButtonByTitleAttribute('Permanently delete'); - button.click(); - }) + dataTable.clickOnItemName(file1) + .then(() => toolbar.actions.getButtonByTitleAttribute('Permanently delete').click()) .then(() => trashPage.getSnackBarMessage()) .then(text => { expect(text).toBe(`${file1} deleted`); @@ -93,11 +83,8 @@ describe('Permanently delete from Trash', () => { }); it('delete folder', () => { - dataTable.clickOnRowByContainingText(folder1) - .then(() => { - const button = toolbar.actions.getButtonByTitleAttribute('Permanently delete'); - button.click(); - }) + dataTable.clickOnItemName(folder1) + .then(() => toolbar.actions.getButtonByTitleAttribute('Permanently delete').click()) .then(() => trashPage.getSnackBarMessage()) .then(text => { expect(text).toBe(`${folder1} deleted`); @@ -107,10 +94,7 @@ describe('Permanently delete from Trash', () => { it('delete multiple items', () => { dataTable.selectMultipleItems([ file2, folder2 ]) - .then(() => { - const button = toolbar.actions.getButtonByTitleAttribute('Permanently delete'); - button.click(); - }) + .then(() => toolbar.actions.getButtonByTitleAttribute('Permanently delete').click()) .then(() => trashPage.getSnackBarMessage()) .then(text => { expect(text).toBe(`2 items deleted`); diff --git a/e2e/suites/actions/restore.test.ts b/e2e/suites/actions/restore.test.ts index dccf13156..7422a9caf 100644 --- a/e2e/suites/actions/restore.test.ts +++ b/e2e/suites/actions/restore.test.ts @@ -25,16 +25,13 @@ describe('Restore from Trash', () => { const username = `user-${Utils.random()}`; const file1 = `file-${Utils.random()}.txt`; - let file1Id; const file2 = `file-${Utils.random()}.txt`; - let file2Id; const file3 = `file-${Utils.random()}.txt`; - let file3Id; + let filesIds; const folder1 = `folder-${Utils.random()}`; - let folder1Id; const folder2 = `folder-${Utils.random()}`; - let folder2Id; + let foldersIds; const apis = { admin: new RepoClient(), @@ -50,17 +47,13 @@ describe('Restore from Trash', () => { beforeAll(done => { apis.admin.people.createUser(username) - .then(() => apis.user.nodes.createFiles([ file1 ]).then(resp => file1Id = resp.data.entry.id)) - .then(() => apis.user.nodes.createFiles([ file2 ]).then(resp => file2Id = resp.data.entry.id)) - .then(() => apis.user.nodes.createFiles([ file3 ]).then(resp => file3Id = resp.data.entry.id)) - .then(() => apis.user.nodes.createFolders([ folder1 ]).then(resp => folder1Id = resp.data.entry.id)) - .then(() => apis.user.nodes.createFolders([ folder2 ]).then(resp => folder2Id = resp.data.entry.id)) + .then(() => apis.user.nodes.createFiles([ file1, file2, file3 ])) + .then(resp => filesIds = resp.data.list.entries.map(entries => entries.entry.id)) + .then(() => apis.user.nodes.createFolders([ folder1, folder2 ])) + .then(resp => foldersIds = resp.data.list.entries.map(entries => entries.entry.id)) - .then(() => apis.user.nodes.deleteNodeById(file1Id, false)) - .then(() => apis.user.nodes.deleteNodeById(file2Id, false)) - .then(() => apis.user.nodes.deleteNodeById(file3Id, false)) - .then(() => apis.user.nodes.deleteNodeById(folder1Id, false)) - .then(() => apis.user.nodes.deleteNodeById(folder2Id, false)) + .then(() => apis.user.nodes.deleteNodesById(filesIds, false)) + .then(() => apis.user.nodes.deleteNodesById(foldersIds, false)) .then(() => loginPage.load()) .then(() => loginPage.loginWith(username)) @@ -75,18 +68,16 @@ describe('Restore from Trash', () => { afterAll(done => { Promise.all([ - apis.user.nodes.deleteNodeById(file1Id), - apis.user.nodes.deleteNodeById(file2Id), - apis.user.nodes.deleteNodeById(file3Id), - apis.user.nodes.deleteNodeById(folder1Id), - apis.user.nodes.deleteNodeById(folder2Id), + apis.user.nodes.deleteNodesById(filesIds), + apis.user.nodes.deleteNodesById(foldersIds), + apis.user.trashcan.emptyTrash(), logoutPage.load() ]) .then(done); }); it('restore file', () => { - dataTable.clickOnRowByContainingText(file1) + dataTable.clickOnItemName(file1) .then(() => toolbar.actions.getButtonByTitleAttribute('Restore').click()) .then(() => trashPage.getSnackBarMessage()) .then(text => { @@ -102,7 +93,7 @@ describe('Restore from Trash', () => { }); it('restore folder', () => { - dataTable.clickOnRowByContainingText(folder1) + dataTable.clickOnItemName(folder1) .then(() => toolbar.actions.getButtonByTitleAttribute('Restore').click()) .then(() => trashPage.getSnackBarMessage()) .then(text => { @@ -136,7 +127,7 @@ describe('Restore from Trash', () => { }); it('View from notification', () => { - dataTable.clickOnRowByContainingText(file3) + dataTable.clickOnItemName(file3) .then(() => toolbar.actions.getButtonByTitleAttribute('Restore').click()) .then(() => trashPage.getSnackBarAction().click()) .then(() => personalFilesPage.dataTable.waitForHeader()) diff --git a/e2e/suites/actions/toolbar-multiple-selection.test.ts b/e2e/suites/actions/toolbar-multiple-selection.test.ts index ca81d85b1..8401919ef 100644 --- a/e2e/suites/actions/toolbar-multiple-selection.test.ts +++ b/e2e/suites/actions/toolbar-multiple-selection.test.ts @@ -189,7 +189,7 @@ describe('Toolbar actions - multiple selection : ', () => { beforeEach(done => { page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES) .then(() => dataTable.waitForHeader()) - .then(() => dataTable.doubleClickOnRowByContainingText(siteName)) + .then(() => dataTable.doubleClickOnItemName(siteName)) .then(() => dataTable.waitForHeader()) .then(done); }); diff --git a/e2e/suites/actions/toolbar-single-selection.test.ts b/e2e/suites/actions/toolbar-single-selection.test.ts index 0e7d331f9..de976bbc4 100644 --- a/e2e/suites/actions/toolbar-single-selection.test.ts +++ b/e2e/suites/actions/toolbar-single-selection.test.ts @@ -49,15 +49,18 @@ describe('Toolbar actions - single selection : ', () => { const loginPage = new LoginPage(); const logoutPage = new LogoutPage(); const page = new BrowsingPage(); - const { dataTable } = page; - const { toolbar } = page; + const { dataTable, toolbar } = page; beforeAll(done => { apis.admin.people.createUser(username) - .then(() => apis.user.nodes.createFiles([ fileUser ]).then(resp => { fileUserId = resp.data.entry.id; })) - .then(() => apis.user.nodes.createFiles([ fileForDelete ]).then(resp => { fileForDeleteId = resp.data.entry.id; })) - .then(() => apis.user.nodes.createFolders([ folderForDelete ]).then((resp) => { folderForDeleteId = resp.data.entry.id; })) - .then(() => apis.user.nodes.createFolders([ folderUser ]).then(resp => { folderUserId = resp.data.entry.id; })) + .then(() => apis.user.nodes.createFiles([ fileUser ])) + .then(resp => fileUserId = resp.data.entry.id) + .then(() => apis.user.nodes.createFiles([ fileForDelete ])) + .then(resp => fileForDeleteId = resp.data.entry.id) + .then(() => apis.user.nodes.createFolders([ folderForDelete ])) + .then(resp => folderForDeleteId = resp.data.entry.id) + .then(() => apis.user.nodes.createFolders([ folderUser ])) + .then(resp => folderUserId = resp.data.entry.id) .then(() => apis.user.shared.shareFileById(fileUserId)) .then(() => apis.user.favorites.addFavoriteById('file', fileUserId)) .then(() => apis.user.favorites.addFavoriteById('folder', folderUserId)) @@ -97,21 +100,21 @@ describe('Toolbar actions - single selection : ', () => { }); it('actions are displayed when a file is selected', () => { - dataTable.clickOnRowByContainingText(fileUser) + dataTable.clickOnItemName(fileUser) .then(() => { expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${fileUser}`); }); }); it('actions are displayed when a folder is selected', () => { - dataTable.clickOnRowByContainingText(folderUser) + dataTable.clickOnItemName(folderUser) .then(() => { expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${folderUser}`); }); }); it('correct actions appear when a file is selected', () => { - dataTable.clickOnRowByContainingText(fileUser) + dataTable.clickOnItemName(fileUser) .then(() => { expect(toolbar.actions.isButtonPresent('View')).toBe(true, `View is not displayed for ${fileUser}`); expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not displayed for ${fileUser}`); @@ -128,7 +131,7 @@ describe('Toolbar actions - single selection : ', () => { }); it('correct actions appear when a folder is selected', () => { - dataTable.clickOnRowByContainingText(folderUser) + dataTable.clickOnItemName(folderUser) .then(() => { expect(toolbar.actions.isButtonPresent('View')).toBe(false, `View is displayed for ${folderUser}`); expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not enabled for ${folderUser}`); @@ -159,7 +162,7 @@ describe('Toolbar actions - single selection : ', () => { beforeEach(done => { page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES) .then(() => dataTable.waitForHeader()) - .then(() => dataTable.doubleClickOnRowByContainingText(siteName)) + .then(() => dataTable.doubleClickOnItemName(siteName)) .then(() => dataTable.waitForHeader()) .then(done); }); @@ -186,21 +189,21 @@ describe('Toolbar actions - single selection : ', () => { }); it('actions are displayed when a file is selected', () => { - dataTable.clickOnRowByContainingText(fileAdmin) + dataTable.clickOnItemName(fileAdmin) .then(() => { expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${fileAdmin}`); }); }); it('actions are displayed when a folder is selected', () => { - dataTable.clickOnRowByContainingText(folderAdmin) + dataTable.clickOnItemName(folderAdmin) .then(() => { expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${folderAdmin}`); }); }); it('correct actions appear when a file is selected', () => { - dataTable.clickOnRowByContainingText(fileAdmin) + dataTable.clickOnItemName(fileAdmin) .then(() => { expect(toolbar.actions.isButtonPresent('View')).toBe(true, `View is not displayed for ${fileAdmin}`); expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not displayed for ${fileAdmin}`); @@ -217,7 +220,7 @@ describe('Toolbar actions - single selection : ', () => { }); it('correct actions appear when a folder is selected', () => { - dataTable.clickOnRowByContainingText(folderAdmin) + dataTable.clickOnItemName(folderAdmin) .then(() => { expect(toolbar.actions.isButtonPresent('View')).toBe(false, `View is displayed for ${folderAdmin}`); expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not enabled for ${folderAdmin}`); @@ -250,21 +253,21 @@ describe('Toolbar actions - single selection : ', () => { }); it('actions are displayed when a file is selected', () => { - dataTable.clickOnRowByContainingText(fileAdmin) + dataTable.clickOnItemName(fileAdmin) .then(() => { expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${fileAdmin}`); }); }); it('actions are displayed when a folder is selected', () => { - dataTable.clickOnRowByContainingText(folderAdmin) + dataTable.clickOnItemName(folderAdmin) .then(() => { expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${folderAdmin}`); }); }); it('correct actions appear when a file is selected', () => { - dataTable.clickOnRowByContainingText(fileAdmin) + dataTable.clickOnItemName(fileAdmin) .then(() => { expect(toolbar.actions.isButtonPresent('View')).toBe(true, `View is not displayed for ${fileAdmin}`); expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not displayed for ${fileAdmin}`); @@ -281,7 +284,7 @@ describe('Toolbar actions - single selection : ', () => { }); it('correct actions appear when a folder is selected', () => { - dataTable.clickOnRowByContainingText(folderAdmin) + dataTable.clickOnItemName(folderAdmin) .then(() => { expect(toolbar.actions.isButtonPresent('View')).toBe(false, `View is displayed for ${folderAdmin}`); expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not enabled for ${folderAdmin}`); @@ -321,14 +324,14 @@ describe('Toolbar actions - single selection : ', () => { }); it('actions are displayed when a file is selected', () => { - dataTable.clickOnRowByContainingText(fileUser) + dataTable.clickOnItemName(fileUser) .then(() => { expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${fileUser}`); }); }); it('correct actions appear when a file is selected', () => { - dataTable.clickOnRowByContainingText(fileUser) + dataTable.clickOnItemName(fileUser) .then(() => { expect(toolbar.actions.isButtonPresent('View')).toBe(true, `View is not displayed for ${fileUser}`); expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not displayed for ${fileUser}`); @@ -367,14 +370,14 @@ describe('Toolbar actions - single selection : ', () => { }); it('actions are displayed when a file is selected', () => { - dataTable.clickOnRowByContainingText(fileUser) + dataTable.clickOnItemName(fileUser) .then(() => { expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${fileUser}`); }); }); it('correct actions appear when a file is selected', () => { - dataTable.clickOnRowByContainingText(fileUser) + dataTable.clickOnItemName(fileUser) .then(() => { expect(toolbar.actions.isButtonPresent('View')).toBe(true, `View is not displayed for ${fileUser}`); expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not displayed for ${fileUser}`); @@ -413,21 +416,21 @@ describe('Toolbar actions - single selection : ', () => { }); it('actions are displayed when a file is selected', () => { - dataTable.clickOnRowByContainingText(fileUser) + dataTable.clickOnItemName(fileUser) .then(() => { expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${fileUser}`); }); }); it('actions are displayed when a folder is selected', () => { - dataTable.clickOnRowByContainingText(folderUser) + dataTable.clickOnItemName(folderUser) .then(() => { expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${folderUser}`); }); }); it('correct actions appear when a file is selected', () => { - dataTable.clickOnRowByContainingText(fileUser) + dataTable.clickOnItemName(fileUser) .then(() => { expect(toolbar.actions.isButtonPresent('View')).toBe(true, `View is not displayed for ${fileUser}`); expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not displayed for ${fileUser}`); @@ -444,7 +447,7 @@ describe('Toolbar actions - single selection : ', () => { }); it('correct actions appear when a folder is selected', () => { - dataTable.clickOnRowByContainingText(folderUser) + dataTable.clickOnItemName(folderUser) .then(() => { expect(toolbar.actions.isButtonPresent('View')).toBe(false, `View is displayed for ${folderUser}`); expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not enabled for ${folderUser}`); @@ -490,21 +493,21 @@ describe('Toolbar actions - single selection : ', () => { }); it('actions are displayed when a file is selected', () => { - dataTable.clickOnRowByContainingText(fileForDelete) + dataTable.clickOnItemName(fileForDelete) .then(() => { expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${fileForDelete}`); }); }); it('actions are displayed when a folder is selected', () => { - dataTable.clickOnRowByContainingText(folderForDelete) + dataTable.clickOnItemName(folderForDelete) .then(() => { expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${folderForDelete}`); }); }); it('correct actions appear when a file is selected', () => { - dataTable.clickOnRowByContainingText(fileForDelete) + dataTable.clickOnItemName(fileForDelete) .then(() => { expect(toolbar.actions.isButtonPresent('Permanently delete')) .toBe(true, `Permanently delete is not displayed for ${fileForDelete}`); @@ -513,7 +516,7 @@ describe('Toolbar actions - single selection : ', () => { }); it('correct actions appear when a folder is selected', () => { - dataTable.clickOnRowByContainingText(folderForDelete) + dataTable.clickOnItemName(folderForDelete) .then(() => { expect(toolbar.actions.isButtonPresent('Permanently delete')) .toBe(true, `Permanently delete is displayed for ${folderForDelete}`); diff --git a/e2e/suites/list-views/empty-list.test.ts b/e2e/suites/list-views/empty-list.test.ts index 223c8588e..d5c2d0856 100644 --- a/e2e/suites/list-views/empty-list.test.ts +++ b/e2e/suites/list-views/empty-list.test.ts @@ -15,8 +15,6 @@ * limitations under the License. */ -import { browser, by } from 'protractor'; - import { APP_ROUTES, SITE_VISIBILITY, SITE_ROLES, SIDEBAR_LABELS } from '../../configs'; import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages'; import { Utils } from '../../utilities/utils'; diff --git a/e2e/suites/list-views/personal-files.test.ts b/e2e/suites/list-views/personal-files.test.ts index d2e079c54..232250fbc 100644 --- a/e2e/suites/list-views/personal-files.test.ts +++ b/e2e/suites/list-views/personal-files.test.ts @@ -134,7 +134,7 @@ describe('Personal Files', () => { .then(response => response.data.entry.id); const navigatePromise = dataTable - .doubleClickOnRowByContainingText(userFolder) + .doubleClickOnItemName(userFolder) .then(() => dataTable.waitForHeader()); Promise @@ -158,7 +158,7 @@ describe('Personal Files', () => { const { actions } = personalFilesPage.toolbar; dataTable - .clickOnRowByContainingText(userFolder) + .clickOnItemName(userFolder) .then(() => { expect(actions.isEmpty()).toBe(false, 'Toolbar to be present'); }) diff --git a/e2e/suites/pagination/pagination.test.ts b/e2e/suites/pagination/pagination.test.ts index e510e3973..f703eba55 100644 --- a/e2e/suites/pagination/pagination.test.ts +++ b/e2e/suites/pagination/pagination.test.ts @@ -65,14 +65,16 @@ describe('Pagination', () => { beforeEach(done => { personalFilesPage.load() .then(() => dataTable.waitForHeader()) - .then(() => dataTable.doubleClickOnRowByContainingText(content.name)) + .then(() => dataTable.doubleClickOnItemName(content.name)) .then(() => dataTable.sortByColumn('Name')) .then(done); }); afterAll(done => { logoutPage.load() - .then(() => nodesApi.deleteNodes([ content.name ])) + .then(() => { + nodesApi.deleteNodes([ content.name ]); + }) .then(done); }); @@ -116,7 +118,7 @@ describe('Pagination', () => { it('changes the current page from menu', () => { pagination.openCurrentPageMenu() - .then(menu => menu.clicktNthItem(3)) + .then(menu => menu.clickNthItem(3)) .then(() => dataTable.waitForHeader()) .then(() => { expect(pagination.range.getText()).toContain('51-75 of 101', 'Range'); @@ -140,7 +142,7 @@ describe('Pagination', () => { it('navigates to previous page', () => { pagination.openCurrentPageMenu() - .then(menu => menu.clicktNthItem(2)) + .then(menu => menu.clickNthItem(2)) .then(() => dataTable.waitForHeader()) .then(() => pagination.previousButton.click()) .then(() => dataTable.waitForHeader()) @@ -153,7 +155,7 @@ describe('Pagination', () => { it('has one item on the last page', () => { pagination.openCurrentPageMenu() - .then(menu => menu.clicktNthItem(5)) + .then(menu => menu.clickNthItem(5)) .then(() => dataTable.waitForHeader()) .then(() => { expect(dataTable.countRows()).toBe(1, 'Single item on the last page'); diff --git a/e2e/utilities/repo-client/apis/favorites/favorites-api.ts b/e2e/utilities/repo-client/apis/favorites/favorites-api.ts index e2b0c4ee0..c8ab9a945 100644 --- a/e2e/utilities/repo-client/apis/favorites/favorites-api.ts +++ b/e2e/utilities/repo-client/apis/favorites/favorites-api.ts @@ -52,6 +52,12 @@ export class FavoritesApi extends RepoApi { .catch(this.handleError); } + addFavoritesByIds(nodeType: string, ids: string[]): Promise { + return ids.reduce((previous, current) => ( + previous.then(() => this.addFavoriteById(nodeType, current)) + ), Promise.resolve()); + } + getFavorite(api: RepoClient, name: string): Promise { return api.nodes.getNodeByPath(name) .then((response) => { diff --git a/e2e/utilities/repo-client/apis/nodes/nodes-api.ts b/e2e/utilities/repo-client/apis/nodes/nodes-api.ts index 71dc14017..90eb669c0 100644 --- a/e2e/utilities/repo-client/apis/nodes/nodes-api.ts +++ b/e2e/utilities/repo-client/apis/nodes/nodes-api.ts @@ -33,6 +33,12 @@ export class NodesApi extends RepoApi { .catch(this.handleError); } + getNodeDescription(name: string): Promise { + return this.getNodeByPath(name) + .then(response => response.data.entry.properties['cm:description']) + .catch(() => Promise.resolve('')); + } + deleteNodeById(id: string, permanent: boolean = true): Promise { return this .delete(`/nodes/${id}?permanent=${permanent}`) @@ -47,19 +53,10 @@ export class NodesApi extends RepoApi { .catch(this.handleError); } - getNodeDescription(name: string): Promise { - return this.getNodeByPath(name) - .then(response => response.data.entry.properties['cm:description']) - .catch(() => Promise.resolve('')); - } - - deleteNodes(names: string[], relativePath: string = '', permanent: boolean = true): Promise { - const deletions = names - .map((name: string): any => { - return this.deleteNodeByPath(`${relativePath}/${name}`, permanent); - }); - - return Promise.all(deletions); + deleteNodes(names: string[], relativePath: string = '', permanent: boolean = true): Promise { + return names.reduce((previous, current) => ( + previous.then(() => this.deleteNodeByPath(`${relativePath}/${current}`, permanent)) + ), Promise.resolve()); } deleteNodesById(ids: string[], permanent: boolean = true): Promise { diff --git a/e2e/utilities/repo-client/apis/shared-links/shared-links-api.ts b/e2e/utilities/repo-client/apis/shared-links/shared-links-api.ts index b11854c3f..c04cdcfd1 100644 --- a/e2e/utilities/repo-client/apis/shared-links/shared-links-api.ts +++ b/e2e/utilities/repo-client/apis/shared-links/shared-links-api.ts @@ -28,6 +28,12 @@ export class SharedLinksApi extends RepoApi { .catch(this.handleError); } + shareFilesByIds(ids: string[]): Promise { + return ids.reduce((previous, current) => ( + previous.then(() => this.shareFileById(current)) + ), Promise.resolve()); + } + getSharedLinks(): Promise { return this.get(`/shared-links`) .catch(this.handleError); diff --git a/e2e/utilities/repo-client/apis/sites/sites-api.ts b/e2e/utilities/repo-client/apis/sites/sites-api.ts index 05b3f7e6c..cb316daa1 100644 --- a/e2e/utilities/repo-client/apis/sites/sites-api.ts +++ b/e2e/utilities/repo-client/apis/sites/sites-api.ts @@ -35,7 +35,7 @@ export class SitesApi extends RepoApi { .catch(this.handleError); } - createSite(title: string, visibility: string, details?: Site): Promise { + createOrUpdateSite(title: string, visibility: string, details?: Site): Promise { const site: Site = new Site(title, visibility, details); const onSuccess = (response) => response; const onError = (response) => { @@ -50,12 +50,31 @@ export class SitesApi extends RepoApi { .catch(this.handleError); } + createSite(title: string, visibility: string, details?: Site): Promise { + const site: Site = new Site(title, visibility, details); + return this + .post(`/sites`, { data: site }) + .catch(this.handleError); + } + + createSites(titles: string[], visibility: string): Promise { + return titles.reduce((previous, current) => ( + previous.then(() => this.createSite(current, visibility)) + ), Promise.resolve()); + } + deleteSite(id: string, permanent: boolean = true): Promise { return this .delete(`/sites/${id}?permanent=${permanent}`) .catch(this.handleError); } + deleteSites(ids: string[], permanent: boolean = true): Promise { + return ids.reduce((previous, current) => ( + previous.then(() => this.deleteSite(current)) + ), Promise.resolve()); + } + updateSiteMember(siteId: string, userId: string, role: string): Promise { return this .put(`/sites/${siteId}/members/${userId}`, { data: { role } }) diff --git a/e2e/utilities/repo-client/apis/trashcan/trashcan-api.ts b/e2e/utilities/repo-client/apis/trashcan/trashcan-api.ts index cc50b1465..7a0e143e7 100644 --- a/e2e/utilities/repo-client/apis/trashcan/trashcan-api.ts +++ b/e2e/utilities/repo-client/apis/trashcan/trashcan-api.ts @@ -23,4 +23,24 @@ export class TrashcanApi extends RepoApi { .delete(`/deleted-nodes/${id}`) .catch(this.handleError); } + + getDeletedNodes(): Promise { + return this + .get(`/deleted-nodes?maxItems=1000`) + .catch(this.handleError); + } + + emptyTrash(): Promise { + return this.getDeletedNodes() + .then(resp => { + return resp.data.list.entries.map(entries => entries.entry.id); + }) + .then(ids => { + return ids.reduce((previous, current) => ( + previous.then(() => this.permanentlyDelete(current)) + ), Promise.resolve()); + }) + .catch(this.handleError); + } + } diff --git a/protractor.conf.js b/protractor.conf.js index 9f995ddbb..60ea06d39 100644 --- a/protractor.conf.js +++ b/protractor.conf.js @@ -7,6 +7,9 @@ const jasmineReporters = require('jasmine-reporters'); const projectRoot = path.resolve(__dirname); +const width = 1366; +const height = 768; + exports.config = { allScriptsTimeout: 11000, @@ -55,6 +58,8 @@ exports.config = { project: 'e2e/tsconfig.e2e.json' }); + browser.manage().window().setSize(width, height); + jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } })); jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({ From c1e9001c38f77e8e79907c3c1b0d671eb7e30e7f Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Tue, 28 Nov 2017 20:03:35 +0000 Subject: [PATCH 18/19] [ACA-1033] pagination fixes (#95) * pagination fixes * test fixes --- src/app/components/favorites/favorites.component.html | 5 ++++- src/app/components/favorites/favorites.component.ts | 7 ++++--- src/app/components/files/files.component.html | 4 +++- src/app/components/files/files.component.ts | 10 +++++++--- src/app/components/libraries/libraries.component.html | 5 ++++- src/app/components/libraries/libraries.component.ts | 7 ++++--- src/app/components/page.component.spec.ts | 2 +- src/app/components/page.component.ts | 8 ++++++++ .../recent-files/recent-files.component.html | 5 ++++- .../components/recent-files/recent-files.component.ts | 6 ++++-- .../shared-files/shared-files.component.html | 5 ++++- .../components/shared-files/shared-files.component.ts | 7 ++++--- src/app/components/trashcan/trashcan.component.html | 5 ++++- src/app/components/trashcan/trashcan.component.ts | 11 +++++++++-- 14 files changed, 64 insertions(+), 23 deletions(-) diff --git a/src/app/components/favorites/favorites.component.html b/src/app/components/favorites/favorites.component.html index 39df9ec91..aaf50b5cb 100644 --- a/src/app/components/favorites/favorites.component.html +++ b/src/app/components/favorites/favorites.component.html @@ -141,6 +141,9 @@ - + + diff --git a/src/app/components/favorites/favorites.component.ts b/src/app/components/favorites/favorites.component.ts index 90f35f0a4..6216a8e3a 100644 --- a/src/app/components/favorites/favorites.component.ts +++ b/src/app/components/favorites/favorites.component.ts @@ -20,7 +20,7 @@ import { Router } from '@angular/router'; import { Subscription } from 'rxjs/Rx'; import { MinimalNodeEntryEntity, MinimalNodeEntity, PathElementEntity, PathInfo } from 'alfresco-js-api'; -import { ContentService, NodesApiService } from '@alfresco/adf-core'; +import { ContentService, NodesApiService, UserPreferencesService } from '@alfresco/adf-core'; import { DocumentListComponent } from '@alfresco/adf-content-services'; import { ContentManagementService } from '../../common/services/content-management.service'; @@ -40,8 +40,9 @@ export class FavoritesComponent extends PageComponent implements OnInit, OnDestr private router: Router, private nodesApi: NodesApiService, private contentService: ContentService, - private content: ContentManagementService) { - super(); + private content: ContentManagementService, + preferences: UserPreferencesService) { + super(preferences); } ngOnInit() { diff --git a/src/app/components/files/files.component.html b/src/app/components/files/files.component.html index fd696572a..b2b693d66 100644 --- a/src/app/components/files/files.component.html +++ b/src/app/components/files/files.component.html @@ -143,8 +143,10 @@ + (change)="load(true, $event)" + (changePageSize)="onChangePageSize($event)"> diff --git a/src/app/components/files/files.component.ts b/src/app/components/files/files.component.ts index 5946bc86a..7b8847f02 100644 --- a/src/app/components/files/files.component.ts +++ b/src/app/components/files/files.component.ts @@ -19,7 +19,10 @@ import { Observable, Subscription } from 'rxjs/Rx'; import { Component, OnInit, OnDestroy, ChangeDetectorRef } from '@angular/core'; import { Router, ActivatedRoute, Params } from '@angular/router'; import { MinimalNodeEntity, MinimalNodeEntryEntity, PathElementEntity, NodePaging, PathElement } from 'alfresco-js-api'; -import { UploadService, FileUploadEvent, NodesApiService, ContentService, AlfrescoApiService } from '@alfresco/adf-core'; +import { + UploadService, FileUploadEvent, NodesApiService, + ContentService, AlfrescoApiService, UserPreferencesService +} from '@alfresco/adf-core'; import { BrowsingFilesService } from '../../common/services/browsing-files.service'; import { ContentManagementService } from '../../common/services/content-management.service'; @@ -47,8 +50,9 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy { private contentManagementService: ContentManagementService, private browsingFilesService: BrowsingFilesService, private contentService: ContentService, - private apiService: AlfrescoApiService) { - super(); + private apiService: AlfrescoApiService, + preferences: UserPreferencesService) { + super(preferences); } ngOnInit() { diff --git a/src/app/components/libraries/libraries.component.html b/src/app/components/libraries/libraries.component.html index 72d3ffe9d..076fb6d81 100644 --- a/src/app/components/libraries/libraries.component.html +++ b/src/app/components/libraries/libraries.component.html @@ -64,6 +64,9 @@ - + + diff --git a/src/app/components/libraries/libraries.component.ts b/src/app/components/libraries/libraries.component.ts index ccf5a111a..e6b141bc5 100644 --- a/src/app/components/libraries/libraries.component.ts +++ b/src/app/components/libraries/libraries.component.ts @@ -17,7 +17,7 @@ import { Component, ViewChild } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; -import { NodesApiService } from '@alfresco/adf-core'; +import { NodesApiService, UserPreferencesService } from '@alfresco/adf-core'; import { DocumentListComponent, ShareDataRow } from '@alfresco/adf-content-services'; import { PageComponent } from '../page.component'; @@ -33,8 +33,9 @@ export class LibrariesComponent extends PageComponent { constructor( private nodesApi: NodesApiService, private route: ActivatedRoute, - private router: Router) { - super(); + private router: Router, + preferences: UserPreferencesService) { + super(preferences); } makeLibraryTooltip(library: any): string { diff --git a/src/app/components/page.component.spec.ts b/src/app/components/page.component.spec.ts index fa45ed439..f8f922dff 100644 --- a/src/app/components/page.component.spec.ts +++ b/src/app/components/page.component.spec.ts @@ -23,7 +23,7 @@ class TestClass extends PageComponent { node: any; constructor() { - super(); + super(null); } fetchNodes(parentNodeId?: string, options?: any) { diff --git a/src/app/components/page.component.ts b/src/app/components/page.component.ts index 133ae97c7..5b19a8f1d 100644 --- a/src/app/components/page.component.ts +++ b/src/app/components/page.component.ts @@ -16,6 +16,7 @@ */ import { MinimalNodeEntity, MinimalNodeEntryEntity, NodePaging, Pagination } from 'alfresco-js-api'; +import { UserPreferencesService } from '@alfresco/adf-core'; export abstract class PageComponent { @@ -31,6 +32,9 @@ export abstract class PageComponent { abstract fetchNodes(parentNodeId?: string, options?: any): void; + constructor(private preferences: UserPreferencesService) { + } + onFetchError(error: any) { this.isLoading = false; } @@ -121,4 +125,8 @@ export abstract class PageComponent { return false; } + + onChangePageSize(event: Pagination): void { + this.preferences.paginationSize = event.maxItems; + } } diff --git a/src/app/components/recent-files/recent-files.component.html b/src/app/components/recent-files/recent-files.component.html index f6f64625d..e6373f5a3 100644 --- a/src/app/components/recent-files/recent-files.component.html +++ b/src/app/components/recent-files/recent-files.component.html @@ -130,6 +130,9 @@ - + + diff --git a/src/app/components/recent-files/recent-files.component.ts b/src/app/components/recent-files/recent-files.component.ts index 6a32a6d6c..4444fe829 100644 --- a/src/app/components/recent-files/recent-files.component.ts +++ b/src/app/components/recent-files/recent-files.component.ts @@ -19,6 +19,7 @@ import { Subscription } from 'rxjs/Rx'; import { Component, ViewChild, OnInit, OnDestroy } from '@angular/core'; import { Router } from '@angular/router'; import { MinimalNodeEntryEntity } from 'alfresco-js-api'; +import { UserPreferencesService } from '@alfresco/adf-core'; import { DocumentListComponent } from '@alfresco/adf-content-services'; import { ContentManagementService } from '../../common/services/content-management.service'; @@ -36,8 +37,9 @@ export class RecentFilesComponent extends PageComponent implements OnInit, OnDes constructor( private router: Router, - private content: ContentManagementService) { - super(); + private content: ContentManagementService, + preferences: UserPreferencesService) { + super(preferences); } ngOnInit() { diff --git a/src/app/components/shared-files/shared-files.component.html b/src/app/components/shared-files/shared-files.component.html index 662bd616e..898f606ba 100644 --- a/src/app/components/shared-files/shared-files.component.html +++ b/src/app/components/shared-files/shared-files.component.html @@ -138,6 +138,9 @@ - + + diff --git a/src/app/components/shared-files/shared-files.component.ts b/src/app/components/shared-files/shared-files.component.ts index 129c885e7..47079bb0e 100644 --- a/src/app/components/shared-files/shared-files.component.ts +++ b/src/app/components/shared-files/shared-files.component.ts @@ -19,7 +19,7 @@ import { Component, OnInit, ViewChild, OnDestroy } from '@angular/core'; import { Router } from '@angular/router'; import { Subscription } from 'rxjs/Rx'; import { MinimalNodeEntity } from 'alfresco-js-api'; -import { AlfrescoApiService } from '@alfresco/adf-core'; +import { AlfrescoApiService, UserPreferencesService } from '@alfresco/adf-core'; import { DocumentListComponent } from '@alfresco/adf-content-services'; import { ContentManagementService } from '../../common/services/content-management.service'; @@ -38,8 +38,9 @@ export class SharedFilesComponent extends PageComponent implements OnInit, OnDes constructor( private router: Router, private content: ContentManagementService, - private apiService: AlfrescoApiService) { - super(); + private apiService: AlfrescoApiService, + preferences: UserPreferencesService) { + super(preferences); } ngOnInit() { diff --git a/src/app/components/trashcan/trashcan.component.html b/src/app/components/trashcan/trashcan.component.html index e91fc0bac..3ac971eea 100644 --- a/src/app/components/trashcan/trashcan.component.html +++ b/src/app/components/trashcan/trashcan.component.html @@ -94,6 +94,9 @@ - + + diff --git a/src/app/components/trashcan/trashcan.component.ts b/src/app/components/trashcan/trashcan.component.ts index 9dc0040b1..1301e41d9 100644 --- a/src/app/components/trashcan/trashcan.component.ts +++ b/src/app/components/trashcan/trashcan.component.ts @@ -17,7 +17,8 @@ import { Component, ViewChild, OnInit, OnDestroy } from '@angular/core'; import { Subscription } from 'rxjs/Rx'; - +import { Pagination } from 'alfresco-js-api'; +import { UserPreferencesService } from '@alfresco/adf-core'; import { DocumentListComponent } from '@alfresco/adf-content-services'; import { ContentManagementService } from '../../common/services/content-management.service'; @@ -29,7 +30,9 @@ export class TrashcanComponent implements OnInit, OnDestroy { @ViewChild(DocumentListComponent) documentList; - constructor(private contentManagementService: ContentManagementService) {} + constructor( + private contentManagementService: ContentManagementService, + private preferences: UserPreferencesService) {} ngOnInit() { this.subscriptions.push(this.contentManagementService.restoreNode.subscribe(() => this.refresh())); @@ -43,4 +46,8 @@ export class TrashcanComponent implements OnInit, OnDestroy { ngOnDestroy() { this.subscriptions.forEach(s => s.unsubscribe()); } + + onChangePageSize(event: Pagination): void { + this.preferences.paginationSize = event.maxItems; + } } From f6f7b0bdf3ae29d8de5ecb41699837c67a2fb1b4 Mon Sep 17 00:00:00 2001 From: Adina Parpalita Date: Tue, 28 Nov 2017 23:29:07 +0200 Subject: [PATCH 19/19] add tests for pagination on multiple list views (#97) --- e2e/components/data-table/data-table.ts | 1 + e2e/suites/pagination/pagination.test.ts | 629 ++++++++++++++++++++--- 2 files changed, 566 insertions(+), 64 deletions(-) diff --git a/e2e/components/data-table/data-table.ts b/e2e/components/data-table/data-table.ts index 9192147e3..951ce2aa5 100644 --- a/e2e/components/data-table/data-table.ts +++ b/e2e/components/data-table/data-table.ts @@ -45,6 +45,7 @@ export class DataTable extends Component { head: ElementFinder = this.component.element(by.css(DataTable.selectors.head)); body: ElementFinder = this.component.element(by.css(DataTable.selectors.body)); + cell = by.css(DataTable.selectors.cell); emptyList: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyListContainer)); emptyFolderDragAndDrop: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyFolderDragAndDrop)); emptyListTitle: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyListTitle)); diff --git a/e2e/suites/pagination/pagination.test.ts b/e2e/suites/pagination/pagination.test.ts index f703eba55..cbeae1cce 100644 --- a/e2e/suites/pagination/pagination.test.ts +++ b/e2e/suites/pagination/pagination.test.ts @@ -15,9 +15,8 @@ * limitations under the License. */ -import { browser } from 'protractor'; - -import { APP_ROUTES } from '../../configs'; +import { browser, protractor, promise } from 'protractor'; +import { SIDEBAR_LABELS, SITE_VISIBILITY } from '../../configs'; import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages'; import { Utils } from '../../utilities/utils'; import { RepoClient, NodeContentTree } from '../../utilities/repo-client/repo-client'; @@ -29,138 +28,640 @@ describe('Pagination', () => { admin: new RepoClient(), user: new RepoClient(username, username) }; + const { + nodes: nodesApi, + trashcan: trashApi, + favorites: favoritesApi, + shared: sharedApi, + sites: sitesApi + } = apis.user; const loginPage = new LoginPage(); const logoutPage = new LogoutPage(); + const page = new BrowsingPage(); + const { dataTable, pagination } = page; + + const parent = `parent-${Utils.random()}`; + const files = Array(101) + .fill('file') + .map((name, index): string => `${name}-${index + 1}.txt`); + let filesIds; + + const filesForDelete = Array(101) + .fill('file') + .map((name, index): string => `${name}-${index + 1}.txt`); + let filesDeletedIds; + + function resetToDefaultPageSize(): promise.Promise { + return pagination.openMaxItemsMenu() + .then(menu => menu.clickMenuItem('25')) + .then(() => dataTable.waitForHeader()); + } + + function resetToDefaultPageNumber(): promise.Promise { + return pagination.openCurrentPageMenu() + .then(menu => menu.clickMenuItem('1')) + .then(() => dataTable.waitForHeader()); + } beforeAll(done => { - apis.admin.people - .createUser(username) + apis.admin.people.createUser(username) + .then(() => nodesApi.createFiles(files, parent)) + .then(resp => filesIds = resp.data.list.entries.map(entries => entries.entry.id)) + + .then(() => sharedApi.shareFilesByIds(filesIds)) + + .then(() => favoritesApi.addFavoritesByIds('file', filesIds)) + + .then(() => nodesApi.createFiles(filesForDelete)) + .then(resp => filesDeletedIds = resp.data.list.entries.map(entries => entries.entry.id)) + .then(() => nodesApi.deleteNodesById(filesDeletedIds, false)) + .then(done); }); + afterAll(done => { + Promise.all([ + nodesApi.deleteNodes([ parent ]), + trashApi.emptyTrash() + ]) + .then(done); + }); + xit(''); describe(`on Personal Files`, () => { - const personalFilesPage = new BrowsingPage(APP_ROUTES.PERSONAL_FILES); - const { dataTable, pagination } = personalFilesPage; - - // Generate files - const content: NodeContentTree = { - name: `user-folder-${Utils.random()}`, - files: Array(101) - .fill('file') - .map((name, index): string => `${name}-${index + 1}.txt`) - }; - - const { nodes: nodesApi } = apis.user; - beforeAll(done => { - nodesApi.createContent(content) - .then(() => loginPage.load() - .then(() => loginPage.loginWith(username)) - .then(done)); + loginPage.load() + .then(() => loginPage.loginWith(username)) + .then(done); }); beforeEach(done => { - personalFilesPage.load() + page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES) .then(() => dataTable.waitForHeader()) - .then(() => dataTable.doubleClickOnItemName(content.name)) - .then(() => dataTable.sortByColumn('Name')) + .then(() => dataTable.doubleClickOnItemName(parent)) .then(done); }); + afterEach(done => { + browser.actions().sendKeys(protractor.Key.ESCAPE).perform().then(done); + }); + afterAll(done => { - logoutPage.load() - .then(() => { - nodesApi.deleteNodes([ content.name ]); - }) - .then(done); + logoutPage.load().then(done); }); - it('has default details', () => { - expect(pagination.range.getText()).toContain('1-25 of 101', 'Range'); - expect(pagination.maxItems.getText()).toContain('25', 'Items per page'); - expect(pagination.currentPage.getText()).toContain('Page 1', 'Current page'); - expect(pagination.totalPages.getText()).toContain('of 5', 'Total pages'); - expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button'); - expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button'); + it('default values', () => { + expect(pagination.range.getText()).toContain('1-25 of 101'); + expect(pagination.maxItems.getText()).toContain('25'); + expect(pagination.currentPage.getText()).toContain('Page 1'); + expect(pagination.totalPages.getText()).toContain('of 5'); + expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled'); + expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled'); }); - it('has page sizes', () => { + it('page sizes', () => { pagination.openMaxItemsMenu() .then(menu => { const [ first, second, third ] = [1, 2, 3] .map(nth => menu.getNthItem(nth).getText()); - - expect(first).toBe('25', 'Items per page'); - expect(second).toBe('50', 'Items per page'); - expect(third).toBe('100', 'Items per page'); + expect(first).toBe('25'); + expect(second).toBe('50'); + expect(third).toBe('100'); }); }); - it('changes the page size', () => { + it('change the page size', () => { pagination.openMaxItemsMenu() .then(menu => menu.clickMenuItem('50')) .then(() => dataTable.waitForHeader()) .then(() => { - expect(pagination.maxItems.getText()).toContain('50', 'Items per page'); - expect(pagination.totalPages.getText()).toContain('of 3', 'Total pages'); - }); + expect(pagination.maxItems.getText()).toContain('50'); + expect(pagination.totalPages.getText()).toContain('of 3'); + }) + + .then(() => resetToDefaultPageSize()); }); - it('has page items', () => { + it('current page menu items', () => { pagination.openCurrentPageMenu() .then(menu => { - expect(menu.items.count()).toBe(5); + expect(menu.getItemsCount()).toBe(5); }); }); - it('changes the current page from menu', () => { + it('change the current page from menu', () => { pagination.openCurrentPageMenu() .then(menu => menu.clickNthItem(3)) .then(() => dataTable.waitForHeader()) .then(() => { - expect(pagination.range.getText()).toContain('51-75 of 101', 'Range'); - expect(pagination.currentPage.getText()).toContain('Page 3', 'Current page'); - expect(pagination.previousButton.isEnabled()).toBe(true, 'Previous button'); - expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button'); + expect(pagination.range.getText()).toContain('51-75 of 101'); + expect(pagination.currentPage.getText()).toContain('Page 3'); + expect(pagination.previousButton.isEnabled()).toBe(true, 'Previous button is not enabled'); + expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled'); expect(dataTable.getRowByContainingText('file-60.txt').isPresent()) .toBe(true, 'File not found on page'); - }); + }) + + .then(() => resetToDefaultPageNumber()); }); - it('navigates to next page', () => { + it('navigate to next page', () => { pagination.nextButton.click() .then(() => dataTable.waitForHeader()) .then(() => { - expect(pagination.range.getText()).toContain('26-50 of 101', 'Range'); + expect(pagination.range.getText()).toContain('26-50 of 101'); expect(dataTable.getRowByContainingText('file-30.txt').isPresent()) .toBe(true, 'File not found on page'); - }); + }) + + .then(() => resetToDefaultPageNumber()); }); - it('navigates to previous page', () => { + it('navigate to previous page', () => { pagination.openCurrentPageMenu() .then(menu => menu.clickNthItem(2)) .then(() => dataTable.waitForHeader()) .then(() => pagination.previousButton.click()) .then(() => dataTable.waitForHeader()) .then(() => { - expect(pagination.range.getText()).toContain('1-25 of 101', 'Range'); + expect(pagination.range.getText()).toContain('1-25 of 101'); expect(dataTable.getRowByContainingText('file-12.txt').isPresent()) .toBe(true, 'File not found on page'); - }); + }) + + .then(() => resetToDefaultPageNumber()); }); - it('has one item on the last page', () => { + it('last page', () => { pagination.openCurrentPageMenu() .then(menu => menu.clickNthItem(5)) .then(() => dataTable.waitForHeader()) .then(() => { - expect(dataTable.countRows()).toBe(1, 'Single item on the last page'); - expect(pagination.currentPage.getText()).toContain('Page 5', 'Last page'); - expect(pagination.nextButton.isEnabled()).toBe(false, 'Next button is not enabled'); + expect(dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page'); + expect(pagination.currentPage.getText()).toContain('Page 5'); + expect(pagination.nextButton.isEnabled()).toBe(false, 'Next button is enabled'); + }); + }); + }); + + describe(`on Recent Files`, () => { + beforeAll(done => { + loginPage.load() + .then(() => loginPage.loginWith(username)) + .then(done); + }); + + beforeEach(done => { + page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES) + .then(() => dataTable.waitForHeader()) + .then(done); + }); + + afterEach(done => { + browser.actions().sendKeys(protractor.Key.ESCAPE).perform().then(done); + }); + + afterAll(done => { + logoutPage.load().then(done); + }); + + it('default values', () => { + expect(pagination.range.getText()).toContain('1-25 of 101'); + expect(pagination.maxItems.getText()).toContain('25'); + expect(pagination.currentPage.getText()).toContain('Page 1'); + expect(pagination.totalPages.getText()).toContain('of 5'); + expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled'); + expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled'); + }); + + it('page sizes', () => { + pagination.openMaxItemsMenu() + .then(menu => { + const [ first, second, third ] = [1, 2, 3] + .map(nth => menu.getNthItem(nth).getText()); + expect(first).toBe('25'); + expect(second).toBe('50'); + expect(third).toBe('100'); + }); + }); + + it('change the page size', () => { + pagination.openMaxItemsMenu() + .then(menu => menu.clickMenuItem('50')) + .then(() => dataTable.waitForHeader()) + .then(() => { + expect(pagination.maxItems.getText()).toContain('50'); + expect(pagination.totalPages.getText()).toContain('of 3'); + }) + + .then(() => resetToDefaultPageSize()); + }); + + it('current page menu items', () => { + pagination.openCurrentPageMenu() + .then(menu => { + expect(menu.getItemsCount()).toBe(5); + }); + }); + + it('change the current page from menu', () => { + pagination.openCurrentPageMenu() + .then(menu => menu.clickNthItem(3)) + .then(() => dataTable.waitForHeader()) + .then(() => { + expect(pagination.range.getText()).toContain('51-75 of 101'); + expect(pagination.currentPage.getText()).toContain('Page 3'); + expect(pagination.previousButton.isEnabled()).toBe(true, 'Previous button is not enabled'); + expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled'); + expect(dataTable.getRowByContainingText('file-40.txt').isPresent()) + .toBe(true, 'File not found on page'); + }) + + .then(() => resetToDefaultPageNumber()); + }); + + it('navigate to next page', () => { + pagination.nextButton.click() + .then(() => dataTable.waitForHeader()) + .then(() => { + expect(pagination.range.getText()).toContain('26-50 of 101'); + expect(dataTable.getRowByContainingText('file-70.txt').isPresent()) + .toBe(true, 'File not found on page'); + }) + + .then(() => resetToDefaultPageNumber()); + }); + + it('navigate to previous page', () => { + pagination.openCurrentPageMenu() + .then(menu => menu.clickNthItem(2)) + .then(() => dataTable.waitForHeader()) + .then(() => pagination.previousButton.click()) + .then(() => dataTable.waitForHeader()) + .then(() => { + expect(pagination.range.getText()).toContain('1-25 of 101'); + expect(dataTable.getRowByContainingText('file-88.txt').isPresent()) + .toBe(true, 'File not found on page'); + }) + + .then(() => resetToDefaultPageNumber()); + }); + + it('last page', () => { + pagination.openCurrentPageMenu() + .then(menu => menu.clickNthItem(5)) + .then(() => dataTable.waitForHeader()) + .then(() => { + expect(dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page'); + expect(pagination.currentPage.getText()).toContain('Page 5'); + expect(pagination.nextButton.isEnabled()).toBe(false, 'Next button is enabled'); + }); + }); + }); + + describe(`on Favorites`, () => { + beforeAll(done => { + loginPage.load() + .then(() => loginPage.loginWith(username)) + .then(done); + }); + + beforeEach(done => { + page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES) + .then(() => dataTable.waitForHeader()) + .then(done); + }); + + afterEach(done => { + browser.actions().sendKeys(protractor.Key.ESCAPE).perform().then(done); + }); + + afterAll(done => { + logoutPage.load().then(done); + }); + + it('default values', () => { + expect(pagination.range.getText()).toContain('1-25 of 101'); + expect(pagination.maxItems.getText()).toContain('25'); + expect(pagination.currentPage.getText()).toContain('Page 1'); + expect(pagination.totalPages.getText()).toContain('of 5'); + expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled'); + expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled'); + }); + + it('page sizes', () => { + pagination.openMaxItemsMenu() + .then(menu => { + const [ first, second, third ] = [1, 2, 3] + .map(nth => menu.getNthItem(nth).getText()); + expect(first).toBe('25'); + expect(second).toBe('50'); + expect(third).toBe('100'); + }); + }); + + it('change the page size', () => { + pagination.openMaxItemsMenu() + .then(menu => menu.clickMenuItem('50')) + .then(() => dataTable.waitForHeader()) + .then(() => { + expect(pagination.maxItems.getText()).toContain('50'); + expect(pagination.totalPages.getText()).toContain('of 3'); + }) + + .then(() => resetToDefaultPageSize()); + }); + + it('current page menu items', () => { + pagination.openCurrentPageMenu() + .then(menu => { + expect(menu.getItemsCount()).toBe(5); + }); + }); + + it('change the current page from menu', () => { + pagination.openCurrentPageMenu() + .then(menu => menu.clickNthItem(3)) + .then(() => dataTable.waitForHeader()) + .then(() => { + expect(pagination.range.getText()).toContain('51-75 of 101'); + expect(pagination.currentPage.getText()).toContain('Page 3'); + expect(pagination.previousButton.isEnabled()).toBe(true, 'Previous button is not enabled'); + expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled'); + expect(dataTable.getRowByContainingText('file-40.txt').isPresent()) + .toBe(true, 'File not found on page'); + }) + + .then(() => resetToDefaultPageNumber()); + }); + + it('navigate to next page', () => { + pagination.nextButton.click() + .then(() => dataTable.waitForHeader()) + .then(() => { + expect(pagination.range.getText()).toContain('26-50 of 101'); + expect(dataTable.getRowByContainingText('file-70.txt').isPresent()) + .toBe(true, 'File not found on page'); + }) + + .then(() => resetToDefaultPageNumber()); + }); + + it('navigate to previous page', () => { + pagination.openCurrentPageMenu() + .then(menu => menu.clickNthItem(2)) + .then(() => dataTable.waitForHeader()) + .then(() => pagination.previousButton.click()) + .then(() => dataTable.waitForHeader()) + .then(() => { + expect(pagination.range.getText()).toContain('1-25 of 101'); + expect(dataTable.getRowByContainingText('file-88.txt').isPresent()) + .toBe(true, 'File not found on page'); + }) + + .then(() => resetToDefaultPageNumber()); + }); + + it('last page', () => { + pagination.openCurrentPageMenu() + .then(menu => menu.clickNthItem(5)) + .then(() => dataTable.waitForHeader()) + .then(() => { + expect(dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page'); + expect(pagination.currentPage.getText()).toContain('Page 5'); + expect(pagination.nextButton.isEnabled()).toBe(false, 'Next button is enabled'); + }); + }); + }); + + describe(`on Shared Files`, () => { + beforeAll(done => { + loginPage.load() + .then(() => loginPage.loginWith(username)) + .then(done); + }); + + beforeEach(done => { + page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES) + .then(() => dataTable.waitForHeader()) + .then(done); + }); + + afterEach(done => { + browser.actions().sendKeys(protractor.Key.ESCAPE).perform().then(done); + }); + + afterAll(done => { + logoutPage.load().then(done); + }); + + it('default values', () => { + expect(pagination.range.getText()).toContain('1-25 of 101'); + expect(pagination.maxItems.getText()).toContain('25'); + expect(pagination.currentPage.getText()).toContain('Page 1'); + expect(pagination.totalPages.getText()).toContain('of 5'); + expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled'); + expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled'); + }); + + it('page sizes', () => { + pagination.openMaxItemsMenu() + .then(menu => { + const [ first, second, third ] = [1, 2, 3] + .map(nth => menu.getNthItem(nth).getText()); + expect(first).toBe('25'); + expect(second).toBe('50'); + expect(third).toBe('100'); + }); + }); + + it('change the page size', () => { + pagination.openMaxItemsMenu() + .then(menu => menu.clickMenuItem('50')) + .then(() => dataTable.waitForHeader()) + .then(() => { + expect(pagination.maxItems.getText()).toContain('50'); + expect(pagination.totalPages.getText()).toContain('of 3'); + }) + + .then(() => resetToDefaultPageSize()); + }); + + it('current page menu items', () => { + pagination.openCurrentPageMenu() + .then(menu => { + expect(menu.getItemsCount()).toBe(5); + }); + }); + + it('change the current page from menu', () => { + pagination.openCurrentPageMenu() + .then(menu => menu.clickNthItem(3)) + .then(() => dataTable.waitForHeader()) + .then(() => { + expect(pagination.range.getText()).toContain('51-75 of 101'); + expect(pagination.currentPage.getText()).toContain('Page 3'); + expect(pagination.previousButton.isEnabled()).toBe(true, 'Previous button is not enabled'); + expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled'); + expect(dataTable.getRowByContainingText('file-40.txt').isPresent()) + .toBe(true, 'File not found on page'); + }) + + .then(() => resetToDefaultPageNumber()); + }); + + it('navigate to next page', () => { + pagination.nextButton.click() + .then(() => dataTable.waitForHeader()) + .then(() => { + expect(pagination.range.getText()).toContain('26-50 of 101'); + expect(dataTable.getRowByContainingText('file-70.txt').isPresent()) + .toBe(true, 'File not found on page'); + }) + + .then(() => resetToDefaultPageNumber()); + }); + + it('navigate to previous page', () => { + pagination.openCurrentPageMenu() + .then(menu => menu.clickNthItem(2)) + .then(() => dataTable.waitForHeader()) + .then(() => pagination.previousButton.click()) + .then(() => dataTable.waitForHeader()) + .then(() => { + expect(pagination.range.getText()).toContain('1-25 of 101'); + expect(dataTable.getRowByContainingText('file-88.txt').isPresent()) + .toBe(true, 'File not found on page'); + }) + + .then(() => resetToDefaultPageNumber()); + }); + + it('last page', () => { + pagination.openCurrentPageMenu() + .then(menu => menu.clickNthItem(5)) + .then(() => dataTable.waitForHeader()) + .then(() => { + expect(dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page'); + expect(pagination.currentPage.getText()).toContain('Page 5'); + expect(pagination.nextButton.isEnabled()).toBe(false, 'Next button is enabled'); + }); + }); + }); + + describe(`on Trash`, () => { + beforeAll(done => { + loginPage.load() + .then(() => loginPage.loginWith(username)) + .then(done); + }); + + beforeEach(done => { + page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH) + .then(() => dataTable.waitForHeader()) + .then(done); + }); + + afterEach(done => { + browser.actions().sendKeys(protractor.Key.ESCAPE).perform().then(done); + }); + + afterAll(done => { + logoutPage.load().then(done); + }); + + it('default values', () => { + expect(pagination.range.getText()).toContain('1-25 of 101'); + expect(pagination.maxItems.getText()).toContain('25'); + expect(pagination.currentPage.getText()).toContain('Page 1'); + expect(pagination.totalPages.getText()).toContain('of 5'); + expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled'); + expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled'); + }); + + it('page sizes', () => { + pagination.openMaxItemsMenu() + .then(menu => { + const [ first, second, third ] = [1, 2, 3] + .map(nth => menu.getNthItem(nth).getText()); + expect(first).toBe('25'); + expect(second).toBe('50'); + expect(third).toBe('100'); + }); + }); + + it('change the page size', () => { + pagination.openMaxItemsMenu() + .then(menu => menu.clickMenuItem('50')) + .then(() => dataTable.waitForHeader()) + .then(() => { + expect(pagination.maxItems.getText()).toContain('50'); + expect(pagination.totalPages.getText()).toContain('of 3'); + }) + + .then(() => resetToDefaultPageSize()); + }); + + it('current page menu items', () => { + pagination.openCurrentPageMenu() + .then(menu => { + expect(menu.getItemsCount()).toBe(5); + }); + }); + + it('change the current page from menu', () => { + pagination.openCurrentPageMenu() + .then(menu => menu.clickNthItem(3)) + .then(() => dataTable.waitForHeader()) + .then(() => { + expect(pagination.range.getText()).toContain('51-75 of 101'); + expect(pagination.currentPage.getText()).toContain('Page 3'); + expect(pagination.previousButton.isEnabled()).toBe(true, 'Previous button is not enabled'); + expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled'); + expect(dataTable.getRowByContainingText('file-40.txt').isPresent()) + .toBe(true, 'File not found on page'); + }) + + .then(() => resetToDefaultPageNumber()); + }); + + it('navigate to next page', () => { + pagination.nextButton.click() + .then(() => dataTable.waitForHeader()) + .then(() => { + expect(pagination.range.getText()).toContain('26-50 of 101'); + expect(dataTable.getRowByContainingText('file-70.txt').isPresent()) + .toBe(true, 'File not found on page'); + }) + + .then(() => resetToDefaultPageNumber()); + }); + + it('navigate to previous page', () => { + pagination.openCurrentPageMenu() + .then(menu => menu.clickNthItem(2)) + .then(() => dataTable.waitForHeader()) + .then(() => pagination.previousButton.click()) + .then(() => dataTable.waitForHeader()) + .then(() => { + expect(pagination.range.getText()).toContain('1-25 of 101'); + expect(dataTable.getRowByContainingText('file-88.txt').isPresent()) + .toBe(true, 'File not found on page'); + }) + + .then(() => resetToDefaultPageNumber()); + }); + + it('last page', () => { + pagination.openCurrentPageMenu() + .then(menu => menu.clickNthItem(5)) + .then(() => dataTable.waitForHeader()) + .then(() => { + expect(dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page'); + expect(pagination.currentPage.getText()).toContain('Page 5'); + expect(pagination.nextButton.isEnabled()).toBe(false, 'Next button is enabled'); }); }); });