From ddc6f36ab4cec240e5424d6f9592daec69c18dd1 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Tue, 14 Jul 2020 10:03:23 +0100 Subject: [PATCH] Prettier upgrade and e2e type checks (#1522) * upgrade prettier * noImplicitAny rule * fix type * update tsconfig * upgrade to 150 print width --- .prettierignore | 1 - .prettierrc | 4 +- .vscode/settings.json | 2 +- .../files-folders/favorites.ts | 67 +- .../files-folders-actions.test.ts | 5 +- .../files-folders/personal-files.ts | 64 +- .../files-folders/recent-files.ts | 44 +- .../files-folders/search-results.ts | 92 ++- .../files-folders/shared-files.ts | 50 +- .../files-folders/test-data.ts | 466 +++++++++++-- .../actions-available/files-folders/trash.ts | 14 +- .../actions-available/files-folders/viewer.ts | 205 ++++-- e2e/suites/actions-available/generic.test.ts | 14 +- .../libraries/library.test.ts | 172 +++-- .../libraries/test-data-libraries.ts | 3 - .../special-permissions/favorites.ts | 96 ++- .../special-permissions/my-libraries.ts | 78 ++- .../special-permissions/other-permissions.ts | 53 +- .../special-permissions/search-results.ts | 98 ++- .../special-permissions/shared-files.ts | 77 ++- .../special-permissions-actions.test.ts | 12 +- .../test-data-permissions.ts | 55 +- .../special-permissions/viewer.ts | 153 ++++- e2e/suites/actions-available/test-util.ts | 6 +- e2e/suites/actions/copy-move/copy.test.ts | 332 ++++++---- .../destination-picker-dialog.test.ts | 12 +- e2e/suites/actions/copy-move/move.test.ts | 75 ++- .../actions/create-file-from-template.test.ts | 12 +- .../create-folder-from-template.test.ts | 9 +- e2e/suites/actions/create-folder.test.ts | 17 +- e2e/suites/actions/create-library.test.ts | 18 +- e2e/suites/actions/delete-undo-delete.test.ts | 130 ++-- e2e/suites/actions/download.test.ts | 46 +- e2e/suites/actions/edit-folder.test.ts | 20 +- e2e/suites/actions/edit-offline.test.ts | 41 +- e2e/suites/actions/library-actions.test.ts | 46 +- e2e/suites/actions/mark-favorite.test.ts | 162 +++-- e2e/suites/actions/new-menu.test.ts | 9 +- e2e/suites/actions/permanently-delete.test.ts | 186 +++--- e2e/suites/actions/restore.test.ts | 46 +- e2e/suites/actions/share-file.test.ts | 67 +- .../unshare-file-search-results.test.ts | 22 +- e2e/suites/actions/unshare-file.test.ts | 91 ++- e2e/suites/actions/upload-file.test.ts | 9 +- e2e/suites/actions/upload-new-version.test.ts | 66 +- e2e/suites/application/general.test.ts | 10 +- e2e/suites/application/page-titles.test.ts | 11 +- e2e/suites/authentication/login.test.ts | 13 +- e2e/suites/authentication/logout.test.ts | 8 +- .../extensions/ext-context-submenus.test.ts | 25 +- .../extensions/ext-document-list.test.ts | 18 +- e2e/suites/extensions/ext-header.test.ts | 92 ++- e2e/suites/extensions/ext-info-drawer.test.ts | 221 +++---- e2e/suites/extensions/ext-metadata.test.ts | 18 +- e2e/suites/extensions/ext-viewer.test.ts | 248 ++++--- e2e/suites/info-drawer/comments.test.ts | 58 +- .../file-folder-properties.test.ts | 38 +- e2e/suites/info-drawer/general.test.ts | 12 +- .../info-drawer/library-properties.test.ts | 19 +- e2e/suites/list-views/empty-list.test.ts | 8 +- e2e/suites/list-views/favorites.test.ts | 19 +- e2e/suites/list-views/file-libraries.test.ts | 27 +- e2e/suites/list-views/generic-errors.test.ts | 15 +- e2e/suites/list-views/permissions.test.ts | 9 +- e2e/suites/list-views/personal-files.test.ts | 26 +- e2e/suites/list-views/recent-files.test.ts | 35 +- e2e/suites/list-views/shared-files.test.ts | 32 +- e2e/suites/list-views/tooltips.test.ts | 34 +- e2e/suites/list-views/trash.test.ts | 68 +- e2e/suites/navigation/breadcrumb.test.ts | 50 +- e2e/suites/navigation/sidebar.test.ts | 9 +- e2e/suites/navigation/single-click.test.ts | 25 +- e2e/suites/pagination/favorites.ts | 3 +- .../pagination/multiple-pages-files.test.ts | 12 +- .../multiple-pages-libraries.test.ts | 11 +- .../pagination/multiple-pages-trash.test.ts | 12 +- e2e/suites/pagination/personal-files.ts | 1 - e2e/suites/pagination/recent-files.ts | 1 - e2e/suites/pagination/search-results.ts | 1 - e2e/suites/pagination/shared-files.ts | 1 - e2e/suites/pagination/single-page.test.ts | 16 +- e2e/suites/search/search-filters.test.ts | 25 +- .../search-results-files-folders.test.ts | 22 +- .../search/search-results-general.test.ts | 21 +- .../search/search-results-libraries.test.ts | 18 +- e2e/suites/search/search-sorting.test.ts | 10 +- e2e/suites/viewer/viewer-actions.test.ts | 148 +++-- e2e/suites/viewer/viewer-general.test.ts | 281 ++++---- .../viewer/viewer-protected-file.test.ts | 13 +- e2e/tsconfig.e2e.typecheck.json | 6 +- package-lock.json | 28 +- package.json | 4 +- projects/aca-shared/rules/src/app.rules.ts | 132 +--- .../aca-shared/rules/src/navigation.rules.ts | 29 +- .../extensions-data-loader.guard.spec.ts | 25 +- .../extensions-data-loader.guard.ts | 18 +- .../generic-error/generic-error.component.ts | 7 +- .../info-drawer/info-drawer.component.spec.ts | 19 +- .../info-drawer/info-drawer.component.ts | 29 +- .../info-drawer/shared-info-drawer.module.ts | 9 +- .../locked-by/locked-by.component.ts | 13 +- .../page-layout-content.component.ts | 12 +- .../page-layout-error.component.ts | 10 +- .../page-layout-header.component.ts | 6 +- .../page-layout/page-layout.component.ts | 7 +- .../page-layout/page-layout.module.ts | 14 +- .../tool-bar/shared-toolbar.module.ts | 14 +- .../toolbar-action.component.ts | 9 +- .../toolbar-menu/toolbar-menu.component.ts | 6 +- .../contextmenu/contextmenu.directive.spec.ts | 7 +- .../contextmenu/contextmenu.directive.ts | 20 +- .../directives/pagination.directive.spec.ts | 11 +- .../lib/directives/pagination.directive.ts | 19 +- .../src/lib/routing/app.routes.strategy.ts | 39 +- .../src/lib/routing/shared.guard.ts | 8 +- .../services/app.extension.service.spec.ts | 21 +- .../src/lib/services/app.extension.service.ts | 201 ++---- .../src/lib/services/app.service.spec.ts | 18 +- .../src/lib/services/content-api.service.ts | 50 +- .../services/node-permission.service.spec.ts | 28 +- .../lib/services/node-permission.service.ts | 36 +- .../aca-shared/src/lib/utils/node.utils.ts | 13 +- .../src/actions/metadata-aspect.actions.ts | 3 +- .../store/src/actions/search.actions.ts | 5 +- .../store/src/effects/dialog.effects.ts | 5 +- .../store/src/effects/router.effects.ts | 32 +- .../store/src/effects/snackbar.effects.ts | 8 +- .../store/src/selectors/app.selectors.ts | 100 +-- .../aca-shared/store/src/states/app.state.ts | 6 +- projects/aca-shared/store/src/store.module.ts | 4 +- projects/aca-shared/test.ts | 10 +- .../src/components/breadcrumb/breadcrumb.ts | 2 +- .../breadcrumb/dropdown-breadcrumb.ts | 16 +- .../src/components/component.ts | 37 +- .../src/components/data-table/data-table.ts | 222 ++----- .../datetime-picker/datetime-picker.ts | 9 +- .../dialog/content-node-selector-dialog.ts | 35 +- .../dialog/create-edit-folder-dialog.ts | 19 +- .../dialog/create-from-template-dialog.ts | 18 +- .../dialog/create-library-dialog.ts | 38 +- .../src/components/dialog/generic-dialog.ts | 7 +- .../src/components/dialog/password-dialog.ts | 19 +- .../dialog/select-template-dialog.ts | 9 +- .../src/components/dialog/share-dialog.ts | 20 +- .../dialog/upload-new-version-dialog.ts | 16 +- .../info-drawer/info-drawer-comments-tab.ts | 14 +- .../info-drawer-metadata-content.ts | 32 +- .../info-drawer-metadata-library.ts | 32 +- .../src/components/info-drawer/info-drawer.ts | 23 +- .../src/components/menu/menu.ts | 67 +- .../components/metadata-card/metadata-card.ts | 8 +- .../src/components/pagination/pagination.ts | 18 +- .../search/filters/created-date-filter.ts | 32 +- .../components/search/filters/facet-filter.ts | 24 +- .../search/filters/generic-filter-panel.ts | 8 +- .../components/search/filters/size-filter.ts | 30 +- .../src/components/search/search-input.ts | 19 +- .../search/search-sorting-picker.ts | 31 +- .../src/components/sidenav/sidenav.ts | 38 +- .../src/components/toolbar/toolbar.ts | 18 +- .../src/pages/browsing-page.ts | 9 +- .../src/pages/login-page.ts | 5 +- projects/aca-testing-shared/src/pages/page.ts | 7 +- .../src/pages/search-results-page.ts | 2 +- .../src/utilities/admin-actions.ts | 120 +--- .../apis/authentication/authentication-api.ts | 2 +- .../repo-client/apis/comments/comments-api.ts | 17 +- .../apis/favorites/favorites-api.ts | 60 +- .../apis/nodes/node-content-tree.ts | 25 +- .../repo-client/apis/nodes/nodes-api.ts | 372 ++--------- .../repo-client/apis/people/people-api.ts | 20 +- .../repo-client/apis/queries/queries-api.ts | 24 +- .../utilities/repo-client/apis/repo-api.ts | 5 +- .../repo-client/apis/search/search-api.ts | 27 +- .../apis/shared-links/shared-links-api.ts | 44 +- .../repo-client/apis/sites/sites-api.ts | 143 +--- .../repo-client/apis/trashcan/trashcan-api.ts | 22 +- .../repo-client/apis/upload/upload-api.ts | 33 +- .../src/utilities/repo-client/repo-client.ts | 5 +- .../aca-testing-shared/src/utilities/utils.ts | 194 ++---- projects/aca-testing-shared/tsconfig.lib.json | 10 +- .../src/lib/aos-extension.module.ts | 5 +- .../src/lib/aos-extension.service.ts | 45 +- .../src/lib/effects/aos.effects.ts | 7 +- .../src/lib/evaluators.ts | 23 +- projects/adf-office-services-ext/src/test.ts | 10 +- src/app/app.component.spec.ts | 55 +- src/app/app.component.ts | 91 +-- src/app/app.module.ts | 12 +- src/app/app.routes.ts | 114 +--- src/app/components/about/about.component.ts | 15 +- src/app/components/about/about.module.ts | 17 +- .../extension-list.component.ts | 9 +- .../license-list/license-list.component.ts | 9 +- .../module-list/module-list.component.ts | 9 +- .../package-list/package-list.component.ts | 9 +- .../status-list/status-list.component.ts | 9 +- src/app/components/common/common.module.ts | 23 +- .../location-link/location-link.component.ts | 59 +- .../common/logout/logout.component.spec.ts | 6 +- .../toggle-shared.component.spec.ts | 4 +- .../toggle-shared/toggle-shared.component.ts | 19 +- .../context-menu-item.component.spec.ts | 22 +- .../context-menu-outside-event.directive.ts | 12 +- .../context-menu.component.spec.ts | 29 +- .../context-menu/context-menu.component.ts | 13 +- .../context-menu/context-menu.module.ts | 13 +- .../context-menu/context-menu.service.spec.ts | 36 +- .../context-menu/context-menu.service.ts | 33 +- .../context-menu/direction.token.ts | 11 +- .../create-menu/create-menu.component.ts | 13 +- .../current-user.component.spec.ts | 18 +- .../current-user/current-user.component.ts | 11 +- .../current-user/current-user.module.ts | 7 +- .../user-menu-item.component.spec.ts | 14 +- .../document-list-custom-components.module.ts | 8 +- .../name-column/name-column.component.spec.ts | 12 +- .../name-column/name-column.component.ts | 47 +- .../favorite-libraries.component.spec.ts | 77 +-- .../favorite-libraries.component.ts | 15 +- .../favorites/favorites.component.spec.ts | 42 +- .../favorites/favorites.component.ts | 31 +- .../components/files/files.component.spec.ts | 39 +- src/app/components/files/files.component.ts | 88 +-- .../header/header.component.spec.ts | 8 +- src/app/components/header/header.component.ts | 29 +- src/app/components/header/header.module.ts | 8 +- .../comments-tab.component.spec.ts | 4 +- .../comments-tab/comments-tab.component.ts | 12 +- .../info-drawer/info.drawer.module.ts | 13 +- .../library-metadata-form.component.spec.ts | 34 +- .../library-metadata-form.component.ts | 30 +- .../library-metadata-tab.component.ts | 3 +- .../metadata-tab.component.spec.ts | 23 +- .../metadata-tab/metadata-tab.component.ts | 33 +- .../versions-tab/versions-tab.component.ts | 8 +- .../app-layout/app-layout.component.spec.ts | 14 +- .../layout/app-layout/app-layout.component.ts | 71 +- .../libraries/libraries.component.spec.ts | 23 +- .../libraries/libraries.component.ts | 8 +- .../node-version-form.component.spec.ts | 10 +- .../node-version-form.component.ts | 17 +- src/app/components/page.component.spec.ts | 30 +- src/app/components/page.component.ts | 50 +- .../permission-manager.component.ts | 39 +- .../preview/preview.component.spec.ts | 100 +-- .../components/preview/preview.component.ts | 155 ++--- .../recent-files.component.spec.ts | 27 +- .../recent-files/recent-files.component.ts | 16 +- .../search-input-control.component.spec.ts | 6 +- .../search-input-control.component.ts | 11 +- .../components/search/search-input.module.ts | 7 +- .../search-input.component.spec.ts | 54 +- .../search-input/search-input.component.ts | 84 +-- ...ch-libraries-query-builder.service.spec.ts | 11 +- .../search-libraries-query-builder.service.ts | 2 +- ...search-libraries-results.component.spec.ts | 7 +- .../search-libraries-results.component.ts | 31 +- .../search-results-row.component.ts | 41 +- .../search/search-results.module.ts | 12 +- .../search-results.component.spec.ts | 55 +- .../search-results.component.ts | 47 +- .../settings/settings.component.spec.ts | 20 +- .../components/settings/settings.component.ts | 53 +- .../shared-files.component.spec.ts | 19 +- .../shared-files/shared-files.component.ts | 20 +- .../shared-link-view.component.spec.ts | 36 +- .../shared-link-view.component.ts | 20 +- .../components/button-menu.component.spec.ts | 10 +- .../components/button-menu.component.ts | 13 +- .../components/expand-menu.component.spec.ts | 10 +- .../components/expand-menu.component.ts | 8 +- .../sidenav/directives/action.directive.ts | 2 +- .../directives/active-link.directive.spec.ts | 26 +- .../directives/active-link.directive.ts | 28 +- .../expansion-panel.directive.spec.ts | 24 +- .../directives/expansion-panel.directive.ts | 20 +- .../directives/menu-panel.directive.ts | 14 +- .../components/sidenav/sidenav.component.ts | 29 +- src/app/components/sidenav/sidenav.module.ts | 9 +- .../document-display-mode.component.ts | 10 +- .../toggle-edit-offline.component.spec.ts | 18 +- .../toggle-edit-offline.component.ts | 14 +- .../toggle-favorite-library.component.spec.ts | 20 +- .../toggle-favorite-library.component.ts | 23 +- .../toggle-favorite.component.spec.ts | 12 +- .../toggle-favorite.component.ts | 20 +- .../toggle-info-drawer.component.ts | 5 +- .../toggle-join-library-button.component.ts | 35 +- .../toggle-join-library-menu.component.ts | 17 +- .../toggle-join-library.component.spec.ts | 30 +- src/app/components/toolbar/toolbar.module.ts | 9 +- .../view-node/view-node.component.spec.ts | 8 +- .../toolbar/view-node/view-node.component.ts | 17 +- .../trashcan/trashcan.component.spec.ts | 19 +- .../components/trashcan/trashcan.component.ts | 8 +- src/app/components/viewer/viewer.component.ts | 150 ++--- .../create-from-template.dialog.spec.ts | 33 +- .../create-from-template.dialog.ts | 48 +- .../node-versions.dialog.spec.ts | 31 +- .../node-versions/node-versions.dialog.ts | 20 +- src/app/directives/directives.module.ts | 7 +- .../document-list.directive.spec.ts | 12 +- src/app/directives/document-list.directive.ts | 22 +- .../library-favorite.directive.spec.ts | 19 +- .../directives/library-favorite.directive.ts | 13 +- .../library-membership.directive.spec.ts | 48 +- .../library-membership.directive.ts | 63 +- .../directives/lock-node.directive.spec.ts | 15 +- src/app/directives/lock-node.directive.ts | 8 +- src/app/extensions/core.extensions.module.ts | 5 +- src/app/material.module.ts | 25 +- .../content-management.service.spec.ts | 401 ++++-------- .../services/content-management.service.ts | 380 ++++------- src/app/services/node-actions.service.spec.ts | 616 +++++------------- src/app/services/node-actions.service.ts | 269 ++------ .../services/node-template.service.spec.ts | 137 ++-- src/app/services/node-template.service.ts | 50 +- src/app/store/app-store.module.ts | 9 +- src/app/store/effects/app.effects.ts | 18 +- src/app/store/effects/contextmenu.effects.ts | 12 +- src/app/store/effects/download.effects.ts | 28 +- src/app/store/effects/favorite.effects.ts | 22 +- src/app/store/effects/library.effects.ts | 24 +- src/app/store/effects/node.effects.spec.ts | 20 +- src/app/store/effects/node.effects.ts | 54 +- src/app/store/effects/search.effects.spec.ts | 13 +- src/app/store/effects/search.effects.ts | 20 +- .../store/effects/template.effects.spec.ts | 48 +- src/app/store/effects/template.effects.ts | 40 +- src/app/store/effects/upload.effects.spec.ts | 50 +- src/app/store/effects/upload.effects.ts | 41 +- src/app/store/effects/viewer.effects.spec.ts | 27 +- src/app/store/effects/viewer.effects.ts | 84 +-- src/app/store/reducers/app.reducer.ts | 53 +- src/app/testing/app-testing.module.ts | 5 +- src/app/testing/translation.service.ts | 12 +- src/test.ts | 12 +- tsconfig.json | 30 +- 339 files changed, 5170 insertions(+), 8763 deletions(-) diff --git a/.prettierignore b/.prettierignore index 6a43710f0..279e3a547 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,5 +1,4 @@ node_modules src/assets/i18n -e2e /angular.json docs/**/*.md diff --git a/.prettierrc b/.prettierrc index 544138be4..35275aa1f 100644 --- a/.prettierrc +++ b/.prettierrc @@ -1,3 +1,5 @@ { - "singleQuote": true + "singleQuote": true, + "trailingComma": "none", + "printWidth": 150 } diff --git a/.vscode/settings.json b/.vscode/settings.json index e1bb8415a..a143f058a 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,7 +3,7 @@ "javascript.preferences.importModuleSpecifier": "relative", "typescript.preferences.quoteStyle": "single", "typescript.preferences.importModuleSpecifier": "relative", - "editor.formatOnSave": false, + "editor.formatOnSave": true, "[json]": { "editor.formatOnSave": false }, diff --git a/e2e/suites/actions-available/files-folders/favorites.ts b/e2e/suites/actions-available/files-folders/favorites.ts index 43c93a1bd..4066ed99c 100755 --- a/e2e/suites/actions-available/files-folders/favorites.ts +++ b/e2e/suites/actions-available/files-folders/favorites.ts @@ -31,7 +31,6 @@ export function favoritesTests() { const page = new BrowsingPage(); describe('available actions : ', () => { - beforeAll(async () => { await page.clickFavoritesAndWait(); }); @@ -41,7 +40,6 @@ export function favoritesTests() { }); describe('on a file', () => { - it('File Office, favorite - [C297618]', async () => { await testUtil.checkToolbarActions(testData.fileDocxFav.name, testData.fileDocxFav.toolbarPrimary, testData.fileDocxFav.favoritesToolbarMore); await testUtil.checkContextMenu(testData.fileDocxFav.name, testData.fileDocxFav.favoritesContextMenu); @@ -53,22 +51,38 @@ export function favoritesTests() { }); it('File Office, shared, favorite - [C297620]', async () => { - await testUtil.checkToolbarActions(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.favoritesToolbarPrimary, testData.fileDocxSharedFav.favoritesToolbarMore); + await testUtil.checkToolbarActions( + testData.fileDocxSharedFav.name, + testData.fileDocxSharedFav.favoritesToolbarPrimary, + testData.fileDocxSharedFav.favoritesToolbarMore + ); await testUtil.checkContextMenu(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.favoritesContextMenu); }); it('File shared, favorite - [C280462]', async () => { - await testUtil.checkToolbarActions(testData.fileSharedFav.name, testData.fileSharedFav.favoritesToolbarPrimary, testData.fileSharedFav.favoritesToolbarMore); + await testUtil.checkToolbarActions( + testData.fileSharedFav.name, + testData.fileSharedFav.favoritesToolbarPrimary, + testData.fileSharedFav.favoritesToolbarMore + ); await testUtil.checkContextMenu(testData.fileSharedFav.name, testData.fileSharedFav.favoritesContextMenu); }); it('File favorite, locked - [C280463]', async () => { - await testUtil.checkToolbarActions(testData.fileFavLocked.name, testData.fileFavLocked.toolbarPrimary, testData.fileFavLocked.favoritesToolbarMore); + await testUtil.checkToolbarActions( + testData.fileFavLocked.name, + testData.fileFavLocked.toolbarPrimary, + testData.fileFavLocked.favoritesToolbarMore + ); await testUtil.checkContextMenu(testData.fileFavLocked.name, testData.fileFavLocked.favoritesContextMenu); }); it('File shared, favorite, locked - [C280469]', async () => { - await testUtil.checkToolbarActions(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.favoritesToolbarPrimary, testData.fileSharedFavLocked.favoritesToolbarMore); + await testUtil.checkToolbarActions( + testData.fileSharedFavLocked.name, + testData.fileSharedFavLocked.favoritesToolbarPrimary, + testData.fileSharedFavLocked.favoritesToolbarMore + ); await testUtil.checkContextMenu(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.favoritesContextMenu); }); }); @@ -82,23 +96,48 @@ export function favoritesTests() { describe('on multiple selection', () => { it('multiple files - [C280656]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileDocxFav.name, testData.fileDocxSharedFav.name ], testData.multipleSelAllFav.favoritesContextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileDocxFav.name, testData.fileDocxSharedFav.name ], testData.multipleSelAllFav.toolbarPrimary, testData.multipleSelAllFav.favoritesToolbarMore); + await testUtil.checkMultipleSelContextMenu( + [testData.fileDocxFav.name, testData.fileDocxSharedFav.name], + testData.multipleSelAllFav.favoritesContextMenu + ); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileDocxFav.name, testData.fileDocxSharedFav.name], + testData.multipleSelAllFav.toolbarPrimary, + testData.multipleSelAllFav.favoritesToolbarMore + ); }); it('multiple locked files - [C297631]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileFavLocked.name, testData.fileSharedFavLocked.name ], testData.multipleSelAllFav.favoritesContextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileFavLocked.name, testData.fileSharedFavLocked.name ], testData.multipleSelAllFav.toolbarPrimary, testData.multipleSelAllFav.favoritesToolbarMore); + await testUtil.checkMultipleSelContextMenu( + [testData.fileFavLocked.name, testData.fileSharedFavLocked.name], + testData.multipleSelAllFav.favoritesContextMenu + ); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileFavLocked.name, testData.fileSharedFavLocked.name], + testData.multipleSelAllFav.toolbarPrimary, + testData.multipleSelAllFav.favoritesToolbarMore + ); }); it('multiple folders - [C280664]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.folderFav.name, testData.folderFav2.name ], testData.multipleSelAllFav.favoritesContextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.folderFav.name, testData.folderFav2.name ], testData.multipleSelAllFav.toolbarPrimary, testData.multipleSelAllFav.favoritesToolbarMore); + await testUtil.checkMultipleSelContextMenu( + [testData.folderFav.name, testData.folderFav2.name], + testData.multipleSelAllFav.favoritesContextMenu + ); + await testUtil.checkMultipleSelToolbarActions( + [testData.folderFav.name, testData.folderFav2.name], + testData.multipleSelAllFav.toolbarPrimary, + testData.multipleSelAllFav.favoritesToolbarMore + ); }); it('both files and folders - [C280657]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileFav.name, testData.folderFav.name ], testData.multipleSelAllFav.favoritesContextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileFav.name, testData.folderFav.name ], testData.multipleSelAllFav.toolbarPrimary, testData.multipleSelAllFav.favoritesToolbarMore); + await testUtil.checkMultipleSelContextMenu([testData.fileFav.name, testData.folderFav.name], testData.multipleSelAllFav.favoritesContextMenu); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileFav.name, testData.folderFav.name], + testData.multipleSelAllFav.toolbarPrimary, + testData.multipleSelAllFav.favoritesToolbarMore + ); }); }); }); diff --git a/e2e/suites/actions-available/files-folders/files-folders-actions.test.ts b/e2e/suites/actions-available/files-folders/files-folders-actions.test.ts index 629b217a6..4ef677ea6 100644 --- a/e2e/suites/actions-available/files-folders/files-folders-actions.test.ts +++ b/e2e/suites/actions-available/files-folders/files-folders-actions.test.ts @@ -36,7 +36,7 @@ import { trashTests } from './trash'; describe('Files / folders actions : ', () => { const random = Utils.random(); - const username = `user-${random}` + const username = `user-${random}`; const parent = `parent-${random}`; @@ -68,7 +68,7 @@ describe('Files / folders actions : ', () => { parentId = (await userApi.nodes.createFolder(parent)).entry.id; - await userApi.upload.uploadFileWithRename(FILES.docxFile, parentId, testData.fileDocx.name ); + await userApi.upload.uploadFileWithRename(FILES.docxFile, parentId, testData.fileDocx.name); fileDocxFavId = (await userApi.upload.uploadFileWithRename(FILES.docxFile, parentId, testData.fileDocxFav.name)).entry.id; await userApi.nodes.createFile(testData.file.name, parentId); fileFavId = (await userApi.nodes.createFile(testData.fileFav.name, parentId)).entry.id; @@ -166,5 +166,4 @@ describe('Files / folders actions : ', () => { describe('on Trash : ', () => { trashTests(); }); - }); diff --git a/e2e/suites/actions-available/files-folders/personal-files.ts b/e2e/suites/actions-available/files-folders/personal-files.ts index ce11d1ae6..c39359e6a 100755 --- a/e2e/suites/actions-available/files-folders/personal-files.ts +++ b/e2e/suites/actions-available/files-folders/personal-files.ts @@ -32,7 +32,6 @@ export function personalFilesTests(parentName?: string) { const { dataTable } = page; describe('available actions : ', () => { - beforeAll(async () => { await page.clickPersonalFilesAndWait(); await dataTable.doubleClickOnRowByName(parentName); @@ -44,7 +43,6 @@ export function personalFilesTests(parentName?: string) { }); describe('on a file', () => { - it('File Office - [C213122]', async () => { await testUtil.checkToolbarActions(testData.fileDocx.name, testData.fileDocx.toolbarPrimary, testData.fileDocx.toolbarMore); await testUtil.checkContextMenu(testData.fileDocx.name, testData.fileDocx.contextMenu); @@ -71,7 +69,11 @@ export function personalFilesTests(parentName?: string) { }); it('File Office, shared, favorite - [C297616]', async () => { - await testUtil.checkToolbarActions(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.toolbarPrimary, testData.fileDocxSharedFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.fileDocxSharedFav.name, + testData.fileDocxSharedFav.toolbarPrimary, + testData.fileDocxSharedFav.toolbarMore + ); await testUtil.checkContextMenu(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.contextMenu); }); @@ -96,18 +98,25 @@ export function personalFilesTests(parentName?: string) { }); it('File shared, locked - [C280453]', async () => { - await testUtil.checkToolbarActions(testData.fileSharedLocked.name, testData.fileSharedLocked.toolbarPrimary, testData.fileSharedLocked.toolbarMore); + await testUtil.checkToolbarActions( + testData.fileSharedLocked.name, + testData.fileSharedLocked.toolbarPrimary, + testData.fileSharedLocked.toolbarMore + ); await testUtil.checkContextMenu(testData.fileSharedLocked.name, testData.fileSharedLocked.contextMenu); }); it('File shared, favorite, locked - [C280454]', async () => { - await testUtil.checkToolbarActions(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.toolbarPrimary, testData.fileSharedFavLocked.toolbarMore); + await testUtil.checkToolbarActions( + testData.fileSharedFavLocked.name, + testData.fileSharedFavLocked.toolbarPrimary, + testData.fileSharedFavLocked.toolbarMore + ); await testUtil.checkContextMenu(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.contextMenu); }); }); describe('on a folder', () => { - it('Folder not favorite - [C213123]', async () => { await testUtil.checkToolbarActions(testData.folder.name, testData.folder.toolbarPrimary, testData.folder.toolbarMore); await testUtil.checkContextMenu(testData.folder.name, testData.folder.contextMenu); @@ -121,28 +130,51 @@ export function personalFilesTests(parentName?: string) { describe('on multiple selection', () => { it('multiple files - [C217112]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileDocx.name, testData.fileDocxSharedFav.name ], testData.multipleSel.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileDocx.name, testData.fileDocxSharedFav.name ], testData.multipleSel.toolbarPrimary, testData.multipleSel.toolbarMore); + await testUtil.checkMultipleSelContextMenu([testData.fileDocx.name, testData.fileDocxSharedFav.name], testData.multipleSel.contextMenu); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileDocx.name, testData.fileDocxSharedFav.name], + testData.multipleSel.toolbarPrimary, + testData.multipleSel.toolbarMore + ); }); it('multiple files - all favorite - [C297619]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileDocxFav.name, testData.fileDocxSharedFav.name ], testData.multipleSelAllFav.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileDocxFav.name, testData.fileDocxSharedFav.name ], testData.multipleSel.toolbarPrimary, testData.multipleSelAllFav.toolbarMore); + await testUtil.checkMultipleSelContextMenu( + [testData.fileDocxFav.name, testData.fileDocxSharedFav.name], + testData.multipleSelAllFav.contextMenu + ); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileDocxFav.name, testData.fileDocxSharedFav.name], + testData.multipleSel.toolbarPrimary, + testData.multipleSelAllFav.toolbarMore + ); }); it('multiple locked files - [C326688]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileLocked.name, testData.fileSharedFavLocked.name ], testData.multipleSel.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileLocked.name, testData.fileSharedFavLocked.name ], testData.multipleSel.toolbarPrimary, testData.multipleSel.toolbarMore); + await testUtil.checkMultipleSelContextMenu([testData.fileLocked.name, testData.fileSharedFavLocked.name], testData.multipleSel.contextMenu); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileLocked.name, testData.fileSharedFavLocked.name], + testData.multipleSel.toolbarPrimary, + testData.multipleSel.toolbarMore + ); }); it('multiple folders - [C280459]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.folderFav.name, testData.folder.name ], testData.multipleSel.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.folderFav.name, testData.folder.name ], testData.multipleSel.toolbarPrimary, testData.multipleSel.toolbarMore); + await testUtil.checkMultipleSelContextMenu([testData.folderFav.name, testData.folder.name], testData.multipleSel.contextMenu); + await testUtil.checkMultipleSelToolbarActions( + [testData.folderFav.name, testData.folder.name], + testData.multipleSel.toolbarPrimary, + testData.multipleSel.toolbarMore + ); }); it('both files and folders - [C280460]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.file.name, testData.folder.name ], testData.multipleSel.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.file.name, testData.folder.name ], testData.multipleSel.toolbarPrimary, testData.multipleSel.toolbarMore); + await testUtil.checkMultipleSelContextMenu([testData.file.name, testData.folder.name], testData.multipleSel.contextMenu); + await testUtil.checkMultipleSelToolbarActions( + [testData.file.name, testData.folder.name], + testData.multipleSel.toolbarPrimary, + testData.multipleSel.toolbarMore + ); }); }); }); diff --git a/e2e/suites/actions-available/files-folders/recent-files.ts b/e2e/suites/actions-available/files-folders/recent-files.ts index 5ac9c9f02..72d98e9d4 100755 --- a/e2e/suites/actions-available/files-folders/recent-files.ts +++ b/e2e/suites/actions-available/files-folders/recent-files.ts @@ -31,7 +31,6 @@ export function recentFilesTests() { const page = new BrowsingPage(); describe('available actions : ', () => { - beforeAll(async () => { await page.clickRecentFilesAndWait(); }); @@ -67,7 +66,11 @@ export function recentFilesTests() { }); it('File Office, shared, favorite - [C280616]', async () => { - await testUtil.checkToolbarActions(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.toolbarPrimary, testData.fileDocxSharedFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.fileDocxSharedFav.name, + testData.fileDocxSharedFav.toolbarPrimary, + testData.fileDocxSharedFav.toolbarMore + ); await testUtil.checkContextMenu(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.contextMenu); }); @@ -92,32 +95,51 @@ export function recentFilesTests() { }); it('File shared, locked - [C297636]', async () => { - await testUtil.checkToolbarActions(testData.fileSharedLocked.name, testData.fileSharedLocked.toolbarPrimary, testData.fileSharedLocked.toolbarMore); + await testUtil.checkToolbarActions( + testData.fileSharedLocked.name, + testData.fileSharedLocked.toolbarPrimary, + testData.fileSharedLocked.toolbarMore + ); await testUtil.checkContextMenu(testData.fileSharedLocked.name, testData.fileSharedLocked.contextMenu); }); it('File shared, favorite, locked - [C286324]', async () => { - await testUtil.checkToolbarActions(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.toolbarPrimary, testData.fileSharedFavLocked.toolbarMore); + await testUtil.checkToolbarActions( + testData.fileSharedFavLocked.name, + testData.fileSharedFavLocked.toolbarPrimary, + testData.fileSharedFavLocked.toolbarMore + ); await testUtil.checkContextMenu(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.contextMenu); }); }); describe('on multiple selection', () => { it('multiple files - [C280468]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileDocxFav.name, testData.fileLocked.name ], testData.multipleSel.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileDocxFav.name, testData.fileLocked.name ], testData.multipleSel.toolbarPrimary, testData.multipleSel.toolbarMore); + await testUtil.checkMultipleSelContextMenu([testData.fileDocxFav.name, testData.fileLocked.name], testData.multipleSel.contextMenu); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileDocxFav.name, testData.fileLocked.name], + testData.multipleSel.toolbarPrimary, + testData.multipleSel.toolbarMore + ); }); it('multiple files - all favorite - [C326689]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileDocxFav.name, testData.fileFav.name ], testData.multipleSelAllFav.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileDocxFav.name, testData.fileFav.name ], testData.multipleSel.toolbarPrimary, testData.multipleSelAllFav.toolbarMore); + await testUtil.checkMultipleSelContextMenu([testData.fileDocxFav.name, testData.fileFav.name], testData.multipleSelAllFav.contextMenu); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileDocxFav.name, testData.fileFav.name], + testData.multipleSel.toolbarPrimary, + testData.multipleSelAllFav.toolbarMore + ); }); it('multiple locked files - [C297624]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileLocked.name, testData.fileSharedFavLocked.name ], testData.multipleSel.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileLocked.name, testData.fileSharedFavLocked.name ], testData.multipleSel.toolbarPrimary, testData.multipleSel.toolbarMore); + await testUtil.checkMultipleSelContextMenu([testData.fileLocked.name, testData.fileSharedFavLocked.name], testData.multipleSel.contextMenu); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileLocked.name, testData.fileSharedFavLocked.name], + testData.multipleSel.toolbarPrimary, + testData.multipleSel.toolbarMore + ); }); }); - }); } diff --git a/e2e/suites/actions-available/files-folders/search-results.ts b/e2e/suites/actions-available/files-folders/search-results.ts index 2b27fd8ba..1ce4fde00 100755 --- a/e2e/suites/actions-available/files-folders/search-results.ts +++ b/e2e/suites/actions-available/files-folders/search-results.ts @@ -33,7 +33,6 @@ export function searchResultsTests() { const searchResultsPage = new SearchResultsPage(); describe('available actions : ', () => { - beforeAll(async () => { await page.clickPersonalFiles(); }); @@ -43,7 +42,6 @@ export function searchResultsTests() { }); describe('on a file', () => { - beforeAll(async () => { await page.clickPersonalFiles(); await searchInput.clickSearchButton(); @@ -57,7 +55,11 @@ export function searchResultsTests() { }); it('File Office, favorite - [C291827]', async () => { - await testUtil.checkToolbarActions(testData.fileDocxFav.name, testData.fileDocxFav.searchToolbarPrimary, testData.fileDocxFav.searchToolbarMore); + await testUtil.checkToolbarActions( + testData.fileDocxFav.name, + testData.fileDocxFav.searchToolbarPrimary, + testData.fileDocxFav.searchToolbarMore + ); await testUtil.checkContextMenu(testData.fileDocxFav.name, testData.fileDocxFav.searchContextMenu); }); @@ -72,12 +74,20 @@ export function searchResultsTests() { }); it('File Office, shared - [C297627]', async () => { - await testUtil.checkToolbarActions(testData.fileDocxShared.name, testData.fileDocxShared.searchToolbarPrimary, testData.fileDocxShared.searchToolbarMore); + await testUtil.checkToolbarActions( + testData.fileDocxShared.name, + testData.fileDocxShared.searchToolbarPrimary, + testData.fileDocxShared.searchToolbarMore + ); await testUtil.checkContextMenu(testData.fileDocxShared.name, testData.fileDocxShared.searchContextMenu); }); it('File Office, shared, favorite - [C280631]', async () => { - await testUtil.checkToolbarActions(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.searchToolbarPrimary, testData.fileDocxSharedFav.searchToolbarMore); + await testUtil.checkToolbarActions( + testData.fileDocxSharedFav.name, + testData.fileDocxSharedFav.searchToolbarPrimary, + testData.fileDocxSharedFav.searchToolbarMore + ); await testUtil.checkContextMenu(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.searchContextMenu); }); @@ -87,7 +97,11 @@ export function searchResultsTests() { }); it('File shared, favorite - [C280641]', async () => { - await testUtil.checkToolbarActions(testData.fileSharedFav.name, testData.fileSharedFav.searchToolbarPrimary, testData.fileSharedFav.searchToolbarMore); + await testUtil.checkToolbarActions( + testData.fileSharedFav.name, + testData.fileSharedFav.searchToolbarPrimary, + testData.fileSharedFav.searchToolbarMore + ); await testUtil.checkContextMenu(testData.fileSharedFav.name, testData.fileSharedFav.searchContextMenu); }); @@ -97,23 +111,34 @@ export function searchResultsTests() { }); it('File favorite, locked - [C280648]', async () => { - await testUtil.checkToolbarActions(testData.fileFavLocked.name, testData.fileFavLocked.searchToolbarPrimary, testData.fileFavLocked.searchToolbarMore); + await testUtil.checkToolbarActions( + testData.fileFavLocked.name, + testData.fileFavLocked.searchToolbarPrimary, + testData.fileFavLocked.searchToolbarMore + ); await testUtil.checkContextMenu(testData.fileFavLocked.name, testData.fileFavLocked.searchContextMenu); }); it('File shared, locked - [C280574]', async () => { - await testUtil.checkToolbarActions(testData.fileSharedLocked.name, testData.fileSharedLocked.searchToolbarPrimary, testData.fileSharedLocked.searchToolbarMore); + await testUtil.checkToolbarActions( + testData.fileSharedLocked.name, + testData.fileSharedLocked.searchToolbarPrimary, + testData.fileSharedLocked.searchToolbarMore + ); await testUtil.checkContextMenu(testData.fileSharedLocked.name, testData.fileSharedLocked.searchContextMenu); }); it('File shared, favorite, locked - [C280642]', async () => { - await testUtil.checkToolbarActions(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.searchToolbarPrimary, testData.fileSharedFavLocked.searchToolbarMore); + await testUtil.checkToolbarActions( + testData.fileSharedFavLocked.name, + testData.fileSharedFavLocked.searchToolbarPrimary, + testData.fileSharedFavLocked.searchToolbarMore + ); await testUtil.checkContextMenu(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.searchContextMenu); }); }); describe('on a folder', () => { - beforeAll(async () => { await page.clickPersonalFiles(); await searchInput.clickSearchButton(); @@ -133,7 +158,6 @@ export function searchResultsTests() { }); describe('on multiple selection', () => { - beforeAll(async () => { await page.clickPersonalFiles(); await searchInput.clickSearchButton(); @@ -142,18 +166,36 @@ export function searchResultsTests() { }); it('multiple files - [C291820]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.file.name, testData.fileDocxShared.name ], testData.multipleSel.searchContextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.file.name, testData.fileDocxShared.name ], testData.multipleSel.searchToolbarPrimary, testData.multipleSel.searchToolbarMore); + await testUtil.checkMultipleSelContextMenu([testData.file.name, testData.fileDocxShared.name], testData.multipleSel.searchContextMenu); + await testUtil.checkMultipleSelToolbarActions( + [testData.file.name, testData.fileDocxShared.name], + testData.multipleSel.searchToolbarPrimary, + testData.multipleSel.searchToolbarMore + ); }); it('multiple files - all favorite - [C326690]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileDocxFav.name, testData.fileSharedFav.name ], testData.multipleSelAllFav.searchContextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileDocxFav.name, testData.fileSharedFav.name ], testData.multipleSelAllFav.searchToolbarPrimary, testData.multipleSelAllFav.searchToolbarMore); + await testUtil.checkMultipleSelContextMenu( + [testData.fileDocxFav.name, testData.fileSharedFav.name], + testData.multipleSelAllFav.searchContextMenu + ); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileDocxFav.name, testData.fileSharedFav.name], + testData.multipleSelAllFav.searchToolbarPrimary, + testData.multipleSelAllFav.searchToolbarMore + ); }); it('multiple locked files - [C297626]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileLocked.name, testData.fileSharedFavLocked.name ], testData.multipleSel.searchContextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileLocked.name, testData.fileSharedFavLocked.name ], testData.multipleSel.searchToolbarPrimary, testData.multipleSel.searchToolbarMore); + await testUtil.checkMultipleSelContextMenu( + [testData.fileLocked.name, testData.fileSharedFavLocked.name], + testData.multipleSel.searchContextMenu + ); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileLocked.name, testData.fileSharedFavLocked.name], + testData.multipleSel.searchToolbarPrimary, + testData.multipleSel.searchToolbarMore + ); }); it('multiple folders - [C291821]', async () => { @@ -161,8 +203,12 @@ export function searchResultsTests() { await searchInput.searchFor('folder-'); await searchResultsPage.waitForResults(); - await testUtil.checkMultipleSelContextMenu([ testData.folder.name, testData.folderFav.name ], testData.multipleSel.searchContextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.folder.name, testData.folderFav.name ], testData.multipleSel.searchToolbarPrimary, testData.multipleSel.searchToolbarMore); + await testUtil.checkMultipleSelContextMenu([testData.folder.name, testData.folderFav.name], testData.multipleSel.searchContextMenu); + await testUtil.checkMultipleSelToolbarActions( + [testData.folder.name, testData.folderFav.name], + testData.multipleSel.searchToolbarPrimary, + testData.multipleSel.searchToolbarMore + ); }); it('both files and folders - [C291822]', async () => { @@ -170,8 +216,12 @@ export function searchResultsTests() { await searchInput.searchFor(`=${testData.file.name} or =${testData.folderFav.name}`); await searchResultsPage.waitForResults(); - await testUtil.checkMultipleSelContextMenu([ testData.file.name, testData.folderFav.name ], testData.multipleSel.searchContextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.file.name, testData.folderFav.name ], testData.multipleSel.searchToolbarPrimary, testData.multipleSel.searchToolbarMore); + await testUtil.checkMultipleSelContextMenu([testData.file.name, testData.folderFav.name], testData.multipleSel.searchContextMenu); + await testUtil.checkMultipleSelToolbarActions( + [testData.file.name, testData.folderFav.name], + testData.multipleSel.searchToolbarPrimary, + testData.multipleSel.searchToolbarMore + ); }); }); }); diff --git a/e2e/suites/actions-available/files-folders/shared-files.ts b/e2e/suites/actions-available/files-folders/shared-files.ts index 13ee5f49a..0a800f51b 100755 --- a/e2e/suites/actions-available/files-folders/shared-files.ts +++ b/e2e/suites/actions-available/files-folders/shared-files.ts @@ -31,7 +31,6 @@ export function sharedFilesTests() { const page = new BrowsingPage(); describe('available actions : ', () => { - beforeAll(async () => { await page.clickSharedFilesAndWait(); }); @@ -47,7 +46,11 @@ export function sharedFilesTests() { }); it('File Office, shared, favorite - [C280652]', async () => { - await testUtil.checkToolbarActions(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.toolbarPrimary, testData.fileDocxSharedFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.fileDocxSharedFav.name, + testData.fileDocxSharedFav.toolbarPrimary, + testData.fileDocxSharedFav.toolbarMore + ); await testUtil.checkContextMenu(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.contextMenu); }); @@ -62,32 +65,57 @@ export function sharedFilesTests() { }); it('File shared, locked - [C286274]', async () => { - await testUtil.checkToolbarActions(testData.fileSharedLocked.name, testData.fileSharedLocked.toolbarPrimary, testData.fileSharedLocked.toolbarMore); + await testUtil.checkToolbarActions( + testData.fileSharedLocked.name, + testData.fileSharedLocked.toolbarPrimary, + testData.fileSharedLocked.toolbarMore + ); await testUtil.checkContextMenu(testData.fileSharedLocked.name, testData.fileSharedLocked.contextMenu); }); it('File shared, favorite, locked - [C286275]', async () => { - await testUtil.checkToolbarActions(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.toolbarPrimary, testData.fileSharedFavLocked.toolbarMore); + await testUtil.checkToolbarActions( + testData.fileSharedFavLocked.name, + testData.fileSharedFavLocked.toolbarPrimary, + testData.fileSharedFavLocked.toolbarMore + ); await testUtil.checkContextMenu(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.contextMenu); }); }); describe('multiple selection', () => { it('multiple files - [C280467]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileShared.name, testData.fileSharedFav.name ], testData.multipleSel.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileShared.name, testData.fileSharedFav.name ], testData.multipleSel.toolbarPrimary, testData.multipleSel.toolbarMore); + await testUtil.checkMultipleSelContextMenu([testData.fileShared.name, testData.fileSharedFav.name], testData.multipleSel.contextMenu); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileShared.name, testData.fileSharedFav.name], + testData.multipleSel.toolbarPrimary, + testData.multipleSel.toolbarMore + ); }); it('multiple files - all favorite - [C326691]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileSharedFav.name, testData.fileSharedFavLocked.name ], testData.multipleSelAllFav.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileSharedFav.name, testData.fileSharedFavLocked.name ], testData.multipleSelAllFav.toolbarPrimary, testData.multipleSelAllFav.toolbarMore); + await testUtil.checkMultipleSelContextMenu( + [testData.fileSharedFav.name, testData.fileSharedFavLocked.name], + testData.multipleSelAllFav.contextMenu + ); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileSharedFav.name, testData.fileSharedFavLocked.name], + testData.multipleSelAllFav.toolbarPrimary, + testData.multipleSelAllFav.toolbarMore + ); }); it('multiple locked files - [C297623]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileSharedLocked.name, testData.fileSharedFavLocked.name ], testData.multipleSel.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileSharedLocked.name, testData.fileSharedFavLocked.name ], testData.multipleSel.toolbarPrimary, testData.multipleSel.toolbarMore); + await testUtil.checkMultipleSelContextMenu( + [testData.fileSharedLocked.name, testData.fileSharedFavLocked.name], + testData.multipleSel.contextMenu + ); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileSharedLocked.name, testData.fileSharedFavLocked.name], + testData.multipleSel.toolbarPrimary, + testData.multipleSel.toolbarMore + ); }); }); - }); } diff --git a/e2e/suites/actions-available/files-folders/test-data.ts b/e2e/suites/actions-available/files-folders/test-data.ts index f0ceb2261..69a04f44e 100644 --- a/e2e/suites/actions-available/files-folders/test-data.ts +++ b/e2e/suites/actions-available/files-folders/test-data.ts @@ -29,26 +29,203 @@ export const trashActions = ['Permanently Delete', 'Restore']; // ----- files ----- -const fileContextMenu = ['Share', 'Download', 'View', 'Edit Offline', 'Upload New Version', 'Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; -const fileSharedFavLockedContextMenu = ['Shared Link Settings', 'Download', 'View', 'Cancel Editing', 'Upload New Version', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; +const fileContextMenu = [ + 'Share', + 'Download', + 'View', + 'Edit Offline', + 'Upload New Version', + 'Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions', + 'Permissions' +]; +const fileSharedFavLockedContextMenu = [ + 'Shared Link Settings', + 'Download', + 'View', + 'Cancel Editing', + 'Upload New Version', + 'Remove Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions', + 'Permissions' +]; const fileToolbarPrimary = ['Share', 'Download', 'View', 'View Details', 'More Actions']; const fileToolbarMore = ['Edit Offline', 'Upload New Version', 'Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; -const fileDocxToolbarMore = ['Edit in Microsoft Office™', 'Edit Offline', 'Upload New Version', 'Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; -const fileDocxContextMenu = ['Share', 'Download', 'View', 'Edit in Microsoft Office™', 'Edit Offline', 'Upload New Version', 'Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; +const fileDocxToolbarMore = [ + 'Edit in Microsoft Office™', + 'Edit Offline', + 'Upload New Version', + 'Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions', + 'Permissions' +]; +const fileDocxContextMenu = [ + 'Share', + 'Download', + 'View', + 'Edit in Microsoft Office™', + 'Edit Offline', + 'Upload New Version', + 'Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions', + 'Permissions' +]; const fileSharedToolbarPrimary = ['Shared Link Settings', 'Download', 'View', 'View Details', 'More Actions']; -const fileFavLockedToolbarMore = ['Cancel Editing', 'Upload New Version', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; -const fileDocxFavContextMenu = ['Share', 'Download', 'View', 'Edit in Microsoft Office™', 'Edit Offline', 'Upload New Version', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; -const fileDocxFavToolbarMore = ['Edit in Microsoft Office™', 'Edit Offline', 'Upload New Version', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; -const fileDocxSharedFavContextMenu = ['Shared Link Settings', 'Download', 'View', 'Edit in Microsoft Office™', 'Edit Offline', 'Upload New Version', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; -const fileDocxSharedContextMenu = ['Shared Link Settings', 'Download', 'View', 'Edit in Microsoft Office™', 'Edit Offline', 'Upload New Version', 'Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; -const fileFavContextMenu = ['Share', 'Download', 'View', 'Edit Offline', 'Upload New Version', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; +const fileFavLockedToolbarMore = [ + 'Cancel Editing', + 'Upload New Version', + 'Remove Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions', + 'Permissions' +]; +const fileDocxFavContextMenu = [ + 'Share', + 'Download', + 'View', + 'Edit in Microsoft Office™', + 'Edit Offline', + 'Upload New Version', + 'Remove Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions', + 'Permissions' +]; +const fileDocxFavToolbarMore = [ + 'Edit in Microsoft Office™', + 'Edit Offline', + 'Upload New Version', + 'Remove Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions', + 'Permissions' +]; +const fileDocxSharedFavContextMenu = [ + 'Shared Link Settings', + 'Download', + 'View', + 'Edit in Microsoft Office™', + 'Edit Offline', + 'Upload New Version', + 'Remove Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions', + 'Permissions' +]; +const fileDocxSharedContextMenu = [ + 'Shared Link Settings', + 'Download', + 'View', + 'Edit in Microsoft Office™', + 'Edit Offline', + 'Upload New Version', + 'Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions', + 'Permissions' +]; +const fileFavContextMenu = [ + 'Share', + 'Download', + 'View', + 'Edit Offline', + 'Upload New Version', + 'Remove Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions', + 'Permissions' +]; const fileFavToolbarMore = ['Edit Offline', 'Upload New Version', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; -const fileSharedFavContextMenu = ['Shared Link Settings', 'Download', 'View', 'Edit Offline', 'Upload New Version', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; -const fileSharedContextMenu = ['Shared Link Settings', 'Download', 'View', 'Edit Offline', 'Upload New Version', 'Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; -const fileFavLockedContextMenu = ['Share', 'Download', 'View', 'Cancel Editing', 'Upload New Version', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; -const fileLockedContextMenu = ['Share', 'Download', 'View', 'Cancel Editing', 'Upload New Version', 'Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; +const fileSharedFavContextMenu = [ + 'Shared Link Settings', + 'Download', + 'View', + 'Edit Offline', + 'Upload New Version', + 'Remove Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions', + 'Permissions' +]; +const fileSharedContextMenu = [ + 'Shared Link Settings', + 'Download', + 'View', + 'Edit Offline', + 'Upload New Version', + 'Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions', + 'Permissions' +]; +const fileFavLockedContextMenu = [ + 'Share', + 'Download', + 'View', + 'Cancel Editing', + 'Upload New Version', + 'Remove Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions', + 'Permissions' +]; +const fileLockedContextMenu = [ + 'Share', + 'Download', + 'View', + 'Cancel Editing', + 'Upload New Version', + 'Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions', + 'Permissions' +]; const fileLockedToolbarMore = ['Cancel Editing', 'Upload New Version', 'Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; -const fileSharedLockedContextMenu = ['Shared Link Settings', 'Download', 'View', 'Cancel Editing', 'Upload New Version', 'Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; +const fileSharedLockedContextMenu = [ + 'Shared Link Settings', + 'Download', + 'View', + 'Cancel Editing', + 'Upload New Version', + 'Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions', + 'Permissions' +]; // ---- VIEWER ---- @@ -56,58 +233,263 @@ const viewerSharedToolbarPrimary = ['Activate full-screen mode', 'Shared Link Se const viewerToolbarPrimary = ['Activate full-screen mode', 'Share', 'Download', 'Print', 'View Details', 'More Actions']; const viewerToolbarMore = ['Edit Offline', 'Upload New Version', 'Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; const viewerFavToolbarMore = ['Edit Offline', 'Upload New Version', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; -const viewerDocxToolbarMore = ['Edit in Microsoft Office™', 'Edit Offline', 'Upload New Version', 'Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; -const viewerFavLockedToolbarMore = ['Cancel Editing', 'Upload New Version', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; -const viewerDocxFavToolbarMore = ['Edit in Microsoft Office™', 'Edit Offline', 'Upload New Version', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; +const viewerDocxToolbarMore = [ + 'Edit in Microsoft Office™', + 'Edit Offline', + 'Upload New Version', + 'Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions', + 'Permissions' +]; +const viewerFavLockedToolbarMore = [ + 'Cancel Editing', + 'Upload New Version', + 'Remove Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions', + 'Permissions' +]; +const viewerDocxFavToolbarMore = [ + 'Edit in Microsoft Office™', + 'Edit Offline', + 'Upload New Version', + 'Remove Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions', + 'Permissions' +]; const viewerLockedToolbarMore = ['Cancel Editing', 'Upload New Version', 'Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; - // ---- FAVORITES workarounds ---- // TODO: investigate why 'Edit Offline', 'Edit in Microsoft Office™' and 'Permissions' are not displayed and raise issue const favoritesContextMenu = ['Share', 'Download', 'View', 'Upload New Version', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions']; // TODO: investigate why 'Permissions' is not displayed and raise issue -const favoritesLockedContextMenu = ['Share', 'Download', 'View', 'Cancel Editing', 'Upload New Version', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions']; +const favoritesLockedContextMenu = [ + 'Share', + 'Download', + 'View', + 'Cancel Editing', + 'Upload New Version', + 'Remove Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions' +]; // TODO: investigate why 'Edit Offline', 'Edit in Microsoft Office™' and 'Permissions' are not displayed and raise issue const favoritesToolbarMore = ['Upload New Version', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions']; // TODO: investigate why 'Permissions' is not displayed and raise issue const favoritesLockedToolbarMore = ['Cancel Editing', 'Upload New Version', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions']; // TODO: investigate why 'Edit Offline', 'Edit in Microsoft Office™' and 'Permissions' are not displayed and raise issue -const favoritesSharedContextMenu = ['Shared Link Settings', 'Download', 'View', 'Upload New Version', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions']; +const favoritesSharedContextMenu = [ + 'Shared Link Settings', + 'Download', + 'View', + 'Upload New Version', + 'Remove Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions' +]; // TODO: investigate why 'Permissions' is not displayed and raise issue -const favoritesSharedLockedContextMenu = ['Shared Link Settings', 'Download', 'View', 'Cancel Editing', 'Upload New Version', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions']; +const favoritesSharedLockedContextMenu = [ + 'Shared Link Settings', + 'Download', + 'View', + 'Cancel Editing', + 'Upload New Version', + 'Remove Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions' +]; // ---- SEARCH workarounds ---- -const searchDocxContextMenu = ['Share', 'Download', 'View', 'Edit in Microsoft Office™', 'Edit Offline', 'Upload New Version', 'Favorite', 'Copy', 'Manage Versions', 'Permissions']; +const searchDocxContextMenu = [ + 'Share', + 'Download', + 'View', + 'Edit in Microsoft Office™', + 'Edit Offline', + 'Upload New Version', + 'Favorite', + 'Copy', + 'Manage Versions', + 'Permissions' +]; const searchToolbarPrimary = ['Toggle search filter', 'Share', 'Download', 'View', 'View Details', 'More Actions']; const searchSharedToolbarPrimary = ['Toggle search filter', 'Shared Link Settings', 'Download', 'View', 'View Details', 'More Actions']; const searchFavLockedToolbarMore = ['Cancel Editing', 'Upload New Version', 'Remove Favorite', 'Copy', 'Manage Versions', 'Permissions']; -const searchSharedFavLockedContextMenu = ['Shared Link Settings', 'Download', 'View', 'Cancel Editing', 'Upload New Version', 'Remove Favorite', 'Copy', 'Manage Versions', 'Permissions']; -const searchDocxToolbarMore = ['Edit in Microsoft Office™', 'Edit Offline', 'Upload New Version', 'Favorite', 'Copy', 'Manage Versions', 'Permissions']; -const searchFavContextMenu = ['Share', 'Download', 'View', 'Edit Offline', 'Upload New Version', 'Remove Favorite', 'Copy', 'Manage Versions', 'Permissions']; -const searchSharedLockedContextMenu = ['Shared Link Settings', 'Download', 'View', 'Cancel Editing', 'Upload New Version', 'Favorite', 'Copy', 'Manage Versions', 'Permissions']; -const searchDocxFavContextMenu = ['Share', 'Download', 'View', 'Edit in Microsoft Office™', 'Edit Offline', 'Upload New Version', 'Remove Favorite', 'Copy', 'Manage Versions', 'Permissions']; -const searchDocxFavToolbarMore = ['Edit in Microsoft Office™', 'Edit Offline', 'Upload New Version', 'Remove Favorite', 'Copy', 'Manage Versions', 'Permissions']; -const searchSharedContextMenu = ['Shared Link Settings', 'Download', 'View', 'Edit Offline', 'Upload New Version', 'Favorite', 'Copy', 'Manage Versions', 'Permissions']; +const searchSharedFavLockedContextMenu = [ + 'Shared Link Settings', + 'Download', + 'View', + 'Cancel Editing', + 'Upload New Version', + 'Remove Favorite', + 'Copy', + 'Manage Versions', + 'Permissions' +]; +const searchDocxToolbarMore = [ + 'Edit in Microsoft Office™', + 'Edit Offline', + 'Upload New Version', + 'Favorite', + 'Copy', + 'Manage Versions', + 'Permissions' +]; +const searchFavContextMenu = [ + 'Share', + 'Download', + 'View', + 'Edit Offline', + 'Upload New Version', + 'Remove Favorite', + 'Copy', + 'Manage Versions', + 'Permissions' +]; +const searchSharedLockedContextMenu = [ + 'Shared Link Settings', + 'Download', + 'View', + 'Cancel Editing', + 'Upload New Version', + 'Favorite', + 'Copy', + 'Manage Versions', + 'Permissions' +]; +const searchDocxFavContextMenu = [ + 'Share', + 'Download', + 'View', + 'Edit in Microsoft Office™', + 'Edit Offline', + 'Upload New Version', + 'Remove Favorite', + 'Copy', + 'Manage Versions', + 'Permissions' +]; +const searchDocxFavToolbarMore = [ + 'Edit in Microsoft Office™', + 'Edit Offline', + 'Upload New Version', + 'Remove Favorite', + 'Copy', + 'Manage Versions', + 'Permissions' +]; +const searchSharedContextMenu = [ + 'Shared Link Settings', + 'Download', + 'View', + 'Edit Offline', + 'Upload New Version', + 'Favorite', + 'Copy', + 'Manage Versions', + 'Permissions' +]; const searchToolbarMore = ['Edit Offline', 'Upload New Version', 'Favorite', 'Copy', 'Manage Versions', 'Permissions']; -const searchDocxSharedFavContextMenu = ['Shared Link Settings', 'Download', 'View', 'Edit in Microsoft Office™', 'Edit Offline', 'Upload New Version', 'Remove Favorite', 'Copy', 'Manage Versions', 'Permissions']; -const searchDocxSharedContextMenu = ['Shared Link Settings', 'Download', 'View', 'Edit in Microsoft Office™', 'Edit Offline', 'Upload New Version', 'Favorite', 'Copy', 'Manage Versions', 'Permissions']; +const searchDocxSharedFavContextMenu = [ + 'Shared Link Settings', + 'Download', + 'View', + 'Edit in Microsoft Office™', + 'Edit Offline', + 'Upload New Version', + 'Remove Favorite', + 'Copy', + 'Manage Versions', + 'Permissions' +]; +const searchDocxSharedContextMenu = [ + 'Shared Link Settings', + 'Download', + 'View', + 'Edit in Microsoft Office™', + 'Edit Offline', + 'Upload New Version', + 'Favorite', + 'Copy', + 'Manage Versions', + 'Permissions' +]; const searchFavToolbarMore = ['Edit Offline', 'Upload New Version', 'Remove Favorite', 'Copy', 'Manage Versions', 'Permissions']; const searchContextMenu = ['Share', 'Download', 'View', 'Edit Offline', 'Upload New Version', 'Favorite', 'Copy', 'Manage Versions', 'Permissions']; -const searchFavLockedContextMenu = ['Share', 'Download', 'View', 'Cancel Editing', 'Upload New Version', 'Remove Favorite', 'Copy', 'Manage Versions', 'Permissions']; +const searchFavLockedContextMenu = [ + 'Share', + 'Download', + 'View', + 'Cancel Editing', + 'Upload New Version', + 'Remove Favorite', + 'Copy', + 'Manage Versions', + 'Permissions' +]; const searchLockedToolbarMore = ['Cancel Editing', 'Upload New Version', 'Favorite', 'Copy', 'Manage Versions', 'Permissions']; -const searchLockedContextMenu = ['Share', 'Download', 'View', 'Cancel Editing', 'Upload New Version', 'Favorite', 'Copy', 'Manage Versions', 'Permissions']; -const searchSharedFavContextMenu = ['Shared Link Settings', 'Download', 'View', 'Edit Offline', 'Upload New Version', 'Remove Favorite', 'Copy', 'Manage Versions', 'Permissions']; +const searchLockedContextMenu = [ + 'Share', + 'Download', + 'View', + 'Cancel Editing', + 'Upload New Version', + 'Favorite', + 'Copy', + 'Manage Versions', + 'Permissions' +]; +const searchSharedFavContextMenu = [ + 'Shared Link Settings', + 'Download', + 'View', + 'Edit Offline', + 'Upload New Version', + 'Remove Favorite', + 'Copy', + 'Manage Versions', + 'Permissions' +]; const searchViewerToolbarMore = ['Edit Offline', 'Upload New Version', 'Favorite', 'Copy', 'Manage Versions', 'Permissions']; const searchViewerFavToolbarMore = ['Edit Offline', 'Upload New Version', 'Remove Favorite', 'Copy', 'Manage Versions', 'Permissions']; -const searchViewerDocxToolbarMore = ['Edit in Microsoft Office™', 'Edit Offline', 'Upload New Version', 'Favorite', 'Copy', 'Manage Versions', 'Permissions']; +const searchViewerDocxToolbarMore = [ + 'Edit in Microsoft Office™', + 'Edit Offline', + 'Upload New Version', + 'Favorite', + 'Copy', + 'Manage Versions', + 'Permissions' +]; const searchViewerFavLockedToolbarMore = ['Cancel Editing', 'Upload New Version', 'Remove Favorite', 'Copy', 'Manage Versions', 'Permissions']; -const searchViewerDocxFavToolbarMore = ['Edit in Microsoft Office™', 'Edit Offline', 'Upload New Version', 'Remove Favorite', 'Copy', 'Manage Versions', 'Permissions']; +const searchViewerDocxFavToolbarMore = [ + 'Edit in Microsoft Office™', + 'Edit Offline', + 'Upload New Version', + 'Remove Favorite', + 'Copy', + 'Manage Versions', + 'Permissions' +]; const searchViewerLockedToolbarMore = ['Cancel Editing', 'Upload New Version', 'Favorite', 'Copy', 'Manage Versions', 'Permissions']; - export const fileDocx = { name: `file-docx-${Utils.random()}.docx`, description: 'file not shared, not fav, office, not locked', @@ -140,7 +522,7 @@ export const fileDocxFav = { searchContextMenu: searchDocxFavContextMenu, searchToolbarPrimary, searchToolbarMore: searchDocxFavToolbarMore, - searchViewerToolbarMore: searchViewerDocxFavToolbarMore, + searchViewerToolbarMore: searchViewerDocxFavToolbarMore }; export const file = { @@ -405,7 +787,6 @@ export const folderFav2 = { // ---- multiple selection --- - // TODO: raise issue to remove 'Permissions' const multipleSelContextMenu = ['Download', 'Favorite', 'Move', 'Copy', 'Delete', 'Permissions']; // TODO: raise issue to remove 'Permissions' @@ -429,7 +810,6 @@ const searchMultipleSelToolbarMore = ['Favorite', 'Copy', 'Permissions']; // TODO: raise issue to remove 'Permissions' const searchMultipleSelAllFavToolbarMore = ['Remove Favorite', 'Copy', 'Permissions']; - export const multipleSel = { contextMenu: multipleSelContextMenu, toolbarPrimary: multipleSelToolbarPrimary, @@ -438,7 +818,7 @@ export const multipleSel = { searchContextMenu: searchMultipleSelContextMenu, searchToolbarMore: searchMultipleSelToolbarMore, searchToolbarPrimary: searchMultipleSelToolbarPrimary -} +}; export const multipleSelAllFav = { contextMenu: multipleSelAllFavContextMenu, @@ -451,4 +831,4 @@ export const multipleSelAllFav = { searchToolbarPrimary: searchMultipleSelToolbarPrimary, searchContextMenu: searchMultipleSelAllFavContextMenu, searchToolbarMore: searchMultipleSelAllFavToolbarMore -} +}; diff --git a/e2e/suites/actions-available/files-folders/trash.ts b/e2e/suites/actions-available/files-folders/trash.ts index bc58bb405..c7efda6ce 100755 --- a/e2e/suites/actions-available/files-folders/trash.ts +++ b/e2e/suites/actions-available/files-folders/trash.ts @@ -31,7 +31,6 @@ export function trashTests() { const page = new BrowsingPage(); describe('available actions : ', () => { - beforeAll(async () => { await page.clickTrashAndWait(); }); @@ -51,19 +50,18 @@ export function trashTests() { }); it('multiple files - [C280472]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileInTrash.name, testData.file2InTrash.name ], testData.trashActions); - await testUtil.checkMultipleSelToolbarPrimary([ testData.fileInTrash.name, testData.file2InTrash.name ], testData.trashActions); + await testUtil.checkMultipleSelContextMenu([testData.fileInTrash.name, testData.file2InTrash.name], testData.trashActions); + await testUtil.checkMultipleSelToolbarPrimary([testData.fileInTrash.name, testData.file2InTrash.name], testData.trashActions); }); it('multiple folders - [C280473]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.folderInTrash.name, testData.folder2InTrash.name ], testData.trashActions); - await testUtil.checkMultipleSelToolbarPrimary([ testData.folderInTrash.name, testData.folder2InTrash.name ], testData.trashActions); + await testUtil.checkMultipleSelContextMenu([testData.folderInTrash.name, testData.folder2InTrash.name], testData.trashActions); + await testUtil.checkMultipleSelToolbarPrimary([testData.folderInTrash.name, testData.folder2InTrash.name], testData.trashActions); }); it('both files and folders - [C280474]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileInTrash.name, testData.folderInTrash.name ], testData.trashActions); - await testUtil.checkMultipleSelToolbarPrimary([ testData.fileInTrash.name, testData.folderInTrash.name ], testData.trashActions); + await testUtil.checkMultipleSelContextMenu([testData.fileInTrash.name, testData.folderInTrash.name], testData.trashActions); + await testUtil.checkMultipleSelToolbarPrimary([testData.fileInTrash.name, testData.folderInTrash.name], testData.trashActions); }); - }); } diff --git a/e2e/suites/actions-available/files-folders/viewer.ts b/e2e/suites/actions-available/files-folders/viewer.ts index 254ee7826..8a4d96fc4 100755 --- a/e2e/suites/actions-available/files-folders/viewer.ts +++ b/e2e/suites/actions-available/files-folders/viewer.ts @@ -34,13 +34,11 @@ export function viewerTests(parentName?: string) { const { searchInput } = page.header; describe('available actions : ', () => { - beforeAll(async () => { await page.clickPersonalFiles(); }); describe('file opened from Personal Files', () => { - beforeAll(async () => { await page.clickPersonalFilesAndWait(); await dataTable.doubleClickOnRowByName(parentName); @@ -52,7 +50,11 @@ export function viewerTests(parentName?: string) { }); it('File Office, favorite - [C297583]', async () => { - await testUtil.checkViewerActions(testData.fileDocxFav.name, testData.fileDocxFav.viewerToolbarPrimary, testData.fileDocxFav.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileDocxFav.name, + testData.fileDocxFav.viewerToolbarPrimary, + testData.fileDocxFav.viewerToolbarMore + ); }); it('File simple - [C297587]', async () => { @@ -64,11 +66,19 @@ export function viewerTests(parentName?: string) { }); it('File Office, shared - [C297597]', async () => { - await testUtil.checkViewerActions(testData.fileDocxShared.name, testData.fileDocxShared.viewerToolbarPrimary, testData.fileDocxShared.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileDocxShared.name, + testData.fileDocxShared.viewerToolbarPrimary, + testData.fileDocxShared.viewerToolbarMore + ); }); it('File Office, shared, favorite - [C297598]', async () => { - await testUtil.checkViewerActions(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.viewerToolbarPrimary, testData.fileDocxSharedFav.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileDocxSharedFav.name, + testData.fileDocxSharedFav.viewerToolbarPrimary, + testData.fileDocxSharedFav.viewerToolbarMore + ); }); it('File shared - [C291831]', async () => { @@ -76,7 +86,11 @@ export function viewerTests(parentName?: string) { }); it('File shared, favorite - [C297632]', async () => { - await testUtil.checkViewerActions(testData.fileSharedFav.name, testData.fileSharedFav.viewerToolbarPrimary, testData.fileSharedFav.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedFav.name, + testData.fileSharedFav.viewerToolbarPrimary, + testData.fileSharedFav.viewerToolbarMore + ); }); it('File locked - [C291832]', async () => { @@ -84,20 +98,31 @@ export function viewerTests(parentName?: string) { }); it('File favorite, locked - [C297593]', async () => { - await testUtil.checkViewerActions(testData.fileFavLocked.name, testData.fileFavLocked.viewerToolbarPrimary, testData.fileFavLocked.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileFavLocked.name, + testData.fileFavLocked.viewerToolbarPrimary, + testData.fileFavLocked.viewerToolbarMore + ); }); it('File shared, locked - [C291833]', async () => { - await testUtil.checkViewerActions(testData.fileSharedLocked.name, testData.fileSharedLocked.viewerToolbarPrimary, testData.fileSharedLocked.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedLocked.name, + testData.fileSharedLocked.viewerToolbarPrimary, + testData.fileSharedLocked.viewerToolbarMore + ); }); it('File shared, favorite, locked - [C297592]', async () => { - await testUtil.checkViewerActions(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.viewerToolbarPrimary, testData.fileSharedFavLocked.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedFavLocked.name, + testData.fileSharedFavLocked.viewerToolbarPrimary, + testData.fileSharedFavLocked.viewerToolbarMore + ); }); }); describe('file opened from Recent Files', () => { - beforeAll(async () => { await page.clickRecentFilesAndWait(); }); @@ -107,7 +132,11 @@ export function viewerTests(parentName?: string) { }); it('File Office, favorite - [C297600]', async () => { - await testUtil.checkViewerActions(testData.fileDocxFav.name, testData.fileDocxFav.viewerToolbarPrimary, testData.fileDocxFav.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileDocxFav.name, + testData.fileDocxFav.viewerToolbarPrimary, + testData.fileDocxFav.viewerToolbarMore + ); }); it('File simple - [C326692]', async () => { @@ -119,11 +148,19 @@ export function viewerTests(parentName?: string) { }); it('File Office, shared - [C326694]', async () => { - await testUtil.checkViewerActions(testData.fileDocxShared.name, testData.fileDocxShared.viewerToolbarPrimary, testData.fileDocxShared.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileDocxShared.name, + testData.fileDocxShared.viewerToolbarPrimary, + testData.fileDocxShared.viewerToolbarMore + ); }); it('File Office, shared, favorite - [C326695]', async () => { - await testUtil.checkViewerActions(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.viewerToolbarPrimary, testData.fileDocxSharedFav.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileDocxSharedFav.name, + testData.fileDocxSharedFav.viewerToolbarPrimary, + testData.fileDocxSharedFav.viewerToolbarMore + ); }); it('File shared - [C326696]', async () => { @@ -131,7 +168,11 @@ export function viewerTests(parentName?: string) { }); it('File shared, favorite - [C326697]', async () => { - await testUtil.checkViewerActions(testData.fileSharedFav.name, testData.fileSharedFav.viewerToolbarPrimary, testData.fileSharedFav.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedFav.name, + testData.fileSharedFav.viewerToolbarPrimary, + testData.fileSharedFav.viewerToolbarMore + ); }); it('File locked - [C326698]', async () => { @@ -139,26 +180,41 @@ export function viewerTests(parentName?: string) { }); it('File favorite, locked - [C326701]', async () => { - await testUtil.checkViewerActions(testData.fileFavLocked.name, testData.fileFavLocked.viewerToolbarPrimary, testData.fileFavLocked.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileFavLocked.name, + testData.fileFavLocked.viewerToolbarPrimary, + testData.fileFavLocked.viewerToolbarMore + ); }); it('File shared, locked - [C326699]', async () => { - await testUtil.checkViewerActions(testData.fileSharedLocked.name, testData.fileSharedLocked.viewerToolbarPrimary, testData.fileSharedLocked.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedLocked.name, + testData.fileSharedLocked.viewerToolbarPrimary, + testData.fileSharedLocked.viewerToolbarMore + ); }); it('File shared, favorite, locked - [C326700]', async () => { - await testUtil.checkViewerActions(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.viewerToolbarPrimary, testData.fileSharedFavLocked.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedFavLocked.name, + testData.fileSharedFavLocked.viewerToolbarPrimary, + testData.fileSharedFavLocked.viewerToolbarMore + ); }); }); describe('file opened from Favorites', () => { - beforeAll(async () => { await page.clickFavoritesAndWait(); }); it('File Office, favorite - [C326702]', async () => { - await testUtil.checkViewerActions(testData.fileDocxFav.name, testData.fileDocxFav.viewerToolbarPrimary, testData.fileDocxFav.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileDocxFav.name, + testData.fileDocxFav.viewerToolbarPrimary, + testData.fileDocxFav.viewerToolbarMore + ); }); it('File favorite - [C326703]', async () => { @@ -166,34 +222,57 @@ export function viewerTests(parentName?: string) { }); it('File Office, shared, favorite - [C326704]', async () => { - await testUtil.checkViewerActions(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.viewerToolbarPrimary, testData.fileDocxSharedFav.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileDocxSharedFav.name, + testData.fileDocxSharedFav.viewerToolbarPrimary, + testData.fileDocxSharedFav.viewerToolbarMore + ); }); it('File shared, favorite - [C326705]', async () => { - await testUtil.checkViewerActions(testData.fileSharedFav.name, testData.fileSharedFav.viewerToolbarPrimary, testData.fileSharedFav.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedFav.name, + testData.fileSharedFav.viewerToolbarPrimary, + testData.fileSharedFav.viewerToolbarMore + ); }); it('File favorite, locked - [C326707]', async () => { - await testUtil.checkViewerActions(testData.fileFavLocked.name, testData.fileFavLocked.viewerToolbarPrimary, testData.fileFavLocked.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileFavLocked.name, + testData.fileFavLocked.viewerToolbarPrimary, + testData.fileFavLocked.viewerToolbarMore + ); }); it('File shared, favorite, locked - [C326706]', async () => { - await testUtil.checkViewerActions(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.viewerToolbarPrimary, testData.fileSharedFavLocked.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedFavLocked.name, + testData.fileSharedFavLocked.viewerToolbarPrimary, + testData.fileSharedFavLocked.viewerToolbarMore + ); }); }); describe('file opened from Shared Files', () => { - beforeAll(async () => { await page.clickSharedFilesAndWait(); }); it('File Office, shared - [C326708]', async () => { - await testUtil.checkViewerActions(testData.fileDocxShared.name, testData.fileDocxShared.viewerToolbarPrimary, testData.fileDocxShared.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileDocxShared.name, + testData.fileDocxShared.viewerToolbarPrimary, + testData.fileDocxShared.viewerToolbarMore + ); }); it('File Office, shared, favorite - [C326709]', async () => { - await testUtil.checkViewerActions(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.viewerToolbarPrimary, testData.fileDocxSharedFav.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileDocxSharedFav.name, + testData.fileDocxSharedFav.viewerToolbarPrimary, + testData.fileDocxSharedFav.viewerToolbarMore + ); }); it('File shared - [C326710]', async () => { @@ -201,20 +280,31 @@ export function viewerTests(parentName?: string) { }); it('File shared, favorite - [C326711]', async () => { - await testUtil.checkViewerActions(testData.fileSharedFav.name, testData.fileSharedFav.viewerToolbarPrimary, testData.fileSharedFav.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedFav.name, + testData.fileSharedFav.viewerToolbarPrimary, + testData.fileSharedFav.viewerToolbarMore + ); }); it('File shared, locked - [C326712]', async () => { - await testUtil.checkViewerActions(testData.fileSharedLocked.name, testData.fileSharedLocked.viewerToolbarPrimary, testData.fileSharedLocked.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedLocked.name, + testData.fileSharedLocked.viewerToolbarPrimary, + testData.fileSharedLocked.viewerToolbarMore + ); }); it('File shared, favorite, locked - [C326713]', async () => { - await testUtil.checkViewerActions(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.viewerToolbarPrimary, testData.fileSharedFavLocked.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedFavLocked.name, + testData.fileSharedFavLocked.viewerToolbarPrimary, + testData.fileSharedFavLocked.viewerToolbarMore + ); }); }); describe('file opened from Search Results', () => { - beforeAll(async () => { await searchInput.clickSearchButton(); await searchInput.searchFor('file-'); @@ -226,7 +316,11 @@ export function viewerTests(parentName?: string) { }); it('File Office, favorite - [C326715]', async () => { - await testUtil.checkViewerActions(testData.fileDocxFav.name, testData.fileDocxFav.viewerToolbarPrimary, testData.fileDocxFav.searchViewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileDocxFav.name, + testData.fileDocxFav.viewerToolbarPrimary, + testData.fileDocxFav.searchViewerToolbarMore + ); }); it('File simple - [C326716]', async () => { @@ -238,37 +332,68 @@ export function viewerTests(parentName?: string) { }); it('File Office, shared - [C326718]', async () => { - await testUtil.checkViewerActions(testData.fileDocxShared.name, testData.fileDocxShared.viewerToolbarPrimary, testData.fileDocxShared.searchViewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileDocxShared.name, + testData.fileDocxShared.viewerToolbarPrimary, + testData.fileDocxShared.searchViewerToolbarMore + ); }); it('File Office, shared, favorite - [C326719]', async () => { - await testUtil.checkViewerActions(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.viewerToolbarPrimary, testData.fileDocxSharedFav.searchViewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileDocxSharedFav.name, + testData.fileDocxSharedFav.viewerToolbarPrimary, + testData.fileDocxSharedFav.searchViewerToolbarMore + ); }); it('File shared - [C326720]', async () => { - await testUtil.checkViewerActions(testData.fileShared.name, testData.fileShared.viewerToolbarPrimary, testData.fileShared.searchViewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileShared.name, + testData.fileShared.viewerToolbarPrimary, + testData.fileShared.searchViewerToolbarMore + ); }); it('File shared, favorite - [C326721]', async () => { - await testUtil.checkViewerActions(testData.fileSharedFav.name, testData.fileSharedFav.viewerToolbarPrimary, testData.fileSharedFav.searchViewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedFav.name, + testData.fileSharedFav.viewerToolbarPrimary, + testData.fileSharedFav.searchViewerToolbarMore + ); }); it('File locked - [C326722]', async () => { - await testUtil.checkViewerActions(testData.fileLocked.name, testData.fileLocked.viewerToolbarPrimary, testData.fileLocked.searchViewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileLocked.name, + testData.fileLocked.viewerToolbarPrimary, + testData.fileLocked.searchViewerToolbarMore + ); }); it('File favorite, locked - [C326725]', async () => { - await testUtil.checkViewerActions(testData.fileFavLocked.name, testData.fileFavLocked.viewerToolbarPrimary, testData.fileFavLocked.searchViewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileFavLocked.name, + testData.fileFavLocked.viewerToolbarPrimary, + testData.fileFavLocked.searchViewerToolbarMore + ); }); it('File shared, locked - [C326723]', async () => { - await testUtil.checkViewerActions(testData.fileSharedLocked.name, testData.fileSharedLocked.viewerToolbarPrimary, testData.fileSharedLocked.searchViewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedLocked.name, + testData.fileSharedLocked.viewerToolbarPrimary, + testData.fileSharedLocked.searchViewerToolbarMore + ); }); it('File shared, favorite, locked - [C326724]', async () => { - await testUtil.checkViewerActions(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.viewerToolbarPrimary, testData.fileSharedFavLocked.searchViewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedFavLocked.name, + testData.fileSharedFavLocked.viewerToolbarPrimary, + testData.fileSharedFavLocked.searchViewerToolbarMore + ); }); }); - }); } diff --git a/e2e/suites/actions-available/generic.test.ts b/e2e/suites/actions-available/generic.test.ts index 138c65924..8e4429d1c 100755 --- a/e2e/suites/actions-available/generic.test.ts +++ b/e2e/suites/actions-available/generic.test.ts @@ -23,14 +23,7 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - RepoClient, - NodeContentTree, - Utils, - AdminActions -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, RepoClient, NodeContentTree, Utils, AdminActions } from '@alfresco/aca-testing-shared'; describe('Generic tests : ', () => { const random = Utils.random(); @@ -122,7 +115,6 @@ describe('Generic tests : ', () => { }); describe('Actions are not displayed when no item is selected', () => { - it('[C213120] on Personal Files', async () => { await page.clickPersonalFilesAndWait(); expect(await toolbar.isEmpty()).toBe(true, `actions displayed though nothing selected`); @@ -175,14 +167,14 @@ describe('Generic tests : ', () => { }); it('[C286268] Context menu appears on right click on a multiple selection of items', async () => { - await dataTable.selectMultipleItems([ file1, file2 ]); + await dataTable.selectMultipleItems([file1, file2]); await dataTable.rightClickOnMultipleSelection(); expect(await dataTable.hasContextMenu()).toBe(true, 'Context menu is not displayed'); }); it('[C286269] Context menu appears when right clicking on a single item while having multiple items selected', async () => { - await dataTable.selectMultipleItems([ file2, folder1 ]); + await dataTable.selectMultipleItems([file2, folder1]); await dataTable.rightClickOnItem(file1); expect(await dataTable.hasContextMenu()).toBe(true, `Context menu is not displayed for ${file1}`); diff --git a/e2e/suites/actions-available/libraries/library.test.ts b/e2e/suites/actions-available/libraries/library.test.ts index 9e1831d4a..25201540b 100755 --- a/e2e/suites/actions-available/libraries/library.test.ts +++ b/e2e/suites/actions-available/libraries/library.test.ts @@ -23,14 +23,7 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - SearchResultsPage, - RepoClient, - Utils, - AdminActions -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, SearchResultsPage, RepoClient, Utils, AdminActions } from '@alfresco/aca-testing-shared'; import * as testData from './test-data-libraries'; import * as testUtil from '../test-util'; @@ -69,14 +62,15 @@ describe('Library actions : ', () => { await userApi.sites.createSite(testData.siteInTrash.name); await userApi.sites.createSite(testData.site2InTrash.name); - await Promise.all([ - userApi.sites.waitForApi({ expect: 8 }), - adminApiActions.sites.waitForApi({ expect: 6 + 1 }) - ]); + await Promise.all([userApi.sites.waitForApi({ expect: 8 }), adminApiActions.sites.waitForApi({ expect: 6 + 1 })]); await userApi.favorites.removeFavoritesByIds([publicUserMemberNotFavId, privateUserMemberNotFavId, moderatedUserMemberNotFavId]); - await userApi.favorites.addFavoritesByIds('site', [testData.publicNotMemberFav.name, testData.moderatedNotMemberFav.name, testData.moderatedRequestedJoinFav.name]); + await userApi.favorites.addFavoritesByIds('site', [ + testData.publicNotMemberFav.name, + testData.moderatedNotMemberFav.name, + testData.moderatedRequestedJoinFav.name + ]); await userApi.sites.requestToJoin(testData.moderatedRequestedJoinFav.name); await userApi.sites.requestToJoin(testData.moderatedRequestedJoinNotFav.name); @@ -114,7 +108,6 @@ describe('Library actions : ', () => { }); describe('on My Libraries', () => { - beforeAll(async () => { await Utils.pressEscape(); await page.goToMyLibrariesAndWait(); @@ -125,39 +118,61 @@ describe('Library actions : ', () => { }); it('[C213135] Public library, user is a member, favorite', async () => { - await testUtil.checkToolbarActions(testData.publicUserMemberFav.name, testData.publicUserMemberFav.toolbarPrimary, testData.publicUserMemberFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.publicUserMemberFav.name, + testData.publicUserMemberFav.toolbarPrimary, + testData.publicUserMemberFav.toolbarMore + ); await testUtil.checkContextMenu(testData.publicUserMemberFav.name, testData.publicUserMemberFav.contextMenu); }); it('[C290080] Private library, user is a member, favorite', async () => { - await testUtil.checkToolbarActions(testData.privateUserMemberFav.name, testData.privateUserMemberFav.toolbarPrimary, testData.privateUserMemberFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.privateUserMemberFav.name, + testData.privateUserMemberFav.toolbarPrimary, + testData.privateUserMemberFav.toolbarMore + ); await testUtil.checkContextMenu(testData.privateUserMemberFav.name, testData.privateUserMemberFav.contextMenu); }); it('[C326676] Moderated library, user is a member, favorite', async () => { - await testUtil.checkToolbarActions(testData.moderatedUserMemberFav.name, testData.moderatedUserMemberFav.toolbarPrimary, testData.moderatedUserMemberFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.moderatedUserMemberFav.name, + testData.moderatedUserMemberFav.toolbarPrimary, + testData.moderatedUserMemberFav.toolbarMore + ); await testUtil.checkContextMenu(testData.moderatedUserMemberFav.name, testData.moderatedUserMemberFav.contextMenu); }); it('[C326677] Public library, user is a member, not favorite', async () => { - await testUtil.checkToolbarActions(testData.publicUserMemberNotFav.name, testData.publicUserMemberNotFav.toolbarPrimary, testData.publicUserMemberNotFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.publicUserMemberNotFav.name, + testData.publicUserMemberNotFav.toolbarPrimary, + testData.publicUserMemberNotFav.toolbarMore + ); await testUtil.checkContextMenu(testData.publicUserMemberNotFav.name, testData.publicUserMemberNotFav.contextMenu); }); it('[C326678] Private library, user is a member, not favorite', async () => { - await testUtil.checkToolbarActions(testData.privateUserMemberNotFav.name, testData.privateUserMemberNotFav.toolbarPrimary, testData.privateUserMemberNotFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.privateUserMemberNotFav.name, + testData.privateUserMemberNotFav.toolbarPrimary, + testData.privateUserMemberNotFav.toolbarMore + ); await testUtil.checkContextMenu(testData.privateUserMemberNotFav.name, testData.privateUserMemberNotFav.contextMenu); }); it('[C326679] Moderated library, user is a member, not favorite', async () => { - await testUtil.checkToolbarActions(testData.moderatedUserMemberNotFav.name, testData.moderatedUserMemberNotFav.toolbarPrimary, testData.moderatedUserMemberNotFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.moderatedUserMemberNotFav.name, + testData.moderatedUserMemberNotFav.toolbarPrimary, + testData.moderatedUserMemberNotFav.toolbarMore + ); await testUtil.checkContextMenu(testData.moderatedUserMemberNotFav.name, testData.moderatedUserMemberNotFav.contextMenu); }); - }); describe('on Favorite Libraries', () => { - beforeAll(async () => { await Utils.pressEscape(); await page.goToFavoriteLibrariesAndWait(); @@ -168,38 +183,61 @@ describe('Library actions : ', () => { }); it('[C289892] Public library, user is a member, favorite', async () => { - await testUtil.checkToolbarActions(testData.publicUserMemberFav.name, testData.publicUserMemberFav.toolbarPrimary, testData.publicUserMemberFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.publicUserMemberFav.name, + testData.publicUserMemberFav.toolbarPrimary, + testData.publicUserMemberFav.toolbarMore + ); await testUtil.checkContextMenu(testData.publicUserMemberFav.name, testData.publicUserMemberFav.contextMenu); }); it('[C290090] Private library, user is a member, favorite', async () => { - await testUtil.checkToolbarActions(testData.privateUserMemberFav.name, testData.privateUserMemberFav.toolbarPrimary, testData.privateUserMemberFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.privateUserMemberFav.name, + testData.privateUserMemberFav.toolbarPrimary, + testData.privateUserMemberFav.toolbarMore + ); await testUtil.checkContextMenu(testData.privateUserMemberFav.name, testData.privateUserMemberFav.contextMenu); }); it('[C290091] Moderated library, user is a member, favorite', async () => { - await testUtil.checkToolbarActions(testData.moderatedUserMemberFav.name, testData.moderatedUserMemberFav.toolbarPrimary, testData.moderatedUserMemberFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.moderatedUserMemberFav.name, + testData.moderatedUserMemberFav.toolbarPrimary, + testData.moderatedUserMemberFav.toolbarMore + ); await testUtil.checkContextMenu(testData.moderatedUserMemberFav.name, testData.moderatedUserMemberFav.contextMenu); }); it('[C290081] Public library, user not a member, favorite', async () => { - await testUtil.checkToolbarActions(testData.publicNotMemberFav.name, testData.publicNotMemberFav.toolbarPrimary, testData.publicNotMemberFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.publicNotMemberFav.name, + testData.publicNotMemberFav.toolbarPrimary, + testData.publicNotMemberFav.toolbarMore + ); await testUtil.checkContextMenu(testData.publicNotMemberFav.name, testData.publicNotMemberFav.contextMenu); }); it('[C290082] Moderated library, user not a member, favorite', async () => { - await testUtil.checkToolbarActions(testData.moderatedNotMemberFav.name, testData.moderatedNotMemberFav.toolbarPrimary, testData.moderatedNotMemberFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.moderatedNotMemberFav.name, + testData.moderatedNotMemberFav.toolbarPrimary, + testData.moderatedNotMemberFav.toolbarMore + ); await testUtil.checkContextMenu(testData.moderatedNotMemberFav.name, testData.moderatedNotMemberFav.contextMenu); }); it('[C290089] Moderated library, user requested to join, favorite', async () => { - await testUtil.checkToolbarActions(testData.moderatedRequestedJoinFav.name, testData.moderatedRequestedJoinFav.toolbarPrimary, testData.moderatedRequestedJoinFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.moderatedRequestedJoinFav.name, + testData.moderatedRequestedJoinFav.toolbarPrimary, + testData.moderatedRequestedJoinFav.toolbarMore + ); await testUtil.checkContextMenu(testData.moderatedRequestedJoinFav.name, testData.moderatedRequestedJoinFav.contextMenu); }); }); describe('on Search Results', () => { - beforeAll(async () => { await Utils.pressEscape(); await page.clickPersonalFiles(); @@ -213,62 +251,110 @@ describe('Library actions : ', () => { }); it('[C290084] Public library, user is a member, favorite', async () => { - await testUtil.checkToolbarActions(testData.publicUserMemberFav.name, testData.publicUserMemberFav.searchToolbarPrimary, testData.publicUserMemberFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.publicUserMemberFav.name, + testData.publicUserMemberFav.searchToolbarPrimary, + testData.publicUserMemberFav.toolbarMore + ); await testUtil.checkContextMenu(testData.publicUserMemberFav.name, testData.publicUserMemberFav.contextMenu); }); it('[C290085] Private library, user is a member, favorite', async () => { - await testUtil.checkToolbarActions(testData.privateUserMemberFav.name, testData.privateUserMemberFav.searchToolbarPrimary, testData.privateUserMemberFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.privateUserMemberFav.name, + testData.privateUserMemberFav.searchToolbarPrimary, + testData.privateUserMemberFav.toolbarMore + ); await testUtil.checkContextMenu(testData.privateUserMemberFav.name, testData.privateUserMemberFav.contextMenu); }); it('[C290086] Moderated library, user is a member, favorite', async () => { - await testUtil.checkToolbarActions(testData.moderatedUserMemberFav.name, testData.moderatedUserMemberFav.searchToolbarPrimary, testData.moderatedUserMemberFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.moderatedUserMemberFav.name, + testData.moderatedUserMemberFav.searchToolbarPrimary, + testData.moderatedUserMemberFav.toolbarMore + ); await testUtil.checkContextMenu(testData.moderatedUserMemberFav.name, testData.moderatedUserMemberFav.contextMenu); }); it('[C291812] Public library, user is a member, not favorite', async () => { - await testUtil.checkToolbarActions(testData.publicUserMemberNotFav.name, testData.publicUserMemberNotFav.searchToolbarPrimary, testData.publicUserMemberNotFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.publicUserMemberNotFav.name, + testData.publicUserMemberNotFav.searchToolbarPrimary, + testData.publicUserMemberNotFav.toolbarMore + ); await testUtil.checkContextMenu(testData.publicUserMemberNotFav.name, testData.publicUserMemberNotFav.contextMenu); }); it('[C291813] Private library, user is a member, not favorite', async () => { - await testUtil.checkToolbarActions(testData.privateUserMemberNotFav.name, testData.privateUserMemberNotFav.searchToolbarPrimary, testData.privateUserMemberNotFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.privateUserMemberNotFav.name, + testData.privateUserMemberNotFav.searchToolbarPrimary, + testData.privateUserMemberNotFav.toolbarMore + ); await testUtil.checkContextMenu(testData.privateUserMemberNotFav.name, testData.privateUserMemberNotFav.contextMenu); }); it('[C291814] Moderated library, user is a member, not favorite', async () => { - await testUtil.checkToolbarActions(testData.moderatedUserMemberNotFav.name, testData.moderatedUserMemberNotFav.searchToolbarPrimary, testData.moderatedUserMemberNotFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.moderatedUserMemberNotFav.name, + testData.moderatedUserMemberNotFav.searchToolbarPrimary, + testData.moderatedUserMemberNotFav.toolbarMore + ); await testUtil.checkContextMenu(testData.moderatedUserMemberNotFav.name, testData.moderatedUserMemberNotFav.contextMenu); }); it('[C326680] Public library, user not a member, favorite', async () => { - await testUtil.checkToolbarActions(testData.publicNotMemberFav.name, testData.publicNotMemberFav.searchToolbarPrimary, testData.publicNotMemberFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.publicNotMemberFav.name, + testData.publicNotMemberFav.searchToolbarPrimary, + testData.publicNotMemberFav.toolbarMore + ); await testUtil.checkContextMenu(testData.publicNotMemberFav.name, testData.publicNotMemberFav.contextMenu); }); it('[C326681] Moderated library, user not a member, favorite', async () => { - await testUtil.checkToolbarActions(testData.moderatedNotMemberFav.name, testData.moderatedNotMemberFav.searchToolbarPrimary, testData.moderatedNotMemberFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.moderatedNotMemberFav.name, + testData.moderatedNotMemberFav.searchToolbarPrimary, + testData.moderatedNotMemberFav.toolbarMore + ); await testUtil.checkContextMenu(testData.moderatedNotMemberFav.name, testData.moderatedNotMemberFav.contextMenu); }); it('[C326682] Public library, user not a member, not favorite', async () => { - await testUtil.checkToolbarActions(testData.publicNotMemberNotFav.name, testData.publicNotMemberNotFav.searchToolbarPrimary, testData.publicNotMemberNotFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.publicNotMemberNotFav.name, + testData.publicNotMemberNotFav.searchToolbarPrimary, + testData.publicNotMemberNotFav.toolbarMore + ); await testUtil.checkContextMenu(testData.publicNotMemberNotFav.name, testData.publicNotMemberNotFav.contextMenu); }); it('[C326683] Moderated library, user not a member, not favorite', async () => { - await testUtil.checkToolbarActions(testData.moderatedNotMemberNotFav.name, testData.moderatedNotMemberNotFav.searchToolbarPrimary, testData.moderatedNotMemberNotFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.moderatedNotMemberNotFav.name, + testData.moderatedNotMemberNotFav.searchToolbarPrimary, + testData.moderatedNotMemberNotFav.toolbarMore + ); await testUtil.checkContextMenu(testData.moderatedNotMemberNotFav.name, testData.moderatedNotMemberNotFav.contextMenu); }); it('[C326685] Moderated library, user requested to join, favorite', async () => { - await testUtil.checkToolbarActions(testData.moderatedRequestedJoinFav.name, testData.moderatedRequestedJoinFav.searchToolbarPrimary, testData.moderatedRequestedJoinFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.moderatedRequestedJoinFav.name, + testData.moderatedRequestedJoinFav.searchToolbarPrimary, + testData.moderatedRequestedJoinFav.toolbarMore + ); await testUtil.checkContextMenu(testData.moderatedRequestedJoinFav.name, testData.moderatedRequestedJoinFav.contextMenu); }); it('[C326684] Moderated library, user requested to join, not favorite', async () => { - await testUtil.checkToolbarActions(testData.moderatedRequestedJoinNotFav.name, testData.moderatedRequestedJoinNotFav.searchToolbarPrimary, testData.moderatedRequestedJoinNotFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.moderatedRequestedJoinNotFav.name, + testData.moderatedRequestedJoinNotFav.searchToolbarPrimary, + testData.moderatedRequestedJoinNotFav.toolbarMore + ); await testUtil.checkContextMenu(testData.moderatedRequestedJoinNotFav.name, testData.moderatedRequestedJoinNotFav.contextMenu); }); }); @@ -289,8 +375,8 @@ describe('Library actions : ', () => { }); it('[C326687] multiple libraries', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.siteInTrash.name, testData.site2InTrash.name ], testData.trashActions); - await testUtil.checkMultipleSelToolbarPrimary([ testData.siteInTrash.name, testData.site2InTrash.name ], testData.trashActions); + await testUtil.checkMultipleSelContextMenu([testData.siteInTrash.name, testData.site2InTrash.name], testData.trashActions); + await testUtil.checkMultipleSelToolbarPrimary([testData.siteInTrash.name, testData.site2InTrash.name], testData.trashActions); }); }); }); diff --git a/e2e/suites/actions-available/libraries/test-data-libraries.ts b/e2e/suites/actions-available/libraries/test-data-libraries.ts index ef864eba9..9d0ca3073 100644 --- a/e2e/suites/actions-available/libraries/test-data-libraries.ts +++ b/e2e/suites/actions-available/libraries/test-data-libraries.ts @@ -29,7 +29,6 @@ import { Utils } from '@alfresco/aca-testing-shared'; export const trashActions = ['Permanently Delete', 'Restore']; - // ---- single selection ---- const memberFavContextMenu = ['Leave Library', 'Delete', 'Remove Favorite']; @@ -47,7 +46,6 @@ const notMemberToolbarPrimary = ['Join', 'More Actions']; const reqJoinNotFavContextMenu = ['Cancel Join Request', 'Delete', 'Favorite']; const reqJoinFavContextMenu = ['Cancel Join Request', 'Delete', 'Remove Favorite']; - export const publicUserMemberFav = { name: `site-public-member-fav-${Utils.random()}`, description: 'public site, user member, user favorite', @@ -177,4 +175,3 @@ export const site2InTrash = { name: `deleted-site2-${Utils.random()}`, trashActions }; - diff --git a/e2e/suites/actions-available/special-permissions/favorites.ts b/e2e/suites/actions-available/special-permissions/favorites.ts index be37a1b3b..90d289828 100755 --- a/e2e/suites/actions-available/special-permissions/favorites.ts +++ b/e2e/suites/actions-available/special-permissions/favorites.ts @@ -31,7 +31,6 @@ export function favoritesTests() { const page = new BrowsingPage(); describe('available actions : ', () => { - beforeAll(async () => { await page.clickFavoritesAndWait(); }); @@ -45,76 +44,117 @@ export function favoritesTests() { }); describe('on a file', () => { - it('File Office, favorite - [C286311]', async () => { await testUtil.checkToolbarActions(testData.fileDocxFav.name, testData.fileDocxFav.toolbarPrimary, testData.fileDocxFav.favoritesToolbarMore); await testUtil.checkContextMenu(testData.fileDocxFav.name, testData.fileDocxFav.favoritesContextMenu); - }); + }); it('File favorite - [C306991]', async () => { await testUtil.checkToolbarActions(testData.fileFav.name, testData.fileFav.toolbarPrimary, testData.fileFav.favoritesToolbarMore); await testUtil.checkContextMenu(testData.fileFav.name, testData.fileFav.favoritesContextMenu); - }); + }); it('File Office, shared, favorite - [C279187]', async () => { - await testUtil.checkToolbarActions(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.toolbarPrimary, testData.fileDocxSharedFav.favoritesToolbarMore); + await testUtil.checkToolbarActions( + testData.fileDocxSharedFav.name, + testData.fileDocxSharedFav.toolbarPrimary, + testData.fileDocxSharedFav.favoritesToolbarMore + ); await testUtil.checkContextMenu(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.favoritesContextMenu); - }); + }); it('File shared, favorite - [C280053]', async () => { - await testUtil.checkToolbarActions(testData.fileSharedFav.name, testData.fileSharedFav.toolbarPrimary, testData.fileSharedFav.favoritesToolbarMore); + await testUtil.checkToolbarActions( + testData.fileSharedFav.name, + testData.fileSharedFav.toolbarPrimary, + testData.fileSharedFav.favoritesToolbarMore + ); await testUtil.checkContextMenu(testData.fileSharedFav.name, testData.fileSharedFav.favoritesContextMenu); }); it('File favorite, locked - [C280050]', async () => { - await testUtil.checkToolbarActions(testData.fileFavLocked.name, testData.fileFavLocked.toolbarPrimary, testData.fileFavLocked.favoritesToolbarMore); + await testUtil.checkToolbarActions( + testData.fileFavLocked.name, + testData.fileFavLocked.toolbarPrimary, + testData.fileFavLocked.favoritesToolbarMore + ); await testUtil.checkContextMenu(testData.fileFavLocked.name, testData.fileFavLocked.favoritesContextMenu); - }); - - it('File shared, favorite, locked - [C325011]', async () => { - await testUtil.checkToolbarActions(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.toolbarPrimary, testData.fileSharedFavLocked.favoritesToolbarMore); - await testUtil.checkContextMenu(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.favoritesContextMenu); }); + it('File shared, favorite, locked - [C325011]', async () => { + await testUtil.checkToolbarActions( + testData.fileSharedFavLocked.name, + testData.fileSharedFavLocked.toolbarPrimary, + testData.fileSharedFavLocked.favoritesToolbarMore + ); + await testUtil.checkContextMenu(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.favoritesContextMenu); + }); }); describe('on a folder', () => { - it('Folder favorite - [C325012]', async () => { await testUtil.checkToolbarActions(testData.folderFav.name, testData.folderFav.toolbarPrimary, testData.folderFav.favoritesToolbarMore); await testUtil.checkContextMenu(testData.folderFav.name, testData.folderFav.favoritesContextMenu); }); - }); describe('on multiple selection', () => { - it('multiple files - [C325046]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileDocxFav.name, testData.fileDocxSharedFav.name ], testData.multipleSelAllFav.favoritesContextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileDocxFav.name, testData.fileDocxSharedFav.name ], testData.multipleSelAllFav.toolbarPrimary, testData.multipleSelAllFav.favoritesToolbarMore); + await testUtil.checkMultipleSelContextMenu( + [testData.fileDocxFav.name, testData.fileDocxSharedFav.name], + testData.multipleSelAllFav.favoritesContextMenu + ); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileDocxFav.name, testData.fileDocxSharedFav.name], + testData.multipleSelAllFav.toolbarPrimary, + testData.multipleSelAllFav.favoritesToolbarMore + ); }); it('multiple locked files - [C217145]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileFavLocked.name, testData.fileSharedFavLocked.name ], testData.multipleSelAllFav.favoritesContextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileFavLocked.name, testData.fileSharedFavLocked.name ], testData.multipleSelAllFav.toolbarPrimary, testData.multipleSelAllFav.favoritesToolbarMore); + await testUtil.checkMultipleSelContextMenu( + [testData.fileFavLocked.name, testData.fileSharedFavLocked.name], + testData.multipleSelAllFav.favoritesContextMenu + ); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileFavLocked.name, testData.fileSharedFavLocked.name], + testData.multipleSelAllFav.toolbarPrimary, + testData.multipleSelAllFav.favoritesToolbarMore + ); }); it('multiple folders - [C213196]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.folderFav.name, testData.folderFav2.name ], testData.multipleSelAllFav.favoritesContextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.folderFav.name, testData.folderFav2.name ], testData.multipleSelAllFav.toolbarPrimary, testData.multipleSelAllFav.favoritesToolbarMore); + await testUtil.checkMultipleSelContextMenu( + [testData.folderFav.name, testData.folderFav2.name], + testData.multipleSelAllFav.favoritesContextMenu + ); + await testUtil.checkMultipleSelToolbarActions( + [testData.folderFav.name, testData.folderFav2.name], + testData.multipleSelAllFav.toolbarPrimary, + testData.multipleSelAllFav.favoritesToolbarMore + ); }); it('both files and folders - [C217146]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileFav.name, testData.folderFav.name ], testData.multipleSelAllFav.favoritesContextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileFav.name, testData.folderFav.name ], testData.multipleSelAllFav.toolbarPrimary, testData.multipleSelAllFav.favoritesToolbarMore); + await testUtil.checkMultipleSelContextMenu([testData.fileFav.name, testData.folderFav.name], testData.multipleSelAllFav.favoritesContextMenu); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileFav.name, testData.folderFav.name], + testData.multipleSelAllFav.toolbarPrimary, + testData.multipleSelAllFav.favoritesToolbarMore + ); }); it('multiple files with different granular permissions - [C213193]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileFav.name, testData.fileGranularPermission ], testData.multipleSelAllFav.favoritesContextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileFav.name, testData.fileGranularPermission ], testData.multipleSelAllFav.toolbarPrimary, testData.multipleSelAllFav.favoritesToolbarMore); + await testUtil.checkMultipleSelContextMenu( + [testData.fileFav.name, testData.fileGranularPermission], + testData.multipleSelAllFav.favoritesContextMenu + ); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileFav.name, testData.fileGranularPermission], + testData.multipleSelAllFav.toolbarPrimary, + testData.multipleSelAllFav.favoritesToolbarMore + ); }); - }); - }); } diff --git a/e2e/suites/actions-available/special-permissions/my-libraries.ts b/e2e/suites/actions-available/special-permissions/my-libraries.ts index 094caa4aa..9f5c64326 100755 --- a/e2e/suites/actions-available/special-permissions/my-libraries.ts +++ b/e2e/suites/actions-available/special-permissions/my-libraries.ts @@ -32,7 +32,6 @@ export function librariesTests(siteName?: string) { const { dataTable } = page; describe('available actions : ', () => { - beforeAll(async () => { await page.goToMyLibrariesAndWait(); await dataTable.doubleClickOnRowByName(siteName); @@ -48,7 +47,6 @@ export function librariesTests(siteName?: string) { }); describe('on a file', () => { - it('File Office - [C280476]', async () => { await testUtil.checkToolbarActions(testData.fileDocx.name, testData.fileDocx.toolbarPrimary, testData.fileDocx.toolbarMore); await testUtil.checkContextMenu(testData.fileDocx.name, testData.fileDocx.contextMenu); @@ -75,7 +73,11 @@ export function librariesTests(siteName?: string) { }); it('File Office, shared, favorite - [C280466]', async () => { - await testUtil.checkToolbarActions(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.toolbarPrimary, testData.fileDocxSharedFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.fileDocxSharedFav.name, + testData.fileDocxSharedFav.toolbarPrimary, + testData.fileDocxSharedFav.toolbarMore + ); await testUtil.checkContextMenu(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.contextMenu); }); @@ -100,19 +102,25 @@ export function librariesTests(siteName?: string) { }); it('File shared, locked - [C280666]', async () => { - await testUtil.checkToolbarActions(testData.fileSharedLocked.name, testData.fileSharedLocked.toolbarPrimary, testData.fileSharedLocked.toolbarMore); + await testUtil.checkToolbarActions( + testData.fileSharedLocked.name, + testData.fileSharedLocked.toolbarPrimary, + testData.fileSharedLocked.toolbarMore + ); await testUtil.checkContextMenu(testData.fileSharedLocked.name, testData.fileSharedLocked.contextMenu); }); it('File shared, favorite, locked - [C280669]', async () => { - await testUtil.checkToolbarActions(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.toolbarPrimary, testData.fileSharedFavLocked.toolbarMore); + await testUtil.checkToolbarActions( + testData.fileSharedFavLocked.name, + testData.fileSharedFavLocked.toolbarPrimary, + testData.fileSharedFavLocked.toolbarMore + ); await testUtil.checkContextMenu(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.contextMenu); }); - }); describe('on a folder', () => { - it('Folder not favorite - [C280456]', async () => { await testUtil.checkToolbarActions(testData.folder.name, testData.folder.toolbarPrimary, testData.folder.toolbarMore); await testUtil.checkContextMenu(testData.folder.name, testData.folder.contextMenu); @@ -125,37 +133,65 @@ export function librariesTests(siteName?: string) { }); describe('on multiple selection', () => { - it('multiple files - [C286264]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileDocx.name, testData.fileDocxSharedFav.name ], testData.multipleSel.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileDocx.name, testData.fileDocxSharedFav.name ], testData.multipleSel.toolbarPrimary, testData.multipleSel.toolbarMore); + await testUtil.checkMultipleSelContextMenu([testData.fileDocx.name, testData.fileDocxSharedFav.name], testData.multipleSel.contextMenu); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileDocx.name, testData.fileDocxSharedFav.name], + testData.multipleSel.toolbarPrimary, + testData.multipleSel.toolbarMore + ); }); it('multiple files - all favorite - [C286283]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileDocxFav.name, testData.fileDocxSharedFav.name ], testData.multipleSelAllFav.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileDocxFav.name, testData.fileDocxSharedFav.name ], testData.multipleSel.toolbarPrimary, testData.multipleSelAllFav.toolbarMore); + await testUtil.checkMultipleSelContextMenu( + [testData.fileDocxFav.name, testData.fileDocxSharedFav.name], + testData.multipleSelAllFav.contextMenu + ); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileDocxFav.name, testData.fileDocxSharedFav.name], + testData.multipleSel.toolbarPrimary, + testData.multipleSelAllFav.toolbarMore + ); }); it('multiple locked files - [C280478]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileLocked.name, testData.fileSharedFavLocked.name ], testData.multipleSel.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileLocked.name, testData.fileSharedFavLocked.name ], testData.multipleSel.toolbarPrimary, testData.multipleSel.toolbarMore); + await testUtil.checkMultipleSelContextMenu([testData.fileLocked.name, testData.fileSharedFavLocked.name], testData.multipleSel.contextMenu); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileLocked.name, testData.fileSharedFavLocked.name], + testData.multipleSel.toolbarPrimary, + testData.multipleSel.toolbarMore + ); }); it('multiple folders - [C213121]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.folderFav.name, testData.folder.name ], testData.multipleSel.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.folderFav.name, testData.folder.name ], testData.multipleSel.toolbarPrimary, testData.multipleSel.toolbarMore); + await testUtil.checkMultipleSelContextMenu([testData.folderFav.name, testData.folder.name], testData.multipleSel.contextMenu); + await testUtil.checkMultipleSelToolbarActions( + [testData.folderFav.name, testData.folder.name], + testData.multipleSel.toolbarPrimary, + testData.multipleSel.toolbarMore + ); }); it('both files and folders - [C286266]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.file.name, testData.folder.name ], testData.multipleSel.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.file.name, testData.folder.name ], testData.multipleSel.toolbarPrimary, testData.multipleSel.toolbarMore); + await testUtil.checkMultipleSelContextMenu([testData.file.name, testData.folder.name], testData.multipleSel.contextMenu); + await testUtil.checkMultipleSelToolbarActions( + [testData.file.name, testData.folder.name], + testData.multipleSel.toolbarPrimary, + testData.multipleSel.toolbarMore + ); }); it('multiple files with different granular permissions - [C286285]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileDocxFav.name, testData.fileGranularPermission ], testData.multipleSelAllFav.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileDocxFav.name, testData.fileGranularPermission ], testData.multipleSel.toolbarPrimary, testData.multipleSelAllFav.toolbarMore); + await testUtil.checkMultipleSelContextMenu( + [testData.fileDocxFav.name, testData.fileGranularPermission], + testData.multipleSelAllFav.contextMenu + ); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileDocxFav.name, testData.fileGranularPermission], + testData.multipleSel.toolbarPrimary, + testData.multipleSelAllFav.toolbarMore + ); }); - }); }); } diff --git a/e2e/suites/actions-available/special-permissions/other-permissions.ts b/e2e/suites/actions-available/special-permissions/other-permissions.ts index d5344a4c2..b1e0ce28d 100755 --- a/e2e/suites/actions-available/special-permissions/other-permissions.ts +++ b/e2e/suites/actions-available/special-permissions/other-permissions.ts @@ -34,7 +34,6 @@ const { searchInput } = searchResultsPage.header; export function collaboratorTests(siteName?: string) { describe('available actions : ', () => { - beforeEach(async () => { await Utils.pressEscape(); }); @@ -91,7 +90,15 @@ export function collaboratorTests(siteName?: string) { await dataTable.waitForHeader(); const expectedToolbarPrimary = ['Activate full-screen mode', 'Shared Link Settings', 'Download', 'Print', 'View Details', 'More Actions']; - const expectedToolbarMore = ['Edit in Microsoft Office™', 'Edit Offline', 'Upload New Version', 'Remove Favorite', 'Copy', 'Manage Versions', 'Permissions']; + const expectedToolbarMore = [ + 'Edit in Microsoft Office™', + 'Edit Offline', + 'Upload New Version', + 'Remove Favorite', + 'Copy', + 'Manage Versions', + 'Permissions' + ]; await testUtil.checkViewerActions(testData.fileDocxSharedFav.name, expectedToolbarPrimary, expectedToolbarMore); }); @@ -100,7 +107,15 @@ export function collaboratorTests(siteName?: string) { await page.clickSharedFilesAndWait(); const expectedToolbarPrimary = ['Activate full-screen mode', 'Shared Link Settings', 'Download', 'Print', 'View Details', 'More Actions']; - const expectedToolbarMore = ['Edit in Microsoft Office™', 'Edit Offline', 'Upload New Version', 'Remove Favorite', 'Copy', 'Manage Versions', 'Permissions']; + const expectedToolbarMore = [ + 'Edit in Microsoft Office™', + 'Edit Offline', + 'Upload New Version', + 'Remove Favorite', + 'Copy', + 'Manage Versions', + 'Permissions' + ]; await testUtil.checkViewerActions(testData.fileDocxSharedFav.name, expectedToolbarPrimary, expectedToolbarMore); }); @@ -109,7 +124,15 @@ export function collaboratorTests(siteName?: string) { await page.clickFavoritesAndWait(); const expectedToolbarPrimary = ['Activate full-screen mode', 'Shared Link Settings', 'Download', 'Print', 'View Details', 'More Actions']; - const expectedToolbarMore = ['Edit in Microsoft Office™', 'Edit Offline', 'Upload New Version', 'Remove Favorite', 'Copy', 'Manage Versions', 'Permissions']; + const expectedToolbarMore = [ + 'Edit in Microsoft Office™', + 'Edit Offline', + 'Upload New Version', + 'Remove Favorite', + 'Copy', + 'Manage Versions', + 'Permissions' + ]; await testUtil.checkViewerActions(testData.fileDocxSharedFav.name, expectedToolbarPrimary, expectedToolbarMore); }); @@ -120,7 +143,15 @@ export function collaboratorTests(siteName?: string) { await searchResultsPage.waitForResults(); const expectedToolbarPrimary = ['Activate full-screen mode', 'Shared Link Settings', 'Download', 'Print', 'View Details', 'More Actions']; - const expectedToolbarMore = ['Edit in Microsoft Office™', 'Edit Offline', 'Upload New Version', 'Remove Favorite', 'Copy', 'Manage Versions', 'Permissions']; + const expectedToolbarMore = [ + 'Edit in Microsoft Office™', + 'Edit Offline', + 'Upload New Version', + 'Remove Favorite', + 'Copy', + 'Manage Versions', + 'Permissions' + ]; await testUtil.checkViewerActions(testData.fileDocxSharedFav.name, expectedToolbarPrimary, expectedToolbarMore); }); @@ -225,7 +256,6 @@ export function filesLockedByCurrentUser(siteName?: string) { export function filesLockedByOtherUser(siteName?: string) { describe('available actions : ', () => { - beforeEach(async () => { await Utils.pressEscape(); }); @@ -250,7 +280,16 @@ export function filesLockedByOtherUser(siteName?: string) { const expectedToolbarPrimary = ['Shared Link Settings', 'Download', 'View', 'View Details', 'More Actions']; // TODO: investigate why 'Upload New Version' appears and raise issue - const expectedToolbarMore = ['Cancel Editing', 'Upload New Version', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions', 'Permissions']; + const expectedToolbarMore = [ + 'Cancel Editing', + 'Upload New Version', + 'Remove Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions', + 'Permissions' + ]; await testUtil.checkToolbarActions(testData.fileLockedByUser, expectedToolbarPrimary, expectedToolbarMore); }); diff --git a/e2e/suites/actions-available/special-permissions/search-results.ts b/e2e/suites/actions-available/special-permissions/search-results.ts index 46f44be76..0230b7178 100755 --- a/e2e/suites/actions-available/special-permissions/search-results.ts +++ b/e2e/suites/actions-available/special-permissions/search-results.ts @@ -33,7 +33,6 @@ export function searchResultsTests() { const { searchInput } = page.header; describe('available actions : ', () => { - beforeEach(async () => { await Utils.pressEscape(); }); @@ -43,7 +42,6 @@ export function searchResultsTests() { }); describe('on a file', () => { - beforeAll(async () => { await page.clickPersonalFiles(); await searchInput.clickSearchButton(); @@ -72,12 +70,20 @@ export function searchResultsTests() { }); it('File Office, shared - [C286280]', async () => { - await testUtil.checkToolbarActions(testData.fileDocxShared.name, testData.fileDocxShared.searchToolbarPrimary, testData.fileDocxShared.toolbarMore); + await testUtil.checkToolbarActions( + testData.fileDocxShared.name, + testData.fileDocxShared.searchToolbarPrimary, + testData.fileDocxShared.toolbarMore + ); await testUtil.checkContextMenu(testData.fileDocxShared.name, testData.fileDocxShared.contextMenu); }); it('File Office, shared, favorite - [C286281]', async () => { - await testUtil.checkToolbarActions(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.searchToolbarPrimary, testData.fileDocxSharedFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.fileDocxSharedFav.name, + testData.fileDocxSharedFav.searchToolbarPrimary, + testData.fileDocxSharedFav.toolbarMore + ); await testUtil.checkContextMenu(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.contextMenu); }); @@ -87,7 +93,11 @@ export function searchResultsTests() { }); it('File shared, favorite - [C291823]', async () => { - await testUtil.checkToolbarActions(testData.fileSharedFav.name, testData.fileSharedFav.searchToolbarPrimary, testData.fileSharedFav.toolbarMore); + await testUtil.checkToolbarActions( + testData.fileSharedFav.name, + testData.fileSharedFav.searchToolbarPrimary, + testData.fileSharedFav.toolbarMore + ); await testUtil.checkContextMenu(testData.fileSharedFav.name, testData.fileSharedFav.contextMenu); }); @@ -97,24 +107,34 @@ export function searchResultsTests() { }); it('File favorite, locked - [C291819]', async () => { - await testUtil.checkToolbarActions(testData.fileFavLocked.name, testData.fileFavLocked.searchToolbarPrimary, testData.fileFavLocked.toolbarMore); + await testUtil.checkToolbarActions( + testData.fileFavLocked.name, + testData.fileFavLocked.searchToolbarPrimary, + testData.fileFavLocked.toolbarMore + ); await testUtil.checkContextMenu(testData.fileFavLocked.name, testData.fileFavLocked.contextMenu); }); it('File shared, locked - [C291824]', async () => { - await testUtil.checkToolbarActions(testData.fileSharedLocked.name, testData.fileSharedLocked.searchToolbarPrimary, testData.fileSharedLocked.toolbarMore); + await testUtil.checkToolbarActions( + testData.fileSharedLocked.name, + testData.fileSharedLocked.searchToolbarPrimary, + testData.fileSharedLocked.toolbarMore + ); await testUtil.checkContextMenu(testData.fileSharedLocked.name, testData.fileSharedLocked.contextMenu); }); it('File shared, favorite, locked - [C291825]', async () => { - await testUtil.checkToolbarActions(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.searchToolbarPrimary, testData.fileSharedFavLocked.toolbarMore); + await testUtil.checkToolbarActions( + testData.fileSharedFavLocked.name, + testData.fileSharedFavLocked.searchToolbarPrimary, + testData.fileSharedFavLocked.toolbarMore + ); await testUtil.checkContextMenu(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.contextMenu); }); - }); describe('on a folder', () => { - beforeAll(async () => { await page.clickPersonalFiles(); await searchInput.clickSearchButton(); @@ -131,13 +151,10 @@ export function searchResultsTests() { await testUtil.checkToolbarActions(testData.folderFav.name, testData.folderFav.searchToolbarPrimary, testData.folderFav.toolbarMore); await testUtil.checkContextMenu(testData.folderFav.name, testData.folderFav.contextMenu); }); - }); describe('on multiple selection', () => { - describe('of files', () => { - beforeAll(async () => { await page.clickPersonalFiles(); await searchInput.clickSearchButton(); @@ -146,23 +163,45 @@ export function searchResultsTests() { }); it('multiple files - [C291830]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.file.name, testData.fileDocxShared.name ], testData.multipleSel.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.file.name, testData.fileDocxShared.name ], testData.multipleSel.searchToolbarPrimary, testData.multipleSel.toolbarMore); + await testUtil.checkMultipleSelContextMenu([testData.file.name, testData.fileDocxShared.name], testData.multipleSel.contextMenu); + await testUtil.checkMultipleSelToolbarActions( + [testData.file.name, testData.fileDocxShared.name], + testData.multipleSel.searchToolbarPrimary, + testData.multipleSel.toolbarMore + ); }); it('multiple files - all favorite - [C291834]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileDocxFav.name, testData.fileSharedFav.name ], testData.multipleSelAllFav.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileDocxFav.name, testData.fileSharedFav.name ], testData.multipleSel.searchToolbarPrimary, testData.multipleSelAllFav.toolbarMore); + await testUtil.checkMultipleSelContextMenu( + [testData.fileDocxFav.name, testData.fileSharedFav.name], + testData.multipleSelAllFav.contextMenu + ); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileDocxFav.name, testData.fileSharedFav.name], + testData.multipleSel.searchToolbarPrimary, + testData.multipleSelAllFav.toolbarMore + ); }); it('multiple locked files - [C291835]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileLocked.name, testData.fileSharedFavLocked.name ], testData.multipleSel.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileLocked.name, testData.fileSharedFavLocked.name ], testData.multipleSel.searchToolbarPrimary, testData.multipleSel.toolbarMore); + await testUtil.checkMultipleSelContextMenu([testData.fileLocked.name, testData.fileSharedFavLocked.name], testData.multipleSel.contextMenu); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileLocked.name, testData.fileSharedFavLocked.name], + testData.multipleSel.searchToolbarPrimary, + testData.multipleSel.toolbarMore + ); }); it('multiple files with different granular permissions - [C286310]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileDocxFav.name, testData.fileGranularPermission ], testData.multipleSelAllFav.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileDocxFav.name, testData.fileGranularPermission ], testData.multipleSel.searchToolbarPrimary, testData.multipleSelAllFav.toolbarMore); + await testUtil.checkMultipleSelContextMenu( + [testData.fileDocxFav.name, testData.fileGranularPermission], + testData.multipleSelAllFav.contextMenu + ); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileDocxFav.name, testData.fileGranularPermission], + testData.multipleSel.searchToolbarPrimary, + testData.multipleSelAllFav.toolbarMore + ); }); }); @@ -171,8 +210,12 @@ export function searchResultsTests() { await searchInput.clickSearchButton(); await searchInput.searchFor('folder-'); - await testUtil.checkMultipleSelContextMenu([ testData.folder.name, testData.folderFav.name ], testData.multipleSel.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.folder.name, testData.folderFav.name ], testData.multipleSel.searchToolbarPrimary, testData.multipleSel.toolbarMore); + await testUtil.checkMultipleSelContextMenu([testData.folder.name, testData.folderFav.name], testData.multipleSel.contextMenu); + await testUtil.checkMultipleSelToolbarActions( + [testData.folder.name, testData.folderFav.name], + testData.multipleSel.searchToolbarPrimary, + testData.multipleSel.toolbarMore + ); }); it('both files and folders - [C268128]', async () => { @@ -180,10 +223,13 @@ export function searchResultsTests() { await searchInput.clickSearchButton(); await searchInput.searchFor(`=${testData.file.name} or =${testData.folderFav.name}`); - await testUtil.checkMultipleSelContextMenu([ testData.file.name, testData.folderFav.name ], testData.multipleSel.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.file.name, testData.folderFav.name ], testData.multipleSel.searchToolbarPrimary, testData.multipleSel.toolbarMore); + await testUtil.checkMultipleSelContextMenu([testData.file.name, testData.folderFav.name], testData.multipleSel.contextMenu); + await testUtil.checkMultipleSelToolbarActions( + [testData.file.name, testData.folderFav.name], + testData.multipleSel.searchToolbarPrimary, + testData.multipleSel.toolbarMore + ); }); - }); }); } diff --git a/e2e/suites/actions-available/special-permissions/shared-files.ts b/e2e/suites/actions-available/special-permissions/shared-files.ts index 026aa7bf4..258e2011a 100755 --- a/e2e/suites/actions-available/special-permissions/shared-files.ts +++ b/e2e/suites/actions-available/special-permissions/shared-files.ts @@ -31,7 +31,6 @@ export function sharedFilesTests() { const page = new BrowsingPage(); describe('available actions : ', () => { - beforeAll(async () => { await page.clickSharedFilesAndWait(); }); @@ -45,14 +44,21 @@ export function sharedFilesTests() { }); describe('single selection', () => { - it('File Office, shared - [C326626]', async () => { - await testUtil.checkToolbarActions(testData.fileDocxShared.name, testData.fileDocxShared.toolbarPrimary, testData.fileDocxShared.sharedToolbarMore); + await testUtil.checkToolbarActions( + testData.fileDocxShared.name, + testData.fileDocxShared.toolbarPrimary, + testData.fileDocxShared.sharedToolbarMore + ); await testUtil.checkContextMenu(testData.fileDocxShared.name, testData.fileDocxShared.sharedContextMenu); }); it('File Office, shared, favorite - [C326627]', async () => { - await testUtil.checkToolbarActions(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.toolbarPrimary, testData.fileDocxSharedFav.sharedToolbarMore); + await testUtil.checkToolbarActions( + testData.fileDocxSharedFav.name, + testData.fileDocxSharedFav.toolbarPrimary, + testData.fileDocxSharedFav.sharedToolbarMore + ); await testUtil.checkContextMenu(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.sharedContextMenu); }); @@ -62,45 +68,78 @@ export function sharedFilesTests() { }); it('File shared, favorite - [C326629]', async () => { - await testUtil.checkToolbarActions(testData.fileSharedFav.name, testData.fileSharedFav.toolbarPrimary, testData.fileSharedFav.sharedToolbarMore); + await testUtil.checkToolbarActions( + testData.fileSharedFav.name, + testData.fileSharedFav.toolbarPrimary, + testData.fileSharedFav.sharedToolbarMore + ); await testUtil.checkContextMenu(testData.fileSharedFav.name, testData.fileSharedFav.sharedContextMenu); }); it('File shared, locked - [C326631]', async () => { - await testUtil.checkToolbarActions(testData.fileSharedLocked.name, testData.fileSharedLocked.toolbarPrimary, testData.fileSharedLocked.sharedToolbarMore); + await testUtil.checkToolbarActions( + testData.fileSharedLocked.name, + testData.fileSharedLocked.toolbarPrimary, + testData.fileSharedLocked.sharedToolbarMore + ); await testUtil.checkContextMenu(testData.fileSharedLocked.name, testData.fileSharedLocked.sharedContextMenu); }); it('File shared, favorite, locked - [C326632]', async () => { - await testUtil.checkToolbarActions(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.toolbarPrimary, testData.fileSharedFavLocked.sharedToolbarMore); + await testUtil.checkToolbarActions( + testData.fileSharedFavLocked.name, + testData.fileSharedFavLocked.toolbarPrimary, + testData.fileSharedFavLocked.sharedToolbarMore + ); await testUtil.checkContextMenu(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.sharedContextMenu); }); - }); describe('multiple selection', () => { - it('multiple files - [C326634]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileShared.name, testData.fileSharedFav.name ], testData.multipleSel.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileShared.name, testData.fileSharedFav.name ], testData.multipleSel.toolbarPrimary, testData.multipleSel.toolbarMore); + await testUtil.checkMultipleSelContextMenu([testData.fileShared.name, testData.fileSharedFav.name], testData.multipleSel.contextMenu); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileShared.name, testData.fileSharedFav.name], + testData.multipleSel.toolbarPrimary, + testData.multipleSel.toolbarMore + ); }); it('multiple files - all favorite - [C326635]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileSharedFav.name, testData.fileSharedFavLocked.name ], testData.multipleSelAllFav.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileSharedFav.name, testData.fileSharedFavLocked.name ], testData.multipleSel.toolbarPrimary, testData.multipleSelAllFav.toolbarMore); + await testUtil.checkMultipleSelContextMenu( + [testData.fileSharedFav.name, testData.fileSharedFavLocked.name], + testData.multipleSelAllFav.contextMenu + ); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileSharedFav.name, testData.fileSharedFavLocked.name], + testData.multipleSel.toolbarPrimary, + testData.multipleSelAllFav.toolbarMore + ); }); it('multiple locked files - [C326636]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileSharedLocked.name, testData.fileSharedFavLocked.name ], testData.multipleSel.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileSharedLocked.name, testData.fileSharedFavLocked.name ], testData.multipleSel.toolbarPrimary, testData.multipleSel.toolbarMore); + await testUtil.checkMultipleSelContextMenu( + [testData.fileSharedLocked.name, testData.fileSharedFavLocked.name], + testData.multipleSel.contextMenu + ); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileSharedLocked.name, testData.fileSharedFavLocked.name], + testData.multipleSel.toolbarPrimary, + testData.multipleSel.toolbarMore + ); }); it('multiple files with different granular permissions - [C326639]', async () => { - await testUtil.checkMultipleSelContextMenu([ testData.fileSharedFav.name, testData.fileGranularPermission ], testData.multipleSelAllFav.contextMenu); - await testUtil.checkMultipleSelToolbarActions([ testData.fileSharedFav.name, testData.fileGranularPermission ], testData.multipleSel.toolbarPrimary, testData.multipleSelAllFav.toolbarMore); + await testUtil.checkMultipleSelContextMenu( + [testData.fileSharedFav.name, testData.fileGranularPermission], + testData.multipleSelAllFav.contextMenu + ); + await testUtil.checkMultipleSelToolbarActions( + [testData.fileSharedFav.name, testData.fileGranularPermission], + testData.multipleSel.toolbarPrimary, + testData.multipleSelAllFav.toolbarMore + ); }); - }); - }); } diff --git a/e2e/suites/actions-available/special-permissions/special-permissions-actions.test.ts b/e2e/suites/actions-available/special-permissions/special-permissions-actions.test.ts index 09e5295c4..42abef042 100644 --- a/e2e/suites/actions-available/special-permissions/special-permissions-actions.test.ts +++ b/e2e/suites/actions-available/special-permissions/special-permissions-actions.test.ts @@ -23,14 +23,7 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - RepoClient, - Utils, - AdminActions, - FILES, - SITE_ROLES -} from '@alfresco/aca-testing-shared'; +import { LoginPage, RepoClient, Utils, AdminActions, FILES, SITE_ROLES } from '@alfresco/aca-testing-shared'; import * as testData from './test-data-permissions'; import { librariesTests } from './my-libraries'; import { favoritesTests } from './favorites'; @@ -85,7 +78,7 @@ describe('Special permissions : ', () => { await userManagerApi.sites.addSiteCollaborator(sitePrivate, userCollaborator); await userManagerApi.sites.addSiteManager(sitePrivate, userDemoted); - await userManagerApi.upload.uploadFileWithRename(FILES.docxFile, docLibId, testData.fileDocx.name ); + await userManagerApi.upload.uploadFileWithRename(FILES.docxFile, docLibId, testData.fileDocx.name); fileDocxFavId = (await userManagerApi.upload.uploadFileWithRename(FILES.docxFile, docLibId, testData.fileDocxFav.name)).entry.id; await userManagerApi.nodes.createFile(testData.file.name, docLibId); fileFavId = (await userManagerApi.nodes.createFile(testData.fileFav.name, docLibId)).entry.id; @@ -158,7 +151,6 @@ describe('Special permissions : ', () => { }); describe('Consumer', () => { - beforeAll(async () => { await loginPage.loginWith(userConsumer); }); diff --git a/e2e/suites/actions-available/special-permissions/test-data-permissions.ts b/e2e/suites/actions-available/special-permissions/test-data-permissions.ts index 418505c85..aba2673c0 100644 --- a/e2e/suites/actions-available/special-permissions/test-data-permissions.ts +++ b/e2e/suites/actions-available/special-permissions/test-data-permissions.ts @@ -55,11 +55,30 @@ const consumerViewerToolbarMore = ['Favorite', 'Copy', 'Manage Versions']; const favoritesConsumerToolbarMore = ['Upload New Version', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions']; // TODO: remove 'Move' and 'Delete' when ACA-1737 is done // TODO: investigate why 'Upload New Version' appears and raise issue -const favoritesConsumerContextMenu = ['Share', 'Download', 'View', 'Upload New Version', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions']; +const favoritesConsumerContextMenu = [ + 'Share', + 'Download', + 'View', + 'Upload New Version', + 'Remove Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions' +]; // TODO: remove 'Move' and 'Delete' when ACA-1737 is done // TODO: investigate why 'Upload New Version' appears and raise issue -const favoritesConsumerSharedContextMenu = ['Shared Link Settings', 'Download', 'View', 'Upload New Version', 'Remove Favorite', 'Move', 'Copy', 'Delete', 'Manage Versions']; - +const favoritesConsumerSharedContextMenu = [ + 'Shared Link Settings', + 'Download', + 'View', + 'Upload New Version', + 'Remove Favorite', + 'Move', + 'Copy', + 'Delete', + 'Manage Versions' +]; // ---- SHARED FILES workaround ---- @@ -77,13 +96,30 @@ const sharedConsumerFavLockedToolbarMore = ['Cancel Editing', 'Upload New Versio const sharedConsumerContextMenu = ['Shared Link Settings', 'Download', 'View', 'Upload New Version', 'Favorite', 'Copy', 'Manage Versions']; // TODO: investigate why 'Cancel Editing' appears and raise issue // TODO: investigate why 'Upload New Version' appears and raise issue -const sharedConsumerLockedContextMenu = ['Shared Link Settings', 'Download', 'View', 'Cancel Editing', 'Upload New Version', 'Favorite', 'Copy', 'Manage Versions']; +const sharedConsumerLockedContextMenu = [ + 'Shared Link Settings', + 'Download', + 'View', + 'Cancel Editing', + 'Upload New Version', + 'Favorite', + 'Copy', + 'Manage Versions' +]; // TODO: investigate why 'Upload New Version' appears and raise issue const sharedConsumerFavContextMenu = ['Shared Link Settings', 'Download', 'View', 'Upload New Version', 'Remove Favorite', 'Copy', 'Manage Versions']; // TODO: investigate why 'Cancel Editing' appears and raise issue // TODO: investigate why 'Upload New Version' appears and raise issue -const sharedConsumerFavLockedContextMenu = ['Shared Link Settings', 'Download', 'View', 'Cancel Editing', 'Upload New Version', 'Remove Favorite', 'Copy', 'Manage Versions']; - +const sharedConsumerFavLockedContextMenu = [ + 'Shared Link Settings', + 'Download', + 'View', + 'Cancel Editing', + 'Upload New Version', + 'Remove Favorite', + 'Copy', + 'Manage Versions' +]; export const fileDocx = { name: `file-docx-${Utils.random()}.docx`, @@ -316,7 +352,7 @@ export const folderFav = { favoritesContextMenu: favoritesConsumerFolderContextMenu, favoritesToolbarMore: favoritesConsumerFolderToolbarMore, - searchToolbarPrimary: searchConsumerFolderToolbarPrimary, + searchToolbarPrimary: searchConsumerFolderToolbarPrimary }; export const folderFav2 = { @@ -344,7 +380,6 @@ const favoritesMultipleSelAllFavContextMenu = ['Download', 'Remove Favorite', 'M // TODO: remove 'Move' and 'Delete' when ACA-1737 is done const favoritesMultipleSelAllFavToolbarMore = ['Remove Favorite', 'Move', 'Copy', 'Delete']; - export const multipleSel = { contextMenu: multipleSelContextMenu, toolbarPrimary: multipleSelToolbarPrimary, @@ -354,7 +389,7 @@ export const multipleSel = { favoritesToolbarMore: favoritesMultipleSelToolbarMore, searchToolbarPrimary: searchMultipleSelToolbarPrimary -} +}; export const multipleSelAllFav = { contextMenu: multipleSelAllFavContextMenu, @@ -365,4 +400,4 @@ export const multipleSelAllFav = { favoritesToolbarMore: favoritesMultipleSelAllFavToolbarMore, searchToolbarPrimary: searchMultipleSelToolbarPrimary -} +}; diff --git a/e2e/suites/actions-available/special-permissions/viewer.ts b/e2e/suites/actions-available/special-permissions/viewer.ts index 32438f757..5269fc9a7 100755 --- a/e2e/suites/actions-available/special-permissions/viewer.ts +++ b/e2e/suites/actions-available/special-permissions/viewer.ts @@ -34,7 +34,6 @@ export function viewerTests(siteName?: string) { const { searchInput } = page.header; describe('available actions : ', () => { - beforeEach(async () => { await Utils.pressEscape(); }); @@ -44,7 +43,6 @@ export function viewerTests(siteName?: string) { }); describe('file opened from File Libraries', () => { - beforeAll(async () => { await page.goToMyLibrariesAndWait(); await dataTable.doubleClickOnRowByName(siteName); @@ -56,7 +54,11 @@ export function viewerTests(siteName?: string) { }); it('File Office, favorite - [C326623]', async () => { - await testUtil.checkViewerActions(testData.fileDocxFav.name, testData.fileDocxFav.viewerToolbarPrimary, testData.fileDocxFav.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileDocxFav.name, + testData.fileDocxFav.viewerToolbarPrimary, + testData.fileDocxFav.viewerToolbarMore + ); }); it('File simple - [C326624]', async () => { @@ -68,11 +70,19 @@ export function viewerTests(siteName?: string) { }); it('File Office, shared - [C326637]', async () => { - await testUtil.checkViewerActions(testData.fileDocxShared.name, testData.fileDocxShared.viewerToolbarPrimary, testData.fileDocxShared.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileDocxShared.name, + testData.fileDocxShared.viewerToolbarPrimary, + testData.fileDocxShared.viewerToolbarMore + ); }); it('File Office, shared, favorite - [C326638]', async () => { - await testUtil.checkViewerActions(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.viewerToolbarPrimary, testData.fileDocxSharedFav.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileDocxSharedFav.name, + testData.fileDocxSharedFav.viewerToolbarPrimary, + testData.fileDocxSharedFav.viewerToolbarMore + ); }); it('File shared - [C326648]', async () => { @@ -80,7 +90,11 @@ export function viewerTests(siteName?: string) { }); it('File shared, favorite - [C326649]', async () => { - await testUtil.checkViewerActions(testData.fileSharedFav.name, testData.fileSharedFav.viewerToolbarPrimary, testData.fileSharedFav.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedFav.name, + testData.fileSharedFav.viewerToolbarPrimary, + testData.fileSharedFav.viewerToolbarMore + ); }); it('File locked - [C326630]', async () => { @@ -88,27 +102,41 @@ export function viewerTests(siteName?: string) { }); it('File favorite, locked - [C326633]', async () => { - await testUtil.checkViewerActions(testData.fileFavLocked.name, testData.fileFavLocked.viewerToolbarPrimary, testData.fileFavLocked.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileFavLocked.name, + testData.fileFavLocked.viewerToolbarPrimary, + testData.fileFavLocked.viewerToolbarMore + ); }); it('File shared, locked - [C326650]', async () => { - await testUtil.checkViewerActions(testData.fileSharedLocked.name, testData.fileSharedLocked.viewerToolbarPrimary, testData.fileSharedLocked.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedLocked.name, + testData.fileSharedLocked.viewerToolbarPrimary, + testData.fileSharedLocked.viewerToolbarMore + ); }); it('File shared, favorite, locked - [C326651]', async () => { - await testUtil.checkViewerActions(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.viewerToolbarPrimary, testData.fileSharedFavLocked.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedFavLocked.name, + testData.fileSharedFavLocked.viewerToolbarPrimary, + testData.fileSharedFavLocked.viewerToolbarMore + ); }); - }); describe('file opened from Favorites', () => { - beforeAll(async () => { await page.clickFavoritesAndWait(); }); it('File Office, favorite - [C326652]', async () => { - await testUtil.checkViewerActions(testData.fileDocxFav.name, testData.fileDocxFav.viewerToolbarPrimary, testData.fileDocxFav.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileDocxFav.name, + testData.fileDocxFav.viewerToolbarPrimary, + testData.fileDocxFav.viewerToolbarMore + ); }); it('File favorite - [C326653]', async () => { @@ -116,35 +144,57 @@ export function viewerTests(siteName?: string) { }); it('File Office, shared, favorite - [C326655]', async () => { - await testUtil.checkViewerActions(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.viewerToolbarPrimary, testData.fileDocxSharedFav.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileDocxSharedFav.name, + testData.fileDocxSharedFav.viewerToolbarPrimary, + testData.fileDocxSharedFav.viewerToolbarMore + ); }); it('File shared, favorite - [C326656]', async () => { - await testUtil.checkViewerActions(testData.fileSharedFav.name, testData.fileSharedFav.viewerToolbarPrimary, testData.fileSharedFav.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedFav.name, + testData.fileSharedFav.viewerToolbarPrimary, + testData.fileSharedFav.viewerToolbarMore + ); }); it('File favorite, locked - [C326654]', async () => { - await testUtil.checkViewerActions(testData.fileFavLocked.name, testData.fileFavLocked.viewerToolbarPrimary, testData.fileFavLocked.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileFavLocked.name, + testData.fileFavLocked.viewerToolbarPrimary, + testData.fileFavLocked.viewerToolbarMore + ); }); it('File shared, favorite, locked - [C326657]', async () => { - await testUtil.checkViewerActions(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.viewerToolbarPrimary, testData.fileSharedFavLocked.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedFavLocked.name, + testData.fileSharedFavLocked.viewerToolbarPrimary, + testData.fileSharedFavLocked.viewerToolbarMore + ); }); - }); describe('file opened from Shared Files', () => { - beforeAll(async () => { await page.clickSharedFilesAndWait(); }); it('File Office, shared - [C326658]', async () => { - await testUtil.checkViewerActions(testData.fileDocxShared.name, testData.fileDocxShared.viewerToolbarPrimary, testData.fileDocxShared.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileDocxShared.name, + testData.fileDocxShared.viewerToolbarPrimary, + testData.fileDocxShared.viewerToolbarMore + ); }); it('File Office, shared, favorite - [C326659]', async () => { - await testUtil.checkViewerActions(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.viewerToolbarPrimary, testData.fileDocxSharedFav.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileDocxSharedFav.name, + testData.fileDocxSharedFav.viewerToolbarPrimary, + testData.fileDocxSharedFav.viewerToolbarMore + ); }); it('File shared - [C326660]', async () => { @@ -152,21 +202,31 @@ export function viewerTests(siteName?: string) { }); it('File shared, favorite - [C326661]', async () => { - await testUtil.checkViewerActions(testData.fileSharedFav.name, testData.fileSharedFav.viewerToolbarPrimary, testData.fileSharedFav.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedFav.name, + testData.fileSharedFav.viewerToolbarPrimary, + testData.fileSharedFav.viewerToolbarMore + ); }); it('File shared, locked - [C326662]', async () => { - await testUtil.checkViewerActions(testData.fileSharedLocked.name, testData.fileSharedLocked.viewerToolbarPrimary, testData.fileSharedLocked.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedLocked.name, + testData.fileSharedLocked.viewerToolbarPrimary, + testData.fileSharedLocked.viewerToolbarMore + ); }); it('File shared, favorite, locked - [C326663]', async () => { - await testUtil.checkViewerActions(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.viewerToolbarPrimary, testData.fileSharedFavLocked.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedFavLocked.name, + testData.fileSharedFavLocked.viewerToolbarPrimary, + testData.fileSharedFavLocked.viewerToolbarMore + ); }); - }); describe('file opened from Search Results', () => { - beforeAll(async () => { await searchInput.clickSearchButton(); await searchInput.searchFor('file-'); @@ -178,7 +238,11 @@ export function viewerTests(siteName?: string) { }); it('File Office, favorite - [C326665]', async () => { - await testUtil.checkViewerActions(testData.fileDocxFav.name, testData.fileDocxFav.viewerToolbarPrimary, testData.fileDocxFav.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileDocxFav.name, + testData.fileDocxFav.viewerToolbarPrimary, + testData.fileDocxFav.viewerToolbarMore + ); }); it('File simple - [C326666]', async () => { @@ -190,11 +254,19 @@ export function viewerTests(siteName?: string) { }); it('File Office, shared - [C326670]', async () => { - await testUtil.checkViewerActions(testData.fileDocxShared.name, testData.fileDocxShared.viewerToolbarPrimary, testData.fileDocxShared.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileDocxShared.name, + testData.fileDocxShared.viewerToolbarPrimary, + testData.fileDocxShared.viewerToolbarMore + ); }); it('File Office, shared, favorite - [C326671]', async () => { - await testUtil.checkViewerActions(testData.fileDocxSharedFav.name, testData.fileDocxSharedFav.viewerToolbarPrimary, testData.fileDocxSharedFav.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileDocxSharedFav.name, + testData.fileDocxSharedFav.viewerToolbarPrimary, + testData.fileDocxSharedFav.viewerToolbarMore + ); }); it('File shared - [C326672]', async () => { @@ -202,7 +274,11 @@ export function viewerTests(siteName?: string) { }); it('File shared, favorite - [C326673]', async () => { - await testUtil.checkViewerActions(testData.fileSharedFav.name, testData.fileSharedFav.viewerToolbarPrimary, testData.fileSharedFav.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedFav.name, + testData.fileSharedFav.viewerToolbarPrimary, + testData.fileSharedFav.viewerToolbarMore + ); }); it('File locked - [C326668]', async () => { @@ -210,17 +286,28 @@ export function viewerTests(siteName?: string) { }); it('File favorite, locked - [C326669]', async () => { - await testUtil.checkViewerActions(testData.fileFavLocked.name, testData.fileFavLocked.viewerToolbarPrimary, testData.fileFavLocked.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileFavLocked.name, + testData.fileFavLocked.viewerToolbarPrimary, + testData.fileFavLocked.viewerToolbarMore + ); }); it('File shared, locked - [C326674]', async () => { - await testUtil.checkViewerActions(testData.fileSharedLocked.name, testData.fileSharedLocked.viewerToolbarPrimary, testData.fileSharedLocked.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedLocked.name, + testData.fileSharedLocked.viewerToolbarPrimary, + testData.fileSharedLocked.viewerToolbarMore + ); }); it('File shared, favorite, locked - [C326675]', async () => { - await testUtil.checkViewerActions(testData.fileSharedFavLocked.name, testData.fileSharedFavLocked.viewerToolbarPrimary, testData.fileSharedFavLocked.viewerToolbarMore); + await testUtil.checkViewerActions( + testData.fileSharedFavLocked.name, + testData.fileSharedFavLocked.viewerToolbarPrimary, + testData.fileSharedFavLocked.viewerToolbarMore + ); }); - }); }); } diff --git a/e2e/suites/actions-available/test-util.ts b/e2e/suites/actions-available/test-util.ts index 306f5e094..0521848e0 100644 --- a/e2e/suites/actions-available/test-util.ts +++ b/e2e/suites/actions-available/test-util.ts @@ -89,7 +89,11 @@ export async function checkMultipleSelToolbarPrimary(items: string[], expectedTo expect(actualPrimaryActions).toEqual(expectedToolbarPrimary); } -export async function checkMultipleSelToolbarActions(items: string[], expectedToolbarPrimary: string[], expectedToolbarMore: string[]): Promise { +export async function checkMultipleSelToolbarActions( + items: string[], + expectedToolbarPrimary: string[], + expectedToolbarMore: string[] +): Promise { await dataTable.selectMultipleItems(items); const actualPrimaryActions = await toolbar.getButtons(); diff --git a/e2e/suites/actions/copy-move/copy.test.ts b/e2e/suites/actions/copy-move/copy.test.ts index 671d157a3..2b83baec1 100755 --- a/e2e/suites/actions/copy-move/copy.test.ts +++ b/e2e/suites/actions/copy-move/copy.test.ts @@ -23,51 +23,68 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - ContentNodeSelectorDialog, - RepoClient, - Utils -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, ContentNodeSelectorDialog, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Copy content', () => { const username = `user-${Utils.random()}`; - const source = `source-${Utils.random()}`; let sourceId; - const destinationPF = `destinationPersonal-${Utils.random()}`; let destinationIdPF; - const destinationRF = `destinationRecent-${Utils.random()}`; let destinationIdRF; - const destinationSF = `destinationShared-${Utils.random()}`; let destinationIdSF; - const destinationFav = `destinationFav-${Utils.random()}`; let destinationIdFav; - const destinationSearch = `destinationSearch-${Utils.random()}`; let destinationIdSearch; + const source = `source-${Utils.random()}`; + let sourceId: string; + const destinationPF = `destinationPersonal-${Utils.random()}`; + let destinationIdPF: string; + const destinationRF = `destinationRecent-${Utils.random()}`; + let destinationIdRF: string; + const destinationSF = `destinationShared-${Utils.random()}`; + let destinationIdSF: string; + const destinationFav = `destinationFav-${Utils.random()}`; + let destinationIdFav: string; + const destinationSearch = `destinationSearch-${Utils.random()}`; + let destinationIdSearch: string; - const file1 = `file1-${Utils.random()}.txt`; let file1Id; + const file1 = `file1-${Utils.random()}.txt`; + let file1Id: string; - const folder1 = `folder1-${Utils.random()}`; let folder1Id; - const fileInFolder = `fileInFolder-${Utils.random()}.txt`; let fileInFolderId; + const folder1 = `folder1-${Utils.random()}`; + let folder1Id: string; + const fileInFolder = `fileInFolder-${Utils.random()}.txt`; + let fileInFolderId: string; - const folder2 = `folder2-${Utils.random()}`; let folder2Id; + const folder2 = `folder2-${Utils.random()}`; + let folder2Id: string; const fileInFolder2 = fileInFolder; - const folderExisting = `folder-existing-${Utils.random()}`; let folderExistingId; + const folderExisting = `folder-existing-${Utils.random()}`; + let folderExistingId: string; const file1InFolderExisting = `file1InFolderExisting-${Utils.random()}.txt`; const file2InFolderExisting = `file2InFolderExisting-${Utils.random()}.txt`; - const file2 = `file2-${Utils.random()}.txt`; let file2Id; - const file3 = `file3-${Utils.random()}.txt`; let file3Id; - const file4 = `file4-${Utils.random()}.txt`; let file4Id; + const file2 = `file2-${Utils.random()}.txt`; + let file2Id: string; + const file3 = `file3-${Utils.random()}.txt`; + let file3Id: string; + const file4 = `file4-${Utils.random()}.txt`; + let file4Id: string; - const fileLocked1 = `file-locked1-${Utils.random()}.txt`; let fileLocked1Id; + const fileLocked1 = `file-locked1-${Utils.random()}.txt`; + let fileLocked1Id: string; - const folderWithLockedFiles = `folder-locked1-${Utils.random()}`; let folderWithLockedFilesId; - const fileLockedInFolder = `file-locked-${Utils.random()}`; let fileLockedInFolderId; + const folderWithLockedFiles = `folder-locked1-${Utils.random()}`; + let folderWithLockedFilesId: string; + const fileLockedInFolder = `file-locked-${Utils.random()}`; + let fileLockedInFolderId: string; - const existingFile = `existing-${Utils.random()}.txt`; let existingFileToCopyId; + const existingFile = `existing-${Utils.random()}.txt`; + let existingFileToCopyId: string; - const existingFolder = `existing-${Utils.random()}`; let existingFolderToCopyId; + const existingFolder = `existing-${Utils.random()}`; + let existingFolderToCopyId: string; - let existingIdPF, existingIdFav, existingIdSearch; - let folderExistingPFId, folderExistingFavId, folderExistingSearchId; + let existingIdPF: string; + let existingIdFav: string; + let existingIdSearch: string; + let folderExistingPFId: string; + let folderExistingFavId: string; + let folderExistingSearchId: string; const file2InFolder = `file2InFolder-${Utils.random()}.txt`; const file3InFolder = `file3InFolder-${Utils.random()}.txt`; @@ -79,7 +96,8 @@ describe('Copy content', () => { const folderSiteFav = `folderSiteFav-${Utils.random()}`; const folderSiteSearch = `folderSiteSearch-${Utils.random()}`; - let locationId, destinationId; + let locationId: string; + let destinationId: string; const apis = { admin: new RepoClient(), @@ -213,17 +231,18 @@ describe('Copy content', () => { it('[C280201] Copy multiple items', async () => copyMultipleItems([file2, file3], source, destinationRF)); - it('[C280196] Copy a file with a name that already exists on the destination', async () => copyFileWithNameThatAlreadyExists(existingFile, source, destinationRF)); + it('[C280196] Copy a file with a name that already exists on the destination', async () => + copyFileWithNameThatAlreadyExists(existingFile, source, destinationRF)); it('[C291899] Copy items into a library', async () => copyItemsIntoLibrary([file1, file2], source, folderSiteRF)); - it('[C280198] Copy locked file', async () => copyLockedFile(fileLocked1, source, destinationRF, () => { - locationId = sourceId; - destinationId = destinationIdRF; - })); + it('[C280198] Copy locked file', async () => + copyLockedFile(fileLocked1, source, destinationRF, () => { + locationId = sourceId; + destinationId = destinationIdRF; + })); it('[C280202] Undo copy of files', async () => undoCopyFile(file4, source, destinationRF)); - }); describe('from Personal Files', () => { @@ -245,33 +264,38 @@ describe('Copy content', () => { it('[C291889] Copy multiple items', async () => copyMultipleItems([file2, file3], '', destinationPF)); - it('[C217137] Copy a file with a name that already exists on the destination', async () => copyFileWithNameThatAlreadyExists(existingFile, '', destinationPF)); + it('[C217137] Copy a file with a name that already exists on the destination', async () => + copyFileWithNameThatAlreadyExists(existingFile, '', destinationPF)); - it('[C217138] Copy a folder with a name that already exists on the destination', async () => copyFolderWithNameThatAlreadyExists(existingFolder, '', destinationPF)); + it('[C217138] Copy a folder with a name that already exists on the destination', async () => + copyFolderWithNameThatAlreadyExists(existingFolder, '', destinationPF)); it('[C280282] Copy items into a library', async () => copyItemsIntoLibrary([file1, folder1], '', folderSitePF)); - it('[C217139] Copy locked file', async () => copyLockedFile(fileLocked1, '', destinationPF, () => { - locationId = sourceId; - destinationId = destinationIdPF; - })); + it('[C217139] Copy locked file', async () => + copyLockedFile(fileLocked1, '', destinationPF, () => { + locationId = sourceId; + destinationId = destinationIdPF; + })); - it('[C217140] Copy folder that contains locked file', async () => copyFolderThatContainsLockedFile(folderWithLockedFiles, '', destinationPF, () => { - locationId = folderWithLockedFilesId; - destinationId = destinationIdPF; - })); + it('[C217140] Copy folder that contains locked file', async () => + copyFolderThatContainsLockedFile(folderWithLockedFiles, '', destinationPF, () => { + locationId = folderWithLockedFilesId; + destinationId = destinationIdPF; + })); it('[C217171] Undo copy of files', async () => undoCopyFile(file4, '', destinationPF)); it('[C217172] Undo copy of folders', async () => undoCopyFolder(folder2, '', destinationPF)); - it('[C217173] Undo copy of a file when a file with same name already exists on the destination', async () => undoCopyFileWithExistingName(fileInFolder, '', folder2, async () => { - await dataTable.doubleClickOnRowByName(folder1); - await dataTable.waitForHeader(); - })); - - it('[C217174] Undo copy of a folder when a folder with same name already exists on the destination', async () => undoCopyFolderWithExistingName(folderExisting, '', destinationPF)); + it('[C217173] Undo copy of a file when a file with same name already exists on the destination', async () => + undoCopyFileWithExistingName(fileInFolder, '', folder2, async () => { + await dataTable.doubleClickOnRowByName(folder1); + await dataTable.waitForHeader(); + })); + it('[C217174] Undo copy of a folder when a folder with same name already exists on the destination', async () => + undoCopyFolderWithExistingName(folderExisting, '', destinationPF)); }); describe('from Shared Files', () => { @@ -290,17 +314,18 @@ describe('Copy content', () => { it('[C280213] Copy multiple items', async () => copyMultipleItems([file2, file3], source, destinationSF)); - it('[C280208] Copy a file with a name that already exists on the destination', async () => copyFileWithNameThatAlreadyExists(existingFile, source, destinationSF)); + it('[C280208] Copy a file with a name that already exists on the destination', async () => + copyFileWithNameThatAlreadyExists(existingFile, source, destinationSF)); it('[C291900] Copy items into a library', async () => copyItemsIntoLibrary([file1, file2], source, folderSiteSF)); - it('[C280210] Copy locked file', async () => copyLockedFile(fileLocked1, source, destinationSF, () => { - locationId = sourceId; - destinationId = destinationIdSF; - })); + it('[C280210] Copy locked file', async () => + copyLockedFile(fileLocked1, source, destinationSF, () => { + locationId = sourceId; + destinationId = destinationIdSF; + })); it('[C280214] Undo copy of files', async () => undoCopyFile(file4, source, destinationSF)); - }); describe('from Favorites', () => { @@ -321,30 +346,35 @@ describe('Copy content', () => { it('[C280225] Copy multiple items', async () => copyMultipleItems([file2, file3], source, destinationFav)); - it('[C280220] Copy a file with a name that already exists on the destination', async () => copyFileWithNameThatAlreadyExists(existingFile, source, destinationFav)); + it('[C280220] Copy a file with a name that already exists on the destination', async () => + copyFileWithNameThatAlreadyExists(existingFile, source, destinationFav)); - it('[C280221] Copy a folder with a name that already exists on the destination', async () => copyFolderWithNameThatAlreadyExists(existingFolder, source, destinationFav)); + it('[C280221] Copy a folder with a name that already exists on the destination', async () => + copyFolderWithNameThatAlreadyExists(existingFolder, source, destinationFav)); it('[C291901] Copy items into a library', async () => copyItemsIntoLibrary([file1, folder1], source, folderSiteFav)); - it('[C280222] Copy locked file', async () => copyLockedFile(fileLocked1, source, destinationFav, () => { - locationId = sourceId; - destinationId = destinationIdFav; - })); + it('[C280222] Copy locked file', async () => + copyLockedFile(fileLocked1, source, destinationFav, () => { + locationId = sourceId; + destinationId = destinationIdFav; + })); - it('[C280223] Copy folder that contains locked file', async () => copyFolderThatContainsLockedFile(folderWithLockedFiles, source, destinationFav, () => { - locationId = folderWithLockedFilesId; - destinationId = destinationIdFav; - })); + it('[C280223] Copy folder that contains locked file', async () => + copyFolderThatContainsLockedFile(folderWithLockedFiles, source, destinationFav, () => { + locationId = folderWithLockedFilesId; + destinationId = destinationIdFav; + })); it('[C280226] Undo copy of files', async () => undoCopyFile(file4, source, destinationFav)); it('[C280227] Undo copy of folders', async () => undoCopyFolder(folder2, source, destinationFav)); - it('[C280228] Undo copy of a file when a file with same name already exists on the destination', async () => undoCopyFileWithExistingName(fileInFolder, folder1, folder2)); - - it('[C280229] Undo copy of a folder when a folder with same name already exists on the destination', async () => undoCopyFolderWithExistingName(folderExisting, source, destinationFav)); + it('[C280228] Undo copy of a file when a file with same name already exists on the destination', async () => + undoCopyFileWithExistingName(fileInFolder, folder1, folder2)); + it('[C280229] Undo copy of a folder when a folder with same name already exists on the destination', async () => + undoCopyFolderWithExistingName(folderExisting, source, destinationFav)); }); describe('from Search Results', () => { @@ -360,72 +390,84 @@ describe('Copy content', () => { done(); }); - it('[C306932] Copy a file', async () => copyFile(file1, source, destinationSearch, async () => { - await searchInput.searchFor(file1); - await dataTable.waitForBody(); - })); + it('[C306932] Copy a file', async () => + copyFile(file1, source, destinationSearch, async () => { + await searchInput.searchFor(file1); + await dataTable.waitForBody(); + })); - it('[C306943] Copy a folder with content', async () => copyFolderWithContent(folder1, source, destinationSearch, async () => { - await searchInput.searchFor(folder1); - await dataTable.waitForBody(); - })); + it('[C306943] Copy a folder with content', async () => + copyFolderWithContent(folder1, source, destinationSearch, async () => { + await searchInput.searchFor(folder1); + await dataTable.waitForBody(); + })); - it('[C306944] Copy multiple items', async () => copyMultipleItems([file2, file3], source, destinationSearch, async () => { - await searchInput.searchFor('file'); - await dataTable.waitForBody(); - })); + it('[C306944] Copy multiple items', async () => + copyMultipleItems([file2, file3], source, destinationSearch, async () => { + await searchInput.searchFor('file'); + await dataTable.waitForBody(); + })); - it('[C306933] Copy a file with a name that already exists on the destination', async () => copyFileWithNameThatAlreadyExists(existingFile, source, destinationSearch, async () => { - await searchInput.searchFor(existingFile); - await dataTable.waitForBody(); - })); + it('[C306933] Copy a file with a name that already exists on the destination', async () => + copyFileWithNameThatAlreadyExists(existingFile, source, destinationSearch, async () => { + await searchInput.searchFor(existingFile); + await dataTable.waitForBody(); + })); - it('[C306934] Copy a folder with a name that already exists on the destination', async () => copyFolderWithNameThatAlreadyExists(existingFolder, source, destinationSearch, async () => { - await searchInput.searchFor(existingFolder); - await dataTable.waitForBody(); - })); + it('[C306934] Copy a folder with a name that already exists on the destination', async () => + copyFolderWithNameThatAlreadyExists(existingFolder, source, destinationSearch, async () => { + await searchInput.searchFor(existingFolder); + await dataTable.waitForBody(); + })); - it('[C306942] Copy items into a library', async () => copyItemsIntoLibrary([file1, file2], source, folderSiteSearch, async () => { - await searchInput.searchFor('file'); - await dataTable.waitForBody(); - })); + it('[C306942] Copy items into a library', async () => + copyItemsIntoLibrary([file1, file2], source, folderSiteSearch, async () => { + await searchInput.searchFor('file'); + await dataTable.waitForBody(); + })); - it('[C306935] Copy locked file', async () => copyLockedFile(fileLocked1, source, destinationSearch, async () => { - locationId = sourceId; - destinationId = destinationIdSearch; - await searchInput.searchFor(fileLocked1); - await dataTable.waitForBody(); - })); + it('[C306935] Copy locked file', async () => + copyLockedFile(fileLocked1, source, destinationSearch, async () => { + locationId = sourceId; + destinationId = destinationIdSearch; + await searchInput.searchFor(fileLocked1); + await dataTable.waitForBody(); + })); - it('[C306936] Copy folder that contains locked file', async () => copyFolderThatContainsLockedFile(folderWithLockedFiles, source, destinationSearch, async () => { - locationId = folderWithLockedFilesId; - destinationId = destinationIdSearch; - await searchInput.searchFor(folderWithLockedFiles); - await dataTable.waitForBody(); - })); + it('[C306936] Copy folder that contains locked file', async () => + copyFolderThatContainsLockedFile(folderWithLockedFiles, source, destinationSearch, async () => { + locationId = folderWithLockedFilesId; + destinationId = destinationIdSearch; + await searchInput.searchFor(folderWithLockedFiles); + await dataTable.waitForBody(); + })); - it('[C306938] Undo copy of files', async () => undoCopyFile(file4, source, destinationSearch, async () => { - await searchInput.searchFor(file4); - await dataTable.waitForBody(); - })); + it('[C306938] Undo copy of files', async () => + undoCopyFile(file4, source, destinationSearch, async () => { + await searchInput.searchFor(file4); + await dataTable.waitForBody(); + })); - it('[C306939] Undo copy of folders', async () => undoCopyFolder(folder2, source, destinationSearch, async () => { - await searchInput.searchFor(folder2); - await dataTable.waitForBody(); - })); + it('[C306939] Undo copy of folders', async () => + undoCopyFolder(folder2, source, destinationSearch, async () => { + await searchInput.searchFor(folder2); + await dataTable.waitForBody(); + })); - it('[C306940] Undo copy of a file when a file with same name already exists on the destination', async () => undoCopyFileWithExistingName(fileInFolder, folder1, folder2, async () => { - await searchInput.searchFor(fileInFolder); - await dataTable.waitForBody(); - })); + it('[C306940] Undo copy of a file when a file with same name already exists on the destination', async () => + undoCopyFileWithExistingName(fileInFolder, folder1, folder2, async () => { + await searchInput.searchFor(fileInFolder); + await dataTable.waitForBody(); + })); - it('[C306941] Undo copy of a folder when a folder with same name already exists on the destination', async () => undoCopyFolderWithExistingName(folderExisting, source, destinationSearch, async () => { - await searchInput.searchFor(folderExisting); - await dataTable.waitForBody(); - })); + it('[C306941] Undo copy of a folder when a folder with same name already exists on the destination', async () => + undoCopyFolderWithExistingName(folderExisting, source, destinationSearch, async () => { + await searchInput.searchFor(folderExisting); + await dataTable.waitForBody(); + })); }); - async function copyFile(fileName: string, location: string = '', destination: string, doBefore = null) { + async function copyFile(fileName: string, location: string = '', destination: string, doBefore?: Function) { if (doBefore) { await doBefore(); } @@ -445,7 +487,7 @@ describe('Copy content', () => { expect(await dataTable.isItemPresent(fileName)).toBe(true, `${fileName} not present in ${destination} folder`); } - async function copyFolderWithContent(folderName: string, location: string = '', destination: string, doBefore = null) { + async function copyFolderWithContent(folderName: string, location: string = '', destination: string, doBefore?: Function) { if (doBefore) { await doBefore(); } @@ -469,7 +511,7 @@ describe('Copy content', () => { expect(await dataTable.isItemPresent(fileInFolder)).toBe(true, `${fileInFolder} is not present in ${folderName} folder in ${destination}`); } - async function copyMultipleItems(items: string[], location: string = '', destination: string, doBefore = null) { + async function copyMultipleItems(items: string[], location: string = '', destination: string, doBefore?: Function) { if (doBefore) { await doBefore(); } @@ -491,7 +533,7 @@ describe('Copy content', () => { expect(await dataTable.isItemPresent(items[1])).toBe(true, `${items[1]} not present in ${destination} folder`); } - async function copyFileWithNameThatAlreadyExists(fileName: string, location: string = '', destination: string, doBefore = null) { + async function copyFileWithNameThatAlreadyExists(fileName: string, location: string = '', destination: string, doBefore?: Function) { if (doBefore) { await doBefore(); } @@ -511,7 +553,7 @@ describe('Copy content', () => { expect(await dataTable.isItemPresent(fileName)).toBe(true, `${fileName}.txt not present in ${destination} folder`); } - async function copyFolderWithNameThatAlreadyExists(folderName: string, location: string = '', destination: string, doBefore = null) { + async function copyFolderWithNameThatAlreadyExists(folderName: string, location: string = '', destination: string, doBefore?: Function) { if (doBefore) { await doBefore(); } @@ -534,7 +576,7 @@ describe('Copy content', () => { expect(await dataTable.isItemPresent(file3InFolder)).toBe(true, `${file3InFolder} not present in ${destination} folder in ${folderName}`); } - async function copyItemsIntoLibrary(items: string[], location: string = '', destination: string, doBefore = null) { + async function copyItemsIntoLibrary(items: string[], location: string = '', destination: string, doBefore?: Function) { if (doBefore) { await doBefore(); } @@ -547,7 +589,7 @@ describe('Copy content', () => { await copyDialog.selectDestination(destination); await copyDialog.copyButton.click(); const msg = await page.getSnackBarMessage(); - expect(msg).toContain(`Copied ${noOfItems} ${ noOfItems === 1 ? 'item' : 'items'}`); + expect(msg).toContain(`Copied ${noOfItems} ${noOfItems === 1 ? 'item' : 'items'}`); expect(msg).toContain('Undo'); await copyDialog.waitForDialogToClose(); @@ -564,7 +606,7 @@ describe('Copy content', () => { } } - async function copyLockedFile(fileName: string, location: string = '', destination: string, doBefore = null) { + async function copyLockedFile(fileName: string, location: string = '', destination: string, doBefore?: Function) { if (doBefore) { await doBefore(); } @@ -587,7 +629,7 @@ describe('Copy content', () => { expect(await apis.user.nodes.isFileLockedByName(fileName, destinationId)).toBe(false, `${fileName} is locked in ${destination}`); } - async function copyFolderThatContainsLockedFile(folderName: string, location: string = '', destination: string, doBefore = null) { + async function copyFolderThatContainsLockedFile(folderName: string, location: string = '', destination: string, doBefore?: Function) { if (doBefore) { await doBefore(); } @@ -610,11 +652,16 @@ describe('Copy content', () => { expect(await apis.user.nodes.isFileLockedByName(fileLockedInFolder, locationId)).toBe(true, `${fileLockedInFolder} not locked in ${location}`); await dataTable.doubleClickOnRowByName(folderName); - expect(await dataTable.isItemPresent(fileLockedInFolder)).toBe(true, `${fileLockedInFolder} is not present in ${folderName} folder from ${destination}`); - expect(await apis.user.nodes.isFileLockedByName(fileLockedInFolder, (await apis.user.nodes.getNodeIdFromParent(folderWithLockedFiles, destinationId)))).toBe(false, `${fileLockedInFolder} is locked in ${destination}`); + expect(await dataTable.isItemPresent(fileLockedInFolder)).toBe( + true, + `${fileLockedInFolder} is not present in ${folderName} folder from ${destination}` + ); + expect( + await apis.user.nodes.isFileLockedByName(fileLockedInFolder, await apis.user.nodes.getNodeIdFromParent(folderWithLockedFiles, destinationId)) + ).toBe(false, `${fileLockedInFolder} is locked in ${destination}`); } - async function undoCopyFile(fileName: string, location: string = '', destination: string, doBefore = null) { + async function undoCopyFile(fileName: string, location: string = '', destination: string, doBefore?: Function) { if (doBefore) { await doBefore(); } @@ -637,7 +684,7 @@ describe('Copy content', () => { expect(await dataTable.isEmpty()).toBe(true, 'Trash is not empty'); } - async function undoCopyFolder(folderName: string, location: string = '', destination: string, doBefore = null) { + async function undoCopyFolder(folderName: string, location: string = '', destination: string, doBefore?: Function) { if (doBefore) { await doBefore(); } @@ -660,7 +707,7 @@ describe('Copy content', () => { expect(await dataTable.isEmpty()).toBe(true, 'Trash is not empty'); } - async function undoCopyFileWithExistingName(fileName: string, location: string = '', destination: string, doBefore = null) { + async function undoCopyFileWithExistingName(fileName: string, location: string = '', destination: string, doBefore?: Function) { if (doBefore) { await doBefore(); } @@ -687,7 +734,7 @@ describe('Copy content', () => { expect(await dataTable.isEmpty()).toBe(true, 'Trash is not empty'); } - async function undoCopyFolderWithExistingName(folderName: string, location: string = '', destination: string, doBefore = null) { + async function undoCopyFolderWithExistingName(folderName: string, location: string = '', destination: string, doBefore?: Function) { if (doBefore) { await doBefore(); } @@ -707,11 +754,16 @@ describe('Copy content', () => { await dataTable.doubleClickOnRowByName(destination); expect(await dataTable.isItemPresent(folderName)).toBe(true, `${folderName} not present in ${destination} folder`); await dataTable.doubleClickOnRowByName(folderName); - expect(await dataTable.isItemPresent(file2InFolderExisting)).toBe(true, `${file2InFolderExisting} not present in ${folderName} in ${destination} folder`); - expect(await dataTable.isItemPresent(file1InFolderExisting)).toBe(false, `${file1InFolderExisting} present in ${folderName} in ${destination} folder`); + expect(await dataTable.isItemPresent(file2InFolderExisting)).toBe( + true, + `${file2InFolderExisting} not present in ${folderName} in ${destination} folder` + ); + expect(await dataTable.isItemPresent(file1InFolderExisting)).toBe( + false, + `${file1InFolderExisting} present in ${folderName} in ${destination} folder` + ); await page.clickTrash(); expect(await dataTable.isEmpty()).toBe(true, 'Trash is not empty'); } - }); diff --git a/e2e/suites/actions/copy-move/destination-picker-dialog.test.ts b/e2e/suites/actions/copy-move/destination-picker-dialog.test.ts index 1dbc64c0b..c4ef197c7 100755 --- a/e2e/suites/actions/copy-move/destination-picker-dialog.test.ts +++ b/e2e/suites/actions/copy-move/destination-picker-dialog.test.ts @@ -23,14 +23,7 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - ContentNodeSelectorDialog, - RepoClient, - Utils, - AdminActions -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, ContentNodeSelectorDialog, RepoClient, Utils, AdminActions } from '@alfresco/aca-testing-shared'; describe('Destination picker dialog : ', () => { const random = Utils.random(); @@ -161,7 +154,7 @@ describe('Destination picker dialog : ', () => { expect(await dataTable.isItemPresent(fileInDestination)).toBe(false, 'file is displayed'); }); - it('[C263881] Folder links are not displayed', async() => { + it('[C263881] Folder links are not displayed', async () => { await dialog.selectLocation('Personal Files'); await dataTable.doubleClickOnRowByName(destination); @@ -290,7 +283,6 @@ describe('Destination picker dialog : ', () => { }); describe('Users with different permissions', () => { - it('[C263876] Consumer user cannot select the folder as destination', async () => { await loginPage.loginWith(consumer); await page.dataTable.selectItem(file); diff --git a/e2e/suites/actions/copy-move/move.test.ts b/e2e/suites/actions/copy-move/move.test.ts index 4e25f8e83..b8e80fb33 100755 --- a/e2e/suites/actions/copy-move/move.test.ts +++ b/e2e/suites/actions/copy-move/move.test.ts @@ -23,28 +23,30 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - ContentNodeSelectorDialog, - RepoClient, - Utils -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, ContentNodeSelectorDialog, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Move content', () => { const username = `user-${Utils.random()}`; - const sourcePF = `sourcePersonal-${Utils.random()}`; let sourceIdPF; - const destinationPF = `destinationPersonal-${Utils.random()}`; let destinationIdPF; + const sourcePF = `sourcePersonal-${Utils.random()}`; + let sourceIdPF: string; + const destinationPF = `destinationPersonal-${Utils.random()}`; + let destinationIdPF: string; - const sourceRF = `sourceRecent-${Utils.random()}`; let sourceIdRF; - const destinationRF = `destinationRecent-${Utils.random()}`; let destinationIdRF; + const sourceRF = `sourceRecent-${Utils.random()}`; + let sourceIdRF: string; + const destinationRF = `destinationRecent-${Utils.random()}`; + let destinationIdRF: string; - const sourceSF = `sourceShared-${Utils.random()}`; let sourceIdSF; - const destinationSF = `destinationShared-${Utils.random()}`; let destinationIdSF; + const sourceSF = `sourceShared-${Utils.random()}`; + let sourceIdSF: string; + const destinationSF = `destinationShared-${Utils.random()}`; + let destinationIdSF: string; - const sourceFav = `sourceFavorites-${Utils.random()}`; let sourceIdFav; - const destinationFav = `destinationFavorites-${Utils.random()}`; let destinationIdFav; + const sourceFav = `sourceFavorites-${Utils.random()}`; + let sourceIdFav: string; + const destinationFav = `destinationFavorites-${Utils.random()}`; + let destinationIdFav: string; const siteName = `site-${Utils.random()}`; const folderSitePF = `folderSitePersonal-${Utils.random()}`; @@ -104,14 +106,16 @@ describe('Move content', () => { describe('from Personal Files', () => { const file1 = `file1-${Utils.random()}.txt`; - const folder1 = `folder1-${Utils.random()}`; let folder1Id; + const folder1 = `folder1-${Utils.random()}`; + let folder1Id; const fileInFolder = `fileInFolder-${Utils.random()}.txt`; const file2 = `file2-${Utils.random()}.txt`; const file3 = `file3-${Utils.random()}.txt`; const file4 = `file4-${Utils.random()}.txt`; - const folder2 = `folder2-${Utils.random()}`; let folder2Id; + const folder2 = `folder2-${Utils.random()}`; + let folder2Id; const fileInFolder2 = `fileInFolder2-${Utils.random()}.txt`; const existingFile = `existing-${Utils.random()}`; @@ -398,14 +402,19 @@ describe('Move content', () => { }); describe('from Shared Files', () => { - const file1 = `file1-${Utils.random()}.txt`; let file1Id; + const file1 = `file1-${Utils.random()}.txt`; + let file1Id; - const file2 = `file2-${Utils.random()}.txt`; let file2Id; - const file3 = `file3-${Utils.random()}.txt`; let file3Id; + const file2 = `file2-${Utils.random()}.txt`; + let file2Id; + const file3 = `file3-${Utils.random()}.txt`; + let file3Id; - const file4 = `file4-${Utils.random()}.txt`; let file4Id; + const file4 = `file4-${Utils.random()}.txt`; + let file4Id; - const existingFile = `existing-${Utils.random()}`; let existingFileId; + const existingFile = `existing-${Utils.random()}`; + let existingFileId; beforeAll(async (done) => { file1Id = (await apis.user.nodes.createFile(file1, sourceIdSF)).entry.id; @@ -520,19 +529,26 @@ describe('Move content', () => { }); describe('from Favorites', () => { - const file1 = `file1-${Utils.random()}.txt`; let file1Id; + const file1 = `file1-${Utils.random()}.txt`; + let file1Id; - const folder1 = `folder1-${Utils.random()}`; let folder1Id; + const folder1 = `folder1-${Utils.random()}`; + let folder1Id; const fileInFolder = `fileInFolder-${Utils.random()}.txt`; - const file2 = `file2-${Utils.random()}.txt`; let file2Id; - const file3 = `file3-${Utils.random()}.txt`; let file3Id; + const file2 = `file2-${Utils.random()}.txt`; + let file2Id; + const file3 = `file3-${Utils.random()}.txt`; + let file3Id; - const file4 = `file4-${Utils.random()}.txt`; let file4Id; - const folder2 = `folder2-${Utils.random()}`; let folder2Id; + const file4 = `file4-${Utils.random()}.txt`; + let file4Id; + const folder2 = `folder2-${Utils.random()}`; + let folder2Id; const fileInFolder2 = `fileInFolder2-${Utils.random()}.txt`; - const existingFile = `existing-${Utils.random()}`; let existingFileId; + const existingFile = `existing-${Utils.random()}`; + let existingFileId; const existingFolder = `existing-${Utils.random()}`; let existingId1, existingId2; @@ -713,5 +729,4 @@ describe('Move content', () => { expect(await dataTable.isItemPresent(fileInFolder2)).toBe(true, `${fileInFolder2} not present in parent folder`); }); }); - }); diff --git a/e2e/suites/actions/create-file-from-template.test.ts b/e2e/suites/actions/create-file-from-template.test.ts index 8d5fee5ed..00335dcd5 100755 --- a/e2e/suites/actions/create-file-from-template.test.ts +++ b/e2e/suites/actions/create-file-from-template.test.ts @@ -54,7 +54,8 @@ describe('Create file from template', () => { const template1InRootFolder = `template3-${random}.txt`; const template2InRootFolder = `template4-${random}.txt`; - const parent = `parent-${random}`; let parentId; + const parent = `parent-${random}`; + let parentId: string; const file1 = { name: `file1-${random}.txt` }; @@ -191,7 +192,7 @@ describe('Create file from template', () => { await selectTemplateDialog.breadcrumb.openPath(); - expect(await selectTemplateDialog.breadcrumb.getPathItems()).toEqual([ templatesFolder2, 'Node Templates' ]); + expect(await selectTemplateDialog.breadcrumb.getPathItems()).toEqual([templatesFolder2, 'Node Templates']); }); it(`[C325047] Templates list doesn't allow multiple selection`, async () => { @@ -199,14 +200,14 @@ describe('Create file from template', () => { await selectTemplateDialog.dataTable.selectItem(template1InRootFolder); expect(await selectTemplateDialog.dataTable.getSelectedRowsCount()).toEqual(1, 'Incorrect number of selected rows'); - expect(await selectTemplateDialog.dataTable.getSelectedRowsNames()).toEqual([ template1InRootFolder ], 'Incorrect selected item'); + expect(await selectTemplateDialog.dataTable.getSelectedRowsNames()).toEqual([template1InRootFolder], 'Incorrect selected item'); await Utils.pressCmd(); await selectTemplateDialog.dataTable.selectItem(template2InRootFolder); await Utils.releaseKeyPressed(); expect(await selectTemplateDialog.dataTable.getSelectedRowsCount()).toEqual(1, 'Incorrect number of selected rows'); - expect(await selectTemplateDialog.dataTable.getSelectedRowsNames()).toEqual([ template2InRootFolder ], 'Incorrect selected item'); + expect(await selectTemplateDialog.dataTable.getSelectedRowsNames()).toEqual([template2InRootFolder], 'Incorrect selected item'); }); it('[C325050] Links to files are not displayed', async () => { @@ -257,7 +258,7 @@ describe('Create file from template', () => { }); it('[C325032] Special characters in file name', async () => { - const namesWithSpecialChars = [ 'a*a', 'a"a', 'aa', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a' ]; + const namesWithSpecialChars = ['a*a', 'a"a', 'aa', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a']; for (const name of namesWithSpecialChars) { await createFromTemplateDialog.enterName(name); @@ -403,5 +404,4 @@ describe('Create file from template', () => { }); }); }); - }); diff --git a/e2e/suites/actions/create-folder-from-template.test.ts b/e2e/suites/actions/create-folder-from-template.test.ts index 1bde7cb4c..8c7f88307 100755 --- a/e2e/suites/actions/create-folder-from-template.test.ts +++ b/e2e/suites/actions/create-folder-from-template.test.ts @@ -177,7 +177,7 @@ describe('Create folder from template', () => { await selectTemplateDialog.breadcrumb.openPath(); - expect(await selectTemplateDialog.breadcrumb.getPathItems()).toEqual([ templateFolder2, 'Space Templates' ]); + expect(await selectTemplateDialog.breadcrumb.getPathItems()).toEqual([templateFolder2, 'Space Templates']); }); it(`[C325150] Templates list doesn't allow multiple selection`, async () => { @@ -185,14 +185,14 @@ describe('Create folder from template', () => { await selectTemplateDialog.dataTable.selectItem(templateFolder1); expect(await selectTemplateDialog.dataTable.getSelectedRowsCount()).toEqual(1, 'Incorrect number of selected rows'); - expect(await selectTemplateDialog.dataTable.getSelectedRowsNames()).toEqual([ templateFolder1 ], 'Incorrect selected item'); + expect(await selectTemplateDialog.dataTable.getSelectedRowsNames()).toEqual([templateFolder1], 'Incorrect selected item'); await Utils.pressCmd(); await selectTemplateDialog.dataTable.selectItem(templateFolder2); await Utils.releaseKeyPressed(); expect(await selectTemplateDialog.dataTable.getSelectedRowsCount()).toEqual(1, 'Incorrect number of selected rows'); - expect(await selectTemplateDialog.dataTable.getSelectedRowsNames()).toEqual([ templateFolder2 ], 'Incorrect selected item'); + expect(await selectTemplateDialog.dataTable.getSelectedRowsNames()).toEqual([templateFolder2], 'Incorrect selected item'); }); it('[C325153] Links to folders are not displayed', async () => { @@ -243,7 +243,7 @@ describe('Create folder from template', () => { }); it('[C325144] Special characters in folder name', async () => { - const namesWithSpecialChars = [ 'a*a', 'a"a', 'aa', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a' ]; + const namesWithSpecialChars = ['a*a', 'a"a', 'aa', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a']; for (const name of namesWithSpecialChars) { await createFromTemplateDialog.enterName(name); @@ -388,5 +388,4 @@ describe('Create folder from template', () => { expect(await createFromTemplateDialog.isDialogOpen()).toBe(true, 'dialog is not present'); }); }); - }); diff --git a/e2e/suites/actions/create-folder.test.ts b/e2e/suites/actions/create-folder.test.ts index 0251866a4..024593144 100755 --- a/e2e/suites/actions/create-folder.test.ts +++ b/e2e/suites/actions/create-folder.test.ts @@ -23,19 +23,13 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - CreateOrEditFolderDialog, - Utils, - clearTextWithBackspace, - RepoClient -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, CreateOrEditFolderDialog, Utils, clearTextWithBackspace, RepoClient } from '@alfresco/aca-testing-shared'; describe('Create folder', () => { const username = `user-${Utils.random()}`; - const parent = `parent-${Utils.random()}`; let parentId; + const parent = `parent-${Utils.random()}`; + let parentId: string; const folderName1 = `folder-${Utils.random()}`; const folderName2 = `folder-${Utils.random()}`; const folderDescription = 'description of my folder'; @@ -46,7 +40,7 @@ describe('Create folder', () => { const folderSite = `folder-site-${Utils.random()}`; const duplicateFolderSite = `folder-${Utils.random()}`; - let docLibUserSite; + let docLibUserSite: string; const apis = { admin: new RepoClient(), @@ -150,7 +144,7 @@ describe('Create folder', () => { }); it('[C216347] with folder name containing special characters', async () => { - const namesWithSpecialChars = [ 'a*a', 'a"a', 'aa', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a' ]; + const namesWithSpecialChars = ['a*a', 'a"a', 'aa', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a']; await page.dataTable.doubleClickOnRowByName(parent); await page.sidenav.openCreateFolderDialog(); @@ -258,5 +252,4 @@ describe('Create folder', () => { expect(await createDialog.isDialogOpen()).toBe(true, 'dialog is not present'); }); }); - }); diff --git a/e2e/suites/actions/create-library.test.ts b/e2e/suites/actions/create-library.test.ts index e719f4f79..d55909ec3 100755 --- a/e2e/suites/actions/create-library.test.ts +++ b/e2e/suites/actions/create-library.test.ts @@ -23,14 +23,7 @@ * along with Alfresco. If not, see . */ -import { - SITE_VISIBILITY, - LoginPage, - BrowsingPage, - CreateLibraryDialog, - Utils, - RepoClient -} from '@alfresco/aca-testing-shared'; +import { SITE_VISIBILITY, LoginPage, BrowsingPage, CreateLibraryDialog, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('Create library', () => { const username = `user-${Utils.random()}`; @@ -43,17 +36,17 @@ describe('Create library', () => { name: `site4-${Utils.random()}`, id: `site4-id-${Utils.random()}`, description: 'site4 description' - } + }; const duplicateSite = { name: `duplicate-${Utils.random()}`, id: `duplicate-${Utils.random()}` - } + }; const siteInTrash = { name: `site-trash-${Utils.random()}`, id: `site-trash-id-${Utils.random()}` - } + }; const apis = { admin: new RepoClient(), @@ -190,7 +183,7 @@ describe('Create library', () => { }); it('[C280026] Library ID cannot contain special characters', async () => { - const idWithSpecialChars = [ 'a*a', 'a"a', 'aa', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a' ]; + const idWithSpecialChars = ['a*a', 'a"a', 'aa', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a']; await page.sidenav.openCreateLibraryDialog(); await createDialog.waitForDialogToOpen(); @@ -216,5 +209,4 @@ describe('Create library', () => { expect(await dataTable.isItemPresent(`${duplicateSite.name} (${duplicateSite.id}-2)`)).toBe(true, `${duplicateSite.name} not in the list`); expect(await apis.user.sites.getTitle(`${duplicateSite.id}-2`)).toEqual(duplicateSite.name); }); - }); diff --git a/e2e/suites/actions/delete-undo-delete.test.ts b/e2e/suites/actions/delete-undo-delete.test.ts index b9976392c..a51aa4978 100755 --- a/e2e/suites/actions/delete-undo-delete.test.ts +++ b/e2e/suites/actions/delete-undo-delete.test.ts @@ -23,12 +23,7 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - RepoClient, - Utils -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Delete and undo delete', () => { const username = `user-${Utils.random()}`; @@ -61,21 +56,32 @@ describe('Delete and undo delete', () => { const file6 = `file6-${Utils.random()}.txt`; const file7 = `file7-${Utils.random()}.txt`; - const folder1 = `folder1-${Utils.random()}`; let folder1Id; - const folder2 = `folder2-${Utils.random()}`; let folder2Id; - const folder3 = `folder3-${Utils.random()}`; let folder3Id; - const folder4 = `folder4-${Utils.random()}`; let folder4Id; - const folder5 = `folder5-${Utils.random()}`; let folder5Id; - const folder6 = `folder6-${Utils.random()}`; let folder6Id; + const folder1 = `folder1-${Utils.random()}`; + let folder1Id: string; + const folder2 = `folder2-${Utils.random()}`; + let folder2Id: string; + const folder3 = `folder3-${Utils.random()}`; + let folder3Id: string; + const folder4 = `folder4-${Utils.random()}`; + let folder4Id: string; + const folder5 = `folder5-${Utils.random()}`; + let folder5Id: string; + const folder6 = `folder6-${Utils.random()}`; + let folder6Id: string; const file1InFolder = `file1InFolder-${Utils.random()}.txt`; const file2InFolder = `file2InFolder-${Utils.random()}.txt`; - const fileLocked1 = `fileLocked1-${Utils.random()}.txt`; let fileLocked1Id; - const fileLocked2 = `fileLocked2-${Utils.random()}.txt`; let fileLocked2Id; - const fileLocked3 = `fileLocked3-${Utils.random()}.txt`; let fileLocked3Id; - const fileLocked4 = `fileLocked4-${Utils.random()}.txt`; let fileLocked4Id; + const fileLocked1 = `fileLocked1-${Utils.random()}.txt`; + let fileLocked1Id: string; + const fileLocked2 = `fileLocked2-${Utils.random()}.txt`; + let fileLocked2Id: string; + const fileLocked3 = `fileLocked3-${Utils.random()}.txt`; + let fileLocked3Id: string; + const fileLocked4 = `fileLocked4-${Utils.random()}.txt`; + let fileLocked4Id: string; - const parent = `parentPF-${Utils.random()}`; let parentId; + const parent = `parentPF-${Utils.random()}`; + let parentId: string; beforeAll(async (done) => { parentId = (await apis.user.nodes.createFolder(parent)).entry.id; @@ -233,14 +239,21 @@ describe('Delete and undo delete', () => { }); describe('on Shared Files', () => { - const sharedFile1 = `sharedFile1-${Utils.random()}.txt`; let sharedFile1Id; - const sharedFile2 = `sharedFile2-${Utils.random()}.txt`; let sharedFile2Id; - const sharedFile3 = `sharedFile3-${Utils.random()}.txt`; let sharedFile3Id; - const sharedFile4 = `sharedFile4-${Utils.random()}.txt`; let sharedFile4Id; - const sharedFile5 = `sharedFile5-${Utils.random()}.txt`; let sharedFile5Id; - const sharedFile6 = `sharedFile6-${Utils.random()}.txt`; let sharedFile6Id; + const sharedFile1 = `sharedFile1-${Utils.random()}.txt`; + let sharedFile1Id: string; + const sharedFile2 = `sharedFile2-${Utils.random()}.txt`; + let sharedFile2Id: string; + const sharedFile3 = `sharedFile3-${Utils.random()}.txt`; + let sharedFile3Id: string; + const sharedFile4 = `sharedFile4-${Utils.random()}.txt`; + let sharedFile4Id: string; + const sharedFile5 = `sharedFile5-${Utils.random()}.txt`; + let sharedFile5Id: string; + const sharedFile6 = `sharedFile6-${Utils.random()}.txt`; + let sharedFile6Id: string; - const parent = `parentSF-${Utils.random()}`; let parentId; + const parent = `parentSF-${Utils.random()}`; + let parentId: string; beforeAll(async (done) => { parentId = (await apis.user.nodes.createFolder(parent)).entry.id; @@ -251,13 +264,7 @@ describe('Delete and undo delete', () => { sharedFile4Id = (await apis.user.nodes.createFile(sharedFile4, parentId)).entry.id; sharedFile5Id = (await apis.user.nodes.createFile(sharedFile5, parentId)).entry.id; sharedFile6Id = (await apis.user.nodes.createFile(sharedFile6, parentId)).entry.id; - await apis.user.shared.shareFilesByIds([ - sharedFile1Id, - sharedFile2Id, - sharedFile3Id, - sharedFile4Id, - sharedFile5Id, - sharedFile6Id]); + await apis.user.shared.shareFilesByIds([sharedFile1Id, sharedFile2Id, sharedFile3Id, sharedFile4Id, sharedFile5Id, sharedFile6Id]); await apis.user.shared.waitForApi({ expect: 6 }); await loginPage.loginWith(username); @@ -318,29 +325,47 @@ describe('Delete and undo delete', () => { }); describe('on Favorites', () => { - const parent = `parentF-${Utils.random()}`; let parentId; + const parent = `parentF-${Utils.random()}`; + let parentId: string; - const favFile1 = `favFile1-${Utils.random()}.txt`; let favFile1Id; - const favFile2 = `favFile2-${Utils.random()}.txt`; let favFile2Id; - const favFile3 = `favFile3-${Utils.random()}.txt`; let favFile3Id; - const favFile4 = `favFile4-${Utils.random()}.txt`; let favFile4Id; - const favFile5 = `favFile5-${Utils.random()}.txt`; let favFile5Id; - const favFile6 = `favFile6-${Utils.random()}.txt`; let favFile6Id; - const favFile7 = `favFile7-${Utils.random()}.txt`; let favFile7Id; + const favFile1 = `favFile1-${Utils.random()}.txt`; + let favFile1Id: string; + const favFile2 = `favFile2-${Utils.random()}.txt`; + let favFile2Id: string; + const favFile3 = `favFile3-${Utils.random()}.txt`; + let favFile3Id: string; + const favFile4 = `favFile4-${Utils.random()}.txt`; + let favFile4Id: string; + const favFile5 = `favFile5-${Utils.random()}.txt`; + let favFile5Id: string; + const favFile6 = `favFile6-${Utils.random()}.txt`; + let favFile6Id: string; + const favFile7 = `favFile7-${Utils.random()}.txt`; + let favFile7Id: string; - const favFolder1 = `favFolder1-${Utils.random()}`; let favFolder1Id; - const favFolder2 = `favFolder2-${Utils.random()}`; let favFolder2Id; - const favFolder3 = `favFolder3-${Utils.random()}`; let favFolder3Id; - const favFolder4 = `favFolder4-${Utils.random()}`; let favFolder4Id; - const favFolder5 = `favFolder5-${Utils.random()}`; let favFolder5Id; - const favFolder6 = `favFolder6-${Utils.random()}`; let favFolder6Id; + const favFolder1 = `favFolder1-${Utils.random()}`; + let favFolder1Id: string; + const favFolder2 = `favFolder2-${Utils.random()}`; + let favFolder2Id: string; + const favFolder3 = `favFolder3-${Utils.random()}`; + let favFolder3Id: string; + const favFolder4 = `favFolder4-${Utils.random()}`; + let favFolder4Id: string; + const favFolder5 = `favFolder5-${Utils.random()}`; + let favFolder5Id: string; + const favFolder6 = `favFolder6-${Utils.random()}`; + let favFolder6Id: string; const file1InFolder = `file1InFolder-${Utils.random()}.txt`; const file2InFolder = `file2InFolder-${Utils.random()}.txt`; - const fileLocked1 = `fileLocked1-${Utils.random()}.txt`; let fileLocked1Id; - const fileLocked2 = `fileLocked2-${Utils.random()}.txt`; let fileLocked2Id; - const fileLocked3 = `fileLocked3-${Utils.random()}.txt`; let fileLocked3Id; - const fileLocked4 = `fileLocked4-${Utils.random()}.txt`; let fileLocked4Id; + const fileLocked1 = `fileLocked1-${Utils.random()}.txt`; + let fileLocked1Id: string; + const fileLocked2 = `fileLocked2-${Utils.random()}.txt`; + let fileLocked2Id: string; + const fileLocked3 = `fileLocked3-${Utils.random()}.txt`; + let fileLocked3Id: string; + const fileLocked4 = `fileLocked4-${Utils.random()}.txt`; + let fileLocked4Id: string; beforeAll(async (done) => { parentId = (await apis.user.nodes.createFolder(parent)).entry.id; @@ -372,8 +397,8 @@ describe('Delete and undo delete', () => { await apis.user.nodes.lockFile(fileLocked3Id, 'FULL'); await apis.user.nodes.lockFile(fileLocked4Id, 'FULL'); - await apis.user.favorites.addFavoritesByIds('file', [ favFile1Id, favFile2Id, favFile3Id, favFile4Id, favFile5Id, favFile6Id, favFile7Id ]); - await apis.user.favorites.addFavoritesByIds('folder', [ favFolder1Id, favFolder2Id, favFolder3Id, favFolder4Id, favFolder5Id, favFolder6Id ]); + await apis.user.favorites.addFavoritesByIds('file', [favFile1Id, favFile2Id, favFile3Id, favFile4Id, favFile5Id, favFile6Id, favFile7Id]); + await apis.user.favorites.addFavoritesByIds('folder', [favFolder1Id, favFolder2Id, favFolder3Id, favFolder4Id, favFolder5Id, favFolder6Id]); await apis.user.favorites.waitForApi({ expect: 13 }); await loginPage.loginWith(username); @@ -501,7 +526,8 @@ describe('Delete and undo delete', () => { }); describe('on Recent Files', () => { - const parent = `parentRF-${Utils.random()}`; let parentId; + const parent = `parentRF-${Utils.random()}`; + let parentId: string; const recentFile1 = `recentFile1-${Utils.random()}.txt`; const recentFile2 = `recentFile2-${Utils.random()}.txt`; diff --git a/e2e/suites/actions/download.test.ts b/e2e/suites/actions/download.test.ts index e7a19e815..e6fb7a310 100755 --- a/e2e/suites/actions/download.test.ts +++ b/e2e/suites/actions/download.test.ts @@ -23,18 +23,13 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - SearchResultsPage, - RepoClient, - Utils -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, SearchResultsPage, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Download', () => { const username = `user-${Utils.random()}`; - const parent = `parent-${Utils.random()}`; let parentId; + const parent = `parent-${Utils.random()}`; + let parentId: string; const filePersonal = `filePersonal-${Utils.random()}.txt`; const fileRecent1 = `fileRecent1-${Utils.random()}.txt`; @@ -58,7 +53,12 @@ describe('Download', () => { const unzippedFavorites = `unzippedFavorites-${Utils.random()}`; const unzippedSearch = `unzippedSearch-${Utils.random()}`; - let fileShared1Id, fileShared2Id, fileFavoritesId, folderPersonalId, folderFavoritesId, folderSearchId; + let fileShared1Id: string; + let fileShared2Id: string; + let fileFavoritesId: string; + let folderPersonalId: string; + let folderFavoritesId: string; + let folderSearchId: string; const archiveZip = 'archive.zip'; @@ -73,7 +73,7 @@ describe('Download', () => { const searchResultsPage = new SearchResultsPage(); const { searchInput } = searchResultsPage.header; - beforeAll(async done => { + beforeAll(async (done) => { await apis.admin.people.createUser({ username }); parentId = (await apis.user.nodes.createFolder(parent)).entry.id; @@ -116,7 +116,6 @@ describe('Download', () => { }); describe('on Personal Files', () => { - beforeEach(async (done) => { await page.clickPersonalFilesAndWait(); await dataTable.doubleClickOnRowByName(parent); @@ -153,13 +152,14 @@ describe('Download', () => { expect(await Utils.fileExistsOnOS(filePersonal, unzippedPersonal)).toBe(true, `${filePersonal} not found in unzipped folder`); expect(await Utils.fileExistsOnOS(folderPersonal, unzippedPersonal)).toBe(true, `${folderPersonal} not found in unzipped folder`); - expect(await Utils.fileExistsOnOS(fileInFolderPersonal, unzippedPersonal, folderPersonal)).toBe(true, `${fileInFolderPersonal} not found in unzipped folder in ${folderPersonal}`) + expect(await Utils.fileExistsOnOS(fileInFolderPersonal, unzippedPersonal, folderPersonal)).toBe( + true, + `${fileInFolderPersonal} not found in unzipped folder in ${folderPersonal}` + ); }); - }); describe('on Favorites', () => { - beforeAll(async (done) => { await apis.user.favorites.waitForApi({ expect: 2 }); done(); @@ -200,13 +200,14 @@ describe('Download', () => { expect(await Utils.fileExistsOnOS(fileFavorites, unzippedFavorites)).toBe(true, `${fileFavorites} not found in unzipped folder`); expect(await Utils.fileExistsOnOS(folderFavorites, unzippedFavorites)).toBe(true, `${folderFavorites} not found in unzipped folder`); - expect(await Utils.fileExistsOnOS(fileInFolderFavorites, unzippedFavorites, folderFavorites)).toBe(true, `${fileInFolderFavorites} not found in unzipped folder in ${folderFavorites}`) + expect(await Utils.fileExistsOnOS(fileInFolderFavorites, unzippedFavorites, folderFavorites)).toBe( + true, + `${fileInFolderFavorites} not found in unzipped folder in ${folderFavorites}` + ); }); - }); describe('on Shared Files', () => { - beforeAll(async (done) => { await apis.user.shared.waitForApi({ expect: 2 }); done(); @@ -235,11 +236,9 @@ describe('Download', () => { expect(await Utils.fileExistsOnOS(fileShared1, unzippedShared)).toBe(true, `${fileShared1} not found in unzipped folder`); expect(await Utils.fileExistsOnOS(fileShared2, unzippedShared)).toBe(true, `${fileShared2} not found in unzipped folder`); }); - }); describe('on Recent Files', () => { - beforeAll(async (done) => { await apis.user.search.waitForApi(username, { expect: 10 }); done(); @@ -268,11 +267,9 @@ describe('Download', () => { expect(await Utils.fileExistsOnOS(fileRecent1, unzippedRecent)).toBe(true, `${fileRecent1} not found in unzipped folder`); expect(await Utils.fileExistsOnOS(fileRecent2, unzippedRecent)).toBe(true, `${fileRecent2} not found in unzipped folder`); }); - }); describe('on Search Results', () => { - beforeEach(async (done) => { await page.clickPersonalFilesAndWait(); await searchInput.clickSearchButton(); @@ -311,9 +308,10 @@ describe('Download', () => { expect(await Utils.fileExistsOnOS(fileSearch, unzippedSearch)).toBe(true, `${fileSearch} not found in unzipped folder`); expect(await Utils.fileExistsOnOS(folderSearch, unzippedSearch)).toBe(true, `${folderSearch} not found in unzipped folder`); - expect(await Utils.fileExistsOnOS(fileInFolderSearch, unzippedSearch, folderSearch)).toBe(true, `${fileInFolderSearch} not found in unzipped folder in ${folderSearch}`) + expect(await Utils.fileExistsOnOS(fileInFolderSearch, unzippedSearch, folderSearch)).toBe( + true, + `${fileInFolderSearch} not found in unzipped folder in ${folderSearch}` + ); }); - }); - }); diff --git a/e2e/suites/actions/edit-folder.test.ts b/e2e/suites/actions/edit-folder.test.ts index 792dc54c4..0e3f1092b 100755 --- a/e2e/suites/actions/edit-folder.test.ts +++ b/e2e/suites/actions/edit-folder.test.ts @@ -37,7 +37,8 @@ import { describe('Edit folder', () => { const username = `user-${Utils.random()}`; - const parent = `parent-${Utils.random()}`; let parentId; + const parent = `parent-${Utils.random()}`; + let parentId: string; const folderName = `folder-${Utils.random()}`; const folderDescription = 'my folder description'; @@ -52,16 +53,21 @@ describe('Edit folder', () => { const siteName = `site-${Utils.random()}`; const folderSite = `folder-site-${Utils.random()}`; - const folderSiteToEdit = `folder-site-${Utils.random()}`; let folderSiteToEditId; + const folderSiteToEdit = `folder-site-${Utils.random()}`; + let folderSiteToEditId: string; const duplicateFolderSite = `folder-${Utils.random()}`; - let docLibUserSite; + let docLibUserSite: string; - const folderFavorite = `folder-fav-${Utils.random()}`; let folderFavoriteId; - const folderFavoriteToEdit = `folder-fav-${Utils.random()}`; let folderFavoriteToEditId; - const folderFavoriteDuplicate = `folder-fav-${Utils.random()}`; let folderFavoriteDuplicateId; + const folderFavorite = `folder-fav-${Utils.random()}`; + let folderFavoriteId: string; + const folderFavoriteToEdit = `folder-fav-${Utils.random()}`; + let folderFavoriteToEditId: string; + const folderFavoriteDuplicate = `folder-fav-${Utils.random()}`; + let folderFavoriteDuplicateId: string; const folderSearch = `folder-search-${Utils.random()}`; - const folderSearchToEdit = `folder-search-${Utils.random()}`; let folderSearchToEditId; + const folderSearchToEdit = `folder-search-${Utils.random()}`; + let folderSearchToEditId: string; const folderSearchDuplicate = `folder-search-${Utils.random()}`; const apis = { diff --git a/e2e/suites/actions/edit-offline.test.ts b/e2e/suites/actions/edit-offline.test.ts index 64fa4ab45..923fb3a07 100755 --- a/e2e/suites/actions/edit-offline.test.ts +++ b/e2e/suites/actions/edit-offline.test.ts @@ -23,30 +23,35 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - FILES, - RepoClient, - Utils -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, FILES, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Edit offline', () => { const username = `user-${Utils.random()}`; - const file1 = `file1-${Utils.random()}.docx`; let file1Id; - const fileLocked = `file-locked-${Utils.random()}.docx`; let fileLockedId; - const fileLocked2 = `file-locked2-${Utils.random()}.docx`; let fileLocked2Id; + const file1 = `file1-${Utils.random()}.docx`; + let file1Id: string; + const fileLocked = `file-locked-${Utils.random()}.docx`; + let fileLockedId: string; + const fileLocked2 = `file-locked2-${Utils.random()}.docx`; + let fileLocked2Id: string; - const fileSearch1 = `file-search-1-${Utils.random()}.docx`; let fileSearch1Id; - const fileSearchLocked = `file-search-locked-${Utils.random()}.docx`; let fileSearchLockedId; - const fileSearchLocked2 = `file-search-locked2-${Utils.random()}.docx`; let fileSearchLocked2Id; + const fileSearch1 = `file-search-1-${Utils.random()}.docx`; + let fileSearch1Id: string; + const fileSearchLocked = `file-search-locked-${Utils.random()}.docx`; + let fileSearchLockedId: string; + const fileSearchLocked2 = `file-search-locked2-${Utils.random()}.docx`; + let fileSearchLocked2Id: string; - const parentPF = `parentPersonal-${Utils.random()}`; let parentPFId; - const parentSF = `parentShared-${Utils.random()}`; let parentSFId; - const parentRF = `parentRecent-${Utils.random()}`; let parentRFId; - const parentFav = `parentFav-${Utils.random()}`; let parentFavId; - const parentSearch = `parentSearch-${Utils.random()}`; let parentSearchId; + const parentPF = `parentPersonal-${Utils.random()}`; + let parentPFId: string; + const parentSF = `parentShared-${Utils.random()}`; + let parentSFId: string; + const parentRF = `parentRecent-${Utils.random()}`; + let parentRFId: string; + const parentFav = `parentFav-${Utils.random()}`; + let parentFavId: string; + const parentSearch = `parentSearch-${Utils.random()}`; + let parentSearchId: string; const apis = { admin: new RepoClient(), diff --git a/e2e/suites/actions/library-actions.test.ts b/e2e/suites/actions/library-actions.test.ts index 9b546d245..7eb580da3 100755 --- a/e2e/suites/actions/library-actions.test.ts +++ b/e2e/suites/actions/library-actions.test.ts @@ -23,15 +23,7 @@ * along with Alfresco. If not, see . */ -import { - SITE_VISIBILITY, - SITE_ROLES, - LoginPage, - BrowsingPage, - Utils, - ConfirmDialog, - RepoClient -} from '@alfresco/aca-testing-shared'; +import { SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, ConfirmDialog, RepoClient } from '@alfresco/aca-testing-shared'; describe('Library actions', () => { const username = `user-${Utils.random()}`; @@ -126,8 +118,7 @@ describe('Library actions', () => { }); describe('Join a public library', () => { - - beforeAll(async done => { + beforeAll(async (done) => { await apis.admin.sites.createSite(sitePublic1Admin); await apis.user.favorites.addFavoriteById('site', sitePublic1Admin); done(); @@ -152,12 +143,10 @@ describe('Library actions', () => { expect(await dataTable.getLibraryRole(siteSearchPublic1Admin)).toEqual('Consumer'); }); - }); describe('Join a moderated library', () => { - - beforeAll(async done => { + beforeAll(async (done) => { await apis.admin.sites.createSite(siteModerated1Admin, SITE_VISIBILITY.MODERATED); await apis.user.favorites.addFavoriteById('site', siteModerated1Admin); await apis.user.queries.waitForSites(siteSearchModerated1Admin, { expect: 1 }); @@ -187,12 +176,10 @@ describe('Library actions', () => { const hasJoinRequest = await apis.user.sites.hasMembershipRequest(siteSearchModerated1Admin); expect(hasJoinRequest).toBe(true, `Join request does not exist on ${siteSearchModerated1Admin}`); }); - }); describe('Leave a library', () => { - - beforeAll(async done => { + beforeAll(async (done) => { await apis.admin.sites.createSite(sitePublic2Admin); await apis.admin.sites.createSite(sitePublic3Admin); await apis.admin.sites.createSite(sitePublic4Admin); @@ -281,8 +268,7 @@ describe('Library actions', () => { }); describe('Cancel join', () => { - - beforeAll(async done => { + beforeAll(async (done) => { await apis.admin.sites.createSite(siteModerated2Admin, SITE_VISIBILITY.MODERATED); await apis.user.favorites.addFavoriteById('site', siteModerated2Admin); await apis.user.sites.requestToJoin(siteModerated2Admin); @@ -316,12 +302,10 @@ describe('Library actions', () => { const hasJoinRequest = await apis.user.sites.hasMembershipRequest(siteSearchModerated2Admin); expect(hasJoinRequest).toBe(false, `Join request exists on ${siteSearchModerated2Admin}`); }); - }); describe('Mark library as favorite', () => { - - beforeAll(async done => { + beforeAll(async (done) => { await apis.admin.sites.createSite(sitePublic6Admin); await apis.admin.sites.addSiteMember(sitePublic6Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); await apis.user.queries.waitForSites(siteSearchPublic3Admin, { expect: 1 }); @@ -345,14 +329,15 @@ describe('Library actions', () => { await dataTable.selectItem(siteSearchPublic3Admin); await toolbar.clickMoreActionsFavorite(); - expect(await apis.user.favorites.isFavoriteWithRetry(siteSearchPublic3Admin, { expect: true })).toBe(true, `${siteSearchPublic3Admin} not favorite`); + expect(await apis.user.favorites.isFavoriteWithRetry(siteSearchPublic3Admin, { expect: true })).toBe( + true, + `${siteSearchPublic3Admin} not favorite` + ); }); - }); describe('Remove library from favorites', () => { - - beforeAll(async done => { + beforeAll(async (done) => { await apis.admin.sites.createSite(sitePublic7Admin); await apis.admin.sites.createSite(sitePublic8Admin); await apis.user.favorites.addFavoriteById('site', sitePublic7Admin); @@ -391,13 +376,15 @@ describe('Library actions', () => { await dataTable.selectItem(siteSearchPublic4Admin); await toolbar.clickMoreActionsRemoveFavorite(); - expect(await apis.user.favorites.isFavoriteWithRetry(siteSearchPublic4Admin, { expect: false })).toBe(false, `${siteSearchPublic4Admin} still favorite`); + expect(await apis.user.favorites.isFavoriteWithRetry(siteSearchPublic4Admin, { expect: false })).toBe( + false, + `${siteSearchPublic4Admin} still favorite` + ); }); }); describe('Delete a library', () => { - - beforeAll(async done => { + beforeAll(async (done) => { await apis.user.sites.createSite(siteForDelete1); await apis.user.sites.createSite(siteForDelete2); await apis.user.queries.waitForSites(siteSearchForDelete, { expect: 1 }); @@ -435,5 +422,4 @@ describe('Library actions', () => { expect(await dataTable.isItemPresent(siteSearchForDelete)).toBe(false, `${siteSearchForDelete} still displayed`); }); }); - }); diff --git a/e2e/suites/actions/mark-favorite.test.ts b/e2e/suites/actions/mark-favorite.test.ts index 2ccc4759f..a7a1ad3a3 100644 --- a/e2e/suites/actions/mark-favorite.test.ts +++ b/e2e/suites/actions/mark-favorite.test.ts @@ -23,17 +23,10 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - SITE_VISIBILITY, - RepoClient, - Utils -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, SITE_VISIBILITY, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Mark items as favorites', () => { const username = `user-${Utils.random()}`; - const parent = `parent-${Utils.random()}`; const fileNotFavUI = `fileNotFavUI-${Utils.random()}.txt`; @@ -48,7 +41,17 @@ describe('Mark items as favorites', () => { const fileFav4 = `fileFav4-${Utils.random()}.txt`; const folder = `folder-${Utils.random()}`; - let fileFavUIId, fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id, fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id, folderId, parentId; + let fileFavUIId: string; + let fileNotFav1Id: string; + let fileNotFav2Id: string; + let fileNotFav3Id: string; + let fileNotFav4Id: string; + let fileFav1Id: string; + let fileFav2Id: string; + let fileFav3Id: string; + let fileFav4Id: string; + let folderId: string; + let parentId: string; const fileSearchNotFav1 = `search-fileNotFav1-${Utils.random()}.txt`; const fileSearchNotFav2 = `search-fileNotFav2-${Utils.random()}.txt`; @@ -60,8 +63,15 @@ describe('Mark items as favorites', () => { const fileSearchFav4 = `search-fileFav4-${Utils.random()}.txt`; const folderSearch = `search-folder-${Utils.random()}`; - let fileSearchNotFav1Id, fileSearchNotFav2Id, fileSearchNotFav3Id, fileSearchNotFav4Id; - let fileSearchFav1Id, fileSearchFav2Id, fileSearchFav3Id, fileSearchFav4Id, folderSearchId; + let fileSearchNotFav1Id: string; + let fileSearchNotFav2Id: string; + let fileSearchNotFav3Id: string; + let fileSearchNotFav4Id: string; + let fileSearchFav1Id: string; + let fileSearchFav2Id: string; + let fileSearchFav3Id: string; + let fileSearchFav4Id: string; + let folderSearchId: string; const apis = { admin: new RepoClient(), @@ -100,14 +110,14 @@ describe('Mark items as favorites', () => { fileSearchFav4Id = (await apis.user.nodes.createFile(fileSearchFav4, parentId)).entry.id; folderSearchId = (await apis.user.nodes.createFolder(folderSearch, parentId)).entry.id; - const currentFavoritesFiles = (await apis.user.favorites.getFavorites()).list.pagination.totalItems; - await apis.user.favorites.addFavoritesByIds('file', [ fileFavUIId, fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]); - await apis.user.favorites.addFavoritesByIds('file', [ fileSearchFav1Id, fileSearchFav2Id, fileSearchFav3Id, fileSearchFav4Id ]); - await apis.user.favorites.waitForApi({ expect: currentFavoritesFiles + 9 }); + const currentFavoritesFiles = (await apis.user.favorites.getFavorites()).list.pagination.totalItems; + await apis.user.favorites.addFavoritesByIds('file', [fileFavUIId, fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id]); + await apis.user.favorites.addFavoritesByIds('file', [fileSearchFav1Id, fileSearchFav2Id, fileSearchFav3Id, fileSearchFav4Id]); + await apis.user.favorites.waitForApi({ expect: currentFavoritesFiles + 9 }); const currentSharedFiles = (await apis.user.shared.getSharedLinks()).list.pagination.totalItems; - await apis.user.shared.shareFilesByIds([ fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]); - await apis.user.shared.shareFilesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]); + await apis.user.shared.shareFilesByIds([fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id]); + await apis.user.shared.shareFilesByIds([fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id]); await apis.user.shared.waitForApi({ expect: currentSharedFiles + 8 }); await loginPage.loginWith(username); @@ -127,12 +137,11 @@ describe('Mark items as favorites', () => { describe('on Personal Files', () => { afterAll(async (done) => { try { - await apis.user.favorites.addFavoritesByIds('file', [ fileFavUIId, fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]); + await apis.user.favorites.addFavoritesByIds('file', [fileFavUIId, fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id]); await apis.user.favorites.addFavoriteById('folder', folderId); - await apis.user.favorites.removeFavoritesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]); + await apis.user.favorites.removeFavoritesByIds([fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id]); await apis.user.favorites.waitForApi({ expect: 10 }); - } catch (error) { - } + } catch (error) {} done(); }); @@ -151,7 +160,7 @@ describe('Mark items as favorites', () => { }); it('[C217187] Favorite action has empty star icon for multiple selection of items when some are not favorite', async () => { - await dataTable.selectMultipleItems([ fileNotFavUI, fileFavUI ]); + await dataTable.selectMultipleItems([fileNotFavUI, fileFavUI]); await toolbar.openMoreMenu(); expect(await toolbar.menu.getItemIconText('Favorite')).toEqual('star_border'); @@ -188,7 +197,7 @@ describe('Mark items as favorites', () => { }); it('[C217192] favorite multiple items - all unfavorite', async () => { - await dataTable.selectMultipleItems([ fileNotFav2, fileNotFav3 ]); + await dataTable.selectMultipleItems([fileNotFav2, fileNotFav3]); await toolbar.clickMoreActionsFavorite(); expect(await apis.user.favorites.isFavoriteWithRetry(fileNotFav2Id, { expect: true })).toBe(true, `${fileNotFav2} not marked as favorite`); @@ -196,7 +205,7 @@ describe('Mark items as favorites', () => { }); it('[C217194] favorite multiple items - some favorite and some unfavorite', async () => { - await dataTable.selectMultipleItems([ fileNotFav4, fileFav2 ]); + await dataTable.selectMultipleItems([fileNotFav4, fileFav2]); await toolbar.clickMoreActionsFavorite(); expect(await apis.user.favorites.isFavoriteWithRetry(fileNotFav4Id, { expect: true })).toBe(true, `${fileNotFav4} not marked as favorite`); @@ -204,7 +213,7 @@ describe('Mark items as favorites', () => { }); it('[C217193] unfavorite multiple items', async () => { - await dataTable.selectMultipleItems([ fileFav3, fileFav4 ]) + await dataTable.selectMultipleItems([fileFav3, fileFav4]); await toolbar.clickMoreActionsRemoveFavorite(); expect(await apis.user.favorites.isFavoriteWithRetry(fileFav3Id, { expect: false })).toBe(false, `${fileFav3} marked as favorite`); @@ -215,12 +224,11 @@ describe('Mark items as favorites', () => { describe('on Recent Files', () => { afterAll(async (done) => { try { - const currentFavoritesFiles = (await apis.user.favorites.getFavorites()).list.pagination.totalItems; - await apis.user.favorites.addFavoritesByIds('file', [ fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]); - await apis.user.favorites.removeFavoritesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]); + const currentFavoritesFiles = (await apis.user.favorites.getFavorites()).list.pagination.totalItems; + await apis.user.favorites.addFavoritesByIds('file', [fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id]); + await apis.user.favorites.removeFavoritesByIds([fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id]); await apis.user.favorites.waitForApi({ expect: currentFavoritesFiles - 1 }); - } catch (error) { - } + } catch (error) {} done(); }); @@ -245,7 +253,7 @@ describe('Mark items as favorites', () => { }); it('[C280355] favorite multiple items - all unfavorite', async () => { - await dataTable.selectMultipleItems([ fileNotFav2, fileNotFav3 ]); + await dataTable.selectMultipleItems([fileNotFav2, fileNotFav3]); await toolbar.clickMoreActionsFavorite(); expect(await apis.user.favorites.isFavoriteWithRetry(fileNotFav2Id, { expect: true })).toBe(true, `${fileNotFav2} not marked as favorite`); @@ -253,7 +261,7 @@ describe('Mark items as favorites', () => { }); it('[C280357] favorite multiple items - some favorite and some unfavorite', async () => { - await dataTable.selectMultipleItems([ fileNotFav4, fileFav2 ]); + await dataTable.selectMultipleItems([fileNotFav4, fileFav2]); await toolbar.clickMoreActionsFavorite(); expect(await apis.user.favorites.isFavoriteWithRetry(fileNotFav4Id, { expect: true })).toBe(true, `${fileNotFav4} not marked as favorite`); @@ -261,7 +269,7 @@ describe('Mark items as favorites', () => { }); it('[C280356] unfavorite multiple items', async () => { - await dataTable.selectMultipleItems([ fileFav3, fileFav4 ]); + await dataTable.selectMultipleItems([fileFav3, fileFav4]); await toolbar.clickMoreActionsRemoveFavorite(); expect(await apis.user.favorites.isFavoriteWithRetry(fileFav3Id, { expect: false })).toBe(false, `${fileFav3} marked as favorite`); @@ -272,11 +280,10 @@ describe('Mark items as favorites', () => { describe('on Shared Files', () => { afterAll(async (done) => { try { - await apis.user.favorites.addFavoritesByIds('file', [ fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]); - await apis.user.favorites.removeFavoritesByIds([ fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id ]); + await apis.user.favorites.addFavoritesByIds('file', [fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id]); + await apis.user.favorites.removeFavoritesByIds([fileNotFav1Id, fileNotFav2Id, fileNotFav3Id, fileNotFav4Id]); await apis.user.favorites.waitForApi({ expect: 10 }); - } catch (error) { - } + } catch (error) {} done(); }); @@ -301,7 +308,7 @@ describe('Mark items as favorites', () => { }); it('[C280365] favorite multiple items - all unfavorite', async () => { - await dataTable.selectMultipleItems([ fileNotFav2, fileNotFav3 ]); + await dataTable.selectMultipleItems([fileNotFav2, fileNotFav3]); await toolbar.clickMoreActionsFavorite(); expect(await apis.user.favorites.isFavoriteWithRetry(fileNotFav2Id, { expect: true })).toBe(true, `${fileNotFav2} not marked as favorite`); @@ -309,7 +316,7 @@ describe('Mark items as favorites', () => { }); it('[C280367] favorite multiple items - some favorite and some unfavorite', async () => { - await dataTable.selectMultipleItems([ fileNotFav4, fileFav2 ]); + await dataTable.selectMultipleItems([fileNotFav4, fileFav2]); await toolbar.clickMoreActionsFavorite(); expect(await apis.user.favorites.isFavoriteWithRetry(fileNotFav4Id, { expect: true })).toBe(true, `${fileNotFav4} not marked as favorite`); @@ -317,7 +324,7 @@ describe('Mark items as favorites', () => { }); it('[C280366] unfavorite multiple items', async () => { - await dataTable.selectMultipleItems([ fileFav3, fileFav4 ]); + await dataTable.selectMultipleItems([fileFav3, fileFav4]); await toolbar.clickMoreActionsRemoveFavorite(); expect(await apis.user.favorites.isFavoriteWithRetry(fileFav3Id, { expect: false })).toBe(false, `${fileFav3} marked as favorite`); @@ -328,10 +335,9 @@ describe('Mark items as favorites', () => { describe('on Favorites', () => { afterAll(async (done) => { try { - await apis.user.favorites.addFavoritesByIds('file', [ fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id ]); + await apis.user.favorites.addFavoritesByIds('file', [fileFav1Id, fileFav2Id, fileFav3Id, fileFav4Id]); await apis.user.favorites.waitForApi({ expect: 10 }); - } catch (error) { - } + } catch (error) {} done(); }); @@ -351,7 +357,7 @@ describe('Mark items as favorites', () => { }); it('[C280374] unfavorite multiple items', async () => { - await dataTable.selectMultipleItems([ fileFav3, fileFav4 ]); + await dataTable.selectMultipleItems([fileFav3, fileFav4]); await toolbar.clickMoreActionsRemoveFavorite(); expect(await apis.user.favorites.isFavoriteWithRetry(fileFav3Id, { expect: false })).toBe(false, `${fileFav3} marked as favorite`); @@ -370,7 +376,7 @@ describe('Mark items as favorites', () => { }); describe('on Search Results', () => { - beforeAll(async done => { + beforeAll(async (done) => { await apis.user.search.waitForNodes('search-f', { expect: 9 }); await searchInput.clickSearchButton(); await searchInput.checkFilesAndFolders(); @@ -379,7 +385,7 @@ describe('Mark items as favorites', () => { done(); }); - afterAll(async done => { + afterAll(async (done) => { await page.header.expandSideNav(); await page.clickPersonalFiles(); done(); @@ -389,7 +395,10 @@ describe('Mark items as favorites', () => { await dataTable.selectItem(fileSearchNotFav1); await toolbar.clickMoreActionsFavorite(); - expect(await apis.user.favorites.isFavoriteWithRetry(fileSearchNotFav1Id, { expect: true })).toBe(true, `${fileSearchNotFav1} not marked as favorite`); + expect(await apis.user.favorites.isFavoriteWithRetry(fileSearchNotFav1Id, { expect: true })).toBe( + true, + `${fileSearchNotFav1} not marked as favorite` + ); }); it('[C306971] favorite a folder', async () => { @@ -403,27 +412,42 @@ describe('Mark items as favorites', () => { await dataTable.selectItem(fileSearchFav1); await toolbar.clickMoreActionsRemoveFavorite(); - expect(await apis.user.favorites.isFavoriteWithRetry(fileSearchFav1Id, { expect: false })).toBe(false, `${fileSearchFav1} is marked as favorite`); + expect(await apis.user.favorites.isFavoriteWithRetry(fileSearchFav1Id, { expect: false })).toBe( + false, + `${fileSearchFav1} is marked as favorite` + ); }); it('[C306968] favorite multiple items - all unfavorite', async () => { - await dataTable.selectMultipleItems([ fileSearchNotFav2, fileSearchNotFav3 ]); + await dataTable.selectMultipleItems([fileSearchNotFav2, fileSearchNotFav3]); await toolbar.clickMoreActionsFavorite(); - expect(await apis.user.favorites.isFavoriteWithRetry(fileSearchNotFav2Id, { expect: true })).toBe(true, `${fileSearchNotFav2} not marked as favorite`); - expect(await apis.user.favorites.isFavoriteWithRetry(fileSearchNotFav3Id, { expect: true })).toBe(true, `${fileSearchNotFav3} not marked as favorite`); + expect(await apis.user.favorites.isFavoriteWithRetry(fileSearchNotFav2Id, { expect: true })).toBe( + true, + `${fileSearchNotFav2} not marked as favorite` + ); + expect(await apis.user.favorites.isFavoriteWithRetry(fileSearchNotFav3Id, { expect: true })).toBe( + true, + `${fileSearchNotFav3} not marked as favorite` + ); }); it('[C306970] favorite multiple items - some favorite and some unfavorite', async () => { - await dataTable.selectMultipleItems([ fileSearchNotFav4, fileSearchFav2 ]); + await dataTable.selectMultipleItems([fileSearchNotFav4, fileSearchFav2]); await toolbar.clickMoreActionsFavorite(); - expect(await apis.user.favorites.isFavoriteWithRetry(fileSearchNotFav4Id, { expect: true })).toBe(true, `${fileSearchNotFav4} not marked as favorite`); - expect(await apis.user.favorites.isFavoriteWithRetry(fileSearchFav2Id, { expect: true })).toBe(true, `${fileSearchFav2} not marked as favorite`); + expect(await apis.user.favorites.isFavoriteWithRetry(fileSearchNotFav4Id, { expect: true })).toBe( + true, + `${fileSearchNotFav4} not marked as favorite` + ); + expect(await apis.user.favorites.isFavoriteWithRetry(fileSearchFav2Id, { expect: true })).toBe( + true, + `${fileSearchFav2} not marked as favorite` + ); }); it('[C306969] unfavorite multiple items', async () => { - await dataTable.selectMultipleItems([ fileSearchFav3, fileSearchFav4 ]) + await dataTable.selectMultipleItems([fileSearchFav3, fileSearchFav4]); await toolbar.clickMoreActionsRemoveFavorite(); expect(await apis.user.favorites.isFavoriteWithRetry(fileSearchFav3Id, { expect: false })).toBe(false, `${fileSearchFav3} marked as favorite`); @@ -431,7 +455,7 @@ describe('Mark items as favorites', () => { }); }); - describe ('on File Libraries', () => { + describe('on File Libraries', () => { const siteName = `site-public-${Utils.random()}`; const folderSite = `folderSite-${Utils.random()}`; @@ -445,8 +469,15 @@ describe('Mark items as favorites', () => { const fileSiteFav3 = `fileSiteFav3-${Utils.random()}.txt`; const fileSiteFav4 = `fileSiteFav4-${Utils.random()}.txt`; - let folderSiteId, fileSiteNotFav1Id, fileSiteNotFav2Id, fileSiteNotFav3Id, fileSiteNotFav4Id; - let fileSiteFav1Id, fileSiteFav2Id, fileSiteFav3Id, fileSiteFav4Id; + let folderSiteId: string; + let fileSiteNotFav1Id: string; + let fileSiteNotFav2Id: string; + let fileSiteNotFav3Id: string; + let fileSiteNotFav4Id: string; + let fileSiteFav1Id: string; + let fileSiteFav2Id: string; + let fileSiteFav3Id: string; + let fileSiteFav4Id: string; beforeAll(async (done) => { await apis.user.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC); @@ -462,7 +493,7 @@ describe('Mark items as favorites', () => { fileSiteFav3Id = (await apis.user.nodes.createFile(fileSiteFav3, folderSiteId)).entry.id; fileSiteFav4Id = (await apis.user.nodes.createFile(fileSiteFav4, folderSiteId)).entry.id; - await apis.user.favorites.addFavoritesByIds('file', [ fileSiteFav1Id, fileSiteFav2Id, fileSiteFav3Id, fileSiteFav4Id ]); + await apis.user.favorites.addFavoritesByIds('file', [fileSiteFav1Id, fileSiteFav2Id, fileSiteFav3Id, fileSiteFav4Id]); await apis.user.favorites.isFavoriteWithRetry(fileSiteFav1Id, { expect: true }); await apis.user.favorites.isFavoriteWithRetry(fileSiteFav2Id, { expect: true }); @@ -485,7 +516,7 @@ describe('Mark items as favorites', () => { done(); }); - it('[C280391] Favorite a folder', async () => { + it('[C280391] Favorite a folder', async () => { await dataTable.selectItem(folderSite); await toolbar.clickMoreActionsFavorite(); @@ -497,7 +528,10 @@ describe('Mark items as favorites', () => { await dataTable.selectItem(fileSiteNotFav1); await toolbar.clickMoreActionsFavorite(); - expect(await apis.user.favorites.isFavoriteWithRetry(fileSiteNotFav1Id, { expect: true })).toBe(true, `${fileSiteNotFav1} not marked as favorite`); + expect(await apis.user.favorites.isFavoriteWithRetry(fileSiteNotFav1Id, { expect: true })).toBe( + true, + `${fileSiteNotFav1} not marked as favorite` + ); }); it('[C280343] Unfavorite an item', async () => { @@ -510,7 +544,7 @@ describe('Mark items as favorites', () => { it('[C280345] Favorite multiple items - all unfavorite', async () => { await page.dataTable.doubleClickOnRowByName(folderSite); - await dataTable.selectMultipleItems([ fileSiteNotFav2, fileSiteNotFav3 ]); + await dataTable.selectMultipleItems([fileSiteNotFav2, fileSiteNotFav3]); await toolbar.clickMoreActionsFavorite(); expect(await apis.user.favorites.isFavoriteWithRetry(fileSiteNotFav2Id, { expect: true })).toBe(true, 'item not marked as favorite'); @@ -519,7 +553,7 @@ describe('Mark items as favorites', () => { it('[C280346] Unfavorite multiple items', async () => { await page.dataTable.doubleClickOnRowByName(folderSite); - await dataTable.selectMultipleItems([ fileSiteFav2, fileSiteFav3 ]); + await dataTable.selectMultipleItems([fileSiteFav2, fileSiteFav3]); await toolbar.clickMoreActionsRemoveFavorite(); expect(await apis.user.favorites.isFavoriteWithRetry(fileSiteFav2Id, { expect: false })).toBe(false, 'item marked as favorite'); @@ -528,7 +562,7 @@ describe('Mark items as favorites', () => { it('[C280347] Favorite multiple items - some favorite and some unfavorite', async () => { await page.dataTable.doubleClickOnRowByName(folderSite); - await dataTable.selectMultipleItems([ fileSiteNotFav4, fileSiteFav4 ]); + await dataTable.selectMultipleItems([fileSiteNotFav4, fileSiteFav4]); await toolbar.clickMoreActionsFavorite(); expect(await apis.user.favorites.isFavoriteWithRetry(fileSiteNotFav4Id, { expect: true })).toBe(true, 'item not marked as favorite'); diff --git a/e2e/suites/actions/new-menu.test.ts b/e2e/suites/actions/new-menu.test.ts index c10c419f9..05b66b27b 100755 --- a/e2e/suites/actions/new-menu.test.ts +++ b/e2e/suites/actions/new-menu.test.ts @@ -23,13 +23,7 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - SITE_ROLES, - RepoClient, - Utils -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, SITE_ROLES, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('New menu', () => { const username = `user-${Utils.random()}`; @@ -154,5 +148,4 @@ describe('New menu', () => { tooltip = await menu.getItemTooltip('Create file from template'); expect(tooltip).toContain('Files cannot be created whilst viewing the current items'); }); - }); diff --git a/e2e/suites/actions/permanently-delete.test.ts b/e2e/suites/actions/permanently-delete.test.ts index c03f44fdd..d4cff410f 100755 --- a/e2e/suites/actions/permanently-delete.test.ts +++ b/e2e/suites/actions/permanently-delete.test.ts @@ -23,126 +23,120 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - ConfirmDialog, - RepoClient, - Utils -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, ConfirmDialog, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Permanently delete from Trash', () => { - const username = `user-${Utils.random()}`; + const username = `user-${Utils.random()}`; - const file1 = `file1-${Utils.random()}.txt`; - const file2 = `file2-${Utils.random()}.txt`; - const file3 = `file3-${Utils.random()}.txt`; - let filesIds; + const file1 = `file1-${Utils.random()}.txt`; + const file2 = `file2-${Utils.random()}.txt`; + const file3 = `file3-${Utils.random()}.txt`; + let filesIds; - const folder1 = `folder1-${Utils.random()}`; - const folder2 = `folder2-${Utils.random()}`; - let foldersIds; + const folder1 = `folder1-${Utils.random()}`; + const folder2 = `folder2-${Utils.random()}`; + let foldersIds; - const site = `site-${Utils.random()}`; + const site = `site-${Utils.random()}`; - const apis = { - admin: new RepoClient(), - user: new RepoClient(username, username) - }; + const apis = { + admin: new RepoClient(), + user: new RepoClient(username, username) + }; - const loginPage = new LoginPage(); - const page = new BrowsingPage(); - const { dataTable, toolbar } = page; + const loginPage = new LoginPage(); + const page = new BrowsingPage(); + const { dataTable, toolbar } = page; - const confirmDialog = new ConfirmDialog(); + const confirmDialog = new ConfirmDialog(); - beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); - filesIds = (await apis.user.nodes.createFiles([ file1, file2, file3 ])).list.entries.map(entries => entries.entry.id); - foldersIds = (await apis.user.nodes.createFolders([ folder1, folder2 ])).list.entries.map(entries => entries.entry.id); - await apis.user.sites.createSite(site); + beforeAll(async (done) => { + await apis.admin.people.createUser({ username }); + filesIds = (await apis.user.nodes.createFiles([file1, file2, file3])).list.entries.map((entries: any) => entries.entry.id); + foldersIds = (await apis.user.nodes.createFolders([folder1, folder2])).list.entries.map((entries: any) => entries.entry.id); + await apis.user.sites.createSite(site); - await apis.user.nodes.deleteNodesById(filesIds, false); - await apis.user.nodes.deleteNodesById(foldersIds, false); - await apis.user.sites.deleteSite(site, false); + await apis.user.nodes.deleteNodesById(filesIds, false); + await apis.user.nodes.deleteNodesById(foldersIds, false); + await apis.user.sites.deleteSite(site, false); - await loginPage.loginWith(username); - done(); - }); + await loginPage.loginWith(username); + done(); + }); - beforeEach(async (done) => { - await page.clickTrashAndWait(); - done(); - }); + beforeEach(async (done) => { + await page.clickTrashAndWait(); + done(); + }); - afterAll(async (done) => { - await apis.user.trashcan.emptyTrash(); - done(); - }); + afterAll(async (done) => { + await apis.user.trashcan.emptyTrash(); + done(); + }); - it('[C217091] delete a file', async () => { - await dataTable.selectItem(file1); - await toolbar.permanentlyDeleteButton.click(); - await page.waitForDialog(); - await confirmDialog.deleteButton.click(); + it('[C217091] delete a file', async () => { + await dataTable.selectItem(file1); + await toolbar.permanentlyDeleteButton.click(); + await page.waitForDialog(); + await confirmDialog.deleteButton.click(); - expect(await page.getSnackBarMessage()).toEqual(`${file1} deleted`); - expect(await dataTable.isItemPresent(file1)).toBe(false, 'Item was not deleted'); - }); + expect(await page.getSnackBarMessage()).toEqual(`${file1} deleted`); + expect(await dataTable.isItemPresent(file1)).toBe(false, 'Item was not deleted'); + }); - it('[C280416] delete a folder', async () => { - await dataTable.selectItem(folder1); - await toolbar.permanentlyDeleteButton.click(); - await page.waitForDialog(); - await confirmDialog.deleteButton.click(); + it('[C280416] delete a folder', async () => { + await dataTable.selectItem(folder1); + await toolbar.permanentlyDeleteButton.click(); + await page.waitForDialog(); + await confirmDialog.deleteButton.click(); - expect(await page.getSnackBarMessage()).toEqual(`${folder1} deleted`); - expect(await dataTable.isItemPresent(folder1)).toBe(false, 'Item was not deleted'); - }); + expect(await page.getSnackBarMessage()).toEqual(`${folder1} deleted`); + expect(await dataTable.isItemPresent(folder1)).toBe(false, 'Item was not deleted'); + }); - it('[C290103] delete a library', async () => { - await dataTable.selectItem(site); - await toolbar.permanentlyDeleteButton.click(); - await page.waitForDialog(); - await confirmDialog.deleteButton.click(); + it('[C290103] delete a library', async () => { + await dataTable.selectItem(site); + await toolbar.permanentlyDeleteButton.click(); + await page.waitForDialog(); + await confirmDialog.deleteButton.click(); - expect(await page.getSnackBarMessage()).toEqual(`${site} deleted`); - expect(await dataTable.isItemPresent(site)).toBe(false, `${site} was not deleted`); - }); + expect(await page.getSnackBarMessage()).toEqual(`${site} deleted`); + expect(await dataTable.isItemPresent(site)).toBe(false, `${site} was not deleted`); + }); - it('[C280417] delete multiple items', async () => { - await dataTable.selectMultipleItems([ file2, folder2 ]); - await toolbar.permanentlyDeleteButton.click(); - await page.waitForDialog(); - await confirmDialog.deleteButton.click(); + it('[C280417] delete multiple items', async () => { + await dataTable.selectMultipleItems([file2, folder2]); + await toolbar.permanentlyDeleteButton.click(); + await page.waitForDialog(); + await confirmDialog.deleteButton.click(); - expect(await page.getSnackBarMessage()).toEqual(`2 items deleted`); - expect(await dataTable.isItemPresent(file2)).toBe(false, 'Item was not deleted'); - expect(await dataTable.isItemPresent(folder2)).toBe(false, 'Item was not deleted'); - }); + expect(await page.getSnackBarMessage()).toEqual(`2 items deleted`); + expect(await dataTable.isItemPresent(file2)).toBe(false, 'Item was not deleted'); + expect(await dataTable.isItemPresent(folder2)).toBe(false, 'Item was not deleted'); + }); - it('[C269113] Confirmation dialog UI', async () => { - await dataTable.selectItem(file3); - await toolbar.permanentlyDeleteButton.click(); - await page.waitForDialog(); + it('[C269113] Confirmation dialog UI', async () => { + await dataTable.selectItem(file3); + await toolbar.permanentlyDeleteButton.click(); + await page.waitForDialog(); - expect(await confirmDialog.isDialogOpen()).toBe(true, 'Confirm delete dialog not open'); - expect(await confirmDialog.getTitle()).toContain('Delete from trash'); - expect(await confirmDialog.getText()).toContain('This will permanently remove the selected item(s)'); - expect(await confirmDialog.isDeleteEnabled()).toBe(true, 'DELETE button is not enabled'); - expect(await confirmDialog.isKeepEnabled()).toBe(true, 'KEEP button is not enabled'); + expect(await confirmDialog.isDialogOpen()).toBe(true, 'Confirm delete dialog not open'); + expect(await confirmDialog.getTitle()).toContain('Delete from trash'); + expect(await confirmDialog.getText()).toContain('This will permanently remove the selected item(s)'); + expect(await confirmDialog.isDeleteEnabled()).toBe(true, 'DELETE button is not enabled'); + expect(await confirmDialog.isKeepEnabled()).toBe(true, 'KEEP button is not enabled'); - await Utils.pressEscape(); - await dataTable.clearSelection(); - }); + await Utils.pressEscape(); + await dataTable.clearSelection(); + }); - it('[C269115] Keep action cancels the deletion', async () => { - await dataTable.selectItem(file3); - await toolbar.permanentlyDeleteButton.click(); - await page.waitForDialog(); + it('[C269115] Keep action cancels the deletion', async () => { + await dataTable.selectItem(file3); + await toolbar.permanentlyDeleteButton.click(); + await page.waitForDialog(); - expect(await confirmDialog.isKeepEnabled()).toBe(true, 'KEEP button is not enabled'); - await confirmDialog.keepButton.click(); - expect(await dataTable.isItemPresent(file3)).toBe(true, 'Item was deleted'); - }); + expect(await confirmDialog.isKeepEnabled()).toBe(true, 'KEEP button is not enabled'); + await confirmDialog.keepButton.click(); + expect(await dataTable.isItemPresent(file3)).toBe(true, 'Item was deleted'); + }); }); diff --git a/e2e/suites/actions/restore.test.ts b/e2e/suites/actions/restore.test.ts index 2fb9e1bd8..93d5148dd 100755 --- a/e2e/suites/actions/restore.test.ts +++ b/e2e/suites/actions/restore.test.ts @@ -24,13 +24,7 @@ */ import { browser } from 'protractor'; -import { - LoginPage, - BrowsingPage, - APP_ROUTES, - RepoClient, - Utils -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, APP_ROUTES, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Restore from Trash', () => { const username = `user-${Utils.random()}`; @@ -56,8 +50,10 @@ describe('Restore from Trash', () => { }); describe('successful restore', () => { - const file = `file-${Utils.random()}.txt`; let fileId; - const folder = `folder-${Utils.random()}`; let folderId; + const file = `file-${Utils.random()}.txt`; + let fileId: string; + const folder = `folder-${Utils.random()}`; + let folderId: string; const site = `site-${Utils.random()}`; beforeAll(async (done) => { @@ -146,14 +142,15 @@ describe('Restore from Trash', () => { describe('failure to restore', () => { const file1 = `file-${Utils.random()}.txt`; - let file1Id1, file1Id2; + let file1Id1: string; + let file1Id2: string; const file2 = `file-${Utils.random()}.txt`; - let file2Id; + let file2Id: string; const folder1 = `folder-${Utils.random()}`; - let folder1Id; + let folder1Id: string; const folder2 = `folder-${Utils.random()}`; - let folder2Id; + let folder2Id: string; beforeAll(async (done) => { folder1Id = (await apis.user.nodes.createFolder(folder1)).entry.id; @@ -175,10 +172,7 @@ describe('Restore from Trash', () => { }); afterAll(async (done) => { - await Promise.all([ - apis.user.nodes.deleteNodeById(file1Id2), - apis.user.trashcan.emptyTrash() - ]); + await Promise.all([apis.user.nodes.deleteNodeById(file1Id2), apis.user.trashcan.emptyTrash()]); done(); }); @@ -199,24 +193,24 @@ describe('Restore from Trash', () => { describe('Notification on partial success', () => { const folder1 = `folder1-${Utils.random()}.txt`; - let folder1Id; + let folder1Id: string; const folder2 = `folder2-${Utils.random()}.txt`; - let folder2Id; + let folder2Id: string; const file1 = `file-${Utils.random()}.txt`; - let file1Id; + let file1Id: string; const file2 = `file-${Utils.random()}.txt`; - let file2Id; + let file2Id: string; const folder3 = `folder3-${Utils.random()}.txt`; - let folder3Id; + let folder3Id: string; const folder4 = `folder4-${Utils.random()}.txt`; - let folder4Id; + let folder4Id: string; const file3 = `file3-${Utils.random()}.txt`; - let file3Id; + let file3Id: string; const file4 = `file4-${Utils.random()}.txt`; - let file4Id; + let file4Id: string; const file5 = `file5-${Utils.random()}.txt`; - let file5Id; + let file5Id: string; beforeAll(async (done) => { folder1Id = (await apis.user.nodes.createFolder(folder1)).entry.id; diff --git a/e2e/suites/actions/share-file.test.ts b/e2e/suites/actions/share-file.test.ts index ffe078494..263712296 100755 --- a/e2e/suites/actions/share-file.test.ts +++ b/e2e/suites/actions/share-file.test.ts @@ -24,29 +24,31 @@ */ import { browser } from 'protractor'; -import { - LoginPage, - BrowsingPage, - SITE_VISIBILITY, - RepoClient, - ShareDialog, - Viewer, - Utils -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, SITE_VISIBILITY, RepoClient, ShareDialog, Viewer, Utils } from '@alfresco/aca-testing-shared'; describe('Share a file', () => { const username = `user-${Utils.random()}`; - const parent = `parent-${Utils.random()}`; let parentId; + const parent = `parent-${Utils.random()}`; + let parentId: string; - const file1 = `file1-${Utils.random()}.txt`; let file1Id; - const file2 = `file2-${Utils.random()}.txt`; let file2Id; - let file3 = `file3-${Utils.random()}.txt`; let file3Id; - const file4 = `file4-${Utils.random()}.txt`; let file4Id; - let file5 = `file5-${Utils.random()}.txt`; let file5Id; - let file6 = `file6-${Utils.random()}.txt`; let file6Id; - let file7 = `file7-${Utils.random()}.txt`; let file7Id; - const file8 = `file8-${Utils.random()}.txt`; let file8Id; - let file9 = `file9-${Utils.random()}.txt`; let file9Id; + const file1 = `file1-${Utils.random()}.txt`; + let file1Id: string; + const file2 = `file2-${Utils.random()}.txt`; + let file2Id: string; + let file3 = `file3-${Utils.random()}.txt`; + let file3Id: string; + const file4 = `file4-${Utils.random()}.txt`; + let file4Id: string; + let file5 = `file5-${Utils.random()}.txt`; + let file5Id: string; + let file6 = `file6-${Utils.random()}.txt`; + let file6Id: string; + let file7 = `file7-${Utils.random()}.txt`; + let file7Id: string; + const file8 = `file8-${Utils.random()}.txt`; + let file8Id: string; + let file9 = `file9-${Utils.random()}.txt`; + let file9Id: string; const viewer = new Viewer(); const page = new BrowsingPage(); @@ -70,7 +72,7 @@ describe('Share a file', () => { }); describe('when logged out', () => { - let file6SharedLink; + let file6SharedLink: string; beforeAll(async (done) => { file6Id = (await apis.user.nodes.createFile(file6, parentId)).entry.id; @@ -94,7 +96,7 @@ describe('Share a file', () => { await toolbar.downloadButton.click(); expect(await Utils.fileExistsOnOS(file6)).toBe(true, 'File not found in download location'); }); - }) + }); describe('when logged in', () => { const expiryDate: any = '2020-12-25T18:30:00.000+0000'; @@ -110,7 +112,6 @@ describe('Share a file', () => { }); describe('from Personal Files', () => { - beforeAll(async (done) => { file1Id = (await apis.user.nodes.createFile(file1, parentId)).entry.id; file2Id = (await apis.user.nodes.createFile(file2, parentId)).entry.id; @@ -220,7 +221,7 @@ describe('Share a file', () => { const date = await shareDialog.dateTimePicker.setDefaultDay(); await shareDialog.dateTimePicker.waitForDateTimePickerToClose(); - const setDate = (`${date}`).replace(',', ''); + const setDate = `${date}`.replace(',', ''); const inputDate = await shareDialog.getExpireDate(); expect(new Date(inputDate)).toEqual(new Date(setDate)); @@ -289,9 +290,9 @@ describe('Share a file', () => { }); describe('from File Libraries', () => { - const siteName = `site-${Utils.random()}`; - const parentInSite = `parent-site-${Utils.random()}`; let parentInSiteId; + const parentInSite = `parent-site-${Utils.random()}`; + let parentInSiteId: string; beforeAll(async (done) => { await apis.user.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC); @@ -401,7 +402,7 @@ describe('Share a file', () => { const date = await shareDialog.dateTimePicker.setDefaultDay(); await shareDialog.dateTimePicker.waitForDateTimePickerToClose(); - const setDate = (`${date}`).replace(',', ''); + const setDate = `${date}`.replace(',', ''); const inputDate = await shareDialog.getExpireDate(); expect(new Date(inputDate)).toEqual(new Date(setDate)); @@ -470,7 +471,6 @@ describe('Share a file', () => { }); describe('from Recent Files', () => { - beforeAll(async (done) => { file1Id = (await apis.user.nodes.createFile(file1, parentId)).entry.id; file2Id = (await apis.user.nodes.createFile(file2, parentId)).entry.id; @@ -579,7 +579,7 @@ describe('Share a file', () => { const date = await shareDialog.dateTimePicker.setDefaultDay(); await shareDialog.dateTimePicker.waitForDateTimePickerToClose(); - const setDate = (`${date}`).replace(',', ''); + const setDate = `${date}`.replace(',', ''); const inputDate = await shareDialog.getExpireDate(); expect(new Date(inputDate)).toEqual(new Date(setDate)); @@ -648,7 +648,6 @@ describe('Share a file', () => { }); describe('from Shared Files', () => { - beforeAll(async (done) => { file1Id = (await apis.user.nodes.createFile(file1, parentId)).entry.id; file2Id = (await apis.user.nodes.createFile(file2, parentId)).entry.id; @@ -798,7 +797,6 @@ describe('Share a file', () => { }); describe('from Favorites', () => { - beforeAll(async (done) => { file1Id = (await apis.user.nodes.createFile(file1, parentId)).entry.id; file2Id = (await apis.user.nodes.createFile(file2, parentId)).entry.id; @@ -919,7 +917,7 @@ describe('Share a file', () => { const date = await shareDialog.dateTimePicker.setDefaultDay(); await shareDialog.dateTimePicker.waitForDateTimePickerToClose(); - const setDate = (`${date}`).replace(',', ''); + const setDate = `${date}`.replace(',', ''); const inputDate = await shareDialog.getExpireDate(); expect(new Date(inputDate)).toEqual(new Date(setDate)); @@ -988,7 +986,6 @@ describe('Share a file', () => { }); describe('from Search Results', () => { - file3 = `search-file3-${Utils.random()}.txt`; file5 = `search-file5-${Utils.random()}.txt`; file6 = `search-file6-${Utils.random()}.txt`; @@ -1008,7 +1005,7 @@ describe('Share a file', () => { done(); }); - beforeEach(async done => { + beforeEach(async (done) => { await searchInput.clickSearchButton(); await searchInput.checkFilesAndFolders(); await searchInput.searchFor('search-f'); @@ -1056,7 +1053,7 @@ describe('Share a file', () => { const date = await shareDialog.dateTimePicker.setDefaultDay(); await shareDialog.dateTimePicker.waitForDateTimePickerToClose(); - const setDate = (`${date}`).replace(',', ''); + const setDate = `${date}`.replace(',', ''); const inputDate = await shareDialog.getExpireDate(); expect(new Date(inputDate)).toEqual(new Date(setDate)); @@ -1106,5 +1103,5 @@ describe('Share a file', () => { expect(url).toContain(sharedId); }); }); - }) + }); }); diff --git a/e2e/suites/actions/unshare-file-search-results.test.ts b/e2e/suites/actions/unshare-file-search-results.test.ts index 4e25a52a6..4a97e95e8 100755 --- a/e2e/suites/actions/unshare-file-search-results.test.ts +++ b/e2e/suites/actions/unshare-file-search-results.test.ts @@ -39,17 +39,24 @@ import { describe('Unshare a file from Search Results', () => { const username = `user-${Utils.random()}`; - const parent = `parent-${Utils.random()}`; let parentId; + const parent = `parent-${Utils.random()}`; + let parentId: string; - const file1 = `search-file1-${Utils.random()}.txt`; let file1Id; - const file2 = `search-file2-${Utils.random()}.txt`; let file2Id; - const file3 = `search-file3-${Utils.random()}.txt`; let file3Id; - const file4 = `search-file4-${Utils.random()}.txt`; let file4Id; + const file1 = `search-file1-${Utils.random()}.txt`; + let file1Id: string; + const file2 = `search-file2-${Utils.random()}.txt`; + let file2Id: string; + const file3 = `search-file3-${Utils.random()}.txt`; + let file3Id: string; + const file4 = `search-file4-${Utils.random()}.txt`; + let file4Id: string; const sitePrivate = `site-private-${Utils.random()}`; - const fileSite1 = `search-fileSite1-${Utils.random()}.txt`; let fileSite1Id; - const fileSite2 = `search-fileSite2-${Utils.random()}.txt`; let fileSite2Id; + const fileSite1 = `search-fileSite1-${Utils.random()}.txt`; + let fileSite1Id: string; + const fileSite2 = `search-fileSite2-${Utils.random()}.txt`; + let fileSite2Id: string; const apis = { admin: new RepoClient(), @@ -239,5 +246,4 @@ describe('Unshare a file from Search Results', () => { expect(await shareDialog.isDialogOpen()).toBe(false, 'Share dialog open'); expect(await apis.user.nodes.isFileShared(fileSite2Id)).toBe(false, `${fileSite2} is shared`); }); - }); diff --git a/e2e/suites/actions/unshare-file.test.ts b/e2e/suites/actions/unshare-file.test.ts index 67da5bbeb..374fbbb9f 100755 --- a/e2e/suites/actions/unshare-file.test.ts +++ b/e2e/suites/actions/unshare-file.test.ts @@ -39,7 +39,8 @@ import { describe('Unshare a file', () => { const username = `user-${Utils.random()}`; - const parent = `parent-${Utils.random()}`; let parentId; + const parent = `parent-${Utils.random()}`; + let parentId: string; const apis = { admin: new RepoClient(), @@ -67,11 +68,14 @@ describe('Unshare a file', () => { }); describe('from Personal Files', () => { - - const file1 = `file1-${Utils.random()}.txt`; let file1Id; - const file2 = `file2-${Utils.random()}.txt`; let file2Id; - const file3 = `file3-${Utils.random()}.txt`; let file3Id; - const file4 = `file4-${Utils.random()}.txt`; let file4Id; + const file1 = `file1-${Utils.random()}.txt`; + let file1Id: string; + const file2 = `file2-${Utils.random()}.txt`; + let file2Id: string; + const file3 = `file3-${Utils.random()}.txt`; + let file3Id: string; + const file4 = `file4-${Utils.random()}.txt`; + let file4Id: string; beforeAll(async (done) => { file1Id = (await apis.user.nodes.createFile(file1, parentId)).entry.id; @@ -182,14 +186,18 @@ describe('Unshare a file', () => { }); describe('from File Libraries', () => { - - const file1 = `file1-${Utils.random()}.txt`; let file1Id; - const file2 = `file2-${Utils.random()}.txt`; let file2Id; - const file3 = `file3-${Utils.random()}.txt`; let file3Id; - const file4 = `file4-${Utils.random()}.txt`; let file4Id; + const file1 = `file1-${Utils.random()}.txt`; + let file1Id: string; + const file2 = `file2-${Utils.random()}.txt`; + let file2Id: string; + const file3 = `file3-${Utils.random()}.txt`; + let file3Id: string; + const file4 = `file4-${Utils.random()}.txt`; + let file4Id: string; const siteName = `site-${Utils.random()}`; - const parentInSite = `parent-site-${Utils.random()}`; let parentInSiteId; + const parentInSite = `parent-site-${Utils.random()}`; + let parentInSiteId: string; beforeAll(async (done) => { await apis.user.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC); @@ -303,11 +311,14 @@ describe('Unshare a file', () => { }); describe('from Recent Files', () => { - - const file1 = `file1-${Utils.random()}.txt`; let file1Id; - const file2 = `file2-${Utils.random()}.txt`; let file2Id; - const file3 = `file3-${Utils.random()}.txt`; let file3Id; - const file4 = `file4-${Utils.random()}.txt`; let file4Id; + const file1 = `file1-${Utils.random()}.txt`; + let file1Id: string; + const file2 = `file2-${Utils.random()}.txt`; + let file2Id: string; + const file3 = `file3-${Utils.random()}.txt`; + let file3Id: string; + const file4 = `file4-${Utils.random()}.txt`; + let file4Id: string; beforeAll(async (done) => { file1Id = (await apis.user.nodes.createFile(file1, parentId)).entry.id; @@ -416,11 +427,14 @@ describe('Unshare a file', () => { }); describe('from Shared Files', () => { - - const file1 = `file1-${Utils.random()}.txt`; let file1Id; - const file2 = `file2-${Utils.random()}.txt`; let file2Id; - const file3 = `file3-${Utils.random()}.txt`; let file3Id; - const file4 = `file4-${Utils.random()}.txt`; let file4Id; + const file1 = `file1-${Utils.random()}.txt`; + let file1Id: string; + const file2 = `file2-${Utils.random()}.txt`; + let file2Id: string; + const file3 = `file3-${Utils.random()}.txt`; + let file3Id: string; + const file4 = `file4-${Utils.random()}.txt`; + let file4Id: string; beforeAll(async (done) => { file1Id = (await apis.user.nodes.createFile(file1, parentId)).entry.id; @@ -529,11 +543,14 @@ describe('Unshare a file', () => { }); describe('from Favorites', () => { - - const file1 = `file1-${Utils.random()}.txt`; let file1Id; - const file2 = `file2-${Utils.random()}.txt`; let file2Id; - const file3 = `file3-${Utils.random()}.txt`; let file3Id; - const file4 = `file4-${Utils.random()}.txt`; let file4Id; + const file1 = `file1-${Utils.random()}.txt`; + let file1Id: string; + const file2 = `file2-${Utils.random()}.txt`; + let file2Id: string; + const file3 = `file3-${Utils.random()}.txt`; + let file3Id: string; + const file4 = `file4-${Utils.random()}.txt`; + let file4Id: string; beforeAll(async (done) => { file1Id = (await apis.user.nodes.createFile(file1, parentId)).entry.id; @@ -649,15 +666,20 @@ describe('Unshare a file', () => { }); describe('as Consumer', () => { - const sitePrivate = `site-private-${Utils.random()}`; - const file1FileLib = `file1-FL-${Utils.random()}.txt`; let file1FileLibId; - const file2FileLib = `file2-FL-${Utils.random()}.txt`; let file2FileLibId; - const file1Shared = `file1-Shared-${Utils.random()}.txt`; let file1SharedId; - const file2Shared = `file2-Shared-${Utils.random()}.txt`; let file2SharedId; - const file1Fav = `file1-Fav-${Utils.random()}.txt`; let file1FavId; - const file2Fav = `file2-Fav-${Utils.random()}.txt`; let file2FavId; + const file1FileLib = `file1-FL-${Utils.random()}.txt`; + let file1FileLibId: string; + const file2FileLib = `file2-FL-${Utils.random()}.txt`; + let file2FileLibId: string; + const file1Shared = `file1-Shared-${Utils.random()}.txt`; + let file1SharedId: string; + const file2Shared = `file2-Shared-${Utils.random()}.txt`; + let file2SharedId: string; + const file1Fav = `file1-Fav-${Utils.random()}.txt`; + let file1FavId: string; + const file2Fav = `file2-Fav-${Utils.random()}.txt`; + let file2FavId: string; beforeAll(async (done) => { await apis.admin.sites.createSite(sitePrivate, SITE_VISIBILITY.PRIVATE); @@ -799,5 +821,4 @@ describe('Unshare a file', () => { expect(await apis.user.nodes.isFileShared(file2FavId)).toBe(false, `${file2Fav} is shared`); }); }); - }); diff --git a/e2e/suites/actions/upload-file.test.ts b/e2e/suites/actions/upload-file.test.ts index 444b2d076..579001226 100755 --- a/e2e/suites/actions/upload-file.test.ts +++ b/e2e/suites/actions/upload-file.test.ts @@ -23,18 +23,13 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - RepoClient, - Utils -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Upload files', () => { const username = `user-${Utils.random()}`; const folder1 = `folder1-${Utils.random()}`; - let folder1Id; + let folder1Id: string; const apis = { admin: new RepoClient(), diff --git a/e2e/suites/actions/upload-new-version.test.ts b/e2e/suites/actions/upload-new-version.test.ts index 494f35acb..ef1b48d1a 100755 --- a/e2e/suites/actions/upload-new-version.test.ts +++ b/e2e/suites/actions/upload-new-version.test.ts @@ -23,41 +23,52 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - FILES, - RepoClient, - Utils, - UploadNewVersionDialog -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, FILES, RepoClient, Utils, UploadNewVersionDialog } from '@alfresco/aca-testing-shared'; describe('Upload new version', () => { const username = `user-${Utils.random()}`; - const file1 = `file1-${Utils.random()}.docx`; let file1Id; - const file2 = `file2-${Utils.random()}.docx`; let file2Id; - const file3 = `file3-${Utils.random()}.docx`; let file3Id; - const file4 = `file4-${Utils.random()}.docx`; let file4Id; - const fileLocked1 = `file-locked1-${Utils.random()}.docx`; let fileLocked1Id; - const fileLocked2 = `file-locked2-${Utils.random()}.docx`; let fileLocked2Id; + const file1 = `file1-${Utils.random()}.docx`; + let file1Id: string; + const file2 = `file2-${Utils.random()}.docx`; + let file2Id: string; + const file3 = `file3-${Utils.random()}.docx`; + let file3Id: string; + const file4 = `file4-${Utils.random()}.docx`; + let file4Id: string; + const fileLocked1 = `file-locked1-${Utils.random()}.docx`; + let fileLocked1Id: string; + const fileLocked2 = `file-locked2-${Utils.random()}.docx`; + let fileLocked2Id: string; - const fileSearch1 = `search-file1-${Utils.random()}.docx`; let fileSearch1Id; - const fileSearch2 = `search-file2-${Utils.random()}.docx`; let fileSearch2Id; - const fileSearch3 = `search-file3-${Utils.random()}.docx`; let fileSearch3Id; - const fileSearch4 = `search-file4-${Utils.random()}.docx`; let fileSearch4Id; - const fileLockedSearch1 = `search-file-locked1-${Utils.random()}.docx`; let fileLockedSearch1Id; - const fileLockedSearch2 = `search-file-locked2-${Utils.random()}.docx`; let fileLockedSearch2Id; + const fileSearch1 = `search-file1-${Utils.random()}.docx`; + let fileSearch1Id: string; + const fileSearch2 = `search-file2-${Utils.random()}.docx`; + let fileSearch2Id: string; + const fileSearch3 = `search-file3-${Utils.random()}.docx`; + let fileSearch3Id: string; + const fileSearch4 = `search-file4-${Utils.random()}.docx`; + let fileSearch4Id: string; + const fileLockedSearch1 = `search-file-locked1-${Utils.random()}.docx`; + let fileLockedSearch1Id: string; + const fileLockedSearch2 = `search-file-locked2-${Utils.random()}.docx`; + let fileLockedSearch2Id: string; - const parentPF = `parentPersonal-${Utils.random()}`; let parentPFId; - const parentSF = `parentShared-${Utils.random()}`; let parentSFId; - const parentRF = `parentRecent-${Utils.random()}`; let parentRFId; - const parentFav = `parentFav-${Utils.random()}`; let parentFavId; - const parentSearch = `parentSearch-${Utils.random()}`; let parentSearchId; + const parentPF = `parentPersonal-${Utils.random()}`; + let parentPFId: string; + const parentSF = `parentShared-${Utils.random()}`; + let parentSFId: string; + const parentRF = `parentRecent-${Utils.random()}`; + let parentRFId: string; + const parentFav = `parentFav-${Utils.random()}`; + let parentFavId: string; + const parentSearch = `parentSearch-${Utils.random()}`; + let parentSearchId: string; const nameConflictMessage = 'New version not uploaded, another file with the same name already exists'; - const file = FILES.pdfFile; let fileId; + const file = FILES.pdfFile; + let fileId: string; const fileToUpload1 = FILES.docxFile; const fileToUpload2 = FILES.xlsxFile; const fileToUpload3 = FILES.pdfFile; @@ -708,7 +719,7 @@ describe('Upload new version', () => { await apis.user.nodes.lockFile(fileLockedSearch1Id); await apis.user.nodes.lockFile(fileLockedSearch2Id); - await apis.user.search.waitForNodes('search-f', { expect: 6 }) + await apis.user.search.waitForNodes('search-f', { expect: 6 }); await loginPage.loginWith(username); done(); @@ -870,5 +881,4 @@ describe('Upload new version', () => { expect(await apis.user.nodes.isFileLockedWrite(fileLockedSearch2Id)).toBe(true, `${fileLockedSearch2} was unlocked`); }); }); - }); diff --git a/e2e/suites/application/general.test.ts b/e2e/suites/application/general.test.ts index d3af42f40..5d45b9959 100644 --- a/e2e/suites/application/general.test.ts +++ b/e2e/suites/application/general.test.ts @@ -25,13 +25,7 @@ import { browser } from 'protractor'; import { Logger } from '@alfresco/adf-testing'; -import { - BrowsingPage, - LoginPage, - CreateOrEditFolderDialog, - RepoClient, - Utils -} from '@alfresco/aca-testing-shared'; +import { BrowsingPage, LoginPage, CreateOrEditFolderDialog, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('General', () => { const loginPage = new LoginPage(); @@ -40,7 +34,7 @@ describe('General', () => { const adminApi = new RepoClient(); const { nodes: nodesApi, authentication: authApi } = adminApi; const folder = `folder-${Utils.random()}`; - let folderId; + let folderId: string; describe('on session expire', () => { beforeAll(async (done) => { diff --git a/e2e/suites/application/page-titles.test.ts b/e2e/suites/application/page-titles.test.ts index b4a03df78..d28d9735d 100755 --- a/e2e/suites/application/page-titles.test.ts +++ b/e2e/suites/application/page-titles.test.ts @@ -24,20 +24,15 @@ */ import { browser } from 'protractor'; -import { - PAGE_TITLES, - LoginPage, - BrowsingPage, - RepoClient, - Utils -} from '@alfresco/aca-testing-shared'; +import { PAGE_TITLES, LoginPage, BrowsingPage, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Page titles', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); const adminApi = new RepoClient(); const { nodes: nodesApi } = adminApi; - const file = `file-${Utils.random()}.txt`; let fileId; + const file = `file-${Utils.random()}.txt`; + let fileId: string; const { searchInput } = page.header; describe('on Login / Logout pages', () => { diff --git a/e2e/suites/authentication/login.test.ts b/e2e/suites/authentication/login.test.ts index 48a19dd4c..b58a4760e 100755 --- a/e2e/suites/authentication/login.test.ts +++ b/e2e/suites/authentication/login.test.ts @@ -24,14 +24,7 @@ */ import { browser } from 'protractor'; -import { - APP_ROUTES, - LoginPage, - BrowsingPage, - Utils, - RepoClient, - navigate -} from '@alfresco/aca-testing-shared'; +import { APP_ROUTES, LoginPage, BrowsingPage, Utils, RepoClient, navigate } from '@alfresco/aca-testing-shared'; describe('Login', () => { const peopleApi = new RepoClient().people; @@ -49,7 +42,9 @@ describe('Login', () => { const johnDoe = { username: `user-${Utils.random()}`, - get password() { return this.username; }, + get password() { + return this.username; + }, firstName: 'John', lastName: 'Doe' }; diff --git a/e2e/suites/authentication/logout.test.ts b/e2e/suites/authentication/logout.test.ts index 26099fe69..0fae22fef 100755 --- a/e2e/suites/authentication/logout.test.ts +++ b/e2e/suites/authentication/logout.test.ts @@ -24,13 +24,7 @@ */ import { browser } from 'protractor'; -import { - LoginPage, - BrowsingPage, - Utils, - RepoClient, - APP_ROUTES -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, Utils, RepoClient, APP_ROUTES } from '@alfresco/aca-testing-shared'; describe('Logout', () => { const page = new BrowsingPage(); diff --git a/e2e/suites/extensions/ext-context-submenus.test.ts b/e2e/suites/extensions/ext-context-submenus.test.ts index 79a7222db..bd752a455 100644 --- a/e2e/suites/extensions/ext-context-submenus.test.ts +++ b/e2e/suites/extensions/ext-context-submenus.test.ts @@ -23,30 +23,24 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - EXTENSIBILITY_CONFIGS, - RepoClient, - Utils -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, EXTENSIBILITY_CONFIGS, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Extensions - Context submenu', () => { const username = `user-${Utils.random()}`; const file = `file-${Utils.random()}.txt`; - let fileId; + let fileId: string; const folder = `folder-${Utils.random()}`; - let folderId; + let folderId: string; const restrictedPermissionsItem = 'Share'; const menuItem1 = { label: 'Test Menu1', - submenu: [ 'Test submenu1', 'Test submenu2', restrictedPermissionsItem ] + submenu: ['Test submenu1', 'Test submenu2', restrictedPermissionsItem] }; const menuItem2 = { label: 'Test Menu2', - submenu: [ restrictedPermissionsItem ] + submenu: [restrictedPermissionsItem] }; const apis = { @@ -56,11 +50,11 @@ describe('Extensions - Context submenu', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); - const {dataTable} = page; + const { dataTable } = page; const contextMenu = dataTable.menu; beforeAll(async (done) => { - await apis.admin.people.createUser({username}); + await apis.admin.people.createUser({ username }); fileId = (await apis.user.nodes.createFile(file)).entry.id; folderId = (await apis.user.nodes.createFolder(folder)).entry.id; @@ -104,7 +98,10 @@ describe('Extensions - Context submenu', () => { expect(await contextMenu.getSubmenuItemsCount()).toBe(2, 'submenu has wrong number of items'); expect(await contextMenu.isSubMenuItemPresent(menuItem1.submenu[0])).toBe(true, `${menuItem1.submenu[0]} is not displayed for ${file}`); expect(await contextMenu.isSubMenuItemPresent(menuItem1.submenu[1])).toBe(true, `${menuItem1.submenu[1]} is not displayed for ${file}`); - expect(await contextMenu.isSubMenuItemPresent(menuItem1.submenu[2])).toBe(false, `no permission submenu ${restrictedPermissionsItem} is displayed`); + expect(await contextMenu.isSubMenuItemPresent(menuItem1.submenu[2])).toBe( + false, + `no permission submenu ${restrictedPermissionsItem} is displayed` + ); }); it('[C287784] The parent item is not displayed if all its children have no permission to be displayed', async () => { diff --git a/e2e/suites/extensions/ext-document-list.test.ts b/e2e/suites/extensions/ext-document-list.test.ts index f4983e468..70513c3f9 100644 --- a/e2e/suites/extensions/ext-document-list.test.ts +++ b/e2e/suites/extensions/ext-document-list.test.ts @@ -23,18 +23,12 @@ * along with Alfresco. If not, see . */ -import { - BrowsingPage, - LoginPage, - RepoClient, - EXTENSIBILITY_CONFIGS, - Utils -} from '@alfresco/aca-testing-shared'; +import { BrowsingPage, LoginPage, RepoClient, EXTENSIBILITY_CONFIGS, Utils } from '@alfresco/aca-testing-shared'; describe('Extensions - DocumentList presets', () => { const username = `user-${Utils.random()}`; const file = `file-${Utils.random()}.txt`; - let fileId; + let fileId: string; const testData = [ { @@ -76,7 +70,7 @@ describe('Extensions - DocumentList presets', () => { done(); }); - beforeEach(async done => { + beforeEach(async (done) => { await page.clickPersonalFilesAndWait(); done(); }); @@ -87,16 +81,14 @@ describe('Extensions - DocumentList presets', () => { }); it('[C286700] Sets the columns to display', async () => { - const expectedColumns = testData - .filter(item => !item.disabled) - .map(data => data.label); + const expectedColumns = testData.filter((item) => !item.disabled).map((data) => data.label); const actualColumns = await dataTable.getColumnHeadersText(); expect(actualColumns).toEqual(expectedColumns); }); it('[C286699] Disabled items are not shown', async () => { - const noColumnLabel = testData.find(item => item.disabled).label; + const noColumnLabel = testData.find((item) => item.disabled).label; const element = dataTable.getColumnHeaderByLabel(noColumnLabel); expect(await element.isPresent()).toBe(false, `"${noColumnLabel}" is displayed`); diff --git a/e2e/suites/extensions/ext-header.test.ts b/e2e/suites/extensions/ext-header.test.ts index 32a2dca65..df9c0a6a3 100755 --- a/e2e/suites/extensions/ext-header.test.ts +++ b/e2e/suites/extensions/ext-header.test.ts @@ -23,65 +23,57 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - RepoClient, - EXTENSIBILITY_CONFIGS, - Utils, - Header, - Menu -} from '@alfresco/aca-testing-shared'; +import { LoginPage, RepoClient, EXTENSIBILITY_CONFIGS, Utils, Header, Menu } from '@alfresco/aca-testing-shared'; describe('Extensions - Info Drawer', () => { - const username = `user-${Utils.random()}`; + const username = `user-${Utils.random()}`; - const disabledMenu = { - id: 'settings', - title: 'App settings', - description: 'Application settings', - icon: 'settings' - }; + const disabledMenu = { + id: 'settings', + title: 'App settings', + description: 'Application settings', + icon: 'settings' + }; - const enabledMenu = { - id: 'button', - title: 'New Button', - description: 'new button description', - icon: 'alarm_on' - }; + const enabledMenu = { + id: 'button', + title: 'New Button', + description: 'new button description', + icon: 'alarm_on' + }; - const apis = { - admin: new RepoClient(), - user: new RepoClient(username, username) - }; + const apis = { + admin: new RepoClient(), + user: new RepoClient(username, username) + }; - const header = new Header(); - const toolbarMenu = new Menu(); + const header = new Header(); + const toolbarMenu = new Menu(); - const loginPage = new LoginPage(); + const loginPage = new LoginPage(); - beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); - await loginPage.load(); - await Utils.setSessionStorageFromConfig(EXTENSIBILITY_CONFIGS.HEADER); - await loginPage.loginWith(username); - done(); - }); + beforeAll(async (done) => { + await apis.admin.people.createUser({ username }); + await loginPage.load(); + await Utils.setSessionStorageFromConfig(EXTENSIBILITY_CONFIGS.HEADER); + await loginPage.loginWith(username); + done(); + }); - afterEach(async (done) => { - await header.closeMoreMenu(); - done(); - }); + afterEach(async (done) => { + await header.closeMoreMenu(); + done(); + }); - it('[C286474] Add a new button in the header', async () => { - await header.openMoreMenu(); - expect(await toolbarMenu.isMenuItemPresent(enabledMenu.title)).toBe(true, 'menu item not present'); - expect(await toolbarMenu.getItemIconText(enabledMenu.title)).toEqual(enabledMenu.icon); - }); - - it('[C286477] Disable a button from the header', async () => { - await header.openMoreMenu(); - expect(await toolbarMenu.isMenuItemPresent(disabledMenu.title)).toBe(true, `${disabledMenu.title} menu item not present`); - expect(await toolbarMenu.isMenuItemDisabled(disabledMenu.title)).toEqual('true', `${disabledMenu.title} is not disabled`); - }); + it('[C286474] Add a new button in the header', async () => { + await header.openMoreMenu(); + expect(await toolbarMenu.isMenuItemPresent(enabledMenu.title)).toBe(true, 'menu item not present'); + expect(await toolbarMenu.getItemIconText(enabledMenu.title)).toEqual(enabledMenu.icon); + }); + it('[C286477] Disable a button from the header', async () => { + await header.openMoreMenu(); + expect(await toolbarMenu.isMenuItemPresent(disabledMenu.title)).toBe(true, `${disabledMenu.title} menu item not present`); + expect(await toolbarMenu.isMenuItemDisabled(disabledMenu.title)).toEqual('true', `${disabledMenu.title} is not disabled`); + }); }); diff --git a/e2e/suites/extensions/ext-info-drawer.test.ts b/e2e/suites/extensions/ext-info-drawer.test.ts index 5eda201f2..e4aa92270 100755 --- a/e2e/suites/extensions/ext-info-drawer.test.ts +++ b/e2e/suites/extensions/ext-info-drawer.test.ts @@ -23,140 +23,133 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, BrowsingPage, - InfoDrawer, - RepoClient, - EXTENSIBILITY_CONFIGS, - Utils -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, InfoDrawer, RepoClient, EXTENSIBILITY_CONFIGS, Utils } from '@alfresco/aca-testing-shared'; describe('Extensions - Info Drawer', () => { - const username = `user-${Utils.random()}`; + const username = `user-${Utils.random()}`; - const file = `file-${Utils.random()}.txt`; - let fileId; + const file = `file-${Utils.random()}.txt`; + let fileId: string; - const properties_tab = { - order: 1, - title: 'MY PROPERTIES' - }; + const properties_tab = { + order: 1, + title: 'MY PROPERTIES' + }; - const custom_tab = { - order: 2, - icon: 'mood', - title: 'MY CUSTOM TITLE', - component: 'app.toolbar.toggleFavorite' - }; + const custom_tab = { + order: 2, + icon: 'mood', + title: 'MY CUSTOM TITLE', + component: 'app.toolbar.toggleFavorite' + }; - const no_title_tab = { - order: 3, - icon: 'check_circle', - title: '' - }; + const no_title_tab = { + order: 3, + icon: 'check_circle', + title: '' + }; - const comments_tab = { - title: 'COMMENTS' - }; + const comments_tab = { + title: 'COMMENTS' + }; - const apis = { - admin: new RepoClient(), - user: new RepoClient(username, username) - }; + const apis = { + admin: new RepoClient(), + user: new RepoClient(username, username) + }; - const infoDrawer = new InfoDrawer(); + const infoDrawer = new InfoDrawer(); - const loginPage = new LoginPage(); - const page = new BrowsingPage(); + const loginPage = new LoginPage(); + const page = new BrowsingPage(); + beforeAll(async (done) => { + await apis.admin.people.createUser({ username }); + fileId = (await apis.user.nodes.createFile(file)).entry.id; + done(); + }); + + afterAll(async (done) => { + await apis.user.nodes.deleteNodeById(fileId); + done(); + }); + + describe('', () => { beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); - fileId = (await apis.user.nodes.createFile(file)).entry.id; - done(); + await loginPage.load(); + await Utils.setSessionStorageFromConfig(EXTENSIBILITY_CONFIGS.INFO_DRAWER); + await loginPage.loginWith(username); + done(); }); - afterAll(async (done) => { - await apis.user.nodes.deleteNodeById(fileId); - done(); + beforeEach(async (done) => { + await page.clickPersonalFilesAndWait(); + await page.dataTable.clearSelection(); + done(); }); - describe('', () => { - beforeAll(async (done) => { - await loginPage.load(); - await Utils.setSessionStorageFromConfig(EXTENSIBILITY_CONFIGS.INFO_DRAWER); - await loginPage.loginWith(username); - done(); - }); + it('[C284646] Add a new tab with icon and title', async () => { + await page.dataTable.selectItem(file); + await page.toolbar.viewDetailsButton.click(); + await infoDrawer.waitForInfoDrawerToOpen(); - beforeEach(async (done) => { - await page.clickPersonalFilesAndWait(); - await page.dataTable.clearSelection(); - done(); - }); - - it('[C284646] Add a new tab with icon and title', async () => { - await page.dataTable.selectItem(file); - await page.toolbar.viewDetailsButton.click(); - await infoDrawer.waitForInfoDrawerToOpen(); - - const val = await infoDrawer.getTabTitle(custom_tab.order); - expect(await infoDrawer.isTabPresent(custom_tab.title)).toBe(true, `${custom_tab.title} tab is not present`); - expect(val.trim()).toEqual(`${custom_tab.icon}\n${custom_tab.title}`.trim()); - }); - - it('[C284647] Remove existing tab', async () => { - await page.dataTable.selectItem(file); - await page.toolbar.viewDetailsButton.click(); - await infoDrawer.waitForInfoDrawerToOpen(); - - expect(await infoDrawer.isTabPresent(comments_tab.title)).toBe(false, `${comments_tab.title} tab should not be present!`); - }); - - it('[C284648] Change tab title', async () => { - await page.dataTable.selectItem(file); - await page.toolbar.viewDetailsButton.click(); - await infoDrawer.waitForInfoDrawerToOpen(); - - expect(await infoDrawer.isTabPresent(properties_tab.title)).toBe(true, `${properties_tab.title} tab is not present`); - expect(await infoDrawer.getTabTitle(properties_tab.order)).toEqual(properties_tab.title); - }); - - it('[C284649] Tab with icon and no title', async () => { - await page.dataTable.selectItem(file); - await page.toolbar.viewDetailsButton.click(); - await infoDrawer.waitForInfoDrawerToOpen(); - - expect(await infoDrawer.isTabPresent(no_title_tab.title)).toBe(true, `${no_title_tab.title} tab is not present`); - expect((await infoDrawer.getTabTitle(no_title_tab.order)).trim()).toEqual(`${no_title_tab.icon}`.trim()); - }); - - it('[C284651] Insert new component in tab', async () => { - await page.dataTable.selectItem(file); - await page.toolbar.viewDetailsButton.click(); - await infoDrawer.waitForInfoDrawerToOpen(); - - expect(await infoDrawer.isTabDisplayed(custom_tab.title)).toBe(true, `${custom_tab.title} tab is not displayed`); - await infoDrawer.clickTab(custom_tab.title); - expect(await infoDrawer.getComponentIdOfTab()).toEqual(custom_tab.component); - }); + const val = await infoDrawer.getTabTitle(custom_tab.order); + expect(await infoDrawer.isTabPresent(custom_tab.title)).toBe(true, `${custom_tab.title} tab is not present`); + expect(val.trim()).toEqual(`${custom_tab.icon}\n${custom_tab.title}`.trim()); }); - describe('', () => { - beforeAll(async (done) => { - await loginPage.load(); - await Utils.setSessionStorageFromConfig(EXTENSIBILITY_CONFIGS.INFO_DRAWER_EMPTY); - await loginPage.loginWith(username); - await page.clickPersonalFilesAndWait(); - done(); - }); + it('[C284647] Remove existing tab', async () => { + await page.dataTable.selectItem(file); + await page.toolbar.viewDetailsButton.click(); + await infoDrawer.waitForInfoDrawerToOpen(); - it('[C284650] Remove all tabs', async () => { - await page.dataTable.selectItem(file); - await page.toolbar.viewDetailsButton.click(); - await infoDrawer.waitForInfoDrawerToOpen(); - - expect(await infoDrawer.isEmpty()).toBe(true, 'Info Drawer is not empty'); - }); + expect(await infoDrawer.isTabPresent(comments_tab.title)).toBe(false, `${comments_tab.title} tab should not be present!`); }); + it('[C284648] Change tab title', async () => { + await page.dataTable.selectItem(file); + await page.toolbar.viewDetailsButton.click(); + await infoDrawer.waitForInfoDrawerToOpen(); + + expect(await infoDrawer.isTabPresent(properties_tab.title)).toBe(true, `${properties_tab.title} tab is not present`); + expect(await infoDrawer.getTabTitle(properties_tab.order)).toEqual(properties_tab.title); + }); + + it('[C284649] Tab with icon and no title', async () => { + await page.dataTable.selectItem(file); + await page.toolbar.viewDetailsButton.click(); + await infoDrawer.waitForInfoDrawerToOpen(); + + expect(await infoDrawer.isTabPresent(no_title_tab.title)).toBe(true, `${no_title_tab.title} tab is not present`); + expect((await infoDrawer.getTabTitle(no_title_tab.order)).trim()).toEqual(`${no_title_tab.icon}`.trim()); + }); + + it('[C284651] Insert new component in tab', async () => { + await page.dataTable.selectItem(file); + await page.toolbar.viewDetailsButton.click(); + await infoDrawer.waitForInfoDrawerToOpen(); + + expect(await infoDrawer.isTabDisplayed(custom_tab.title)).toBe(true, `${custom_tab.title} tab is not displayed`); + await infoDrawer.clickTab(custom_tab.title); + expect(await infoDrawer.getComponentIdOfTab()).toEqual(custom_tab.component); + }); + }); + + describe('', () => { + beforeAll(async (done) => { + await loginPage.load(); + await Utils.setSessionStorageFromConfig(EXTENSIBILITY_CONFIGS.INFO_DRAWER_EMPTY); + await loginPage.loginWith(username); + await page.clickPersonalFilesAndWait(); + done(); + }); + + it('[C284650] Remove all tabs', async () => { + await page.dataTable.selectItem(file); + await page.toolbar.viewDetailsButton.click(); + await infoDrawer.waitForInfoDrawerToOpen(); + + expect(await infoDrawer.isEmpty()).toBe(true, 'Info Drawer is not empty'); + }); + }); }); diff --git a/e2e/suites/extensions/ext-metadata.test.ts b/e2e/suites/extensions/ext-metadata.test.ts index 2d67cf665..bf7c7f151 100644 --- a/e2e/suites/extensions/ext-metadata.test.ts +++ b/e2e/suites/extensions/ext-metadata.test.ts @@ -23,22 +23,14 @@ * along with Alfresco. If not, see . */ -import { - BrowsingPage, - LoginPage, - RepoClient, - EXTENSIBILITY_CONFIGS, - Utils, - InfoDrawer, - MetadataCard -} from '@alfresco/aca-testing-shared'; +import { BrowsingPage, LoginPage, RepoClient, EXTENSIBILITY_CONFIGS, Utils, InfoDrawer, MetadataCard } from '@alfresco/aca-testing-shared'; describe('Extensions - Metadata presets', () => { const username = `user-${Utils.random()}`; const file = `file-${Utils.random()}.png`; - let fileId; + let fileId: string; const properties_tab = { title: 'Properties', @@ -71,7 +63,7 @@ describe('Extensions - Metadata presets', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); - beforeAll(async done => { + beforeAll(async (done) => { await apis.admin.people.createUser({ username }); fileId = (await apis.user.nodes.createImage(file)).entry.id; @@ -82,7 +74,7 @@ describe('Extensions - Metadata presets', () => { done(); }); - beforeEach(async done => { + beforeEach(async (done) => { await page.refresh(); await page.dataTable.selectItem(file); @@ -96,7 +88,7 @@ describe('Extensions - Metadata presets', () => { done(); }); - afterAll(async done => { + afterAll(async (done) => { await apis.user.nodes.deleteNodeById(fileId); done(); }); diff --git a/e2e/suites/extensions/ext-viewer.test.ts b/e2e/suites/extensions/ext-viewer.test.ts index 08ca3844c..c667f6ca0 100755 --- a/e2e/suites/extensions/ext-viewer.test.ts +++ b/e2e/suites/extensions/ext-viewer.test.ts @@ -23,155 +23,147 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - Viewer, - RepoClient, - EXTENSIBILITY_CONFIGS, - FILES, - Utils - } from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, Viewer, RepoClient, EXTENSIBILITY_CONFIGS, FILES, Utils } from '@alfresco/aca-testing-shared'; describe('Extensions - Viewer', () => { - const username = `user-${Utils.random()}`; + const username = `user-${Utils.random()}`; - const pdfFile = { - file_name: FILES.pdfFile, - component: 'app.components.tabs.metadata' - }; - let pdfFileId; + const pdfFile = { + file_name: FILES.pdfFile, + component: 'app.components.tabs.metadata' + }; + let pdfFileId: string; - const docxFile = { - file_name: FILES.docxFile, - component: 'app.components.tabs.comments' - }; - let docxFileId; + const docxFile = { + file_name: FILES.docxFile, + component: 'app.components.tabs.comments' + }; + let docxFileId: string; - const customAction = { - id: 'app.viewer.my-action', - title: 'My action', - icon: 'http' - }; + const customAction = { + id: 'app.viewer.my-action', + title: 'My action', + icon: 'http' + }; - const customSecondaryAction = { - id: 'app.viewer.my-secondary-action', - title: 'My secondary action', - icon: 'alarm' - }; + const customSecondaryAction = { + id: 'app.viewer.my-secondary-action', + title: 'My secondary action', + icon: 'alarm' + }; - const downloadButton = { - id: 'app.viewer.download', - title: 'My custom title' - }; + const downloadButton = { + id: 'app.viewer.download', + title: 'My custom title' + }; - const moveAction = { - id: 'app.viewer.move', - title: 'My new title' - } + const moveAction = { + id: 'app.viewer.move', + title: 'My new title' + }; - const apis = { - admin: new RepoClient(), - user: new RepoClient(username, username) - }; + const apis = { + admin: new RepoClient(), + user: new RepoClient(username, username) + }; - const loginPage = new LoginPage(); - const page = new BrowsingPage(); + const loginPage = new LoginPage(); + const page = new BrowsingPage(); - const viewer = new Viewer(); - const { toolbar } = viewer; + const viewer = new Viewer(); + const { toolbar } = viewer; - beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); - pdfFileId = (await apis.user.upload.uploadFile(pdfFile.file_name)).entry.id; - docxFileId = (await apis.user.upload.uploadFile(docxFile.file_name)).entry.id; + beforeAll(async (done) => { + await apis.admin.people.createUser({ username }); + pdfFileId = (await apis.user.upload.uploadFile(pdfFile.file_name)).entry.id; + docxFileId = (await apis.user.upload.uploadFile(docxFile.file_name)).entry.id; - await loginPage.load(); - await Utils.setSessionStorageFromConfig(EXTENSIBILITY_CONFIGS.VIEWER); - await loginPage.loginWith(username); - done(); + await loginPage.load(); + await Utils.setSessionStorageFromConfig(EXTENSIBILITY_CONFIGS.VIEWER); + await loginPage.loginWith(username); + done(); + }); + + afterAll(async (done) => { + await apis.user.nodes.deleteNodesById([pdfFileId, docxFileId]); + done(); + }); + + beforeEach(async (done) => { + await page.clickPersonalFilesAndWait(); + done(); + }); + + afterEach(async (done) => { + await Utils.pressEscape(); + done(); + }); + + describe('content', () => { + it('[C284659] Insert new component in a content viewer', async () => { + await page.dataTable.doubleClickOnRowByName(pdfFile.file_name); + expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); + expect(await viewer.isCustomContentPresent()).toBe(true, 'Custom content is not present'); + expect(await viewer.getComponentIdOfView()).toEqual(pdfFile.component); + await viewer.closeButton.click(); + + await page.dataTable.doubleClickOnRowByName(docxFile.file_name); + expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); + expect(await viewer.isCustomContentPresent()).toBe(true, 'Custom content is not present'); + expect(await viewer.getComponentIdOfView()).toEqual(docxFile.component); + }); + }); + + describe('toolbar actions', () => { + it('[C286416] Add a new action in the toolbar', async () => { + await page.dataTable.doubleClickOnRowByName(pdfFile.file_name); + expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); + + expect(await toolbar.isButtonPresent(customAction.title)).toBe(true, 'Custom action is not present'); + expect(await toolbar.getButtonByTitleAttribute(customAction.title).getAttribute('id')).toEqual(customAction.id); + expect(await toolbar.getButtonByTitleAttribute(customAction.title).getText()).toEqual(customAction.icon); }); - afterAll(async (done) => { - await apis.user.nodes.deleteNodesById([ pdfFileId, docxFileId ]); - done(); + it('[C286417] Modify title of action from toolbar', async () => { + await page.dataTable.doubleClickOnRowByName(pdfFile.file_name); + expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); + + expect(await toolbar.getButtonById(downloadButton.id).getAttribute('title')).toEqual(downloadButton.title); }); - beforeEach(async (done) => { - await page.clickPersonalFilesAndWait(); - done(); + it('[C286419] Remove action from toolbar', async () => { + await page.dataTable.doubleClickOnRowByName(pdfFile.file_name); + expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); + + expect(await toolbar.isPrintPresent()).toBe(false, 'Print button is still displayed'); + }); + }); + + describe('toolbar More actions menu', () => { + it('[C286420] Add a new action', async () => { + await page.dataTable.doubleClickOnRowByName(pdfFile.file_name); + expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); + + await toolbar.openMoreMenu(); + expect(await toolbar.menu.isMenuItemPresent(customSecondaryAction.title)).toBe(true, 'action is not present'); + expect(await toolbar.menu.getItemIconText(customSecondaryAction.title)).toEqual(customSecondaryAction.icon); + expect(await toolbar.menu.getItemIdAttribute(customSecondaryAction.title)).toEqual(customSecondaryAction.id); }); - afterEach(async (done) => { - await Utils.pressEscape(); - done(); + it('[C286421] Modify title of action from More actions menu', async () => { + await page.dataTable.doubleClickOnRowByName(pdfFile.file_name); + expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); + + await toolbar.openMoreMenu(); + expect(await toolbar.menu.getItemById(moveAction.id).getAttribute('title')).toEqual(moveAction.title); }); - describe('content', () => { - it('[C284659] Insert new component in a content viewer', async () => { - await page.dataTable.doubleClickOnRowByName(pdfFile.file_name); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - expect(await viewer.isCustomContentPresent()).toBe(true, 'Custom content is not present'); - expect(await viewer.getComponentIdOfView()).toEqual(pdfFile.component); - await viewer.closeButton.click(); + it('[C286423] Remove action from More actions menu', async () => { + await page.dataTable.doubleClickOnRowByName(pdfFile.file_name); + expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - await page.dataTable.doubleClickOnRowByName(docxFile.file_name); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - expect(await viewer.isCustomContentPresent()).toBe(true, 'Custom content is not present'); - expect(await viewer.getComponentIdOfView()).toEqual(docxFile.component); - }); - }); - - describe('toolbar actions', () => { - it('[C286416] Add a new action in the toolbar', async () => { - await page.dataTable.doubleClickOnRowByName(pdfFile.file_name); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - - expect(await toolbar.isButtonPresent(customAction.title)).toBe(true, 'Custom action is not present'); - expect(await toolbar.getButtonByTitleAttribute(customAction.title).getAttribute('id')).toEqual(customAction.id); - expect(await toolbar.getButtonByTitleAttribute(customAction.title).getText()).toEqual(customAction.icon); - }); - - it('[C286417] Modify title of action from toolbar', async () => { - await page.dataTable.doubleClickOnRowByName(pdfFile.file_name); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - - expect(await toolbar.getButtonById(downloadButton.id).getAttribute('title')).toEqual(downloadButton.title); - }); - - it('[C286419] Remove action from toolbar', async () => { - await page.dataTable.doubleClickOnRowByName(pdfFile.file_name); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - - expect(await toolbar.isPrintPresent()).toBe(false, 'Print button is still displayed'); - }); - }); - - describe('toolbar More actions menu', () => { - it('[C286420] Add a new action', async () => { - await page.dataTable.doubleClickOnRowByName(pdfFile.file_name); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - - await toolbar.openMoreMenu(); - expect(await toolbar.menu.isMenuItemPresent(customSecondaryAction.title)).toBe(true, 'action is not present'); - expect(await toolbar.menu.getItemIconText(customSecondaryAction.title)).toEqual(customSecondaryAction.icon); - expect(await toolbar.menu.getItemIdAttribute(customSecondaryAction.title)).toEqual(customSecondaryAction.id); - }); - - it('[C286421] Modify title of action from More actions menu', async () => { - await page.dataTable.doubleClickOnRowByName(pdfFile.file_name); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - - await toolbar.openMoreMenu(); - expect(await toolbar.menu.getItemById(moveAction.id).getAttribute('title')).toEqual(moveAction.title); - }); - - it('[C286423] Remove action from More actions menu', async () => { - await page.dataTable.doubleClickOnRowByName(pdfFile.file_name); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - - await toolbar.openMoreMenu(); - expect(await toolbar.menu.managePermissionsAction.isPresent()).toBe(false, 'Action is still displayed'); - }); + await toolbar.openMoreMenu(); + expect(await toolbar.menu.managePermissionsAction.isPresent()).toBe(false, 'Action is still displayed'); }); + }); }); diff --git a/e2e/suites/info-drawer/comments.test.ts b/e2e/suites/info-drawer/comments.test.ts index 7a0f83b20..a813e6f5f 100755 --- a/e2e/suites/info-drawer/comments.test.ts +++ b/e2e/suites/info-drawer/comments.test.ts @@ -23,35 +23,35 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - RepoClient, - InfoDrawer, - Utils -} from '@alfresco/aca-testing-shared'; - -import * as moment from 'moment'; +import { LoginPage, BrowsingPage, RepoClient, InfoDrawer, Utils } from '@alfresco/aca-testing-shared'; +const moment = require('moment'); describe('Comments', () => { const username = `user1-${Utils.random()}`; - const parent = `parent-${Utils.random()}`; let parentId; + const parent = `parent-${Utils.random()}`; + let parentId: string; const file1 = `file1-${Utils.random()}.txt`; const folder1 = `folder1-${Utils.random()}`; - const folder2 = `folder2-${Utils.random()}`; let folder2Id; + const folder2 = `folder2-${Utils.random()}`; + let folder2Id: string; - const fileWith1Comment = `file1Comment-${Utils.random()}.txt`; let fileWith1CommentId; - const fileWith2Comments = `file2Comments-${Utils.random()}.txt`; let fileWith2CommentsId; + const fileWith1Comment = `file1Comment-${Utils.random()}.txt`; + let fileWith1CommentId: string; + const fileWith2Comments = `file2Comments-${Utils.random()}.txt`; + let fileWith2CommentsId: string; const file2Personal = `file2Personal-${Utils.random()}.txt`; - const file2Shared = `file2Shared-${Utils.random()}.txt`; let file2SharedId; + const file2Shared = `file2Shared-${Utils.random()}.txt`; + let file2SharedId: string; const file2Recent = `file2Recent-${Utils.random()}.txt`; - const file2Favorites = `file2Favorites-${Utils.random()}.txt`; let file2FavoritesId; + const file2Favorites = `file2Favorites-${Utils.random()}.txt`; + let file2FavoritesId: string; - let commentFile1Entry; - let comment1File2Entry, comment2File2Entry; + let commentFile1Entry: any; + let comment1File2Entry: any; + let comment2File2Entry: any; const apis = { admin: new RepoClient(), @@ -73,7 +73,7 @@ describe('Comments', () => { await apis.user.nodes.createFile(file1, parentId); await apis.user.nodes.createFile(file2Personal, parentId); await apis.user.nodes.createFile(file2Recent, parentId); - file2SharedId = (await apis.user.nodes.createFile(file2Shared, parentId)).entry.id + file2SharedId = (await apis.user.nodes.createFile(file2Shared, parentId)).entry.id; file2FavoritesId = (await apis.user.nodes.createFile(file2Favorites, parentId)).entry.id; fileWith1CommentId = (await apis.user.nodes.createFile(fileWith1Comment, parentId)).entry.id; @@ -378,7 +378,10 @@ describe('Comments', () => { expect(await commentsTab.isCommentDisplayed(commentFile1Entry.id)).toBe(true, `Comment with id: ${commentFile1Entry.id} not displayed`); expect(await commentsTab.getCommentText(commentFile1Entry.id)).toBe(commentFile1Entry.content, 'Incorrect comment text'); expect(await commentsTab.getCommentUserName(commentFile1Entry.id)).toBe(`${username} ${username}`, 'Incorrect comment user'); - expect(await commentsTab.getCommentTime(commentFile1Entry.id)).toBe(moment(commentFile1Entry.createdAt).fromNow(), 'Incorrect comment created time'); + expect(await commentsTab.getCommentTime(commentFile1Entry.id)).toBe( + moment(commentFile1Entry.createdAt).fromNow(), + 'Incorrect comment created time' + ); expect(await commentsTab.isCommentUserAvatarDisplayed(commentFile1Entry.id)).toBe(true, 'User avatar not displayed'); }); @@ -397,7 +400,10 @@ describe('Comments', () => { expect(await commentsTab.isCommentDisplayed(commentFile1Entry.id)).toBe(true, `Comment with id: ${commentFile1Entry.id} not displayed`); expect(await commentsTab.getCommentText(commentFile1Entry.id)).toBe(commentFile1Entry.content, 'Incorrect comment text'); expect(await commentsTab.getCommentUserName(commentFile1Entry.id)).toBe(`${username} ${username}`, 'Incorrect comment user'); - expect(await commentsTab.getCommentTime(commentFile1Entry.id)).toBe(moment(commentFile1Entry.createdAt).fromNow(), 'Incorrect comment created time'); + expect(await commentsTab.getCommentTime(commentFile1Entry.id)).toBe( + moment(commentFile1Entry.createdAt).fromNow(), + 'Incorrect comment created time' + ); expect(await commentsTab.isCommentUserAvatarDisplayed(commentFile1Entry.id)).toBe(true, 'User avatar not displayed'); }); @@ -416,7 +422,10 @@ describe('Comments', () => { expect(await commentsTab.isCommentDisplayed(commentFile1Entry.id)).toBe(true, `Comment with id: ${commentFile1Entry.id} not displayed`); expect(await commentsTab.getCommentText(commentFile1Entry.id)).toBe(commentFile1Entry.content, 'Incorrect comment text'); expect(await commentsTab.getCommentUserName(commentFile1Entry.id)).toBe(`${username} ${username}`, 'Incorrect comment user'); - expect(await commentsTab.getCommentTime(commentFile1Entry.id)).toBe(moment(commentFile1Entry.createdAt).fromNow(), 'Incorrect comment created time'); + expect(await commentsTab.getCommentTime(commentFile1Entry.id)).toBe( + moment(commentFile1Entry.createdAt).fromNow(), + 'Incorrect comment created time' + ); expect(await commentsTab.isCommentUserAvatarDisplayed(commentFile1Entry.id)).toBe(true, 'User avatar not displayed'); }); @@ -435,10 +444,11 @@ describe('Comments', () => { expect(await commentsTab.isCommentDisplayed(commentFile1Entry.id)).toBe(true, `Comment with id: ${commentFile1Entry.id} not displayed`); expect(await commentsTab.getCommentText(commentFile1Entry.id)).toBe(commentFile1Entry.content, 'Incorrect comment text'); expect(await commentsTab.getCommentUserName(commentFile1Entry.id)).toBe(`${username} ${username}`, 'Incorrect comment user'); - expect(await commentsTab.getCommentTime(commentFile1Entry.id)).toBe(moment(commentFile1Entry.createdAt).fromNow(), 'Incorrect comment created time'); + expect(await commentsTab.getCommentTime(commentFile1Entry.id)).toBe( + moment(commentFile1Entry.createdAt).fromNow(), + 'Incorrect comment created time' + ); expect(await commentsTab.isCommentUserAvatarDisplayed(commentFile1Entry.id)).toBe(true, 'User avatar not displayed'); }); - }); - }); diff --git a/e2e/suites/info-drawer/file-folder-properties.test.ts b/e2e/suites/info-drawer/file-folder-properties.test.ts index 55a60f481..64e6bdac4 100755 --- a/e2e/suites/info-drawer/file-folder-properties.test.ts +++ b/e2e/suites/info-drawer/file-folder-properties.test.ts @@ -23,23 +23,15 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - RepoClient, - InfoDrawer, - Utils, - FILES, - DATE_TIME_FORMAT, - DATE_FORMAT -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, RepoClient, InfoDrawer, Utils, FILES, DATE_TIME_FORMAT, DATE_FORMAT } from '@alfresco/aca-testing-shared'; -import * as moment from 'moment'; +const moment = require('moment'); describe('File / Folder properties', () => { const username = `user1-${Utils.random()}`; - const parent = `parent-${Utils.random()}`; let parentId; + const parent = `parent-${Utils.random()}`; + let parentId: string; const file1 = { name: `file1-${Utils.random()}.txt`, @@ -47,15 +39,15 @@ describe('File / Folder properties', () => { description: 'file description', author: 'file author' }; - let file1Id; + let file1Id: string; const image1 = { name: FILES.jpgFile, title: 'image title', description: 'image description', author: 'image author' - } - let image1Id; + }; + let image1Id: string; const folder1 = { name: `folder1-${Utils.random()}`, @@ -63,7 +55,7 @@ describe('File / Folder properties', () => { description: 'folder description', author: 'folder author' }; - let folder1Id; + let folder1Id: string; const apis = { admin: new RepoClient(), @@ -152,16 +144,7 @@ describe('File / Folder properties', () => { it('[C307106] Folder properties', async () => { const apiProps = await apis.user.nodes.getNodeById(folder1Id); - const expectedPropLabels = [ - 'Name', - 'Title', - 'Creator', - 'Created Date', - 'Modifier', - 'Modified Date', - 'Author', - 'Description' - ]; + const expectedPropLabels = ['Name', 'Title', 'Creator', 'Created Date', 'Modifier', 'Modified Date', 'Author', 'Description']; const expectedPropValues = [ folder1.name, folder1.title, @@ -231,7 +214,7 @@ describe('File / Folder properties', () => { properties['exif:flash'], properties['exif:focalLength'].toString(), properties['exif:isoSpeedRatings'], - (properties['exif:orientation']).toString(), + properties['exif:orientation'].toString(), properties['exif:manufacturer'], properties['exif:model'], properties['exif:software'] @@ -252,5 +235,4 @@ describe('File / Folder properties', () => { expect(await propertiesTab.isLessInfoButtonEnabled()).toBe(true, 'Less information button not enabled'); }); }); - }); diff --git a/e2e/suites/info-drawer/general.test.ts b/e2e/suites/info-drawer/general.test.ts index 653897aee..dd50e4892 100755 --- a/e2e/suites/info-drawer/general.test.ts +++ b/e2e/suites/info-drawer/general.test.ts @@ -23,18 +23,13 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - RepoClient, - InfoDrawer, - Utils -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, RepoClient, InfoDrawer, Utils } from '@alfresco/aca-testing-shared'; describe('General', () => { const username = `user1-${Utils.random()}`; - const parent = `parent-${Utils.random()}`; let parentId; + const parent = `parent-${Utils.random()}`; + let parentId: string; const file1 = `file1-${Utils.random()}.txt`; const folder1 = `folder1-${Utils.random()}`; @@ -89,5 +84,4 @@ describe('General', () => { expect(await infoDrawer.isOpen()).toBe(false, 'Info drawer open'); }); - }); diff --git a/e2e/suites/info-drawer/library-properties.test.ts b/e2e/suites/info-drawer/library-properties.test.ts index 8552dac0e..05a732fb3 100755 --- a/e2e/suites/info-drawer/library-properties.test.ts +++ b/e2e/suites/info-drawer/library-properties.test.ts @@ -23,15 +23,7 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - SITE_VISIBILITY, - SITE_ROLES, - RepoClient, - InfoDrawer, - Utils -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, SITE_VISIBILITY, SITE_ROLES, RepoClient, InfoDrawer, Utils } from '@alfresco/aca-testing-shared'; describe('Library properties', () => { const username = `user1-${Utils.random()}`; @@ -56,7 +48,7 @@ describe('Library properties', () => { name: `site-for-rename-${Utils.random()}`, visibility: SITE_VISIBILITY.PRIVATE, description: 'new description' - } + }; const siteDup = `site3-${Utils.random()}`; @@ -99,7 +91,7 @@ describe('Library properties', () => { done(); }); - afterEach(async done => { + afterEach(async (done) => { if (await infoDrawer.isOpen()) { await page.toolbar.viewDetailsButton.click(); } @@ -120,7 +112,7 @@ describe('Library properties', () => { expect(await aboutTab.getName()).toEqual(site.name); expect(await aboutTab.getLibraryId()).toEqual(site.id); - expect((await aboutTab.getVisibility()).toLowerCase()).toEqual((site.visibility).toLowerCase()); + expect((await aboutTab.getVisibility()).toLowerCase()).toEqual(site.visibility.toLowerCase()); expect(await aboutTab.getDescription()).toEqual(site.description); expect(await aboutTab.isEditLibraryPropertiesDisplayed()).toBe(true, 'Edit action is not displayed'); @@ -231,7 +223,7 @@ describe('Library properties', () => { }); describe('Non manager', () => { - afterAll(async done => { + afterAll(async (done) => { await loginPage.loginWith(username); done(); }); @@ -260,5 +252,4 @@ describe('Library properties', () => { expect(await page.getSnackBarMessage()).toEqual('There was an error updating library properties'); }); }); - }); diff --git a/e2e/suites/list-views/empty-list.test.ts b/e2e/suites/list-views/empty-list.test.ts index 4fb5ce844..3270982be 100755 --- a/e2e/suites/list-views/empty-list.test.ts +++ b/e2e/suites/list-views/empty-list.test.ts @@ -23,13 +23,7 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - SearchResultsPage, - Utils, - RepoClient -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, SearchResultsPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('Empty list views', () => { const username = `user-${Utils.random()}`; diff --git a/e2e/suites/list-views/favorites.test.ts b/e2e/suites/list-views/favorites.test.ts index 6f6d69315..10c73cc09 100755 --- a/e2e/suites/list-views/favorites.test.ts +++ b/e2e/suites/list-views/favorites.test.ts @@ -23,14 +23,7 @@ * along with Alfresco. If not, see . */ -import { - SITE_VISIBILITY, - SITE_ROLES, - LoginPage, - BrowsingPage, - Utils, - RepoClient -} from '@alfresco/aca-testing-shared'; +import { SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('Favorites', () => { const username = `user-${Utils.random()}`; @@ -86,13 +79,13 @@ describe('Favorites', () => { afterAll(async (done) => { await apis.admin.sites.deleteSite(siteName); - await apis.user.nodes.deleteNodes([ favFolderName, parentFolder ]); + await apis.user.nodes.deleteNodes([favFolderName, parentFolder]); await apis.user.trashcan.emptyTrash(); done(); }); it('[C280482] has the correct columns', async () => { - const expectedColumns = [ 'Name', 'Location', 'Size', 'Modified', 'Modified by' ]; + const expectedColumns = ['Name', 'Location', 'Size', 'Modified', 'Modified by']; const actualColumns = await dataTable.getColumnHeadersText(); expect(actualColumns).toEqual(expectedColumns); @@ -127,17 +120,17 @@ describe('Favorites', () => { it('[C213650] Location column redirect - item in user Home', async () => { await dataTable.clickItemLocation(favFolderName); - expect(await breadcrumb.getAllItems()).toEqual([ 'Personal Files' ]); + expect(await breadcrumb.getAllItems()).toEqual(['Personal Files']); }); it('[C280484] Location column redirect - file in folder', async () => { await dataTable.clickItemLocation(fileName2); - expect(await breadcrumb.getAllItems()).toEqual([ 'Personal Files', parentFolder ]); + expect(await breadcrumb.getAllItems()).toEqual(['Personal Files', parentFolder]); }); it('[C280485] Location column redirect - file in site', async () => { await dataTable.clickItemLocation(fileName1); - expect(await breadcrumb.getAllItems()).toEqual([ 'My Libraries', siteName ]); + expect(await breadcrumb.getAllItems()).toEqual(['My Libraries', siteName]); }); it('[C213230] Navigate into folder from Favorites', async () => { diff --git a/e2e/suites/list-views/file-libraries.test.ts b/e2e/suites/list-views/file-libraries.test.ts index bc2989fe9..47bda919e 100755 --- a/e2e/suites/list-views/file-libraries.test.ts +++ b/e2e/suites/list-views/file-libraries.test.ts @@ -23,14 +23,7 @@ * along with Alfresco. If not, see . */ -import { - SITE_VISIBILITY, - SITE_ROLES, - LoginPage, - BrowsingPage, - Utils, - RepoClient -} from '@alfresco/aca-testing-shared'; +import { SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('File Libraries', () => { const username = `user-${Utils.random()}`; @@ -95,8 +88,8 @@ describe('File Libraries', () => { }); afterAll(async (done) => { - await apis.user.sites.deleteSites([ userSitePublic, userSiteModerated, userSitePrivate, siteId1, siteId2 ]); - await apis.admin.sites.deleteSites([ adminSite1, adminSite2, adminSite3, adminSite4, adminSite5, adminSite6 ]); + await apis.user.sites.deleteSites([userSitePublic, userSiteModerated, userSitePrivate, siteId1, siteId2]); + await apis.admin.sites.deleteSites([adminSite1, adminSite2, adminSite3, adminSite4, adminSite5, adminSite6]); done(); }); @@ -107,7 +100,7 @@ describe('File Libraries', () => { }); it('[C217095] has the correct columns', async () => { - const expectedColumns = [ 'Name', 'Description', 'My Role', 'Visibility' ]; + const expectedColumns = ['Name', 'Description', 'My Role', 'Visibility']; const actualColumns = await dataTable.getColumnHeadersText(); expect(actualColumns).toEqual(expectedColumns); @@ -150,10 +143,7 @@ describe('File Libraries', () => { }); it('[C217098] Site ID is displayed when two sites have the same name', async () => { - const expectedSites = [ - `${siteName} (${siteId1})`, - `${siteName} (${siteId2})` - ]; + const expectedSites = [`${siteName} (${siteId1})`, `${siteName} (${siteId2})`]; const actualSites = await dataTable.getCellsContainingName(siteName); expect(actualSites.sort()).toEqual(expectedSites.sort()); }); @@ -176,7 +166,7 @@ describe('File Libraries', () => { }); it('[C289893] has the correct columns', async () => { - const expectedColumns = [ 'Name', 'Description', 'My Role', 'Visibility' ]; + const expectedColumns = ['Name', 'Description', 'My Role', 'Visibility']; const actualColumns = await dataTable.getColumnHeadersText(); expect(actualColumns).toEqual(expectedColumns); @@ -219,10 +209,7 @@ describe('File Libraries', () => { }); it('[C289896] Site ID is displayed when two sites have the same name', async () => { - const expectedSites = [ - `${siteName} (${siteId1})`, - `${siteName} (${siteId2})` - ]; + const expectedSites = [`${siteName} (${siteId1})`, `${siteName} (${siteId2})`]; const actualSites = await dataTable.getCellsContainingName(siteName); expect(actualSites.sort()).toEqual(expectedSites.sort()); }); diff --git a/e2e/suites/list-views/generic-errors.test.ts b/e2e/suites/list-views/generic-errors.test.ts index 79b713de1..7cd39bcf6 100755 --- a/e2e/suites/list-views/generic-errors.test.ts +++ b/e2e/suites/list-views/generic-errors.test.ts @@ -24,21 +24,17 @@ */ import { browser } from 'protractor'; -import { - LoginPage, - BrowsingPage, - Utils, - RepoClient -} from '@alfresco/aca-testing-shared'; - +import { LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('Generic errors', () => { const username = `user-${Utils.random()}`; const username2 = `user2-${Utils.random()}`; - const parent = `folder-${Utils.random()}`; let parentId; - const file1 = `file1-${Utils.random()}.txt`; let file1Id; + const parent = `folder-${Utils.random()}`; + let parentId: string; + const file1 = `file1-${Utils.random()}.txt`; + let file1Id: string; const file2 = `file2-${Utils.random()}.txt`; const apis = { @@ -84,7 +80,6 @@ describe('Generic errors', () => { expect(await page.genericError.isDisplayed()).toBe(true, 'Generic error page not displayed'); expect(await page.genericErrorTitle.getText()).toContain(`This item no longer exists or you don't have permission to view it.`); - }); it('[C217314] Permission denied', async () => { diff --git a/e2e/suites/list-views/permissions.test.ts b/e2e/suites/list-views/permissions.test.ts index e75c1cafc..7fcdd5fef 100755 --- a/e2e/suites/list-views/permissions.test.ts +++ b/e2e/suites/list-views/permissions.test.ts @@ -23,14 +23,7 @@ * along with Alfresco. If not, see . */ -import { - SITE_VISIBILITY, - SITE_ROLES, - LoginPage, - BrowsingPage, - Utils, - RepoClient -} from '@alfresco/aca-testing-shared'; +import { SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('Special permissions', () => { const username = `user-${Utils.random()}`; diff --git a/e2e/suites/list-views/personal-files.test.ts b/e2e/suites/list-views/personal-files.test.ts index db71d4ff3..ac1243937 100755 --- a/e2e/suites/list-views/personal-files.test.ts +++ b/e2e/suites/list-views/personal-files.test.ts @@ -25,13 +25,7 @@ import { browser } from 'protractor'; -import { - APP_ROUTES, - LoginPage, - BrowsingPage, - Utils, - RepoClient -} from '@alfresco/aca-testing-shared'; +import { APP_ROUTES, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('Personal Files', () => { const username = `user-${Utils.random()}`; @@ -51,20 +45,14 @@ describe('Personal Files', () => { const userFile = `file-${Utils.random()}.txt`; beforeAll(async (done) => { - await Promise.all([ - apis.admin.people.createUser({ username }), - apis.admin.nodes.createFolders([ adminFolder ]) - ]); - await apis.user.nodes.createFolders([ userFolder ]); - await apis.user.nodes.createFiles([ userFile ], userFolder); + await Promise.all([apis.admin.people.createUser({ username }), apis.admin.nodes.createFolders([adminFolder])]); + await apis.user.nodes.createFolders([userFolder]); + await apis.user.nodes.createFiles([userFile], userFolder); done(); }); afterAll(async (done) => { - await Promise.all([ - apis.admin.nodes.deleteNodes([ adminFolder ]), - apis.user.nodes.deleteNodes([ userFolder ]) - ]); + await Promise.all([apis.admin.nodes.deleteNodes([adminFolder]), apis.user.nodes.deleteNodes([userFolder])]); done(); }); @@ -97,7 +85,7 @@ describe('Personal Files', () => { }); it('[C217142] has the correct columns', async () => { - const expectedColumns = [ 'Name', 'Size', 'Modified', 'Modified by' ]; + const expectedColumns = ['Name', 'Size', 'Modified', 'Modified by']; const actualColumns = await dataTable.getColumnHeadersText(); expect(actualColumns).toEqual(expectedColumns); @@ -114,7 +102,7 @@ describe('Personal Files', () => { it('[C213244] navigates to folder', async () => { const nodeId = (await apis.user.nodes.getNodeByPath(`/${userFolder}`)).entry.id; - await dataTable.doubleClickOnRowByName(userFolder) + await dataTable.doubleClickOnRowByName(userFolder); await dataTable.waitForHeader(); expect(await browser.getCurrentUrl()).toContain(nodeId, 'Node ID is not in the URL'); diff --git a/e2e/suites/list-views/recent-files.test.ts b/e2e/suites/list-views/recent-files.test.ts index 8099b2d0c..dab99a457 100755 --- a/e2e/suites/list-views/recent-files.test.ts +++ b/e2e/suites/list-views/recent-files.test.ts @@ -23,24 +23,21 @@ * along with Alfresco. If not, see . */ -import { - SITE_VISIBILITY, - LoginPage, - BrowsingPage, - Utils, - RepoClient -} from '@alfresco/aca-testing-shared'; +import { SITE_VISIBILITY, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('Recent Files', () => { const username = `user-${Utils.random()}`; - const folderName = `folder-${Utils.random()}`; let folderId; + const folderName = `folder-${Utils.random()}`; + let folderId: string; const fileName1 = `file-${Utils.random()}.txt`; - const fileName2 = `file-${Utils.random()}.txt`; let file2Id; + const fileName2 = `file-${Utils.random()}.txt`; + let file2Id: string; const fileName3 = `file-${Utils.random()}.txt`; const siteName = `site-${Utils.random()}`; - const folderSite = `folder2-${Utils.random()}`; let folderSiteId; + const folderSite = `folder2-${Utils.random()}`; + let folderSiteId: string; const fileSite = `file-${Utils.random()}.txt`; const apis = { @@ -54,10 +51,10 @@ describe('Recent Files', () => { beforeAll(async (done) => { await apis.admin.people.createUser({ username }); - folderId = (await apis.user.nodes.createFolders([ folderName ])).entry.id; - await apis.user.nodes.createFiles([ fileName1 ], folderName); - file2Id = (await apis.user.nodes.createFiles([ fileName2 ])).entry.id; - const id = (await apis.user.nodes.createFiles([ fileName3 ])).entry.id; + folderId = (await apis.user.nodes.createFolders([folderName])).entry.id; + await apis.user.nodes.createFiles([fileName1], folderName); + file2Id = (await apis.user.nodes.createFiles([fileName2])).entry.id; + const id = (await apis.user.nodes.createFiles([fileName3])).entry.id; await apis.user.nodes.deleteNodeById(id, false); await apis.user.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC); @@ -77,14 +74,14 @@ describe('Recent Files', () => { }); afterAll(async (done) => { - await apis.user.nodes.deleteNodesById([ folderId, file2Id ]); + await apis.user.nodes.deleteNodesById([folderId, file2Id]); await apis.user.sites.deleteSite(siteName); await apis.user.trashcan.emptyTrash(); done(); }); it('[C213168] has the correct columns', async () => { - const expectedColumns = [ 'Name', 'Location', 'Size', 'Modified' ]; + const expectedColumns = ['Name', 'Location', 'Size', 'Modified']; const actualColumns = await dataTable.getColumnHeadersText(); expect(actualColumns).toEqual(expectedColumns); @@ -120,16 +117,16 @@ describe('Recent Files', () => { it('[C213176] Location column redirect - file in user Home', async () => { await dataTable.clickItemLocation(fileName2); - expect(await breadcrumb.getAllItems()).toEqual([ 'Personal Files' ]); + expect(await breadcrumb.getAllItems()).toEqual(['Personal Files']); }); it('[C280486] Location column redirect - file in folder', async () => { await dataTable.clickItemLocation(fileName1); - expect(await breadcrumb.getAllItems()).toEqual([ 'Personal Files', folderName ]); + expect(await breadcrumb.getAllItems()).toEqual(['Personal Files', folderName]); }); it('[C280487] Location column redirect - file in site', async () => { await dataTable.clickItemLocation(fileSite); - expect(await breadcrumb.getAllItems()).toEqual([ 'My Libraries', siteName, folderSite ]); + expect(await breadcrumb.getAllItems()).toEqual(['My Libraries', siteName, folderSite]); }); }); diff --git a/e2e/suites/list-views/shared-files.test.ts b/e2e/suites/list-views/shared-files.test.ts index 229075dd9..128c6fc3e 100755 --- a/e2e/suites/list-views/shared-files.test.ts +++ b/e2e/suites/list-views/shared-files.test.ts @@ -23,14 +23,7 @@ * along with Alfresco. If not, see . */ -import { - SITE_VISIBILITY, - SITE_ROLES, - LoginPage, - BrowsingPage, - Utils, - RepoClient -} from '@alfresco/aca-testing-shared'; +import { SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('Shared Files', () => { const username = `user-${Utils.random()}`; @@ -39,11 +32,16 @@ describe('Shared Files', () => { const siteName = `site-${Utils.random()}`; const fileAdmin = `fileSite-${Utils.random()}.txt`; - const folderUser = `folder-${Utils.random()}`; let folderId; - const file1User = `file1-${Utils.random()}.txt`; let file1Id; - const file2User = `file2-${Utils.random()}.txt`; let file2Id; - const file3User = `file3-${Utils.random()}.txt`; let file3Id; - const file4User = `file4-${Utils.random()}.txt`; let file4Id; + const folderUser = `folder-${Utils.random()}`; + let folderId: string; + const file1User = `file1-${Utils.random()}.txt`; + let file1Id: string; + const file2User = `file2-${Utils.random()}.txt`; + let file2Id: string; + const file3User = `file3-${Utils.random()}.txt`; + let file3Id: string; + const file4User = `file4-${Utils.random()}.txt`; + let file4Id: string; const apis = { admin: new RepoClient(), @@ -91,7 +89,7 @@ describe('Shared Files', () => { }); it('[C213113] has the correct columns', async () => { - const expectedColumns = [ 'Name', 'Location', 'Size', 'Modified', 'Modified by', 'Shared by' ]; + const expectedColumns = ['Name', 'Location', 'Size', 'Modified', 'Modified by', 'Shared by']; const actualColumns = await dataTable.getColumnHeadersText(); expect(actualColumns).toEqual(expectedColumns); @@ -123,17 +121,17 @@ describe('Shared Files', () => { it('[C213666] Location column redirect - file in user Home', async () => { await dataTable.clickItemLocation(file4User); - expect(await breadcrumb.getAllItems()).toEqual([ 'Personal Files' ]); + expect(await breadcrumb.getAllItems()).toEqual(['Personal Files']); }); it('[C280490] Location column redirect - file in folder', async () => { await dataTable.clickItemLocation(file1User); - expect(await breadcrumb.getAllItems()).toEqual([ 'Personal Files', folderUser ]); + expect(await breadcrumb.getAllItems()).toEqual(['Personal Files', folderUser]); }); it('[C280491] Location column redirect - file in site', async () => { await dataTable.clickItemLocation(fileAdmin); - expect(await breadcrumb.getAllItems()).toEqual([ 'My Libraries', siteName ]); + expect(await breadcrumb.getAllItems()).toEqual(['My Libraries', siteName]); }); it('[C213667] Location column displays a tooltip with the entire path of the file', async () => { diff --git a/e2e/suites/list-views/tooltips.test.ts b/e2e/suites/list-views/tooltips.test.ts index 2962f1e66..b98bed392 100755 --- a/e2e/suites/list-views/tooltips.test.ts +++ b/e2e/suites/list-views/tooltips.test.ts @@ -23,12 +23,7 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - Utils, - RepoClient -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('File / folder tooltips', () => { const username = `user-${Utils.random()}`; @@ -59,7 +54,7 @@ describe('File / folder tooltips', () => { beforeAll(async (done) => { await apis.admin.people.createUser({ username }); - parentId = (await apis.user.nodes.createFolder( parent )).entry.id; + parentId = (await apis.user.nodes.createFolder(parent)).entry.id; file1Id = (await apis.user.nodes.createFile(file, parentId)).entry.id; file2Id = (await apis.user.nodes.createFile(fileWithDesc, parentId, '', fileDescription)).entry.id; @@ -70,21 +65,16 @@ describe('File / folder tooltips', () => { file7Id = (await apis.user.nodes.createFile(fileNameEqDescDiffTitle, parentId, fileTitle, fileNameEqDescDiffTitle)).entry.id; file8Id = (await apis.user.nodes.createFile(fileTitleEqDesc, parentId, fileTitle, fileTitle)).entry.id; - await apis.user.shared.shareFilesByIds([ file1Id, file2Id, file3Id, file4Id, file5Id, file6Id, file7Id, file8Id ]); + await apis.user.shared.shareFilesByIds([file1Id, file2Id, file3Id, file4Id, file5Id, file6Id, file7Id, file8Id]); - await apis.user.favorites.addFavoritesByIds('file', [ - file1Id, file2Id, file3Id, file4Id, file5Id, file6Id, file7Id, file8Id - ]); + await apis.user.favorites.addFavoritesByIds('file', [file1Id, file2Id, file3Id, file4Id, file5Id, file6Id, file7Id, file8Id]); await loginPage.loginWith(username); done(); }); afterAll(async (done) => { - await Promise.all([ - apis.user.nodes.deleteNodes([ parent ]), - apis.user.trashcan.emptyTrash() - ]); + await Promise.all([apis.user.nodes.deleteNodes([parent]), apis.user.trashcan.emptyTrash()]); done(); }); @@ -254,26 +244,28 @@ describe('File / folder tooltips', () => { let file5TrashId, file6TrashId, file7TrashId, file8TrashId; beforeAll(async (done) => { - parentForTrashId = (await apis.user.nodes.createFolder( parentForTrash )).entry.id; + parentForTrashId = (await apis.user.nodes.createFolder(parentForTrash)).entry.id; file1TrashId = (await apis.user.nodes.createFile(file, parentForTrashId)).entry.id; file2TrashId = (await apis.user.nodes.createFile(fileWithDesc, parentForTrashId, '', fileDescription)).entry.id; file3TrashId = (await apis.user.nodes.createFile(fileWithTitle, parentForTrashId, fileTitle)).entry.id; file4TrashId = (await apis.user.nodes.createFile(fileWithTitleAndDesc, parentForTrashId, fileTitle, fileDescription)).entry.id; - file5TrashId = (await apis.user.nodes.createFile(fileNameEqTitleEqDesc, parentForTrashId, fileNameEqTitleEqDesc, fileNameEqTitleEqDesc)).entry.id; + file5TrashId = (await apis.user.nodes.createFile(fileNameEqTitleEqDesc, parentForTrashId, fileNameEqTitleEqDesc, fileNameEqTitleEqDesc)).entry + .id; file6TrashId = (await apis.user.nodes.createFile(fileNameEqTitleDiffDesc, parentForTrashId, fileNameEqTitleDiffDesc, fileDescription)).entry.id; file7TrashId = (await apis.user.nodes.createFile(fileNameEqDescDiffTitle, parentForTrashId, fileTitle, fileNameEqDescDiffTitle)).entry.id; file8TrashId = (await apis.user.nodes.createFile(fileTitleEqDesc, parentForTrashId, fileTitle, fileTitle)).entry.id; - await apis.user.nodes.deleteNodesById([ - file1TrashId, file2TrashId, file3TrashId, file4TrashId, file5TrashId, file6TrashId, file7TrashId, file8TrashId - ], false); + await apis.user.nodes.deleteNodesById( + [file1TrashId, file2TrashId, file3TrashId, file4TrashId, file5TrashId, file6TrashId, file7TrashId, file8TrashId], + false + ); await page.clickTrashAndWait(); done(); }); afterAll(async (done) => { - await apis.user.nodes.deleteNodes([ parentForTrash ]); + await apis.user.nodes.deleteNodes([parentForTrash]); await apis.user.trashcan.emptyTrash(); done(); }); diff --git a/e2e/suites/list-views/trash.test.ts b/e2e/suites/list-views/trash.test.ts index 275185d5e..c1210d9d9 100755 --- a/e2e/suites/list-views/trash.test.ts +++ b/e2e/suites/list-views/trash.test.ts @@ -23,32 +23,34 @@ * along with Alfresco. If not, see . */ -import { - SITE_VISIBILITY, - SITE_ROLES, - LoginPage, - BrowsingPage, - Utils, - RepoClient -} from '@alfresco/aca-testing-shared'; +import { SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('Trash', () => { const username = `user-${Utils.random()}`; const siteName = `site-${Utils.random()}`; - const fileSite = `file-${Utils.random()}.txt`; let fileSiteId; + const fileSite = `file-${Utils.random()}.txt`; + let fileSiteId; - const folderAdmin = `folder-${Utils.random()}`; let folderAdminId; - const fileAdmin = `file-${Utils.random()}.txt`; let fileAdminId; + const folderAdmin = `folder-${Utils.random()}`; + let folderAdminId; + const fileAdmin = `file-${Utils.random()}.txt`; + let fileAdminId; - const folderUser = `folder-${Utils.random()}`; let folderUserId; - const fileUser = `file-${Utils.random()}.txt`; let fileUserId; + const folderUser = `folder-${Utils.random()}`; + let folderUserId; + const fileUser = `file-${Utils.random()}.txt`; + let fileUserId; - const folderDeleted = `folder-${Utils.random()}`; let folderDeletedId; - const fileDeleted = `file-${Utils.random()}.txt`; let fileDeletedId; + const folderDeleted = `folder-${Utils.random()}`; + let folderDeletedId; + const fileDeleted = `file-${Utils.random()}.txt`; + let fileDeletedId; - const folderNotDeleted = `folder-${Utils.random()}`; let folderNotDeletedId; - const fileInFolder = `file-${Utils.random()}.txt`; let fileInFolderId; + const folderNotDeleted = `folder-${Utils.random()}`; + let folderNotDeletedId: string; + const fileInFolder = `file-${Utils.random()}.txt`; + let fileInFolderId; const apis = { admin: new RepoClient(), @@ -61,21 +63,21 @@ describe('Trash', () => { beforeAll(async (done) => { await apis.admin.people.createUser({ username }); - fileAdminId = (await apis.admin.nodes.createFiles([ fileAdmin ])).entry.id; - folderAdminId = (await apis.admin.nodes.createFolders([ folderAdmin ])).entry.id; + fileAdminId = (await apis.admin.nodes.createFiles([fileAdmin])).entry.id; + folderAdminId = (await apis.admin.nodes.createFolders([folderAdmin])).entry.id; await apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC); await apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_MANAGER.ROLE); const docLibId = await apis.admin.sites.getDocLibId(siteName); fileSiteId = (await apis.admin.nodes.createFile(fileSite, docLibId)).entry.id; - fileUserId = (await apis.user.nodes.createFiles([ fileUser ])).entry.id; - folderUserId = (await apis.user.nodes.createFolders([ folderUser ])).entry.id; + fileUserId = (await apis.user.nodes.createFiles([fileUser])).entry.id; + folderUserId = (await apis.user.nodes.createFolders([folderUser])).entry.id; folderDeletedId = (await apis.user.nodes.createFolder(folderDeleted)).entry.id; - fileDeletedId = (await apis.user.nodes.createFiles([ fileDeleted ], folderDeleted)).entry.id; + fileDeletedId = (await apis.user.nodes.createFiles([fileDeleted], folderDeleted)).entry.id; folderNotDeletedId = (await apis.user.nodes.createFolder(folderNotDeleted)).entry.id; - fileInFolderId = (await apis.user.nodes.createFiles([ fileInFolder ], folderNotDeleted)).entry.id; + fileInFolderId = (await apis.user.nodes.createFiles([fileInFolder], folderNotDeleted)).entry.id; - await apis.admin.nodes.deleteNodesById([ fileAdminId, folderAdminId ], false); - await apis.user.nodes.deleteNodesById([ fileSiteId, fileUserId, folderUserId, fileInFolderId ], false); + await apis.admin.nodes.deleteNodesById([fileAdminId, folderAdminId], false); + await apis.user.nodes.deleteNodesById([fileSiteId, fileUserId, folderUserId, fileInFolderId], false); await apis.user.nodes.deleteNodeById(fileDeletedId, false); await apis.user.nodes.deleteNodeById(folderDeletedId, false); @@ -83,11 +85,7 @@ describe('Trash', () => { }); afterAll(async (done) => { - await Promise.all([ - apis.admin.sites.deleteSite(siteName), - apis.user.nodes.deleteNodeById(folderNotDeletedId), - apis.admin.trashcan.emptyTrash() - ]); + await Promise.all([apis.admin.sites.deleteSite(siteName), apis.user.nodes.deleteNodeById(folderNotDeletedId), apis.admin.trashcan.emptyTrash()]); done(); }); @@ -103,7 +101,7 @@ describe('Trash', () => { }); it('[C213217] has the correct columns', async () => { - const expectedColumns = [ 'Name', 'Location', 'Size', 'Deleted', 'Deleted by' ]; + const expectedColumns = ['Name', 'Location', 'Size', 'Deleted', 'Deleted by']; const actualColumns = await dataTable.getColumnHeadersText(); expect(actualColumns).toEqual(expectedColumns); @@ -132,7 +130,7 @@ describe('Trash', () => { }); it('[C280494] has the correct columns', async () => { - const expectedColumns = [ 'Name', 'Location', 'Size', 'Deleted']; + const expectedColumns = ['Name', 'Location', 'Size', 'Deleted']; const actualColumns = await dataTable.getColumnHeadersText(); expect(actualColumns).toEqual(expectedColumns); @@ -170,17 +168,17 @@ describe('Trash', () => { it('[C217144] Location column redirect - file in user Home', async () => { await dataTable.clickItemLocation(fileUser); - expect(await breadcrumb.getAllItems()).toEqual([ 'Personal Files' ]); + expect(await breadcrumb.getAllItems()).toEqual(['Personal Files']); }); it('[C280496] Location column redirect - file in folder', async () => { await dataTable.clickItemLocation(fileInFolder); - expect(await breadcrumb.getAllItems()).toEqual([ 'Personal Files', folderNotDeleted ]); + expect(await breadcrumb.getAllItems()).toEqual(['Personal Files', folderNotDeleted]); }); it('[C280497] Location column redirect - file in site', async () => { await dataTable.clickItemLocation(fileSite); - expect(await breadcrumb.getAllItems()).toEqual([ 'My Libraries', siteName ]); + expect(await breadcrumb.getAllItems()).toEqual(['My Libraries', siteName]); }); }); }); diff --git a/e2e/suites/navigation/breadcrumb.test.ts b/e2e/suites/navigation/breadcrumb.test.ts index c512f3660..57879873d 100755 --- a/e2e/suites/navigation/breadcrumb.test.ts +++ b/e2e/suites/navigation/breadcrumb.test.ts @@ -25,26 +25,25 @@ import { browser } from 'protractor'; -import { - SITE_VISIBILITY, - LoginPage, - BrowsingPage, - Utils, - RepoClient -} from '@alfresco/aca-testing-shared'; +import { SITE_VISIBILITY, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('Breadcrumb', () => { const username = `user-${Utils.random()}`; - const parent = `parent-${Utils.random()}`; let parentId; - const subFolder1 = `subFolder1-${Utils.random()}`; let subFolder1Id; - const subFolder2 = `subFolder2-${Utils.random()}`; let subFolder2Id; + const parent = `parent-${Utils.random()}`; + let parentId: string; + const subFolder1 = `subFolder1-${Utils.random()}`; + let subFolder1Id: string; + const subFolder2 = `subFolder2-${Utils.random()}`; + let subFolder2Id: string; const fileName1 = `file1-${Utils.random()}.txt`; const siteName = `site-${Utils.random()}`; - const parent2 = `parent2-${Utils.random()}`; let parent2Id; - const folder1 = `folder1-${Utils.random()}`; let folder1Id; + const parent2 = `parent2-${Utils.random()}`; + let parent2Id: string; + const folder1 = `folder1-${Utils.random()}`; + let folder1Id: string; const folder1Renamed = `renamed-${Utils.random()}`; const loginPage = new LoginPage(); @@ -52,8 +51,8 @@ describe('Breadcrumb', () => { const { breadcrumb } = page; const apis = { - admin: new RepoClient(), - user: new RepoClient(username, username) + admin: new RepoClient(), + user: new RepoClient(username, username) }; beforeAll(async (done) => { @@ -78,11 +77,7 @@ describe('Breadcrumb', () => { }); afterAll(async (done) => { - await Promise.all([ - apis.user.nodes.deleteNodeById(parentId), - apis.user.nodes.deleteNodeById(parent2Id), - apis.user.sites.deleteSite(siteName) - ]); + await Promise.all([apis.user.nodes.deleteNodeById(parentId), apis.user.nodes.deleteNodeById(parent2Id), apis.user.sites.deleteSite(siteName)]); done(); }); @@ -133,7 +128,7 @@ describe('Breadcrumb', () => { await page.dataTable.doubleClickOnRowByName(parent); await page.dataTable.doubleClickOnRowByName(subFolder1); await page.dataTable.doubleClickOnRowByName(subFolder2); - const expectedBreadcrumb = [ 'Personal Files', parent, subFolder1, subFolder2 ]; + const expectedBreadcrumb = ['Personal Files', parent, subFolder1, subFolder2]; expect(await breadcrumb.getAllItems()).toEqual(expectedBreadcrumb); }); @@ -143,7 +138,7 @@ describe('Breadcrumb', () => { await page.dataTable.doubleClickOnRowByName(parent); await page.dataTable.doubleClickOnRowByName(subFolder1); await page.dataTable.doubleClickOnRowByName(subFolder2); - const expectedItems = [ 'My Libraries', siteName, parent, subFolder1, subFolder2 ]; + const expectedItems = ['My Libraries', siteName, parent, subFolder1, subFolder2]; expect(await breadcrumb.getAllItems()).toEqual(expectedItems); }); @@ -153,7 +148,7 @@ describe('Breadcrumb', () => { await page.dataTable.doubleClickOnRowByName(subFolder1); await page.dataTable.doubleClickOnRowByName(subFolder2); await breadcrumb.clickItem(subFolder1); - const expectedBreadcrumb = [ 'Personal Files', parent, subFolder1 ]; + const expectedBreadcrumb = ['Personal Files', parent, subFolder1]; expect(await breadcrumb.getAllItems()).toEqual(expectedBreadcrumb); }); @@ -174,7 +169,7 @@ describe('Breadcrumb', () => { await page.dataTable.doubleClickOnRowByName(parent2); await page.dataTable.doubleClickOnRowByName(folder1); await page.dataTable.wait(); - await apis.user.nodes.renameNode(folder1Id, folder1Renamed) + await apis.user.nodes.renameNode(folder1Id, folder1Renamed); await page.refresh(); await page.dataTable.wait(); expect(await breadcrumb.currentItem.getText()).toEqual(folder1Renamed); @@ -188,13 +183,14 @@ describe('Breadcrumb', () => { await page.clickTrash(); await page.dataTable.waitForEmptyState(); await browser.navigate().back(); - const expectedBreadcrumb = [ 'Personal Files', parent, subFolder1, subFolder2 ]; + const expectedBreadcrumb = ['Personal Files', parent, subFolder1, subFolder2]; expect(await breadcrumb.getAllItems()).toEqual(expectedBreadcrumb); }); describe('as admin', () => { const user2 = `user2-${Utils.random()}`; - const userFolder = `userFolder-${Utils.random()}`; let userFolderId; + const userFolder = `userFolder-${Utils.random()}`; + let userFolderId: string; const user2Api = new RepoClient(user2, user2); beforeAll(async (done) => { @@ -212,9 +208,9 @@ describe('Breadcrumb', () => { it(`[C260970] Breadcrumb on navigation to a user's home`, async () => { await page.dataTable.doubleClickOnRowByName('User Homes'); await page.dataTable.doubleClickOnRowByName(user2); - expect(await breadcrumb.getAllItems()).toEqual([ 'Personal Files', 'User Homes', user2 ]); + expect(await breadcrumb.getAllItems()).toEqual(['Personal Files', 'User Homes', user2]); await page.dataTable.doubleClickOnRowByName(userFolder); - expect(await breadcrumb.getAllItems()).toEqual([ 'Personal Files', 'User Homes', user2, userFolder ]); + expect(await breadcrumb.getAllItems()).toEqual(['Personal Files', 'User Homes', user2, userFolder]); }); }); }); diff --git a/e2e/suites/navigation/sidebar.test.ts b/e2e/suites/navigation/sidebar.test.ts index 6e892c43e..c7f7e3d04 100755 --- a/e2e/suites/navigation/sidebar.test.ts +++ b/e2e/suites/navigation/sidebar.test.ts @@ -24,14 +24,7 @@ */ import { browser } from 'protractor'; -import { - APP_ROUTES, - SIDEBAR_LABELS, - LoginPage, - BrowsingPage, - SearchResultsPage, - Utils -} from '@alfresco/aca-testing-shared'; +import { APP_ROUTES, SIDEBAR_LABELS, LoginPage, BrowsingPage, SearchResultsPage, Utils } from '@alfresco/aca-testing-shared'; describe('Sidebar', () => { const loginPage = new LoginPage(); diff --git a/e2e/suites/navigation/single-click.test.ts b/e2e/suites/navigation/single-click.test.ts index 862fb0081..c695e9c0f 100755 --- a/e2e/suites/navigation/single-click.test.ts +++ b/e2e/suites/navigation/single-click.test.ts @@ -23,22 +23,20 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - Viewer, - RepoClient, - Utils -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, Viewer, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Single click on item name', () => { const username = `user-${Utils.random()}`; - const file1 = `file1-${Utils.random()}.txt`; let file1Id; - const folder1 = `folder1-${Utils.random()}`; let folder1Id; + const file1 = `file1-${Utils.random()}.txt`; + let file1Id: string; + const folder1 = `folder1-${Utils.random()}`; + let folder1Id: string; - const deletedFile1 = `file1-${Utils.random()}.txt`; let deletedFile1Id; - const deletedFolder1 = `folder1-${Utils.random()}`; let deletedFolder1Id; + const deletedFile1 = `file1-${Utils.random()}.txt`; + let deletedFile1Id: string; + const deletedFolder1 = `folder1-${Utils.random()}`; + let deletedFolder1Id: string; const siteName = `site-${Utils.random()}`; const fileSite = `fileSite-${Utils.random()}.txt`; @@ -65,7 +63,7 @@ describe('Single click on item name', () => { await apis.user.nodes.deleteNodeById(deletedFolder1Id, false); await apis.user.sites.createSite(siteName); - const docLibId = (await apis.user.sites.getDocLibId(siteName)); + const docLibId = await apis.user.sites.getDocLibId(siteName); await apis.user.nodes.createFile(fileSite, docLibId); await apis.user.shared.shareFileById(file1Id); @@ -201,7 +199,7 @@ describe('Single click on item name', () => { }); describe('on Search Results', () => { - beforeEach(async done => { + beforeEach(async (done) => { await searchInput.clickSearchButton(); await searchInput.checkFilesAndFolders(); done(); @@ -238,5 +236,4 @@ describe('Single click on item name', () => { expect(await breadcrumb.currentItem.getText()).toBe(folder1); }); }); - }); diff --git a/e2e/suites/pagination/favorites.ts b/e2e/suites/pagination/favorites.ts index 87f9a0ee3..0deaeb84b 100755 --- a/e2e/suites/pagination/favorites.ts +++ b/e2e/suites/pagination/favorites.ts @@ -30,7 +30,6 @@ export function favoritesTests() { const { dataTable, pagination } = page; describe('Pagination controls : ', () => { - beforeAll(async () => { await page.clickFavoritesAndWait(); }); @@ -57,7 +56,7 @@ export function favoritesTests() { }); it('current page menu items - [C280115]', async () => { - await pagination.openMaxItemsMenu() + await pagination.openMaxItemsMenu(); await pagination.menu.clickMenuItem('25'); expect(await pagination.getMaxItems()).toContain('25'); expect(await pagination.getTotalPages()).toContain('of 5'); diff --git a/e2e/suites/pagination/multiple-pages-files.test.ts b/e2e/suites/pagination/multiple-pages-files.test.ts index a056a8647..0230eb378 100644 --- a/e2e/suites/pagination/multiple-pages-files.test.ts +++ b/e2e/suites/pagination/multiple-pages-files.test.ts @@ -23,12 +23,7 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - Utils, - AdminActions, - RepoClient -} from '@alfresco/aca-testing-shared'; +import { LoginPage, Utils, AdminActions, RepoClient } from '@alfresco/aca-testing-shared'; import { personalFilesTests } from './personal-files'; import { recentFilesTests } from './recent-files'; import { searchResultsTests } from './search-results'; @@ -55,7 +50,7 @@ describe('Pagination on multiple pages : ', () => { beforeAll(async () => { await adminApiActions.createUser({ username }); parentId = (await userApi.nodes.createFolder(parent)).entry.id; - filesIds = (await userApi.nodes.createFiles(files, parent)).list.entries.map(entries => entries.entry.id); + filesIds = (await userApi.nodes.createFiles(files, parent)).list.entries.map((entries: any) => entries.entry.id); await userApi.shared.shareFilesByIds(filesIds); await userApi.favorites.addFavoritesByIds('file', filesIds); @@ -63,7 +58,7 @@ describe('Pagination on multiple pages : ', () => { await Promise.all([ userApi.favorites.waitForApi({ expect: 101 }), userApi.shared.waitForApi({ expect: 101 }), - userApi.search.waitForApi(username, { expect: 101 }), + userApi.search.waitForApi(username, { expect: 101 }) ]); await loginPage.loginWith(username); @@ -92,5 +87,4 @@ describe('Pagination on multiple pages : ', () => { describe('on Favorites', () => { favoritesTests(); }); - }); diff --git a/e2e/suites/pagination/multiple-pages-libraries.test.ts b/e2e/suites/pagination/multiple-pages-libraries.test.ts index 5e15f714a..d7012b366 100755 --- a/e2e/suites/pagination/multiple-pages-libraries.test.ts +++ b/e2e/suites/pagination/multiple-pages-libraries.test.ts @@ -23,13 +23,7 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - Utils, - AdminActions, - RepoClient -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, Utils, AdminActions, RepoClient } from '@alfresco/aca-testing-shared'; describe('Pagination on multiple pages', () => { const random = Utils.random(); @@ -56,7 +50,7 @@ describe('Pagination on multiple pages', () => { afterAll(async () => { await userApi.sites.deleteSites(sites); - }) + }); describe('on My Libraries', () => { beforeAll(async () => { @@ -255,5 +249,4 @@ describe('Pagination on multiple pages', () => { expect(await pagination.isNextEnabled()).toBe(false, 'Next button is enabled on last page'); }); }); - }); diff --git a/e2e/suites/pagination/multiple-pages-trash.test.ts b/e2e/suites/pagination/multiple-pages-trash.test.ts index a053ebf55..a32771464 100755 --- a/e2e/suites/pagination/multiple-pages-trash.test.ts +++ b/e2e/suites/pagination/multiple-pages-trash.test.ts @@ -23,13 +23,7 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - Utils, - AdminActions, - RepoClient -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, Utils, AdminActions, RepoClient } from '@alfresco/aca-testing-shared'; describe('Pagination on multiple pages on Trash', () => { const random = Utils.random(); @@ -49,10 +43,10 @@ describe('Pagination on multiple pages on Trash', () => { beforeAll(async () => { await adminApiActions.createUser({ username }); - filesDeletedIds = (await userApi.nodes.createFiles(filesForDelete)).list.entries.map(entries => entries.entry.id); + filesDeletedIds = (await userApi.nodes.createFiles(filesForDelete)).list.entries.map((entries: any) => entries.entry.id); await userApi.nodes.deleteNodesById(filesDeletedIds, false); - await userApi.trashcan.waitForApi({expect: 101}); + await userApi.trashcan.waitForApi({ expect: 101 }); await loginPage.loginWith(username); await page.clickTrashAndWait(); diff --git a/e2e/suites/pagination/personal-files.ts b/e2e/suites/pagination/personal-files.ts index 52a53585e..f4b1fab7c 100755 --- a/e2e/suites/pagination/personal-files.ts +++ b/e2e/suites/pagination/personal-files.ts @@ -30,7 +30,6 @@ export function personalFilesTests(parentName: string) { const { dataTable, pagination } = page; describe('Pagination controls : ', () => { - beforeAll(async () => { await page.clickPersonalFilesAndWait(); await dataTable.doubleClickOnRowByName(parentName); diff --git a/e2e/suites/pagination/recent-files.ts b/e2e/suites/pagination/recent-files.ts index 77be62e8b..5c4d1a545 100755 --- a/e2e/suites/pagination/recent-files.ts +++ b/e2e/suites/pagination/recent-files.ts @@ -30,7 +30,6 @@ export function recentFilesTests() { const { dataTable, pagination } = page; describe('Pagination controls : ', () => { - beforeAll(async () => { await page.clickRecentFilesAndWait(); }); diff --git a/e2e/suites/pagination/search-results.ts b/e2e/suites/pagination/search-results.ts index 0622fefa1..09bfc6b5b 100755 --- a/e2e/suites/pagination/search-results.ts +++ b/e2e/suites/pagination/search-results.ts @@ -31,7 +31,6 @@ export function searchResultsTests() { const { searchInput } = page.header; describe('Pagination controls : ', () => { - beforeAll(async () => { await searchInput.clickSearchButton(); await searchInput.searchFor('my-file-'); diff --git a/e2e/suites/pagination/shared-files.ts b/e2e/suites/pagination/shared-files.ts index 11de1a93e..f53d59498 100755 --- a/e2e/suites/pagination/shared-files.ts +++ b/e2e/suites/pagination/shared-files.ts @@ -30,7 +30,6 @@ export function sharedFilesTests() { const { dataTable, pagination } = page; describe('Pagination controls : ', () => { - beforeAll(async () => { await page.clickSharedFilesAndWait(); }); diff --git a/e2e/suites/pagination/single-page.test.ts b/e2e/suites/pagination/single-page.test.ts index 6f84665a5..30dad7753 100755 --- a/e2e/suites/pagination/single-page.test.ts +++ b/e2e/suites/pagination/single-page.test.ts @@ -23,14 +23,7 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - SearchResultsPage, - Utils, - AdminActions, - RepoClient -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, SearchResultsPage, Utils, AdminActions, RepoClient } from '@alfresco/aca-testing-shared'; describe('Pagination on single page', () => { const random = Utils.random(); @@ -76,11 +69,7 @@ describe('Pagination on single page', () => { }); afterAll(async () => { - await Promise.all([ - userApi.nodes.deleteNodeById(fileId), - userApi.sites.deleteSite(siteId), - userApi.trashcan.emptyTrash() - ]); + await Promise.all([userApi.nodes.deleteNodeById(fileId), userApi.sites.deleteSite(siteId), userApi.trashcan.emptyTrash()]); }); it('[C280112] page selector not displayed on Favorites', async () => { @@ -124,5 +113,4 @@ describe('Pagination on single page', () => { await searchResultsPage.waitForResults(); expect(await pagination.isPagesButtonPresent()).toBe(false, 'page selector displayed'); }); - }); diff --git a/e2e/suites/search/search-filters.test.ts b/e2e/suites/search/search-filters.test.ts index c3bc30f2f..7edcd5b69 100644 --- a/e2e/suites/search/search-filters.test.ts +++ b/e2e/suites/search/search-filters.test.ts @@ -23,17 +23,9 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - SearchResultsPage, - RepoClient, - Utils, - FILES, - SITE_VISIBILITY, - SITE_ROLES -} from '@alfresco/aca-testing-shared'; +import { LoginPage, SearchResultsPage, RepoClient, Utils, FILES, SITE_VISIBILITY, SITE_ROLES } from '@alfresco/aca-testing-shared'; -import * as moment from 'moment'; +const moment = require('moment'); describe('Search filters', () => { const random = Utils.random(); @@ -44,7 +36,8 @@ describe('Search filters', () => { const parent = `parent-${random}`; let parentId: string; - const site = `site-${Utils.random()}`; let docLibId; + const site = `site-${Utils.random()}`; + let docLibId: string; const fileJpgUser1 = { name: `search-filters-file-1-${random}.jpg`, @@ -112,10 +105,7 @@ describe('Search filters', () => { }); afterAll(async (done) => { - await Promise.all([ - apis.user1.nodes.deleteNodeById(parentId), - apis.user1.sites.deleteSite(site) - ]); + await Promise.all([apis.user1.nodes.deleteNodeById(parentId), apis.user1.sites.deleteSite(site)]); done(); }); @@ -562,7 +552,10 @@ describe('Search filters', () => { await modifiedDateFilter.expandPanel(); expect(await modifiedDateFilter.getFiltersValues()).toEqual(expectedDateFilters, 'Incorrect Modified date filters facets'); await modifiedDateFilter.filterCategoriesBy('This'); - expect(await modifiedDateFilter.getFiltersValues()).toEqual(['This week (2)', 'This month (2)', 'This year (2)'], 'Incorrect Modified date filters facets'); + expect(await modifiedDateFilter.getFiltersValues()).toEqual( + ['This week (2)', 'This month (2)', 'This year (2)'], + 'Incorrect Modified date filters facets' + ); }); }); diff --git a/e2e/suites/search/search-results-files-folders.test.ts b/e2e/suites/search/search-results-files-folders.test.ts index aa52dccbd..b96d84cd3 100644 --- a/e2e/suites/search/search-results-files-folders.test.ts +++ b/e2e/suites/search/search-results-files-folders.test.ts @@ -23,29 +23,23 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - SearchResultsPage, - RepoClient, - Utils -} from '@alfresco/aca-testing-shared'; - -import * as moment from 'moment'; +import { LoginPage, SearchResultsPage, RepoClient, Utils } from '@alfresco/aca-testing-shared'; +const moment = require('moment'); describe('Search results - files and folders', () => { const username = `user-${Utils.random()}`; const file = `test-file-${Utils.random()}.txt`; - let fileId; + let fileId: string; const fileTitle = 'file title'; const fileDescription = 'file description'; /* cspell:disable-next-line */ const fileRussian = `любимый-сайт-${Utils.random()}`; - let fileRussianId; + let fileRussianId: string; const folder = `test-folder-${Utils.random()}`; - let folderId; + let folderId: string; const folderTitle = 'folder title'; const folderDescription = 'folder description'; @@ -61,7 +55,7 @@ describe('Search results - files and folders', () => { const { searchInput } = page.header; const { dataTable, breadcrumb } = page; - beforeAll(async done => { + beforeAll(async (done) => { await apis.admin.people.createUser({ username }); fileId = (await apis.user.nodes.createFile(file, '-my-', fileTitle, fileDescription)).entry.id; @@ -77,12 +71,12 @@ describe('Search results - files and folders', () => { done(); }); - beforeEach(async done => { + beforeEach(async (done) => { await page.refresh(); done(); }); - afterAll(async done => { + afterAll(async (done) => { await Promise.all([ apis.user.nodes.deleteNodeById(fileId), apis.user.nodes.deleteNodeById(fileRussianId), diff --git a/e2e/suites/search/search-results-general.test.ts b/e2e/suites/search/search-results-general.test.ts index c6f568fc3..2e78fff3a 100644 --- a/e2e/suites/search/search-results-general.test.ts +++ b/e2e/suites/search/search-results-general.test.ts @@ -23,20 +23,16 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - SearchResultsPage, - RepoClient, - Utils -} from '@alfresco/aca-testing-shared'; - +import { LoginPage, SearchResultsPage, RepoClient, Utils } from '@alfresco/aca-testing-shared'; import { browser } from 'protractor'; describe('Search results general', () => { const username = `user-${Utils.random()}`; - const file = `test-file-${Utils.random()}.txt`; let fileId; - const folder = `test-folder-${Utils.random()}`; let folderId; + const file = `test-file-${Utils.random()}.txt`; + let fileId: string; + const folder = `test-folder-${Utils.random()}`; + let folderId: string; const site = `test-site-${Utils.random()}`; const apis = { @@ -64,11 +60,7 @@ describe('Search results general', () => { }); afterAll(async (done) => { - await Promise.all([ - apis.user.nodes.deleteNodeById(fileId), - apis.user.nodes.deleteNodeById(folderId), - apis.user.sites.deleteSite(site) - ]); + await Promise.all([apis.user.nodes.deleteNodeById(fileId), apis.user.nodes.deleteNodeById(folderId), apis.user.sites.deleteSite(site)]); done(); }); @@ -152,5 +144,4 @@ describe('Search results general', () => { expect(await dataTable.isItemPresent(site)).toBe(true, `${site} not displayed`); }); - }); diff --git a/e2e/suites/search/search-results-libraries.test.ts b/e2e/suites/search/search-results-libraries.test.ts index ad3bae632..fc54ff1cb 100644 --- a/e2e/suites/search/search-results-libraries.test.ts +++ b/e2e/suites/search/search-results-libraries.test.ts @@ -23,14 +23,7 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - SearchResultsPage, - RepoClient, - Utils, - SITE_VISIBILITY, - SITE_ROLES -} from '@alfresco/aca-testing-shared'; +import { LoginPage, SearchResultsPage, RepoClient, Utils, SITE_VISIBILITY, SITE_ROLES } from '@alfresco/aca-testing-shared'; describe('Search results - libraries', () => { const username = `user-${Utils.random()}`; @@ -114,8 +107,8 @@ describe('Search results - libraries', () => { afterAll(async (done) => { await Promise.all([ - apis.admin.sites.deleteSites([ adminSite1, adminSite2, adminSite3, adminSite4, adminPrivate ]), - apis.user.sites.deleteSites([ site1.id, site2.id, site3.id, site4.id, userSitePublic, userSiteModerated, userSitePrivate, siteRussian.id ]) + apis.admin.sites.deleteSites([adminSite1, adminSite2, adminSite3, adminSite4, adminPrivate]), + apis.user.sites.deleteSites([site1.id, site2.id, site3.id, site4.id, userSitePublic, userSiteModerated, userSitePrivate, siteRussian.id]) ]); done(); }); @@ -176,7 +169,7 @@ describe('Search results - libraries', () => { await searchInput.searchFor(site1.name); await dataTable.waitForBody(); - const expectedColumns = [ 'Name', 'Description', 'My Role', 'Visibility' ]; + const expectedColumns = ['Name', 'Description', 'My Role', 'Visibility']; const actualColumns = await dataTable.getColumnHeadersText(); expect(actualColumns).toEqual(expectedColumns); @@ -214,7 +207,7 @@ describe('Search results - libraries', () => { [adminSite4]: SITE_ROLES.SITE_MANAGER.LABEL }; - const sitesList = await dataTable.getSitesNameAndRole(); + const sitesList: any = await dataTable.getSitesNameAndRole(); for (const site of Object.keys(expectedSitesRoles)) { expect(sitesList[site]).toEqual(expectedSitesRoles[site]); @@ -238,5 +231,4 @@ describe('Search results - libraries', () => { expect(await dataTable.isItemPresent(siteRussian.name)).toBe(true, `${siteRussian.name} not displayed`); }); - }); diff --git a/e2e/suites/search/search-sorting.test.ts b/e2e/suites/search/search-sorting.test.ts index 1f365869e..36d44cd72 100644 --- a/e2e/suites/search/search-sorting.test.ts +++ b/e2e/suites/search/search-sorting.test.ts @@ -23,13 +23,7 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - SearchResultsPage, - RepoClient, - Utils, - FILES -} from '@alfresco/aca-testing-shared'; +import { LoginPage, SearchResultsPage, RepoClient, Utils, FILES } from '@alfresco/aca-testing-shared'; describe('Search sorting', () => { const random = Utils.random(); @@ -101,7 +95,7 @@ describe('Search sorting', () => { await page.sortingPicker.clickSortByDropdown(); - const expectedOptions = [ 'Relevance', 'Filename', 'Title', 'Modified date', 'Modifier', 'Created date', 'Size', 'Type' ]; + const expectedOptions = ['Relevance', 'Filename', 'Title', 'Modified date', 'Modifier', 'Created date', 'Size', 'Type']; expect(await page.sortingPicker.getSortByOptionsList()).toEqual(expectedOptions, 'Incorrect sort options list'); }); diff --git a/e2e/suites/viewer/viewer-actions.test.ts b/e2e/suites/viewer/viewer-actions.test.ts index 4218419ba..719904fb7 100755 --- a/e2e/suites/viewer/viewer-actions.test.ts +++ b/e2e/suites/viewer/viewer-actions.test.ts @@ -59,25 +59,33 @@ describe('Viewer actions', () => { const manageVersionsDialog = new ManageVersionsDialog(); const uploadNewVersionDialog = new UploadNewVersionDialog(); - beforeAll(async done => { + beforeAll(async (done) => { await apis.admin.people.createUser({ username }); done(); }); describe('from Personal Files', () => { - const parent = `parentPF-${Utils.random()}`; let parentId; - const destination = `destPF-${Utils.random()}`; let destinationId; + const parent = `parentPF-${Utils.random()}`; + let parentId: string; + const destination = `destPF-${Utils.random()}`; + let destinationId: string; - const docxPersonalFiles = `docxPF-${Utils.random()}.docx`; let docxFileId; + const docxPersonalFiles = `docxPF-${Utils.random()}.docx`; + let docxFileId: string; const xlsxPersonalFiles = `xlsxPF-${Utils.random()}.xlsx`; const pdfPersonalFiles = `pdfPF-${Utils.random()}.pdf`; - const filePersonalFiles = docxFile2; let filePersonalFilesId; + const filePersonalFiles = docxFile2; + let filePersonalFilesId: string; - const fileForEditOffline = `file1-${Utils.random()}.docx`; let fileForEditOfflineId; - const fileForCancelEditing = `file2-${Utils.random()}.docx`; let fileForCancelEditingId; - const fileForUploadNewVersion = `file3-${Utils.random()}.docx`; let fileForUploadNewVersionId; - const fileForUploadNewVersion2 = `file4-${Utils.random()}.docx`; let fileForUploadNewVersionId2; + const fileForEditOffline = `file1-${Utils.random()}.docx`; + let fileForEditOfflineId: string; + const fileForCancelEditing = `file2-${Utils.random()}.docx`; + let fileForCancelEditingId: string; + const fileForUploadNewVersion = `file3-${Utils.random()}.docx`; + let fileForUploadNewVersionId: string; + const fileForUploadNewVersion2 = `file4-${Utils.random()}.docx`; + let fileForUploadNewVersionId2: string; beforeAll(async (done) => { parentId = (await apis.user.nodes.createFolder(parent)).entry.id; @@ -98,7 +106,6 @@ describe('Viewer actions', () => { await apis.user.nodes.lockFile(fileForUploadNewVersionId); await apis.user.nodes.lockFile(fileForUploadNewVersionId2); - await loginPage.loginWith(username); done(); }); @@ -291,17 +298,23 @@ describe('Viewer actions', () => { describe('from File Libraries', () => { const siteName = `site-${Utils.random()}`; - const destination = `destFL-${Utils.random()}`; let destinationId; + const destination = `destFL-${Utils.random()}`; + let destinationId: string; - const docxLibraries = `docxFL-${Utils.random()}.docx`; let docxFileId; + const docxLibraries = `docxFL-${Utils.random()}.docx`; + let docxFileId: string; const xlsxLibraries = `xlsxFL-${Utils.random()}.xlsx`; const pdfLibraries = `pdfFL-${Utils.random()}.pdf`; - const fileLibraries = docxFile2; let fileLibrariesId; + const fileLibraries = docxFile2; + let fileLibrariesId: string; - const fileForEditOffline = `file1-${Utils.random()}.docx`; let fileForEditOfflineId; - const fileForCancelEditing = `file2-${Utils.random()}.docx`; let fileForCancelEditingId; - const fileForUploadNewVersion = `file3-${Utils.random()}.docx`; let fileForUploadNewVersionId; + const fileForEditOffline = `file1-${Utils.random()}.docx`; + let fileForEditOfflineId: string; + const fileForCancelEditing = `file2-${Utils.random()}.docx`; + let fileForCancelEditingId: string; + const fileForUploadNewVersion = `file3-${Utils.random()}.docx`; + let fileForUploadNewVersionId: string; beforeAll(async (done) => { await apis.user.sites.createSite(siteName); @@ -469,21 +482,28 @@ describe('Viewer actions', () => { }); describe('from Recent Files', () => { - const parent = `parentRF-${Utils.random()}`; let parentId; - const destination = `destRF-${Utils.random()}`; let destinationId; + const parent = `parentRF-${Utils.random()}`; + let parentId: string; + const destination = `destRF-${Utils.random()}`; + let destinationId: string; - const docxRecentFiles = `docxRF-${Utils.random()}.docx`; let docxFileId; + const docxRecentFiles = `docxRF-${Utils.random()}.docx`; + let docxFileId: string; const xlsxRecentFiles = `xlsxRF-${Utils.random()}.xlsx`; const pdfRecentFiles = `pdfRF-${Utils.random()}.pdf`; - const fileRecent = docxFile2; let fileRecentId; + const fileRecent = docxFile2; + let fileRecentId: string; - const fileForEditOffline = `file1-${Utils.random()}.docx`; let fileForEditOfflineId; - const fileForCancelEditing = `file2-${Utils.random()}.docx`; let fileForCancelEditingId; - const fileForUploadNewVersion = `file3-${Utils.random()}.docx`; let fileForUploadNewVersionId; + const fileForEditOffline = `file1-${Utils.random()}.docx`; + let fileForEditOfflineId: string; + const fileForCancelEditing = `file2-${Utils.random()}.docx`; + let fileForCancelEditingId: string; + const fileForUploadNewVersion = `file3-${Utils.random()}.docx`; + let fileForUploadNewVersionId: string; beforeAll(async (done) => { - await apis.user.search.waitForApi(username, {expect: 0}); + await apis.user.search.waitForApi(username, { expect: 0 }); parentId = (await apis.user.nodes.createFolder(parent)).entry.id; destinationId = (await apis.user.nodes.createFolder(destination)).entry.id; @@ -498,11 +518,10 @@ describe('Viewer actions', () => { await apis.user.nodes.lockFile(fileForCancelEditingId); await apis.user.nodes.lockFile(fileForUploadNewVersionId); - await apis.user.upload.uploadFileWithRename(xlsxFileForMove, parentId, xlsxRecentFiles); await apis.user.upload.uploadFileWithRename(pdfFileForDelete, parentId, pdfRecentFiles); - await apis.user.search.waitForApi(username, {expect: 7}); + await apis.user.search.waitForApi(username, { expect: 7 }); await loginPage.loginWith(username); done(); @@ -651,18 +670,27 @@ describe('Viewer actions', () => { }); describe('from Shared Files', () => { - const parent = `parentSF-${Utils.random()}`; let parentId; - const destination = `destSF-${Utils.random()}`; let destinationId; + const parent = `parentSF-${Utils.random()}`; + let parentId: string; + const destination = `destSF-${Utils.random()}`; + let destinationId: string; - const docxSharedFiles = `docxSF-${Utils.random()}.docx`; let docxFileId; + const docxSharedFiles = `docxSF-${Utils.random()}.docx`; + let docxFileId: string; - const xlsxSharedFiles = `xlsxSF-${Utils.random()}.xlsx`; let xlsxFileId; - const pdfSharedFiles = `pdfSF-${Utils.random()}.pdf`; let pdfFileId; - const fileShared = docxFile2; let fileSharedId; + const xlsxSharedFiles = `xlsxSF-${Utils.random()}.xlsx`; + let xlsxFileId: string; + const pdfSharedFiles = `pdfSF-${Utils.random()}.pdf`; + let pdfFileId: string; + const fileShared = docxFile2; + let fileSharedId: string; - const fileForEditOffline = `file1-${Utils.random()}.docx`; let fileForEditOfflineId; - const fileForCancelEditing = `file2-${Utils.random()}.docx`; let fileForCancelEditingId; - const fileForUploadNewVersion = `file3-${Utils.random()}.docx`; let fileForUploadNewVersionId; + const fileForEditOffline = `file1-${Utils.random()}.docx`; + let fileForEditOfflineId: string; + const fileForCancelEditing = `file2-${Utils.random()}.docx`; + let fileForCancelEditingId: string; + const fileForUploadNewVersion = `file3-${Utils.random()}.docx`; + let fileForUploadNewVersionId; beforeAll(async (done) => { parentId = (await apis.user.nodes.createFolder(parent)).entry.id; @@ -680,8 +708,16 @@ describe('Viewer actions', () => { await apis.user.nodes.lockFile(fileForCancelEditingId); await apis.user.nodes.lockFile(fileForUploadNewVersionId); - await apis.user.shared.shareFilesByIds([docxFileId, xlsxFileId, pdfFileId, fileForCancelEditingId, fileForEditOfflineId, fileForUploadNewVersionId, fileSharedId]) - await apis.user.shared.waitForApi({expect: 7}); + await apis.user.shared.shareFilesByIds([ + docxFileId, + xlsxFileId, + pdfFileId, + fileForCancelEditingId, + fileForEditOfflineId, + fileForUploadNewVersionId, + fileSharedId + ]); + await apis.user.shared.waitForApi({ expect: 7 }); await loginPage.loginWith(username); done(); @@ -831,19 +867,26 @@ describe('Viewer actions', () => { describe('from Favorites', () => { const parent = `parentFav-${Utils.random()}`; - let parentId; + let parentId: string; const destination = `destFav-${Utils.random()}`; - let destinationId; + let destinationId: string; - const docxFavorites = `docxFav-${Utils.random()}.docx`; let docxFileId; + const docxFavorites = `docxFav-${Utils.random()}.docx`; + let docxFileId: string; - const xlsxFavorites = `xlsxFav-${Utils.random()}.xlsx`; let xlsxFileId; - const pdfFavorites = `pdfFav-${Utils.random()}.pdf`; let pdfFileId; - const fileFav = docxFile2; let fileFavId; + const xlsxFavorites = `xlsxFav-${Utils.random()}.xlsx`; + let xlsxFileId: string; + const pdfFavorites = `pdfFav-${Utils.random()}.pdf`; + let pdfFileId: string; + const fileFav = docxFile2; + let fileFavId: string; - const fileForEditOffline = `file1-${Utils.random()}.docx`; let fileForEditOfflineId; - const fileForCancelEditing = `file2-${Utils.random()}.docx`; let fileForCancelEditingId; - const fileForUploadNewVersion = `file3-${Utils.random()}.docx`; let fileForUploadNewVersionId; + const fileForEditOffline = `file1-${Utils.random()}.docx`; + let fileForEditOfflineId: string; + const fileForCancelEditing = `file2-${Utils.random()}.docx`; + let fileForCancelEditingId: string; + const fileForUploadNewVersion = `file3-${Utils.random()}.docx`; + let fileForUploadNewVersionId: string; beforeAll(async (done) => { parentId = (await apis.user.nodes.createFolder(parent)).entry.id; @@ -861,9 +904,16 @@ describe('Viewer actions', () => { await apis.user.nodes.lockFile(fileForCancelEditingId); await apis.user.nodes.lockFile(fileForUploadNewVersionId); - - await apis.user.favorites.addFavoritesByIds('file', [docxFileId, xlsxFileId, pdfFileId, fileForEditOfflineId, fileForCancelEditingId, fileForUploadNewVersionId, fileFavId]) - await apis.user.favorites.waitForApi({expect: 7}); + await apis.user.favorites.addFavoritesByIds('file', [ + docxFileId, + xlsxFileId, + pdfFileId, + fileForEditOfflineId, + fileForCancelEditingId, + fileForUploadNewVersionId, + fileFavId + ]); + await apis.user.favorites.waitForApi({ expect: 7 }); await loginPage.loginWith(username); done(); diff --git a/e2e/suites/viewer/viewer-general.test.ts b/e2e/suites/viewer/viewer-general.test.ts index aab57b986..bb16672af 100755 --- a/e2e/suites/viewer/viewer-general.test.ts +++ b/e2e/suites/viewer/viewer-general.test.ts @@ -23,175 +23,172 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - FILES, SITE_VISIBILITY, - RepoClient, - Utils, - Viewer -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, FILES, SITE_VISIBILITY, RepoClient, Utils, Viewer } from '@alfresco/aca-testing-shared'; describe('Viewer general', () => { - const username = `user-${Utils.random()}`; + const username = `user-${Utils.random()}`; - const parent = `parent-${Utils.random()}`; let parentId; + const parent = `parent-${Utils.random()}`; + let parentId: string; - const xlsxFile = FILES.xlsxFile; let xlsxFileId; - const fileAdmin = FILES.docxFile; let fileAdminId; + const xlsxFile = FILES.xlsxFile; + let xlsxFileId: string; + const fileAdmin = FILES.docxFile; + let fileAdminId: string; - const siteAdmin = `siteAdmin-${Utils.random()}`; let docLibId; - const siteUser = `siteUser-${Utils.random()}`; let docLibSiteUserId; + const siteAdmin = `siteAdmin-${Utils.random()}`; + let docLibId: string; + const siteUser = `siteUser-${Utils.random()}`; + let docLibSiteUserId: string; - const fileInSite = FILES.docxFile; + const fileInSite = FILES.docxFile; - const apis = { - admin: new RepoClient(), - user: new RepoClient(username, username) - }; + const apis = { + admin: new RepoClient(), + user: new RepoClient(username, username) + }; - const loginPage = new LoginPage(); - const page = new BrowsingPage(); - const { dataTable } = page; - const viewer = new Viewer(); - const { searchInput } = page.header; + const loginPage = new LoginPage(); + const page = new BrowsingPage(); + const { dataTable } = page; + const viewer = new Viewer(); + const { searchInput } = page.header; - beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); - parentId = (await apis.user.nodes.createFolder(parent)).entry.id; - xlsxFileId = (await apis.user.upload.uploadFile(xlsxFile, parentId)).entry.id; + beforeAll(async (done) => { + await apis.admin.people.createUser({ username }); + parentId = (await apis.user.nodes.createFolder(parent)).entry.id; + xlsxFileId = (await apis.user.upload.uploadFile(xlsxFile, parentId)).entry.id; - await apis.admin.sites.createSite(siteAdmin, SITE_VISIBILITY.PRIVATE); - docLibId = await apis.admin.sites.getDocLibId(siteAdmin); - fileAdminId = (await apis.admin.upload.uploadFile(fileAdmin, docLibId)).entry.id; + await apis.admin.sites.createSite(siteAdmin, SITE_VISIBILITY.PRIVATE); + docLibId = await apis.admin.sites.getDocLibId(siteAdmin); + fileAdminId = (await apis.admin.upload.uploadFile(fileAdmin, docLibId)).entry.id; - await apis.user.sites.createSite(siteUser, SITE_VISIBILITY.PUBLIC); - docLibSiteUserId = await apis.user.sites.getDocLibId(siteUser); - await apis.user.upload.uploadFile(fileInSite, docLibSiteUserId); + await apis.user.sites.createSite(siteUser, SITE_VISIBILITY.PUBLIC); + docLibSiteUserId = await apis.user.sites.getDocLibId(siteUser); + await apis.user.upload.uploadFile(fileInSite, docLibSiteUserId); - await apis.user.shared.shareFileById(xlsxFileId); - await apis.user.shared.waitForApi({ expect: 1 }); - await apis.user.favorites.addFavoriteById('file', xlsxFileId); - await apis.user.favorites.waitForApi({ expect: 2 }); + await apis.user.shared.shareFileById(xlsxFileId); + await apis.user.shared.waitForApi({ expect: 1 }); + await apis.user.favorites.addFavoriteById('file', xlsxFileId); + await apis.user.favorites.waitForApi({ expect: 2 }); - await loginPage.loginWith(username); - done(); - }); + await loginPage.loginWith(username); + done(); + }); - beforeEach(async (done) => { - await page.header.expandSideNav(); - await page.clickPersonalFilesAndWait(); - await dataTable.doubleClickOnRowByName(parent); - await dataTable.waitForHeader(); - done(); - }); + beforeEach(async (done) => { + await page.header.expandSideNav(); + await page.clickPersonalFilesAndWait(); + await dataTable.doubleClickOnRowByName(parent); + await dataTable.waitForHeader(); + done(); + }); - afterEach(async (done) => { - await Utils.pressEscape(); - await page.header.expandSideNav(); - done(); - }); + afterEach(async (done) => { + await Utils.pressEscape(); + await page.header.expandSideNav(); + done(); + }); - afterAll(async (done) => { - await apis.user.nodes.deleteNodeById(parentId); - await apis.admin.sites.deleteSite(siteAdmin); - await apis.user.sites.deleteSite(siteUser); - done(); - }); + afterAll(async (done) => { + await apis.user.nodes.deleteNodeById(parentId); + await apis.admin.sites.deleteSite(siteAdmin); + await apis.user.sites.deleteSite(siteUser); + done(); + }); - it('[C279269] Viewer opens on double clicking on a file from Personal Files', async () => { - await dataTable.doubleClickOnRowByName(xlsxFile); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - }); + it('[C279269] Viewer opens on double clicking on a file from Personal Files', async () => { + await dataTable.doubleClickOnRowByName(xlsxFile); + expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); + }); - it('[C279270] Viewer opens when clicking the View action for a file', async () => { - await dataTable.selectItem(xlsxFile); - await page.toolbar.viewButton.click(); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - }); + it('[C279270] Viewer opens when clicking the View action for a file', async () => { + await dataTable.selectItem(xlsxFile); + await page.toolbar.viewButton.click(); + expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); + }); - it('[C279283] The viewer general elements are displayed', async () => { - await dataTable.doubleClickOnRowByName(xlsxFile); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - expect(await viewer.isViewerToolbarDisplayed()).toBe(true, 'Toolbar not displayed'); - expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed'); - expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed'); - }); + it('[C279283] The viewer general elements are displayed', async () => { + await dataTable.doubleClickOnRowByName(xlsxFile); + expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); + expect(await viewer.isViewerToolbarDisplayed()).toBe(true, 'Toolbar not displayed'); + expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed'); + expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed'); + }); - it('[C279271] Close the viewer', async () => { - await dataTable.doubleClickOnRowByName(xlsxFile); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - await viewer.closeButton.click(); - expect(await viewer.isViewerOpened()).toBe(false, 'Viewer did not close'); - }); + it('[C279271] Close the viewer', async () => { + await dataTable.doubleClickOnRowByName(xlsxFile); + expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); + await viewer.closeButton.click(); + expect(await viewer.isViewerOpened()).toBe(false, 'Viewer did not close'); + }); - it('[C284632] Close button tooltip', async () => { - await dataTable.doubleClickOnRowByName(xlsxFile); - expect(await viewer.getCloseButtonTooltip()).toEqual('Close'); - }); + it('[C284632] Close button tooltip', async () => { + await dataTable.doubleClickOnRowByName(xlsxFile); + expect(await viewer.getCloseButtonTooltip()).toEqual('Close'); + }); - it('[C279285] Viewer opens when accessing the preview URL for a file', async () => { - const previewURL = `personal-files/${parentId}/(viewer:view/${xlsxFileId})` - await page.load(previewURL); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - expect(await viewer.getFileTitle()).toEqual(xlsxFile); - }); + it('[C279285] Viewer opens when accessing the preview URL for a file', async () => { + const previewURL = `personal-files/${parentId}/(viewer:view/${xlsxFileId})`; + await page.load(previewURL); + expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); + expect(await viewer.getFileTitle()).toEqual(xlsxFile); + }); - it('[C279287] Viewer does not open when accessing the preview URL for a file without permissions', async () => { - const previewURL = `libraries/${docLibId}/(viewer:view/${fileAdminId})` - await page.load(previewURL); - expect(await viewer.isViewerOpened()).toBe(false, 'Viewer should not be opened!'); - }); + it('[C279287] Viewer does not open when accessing the preview URL for a file without permissions', async () => { + const previewURL = `libraries/${docLibId}/(viewer:view/${fileAdminId})`; + await page.load(previewURL); + expect(await viewer.isViewerOpened()).toBe(false, 'Viewer should not be opened!'); + }); - it('[C284633] Viewer opens for a file from File Libraries', async () => { - await page.goToMyLibrariesAndWait(); - await dataTable.doubleClickOnRowByName(siteUser); - await dataTable.waitForHeader(); - await dataTable.doubleClickOnRowByName(fileInSite); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - expect(await viewer.isViewerToolbarDisplayed()).toBe(true, 'Toolbar not displayed'); - expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed'); - expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed'); - }); + it('[C284633] Viewer opens for a file from File Libraries', async () => { + await page.goToMyLibrariesAndWait(); + await dataTable.doubleClickOnRowByName(siteUser); + await dataTable.waitForHeader(); + await dataTable.doubleClickOnRowByName(fileInSite); + expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); + expect(await viewer.isViewerToolbarDisplayed()).toBe(true, 'Toolbar not displayed'); + expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed'); + expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed'); + }); - it('[C284636] Viewer opens for a file from Recent Files', async () => { - await page.clickRecentFilesAndWait(); - await dataTable.doubleClickOnRowByName(xlsxFile); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - expect(await viewer.isViewerToolbarDisplayed()).toBe(true, 'Toolbar not displayed'); - expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed'); - expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed'); - }); + it('[C284636] Viewer opens for a file from Recent Files', async () => { + await page.clickRecentFilesAndWait(); + await dataTable.doubleClickOnRowByName(xlsxFile); + expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); + expect(await viewer.isViewerToolbarDisplayed()).toBe(true, 'Toolbar not displayed'); + expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed'); + expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed'); + }); - it('[C284635] Viewer opens for a file from Shared Files', async () => { - await page.clickSharedFilesAndWait(); - await dataTable.doubleClickOnRowByName(xlsxFile); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - expect(await viewer.isViewerToolbarDisplayed()).toBe(true, 'Toolbar not displayed'); - expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed'); - expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed'); - }); + it('[C284635] Viewer opens for a file from Shared Files', async () => { + await page.clickSharedFilesAndWait(); + await dataTable.doubleClickOnRowByName(xlsxFile); + expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); + expect(await viewer.isViewerToolbarDisplayed()).toBe(true, 'Toolbar not displayed'); + expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed'); + expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed'); + }); - it('[C284634] Viewer opens for a file from Favorites', async () => { - await page.clickFavoritesAndWait(); - await dataTable.doubleClickOnRowByName(xlsxFile); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - expect(await viewer.isViewerToolbarDisplayed()).toBe(true, 'Toolbar not displayed'); - expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed'); - expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed'); - }); + it('[C284634] Viewer opens for a file from Favorites', async () => { + await page.clickFavoritesAndWait(); + await dataTable.doubleClickOnRowByName(xlsxFile); + expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); + expect(await viewer.isViewerToolbarDisplayed()).toBe(true, 'Toolbar not displayed'); + expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed'); + expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed'); + }); - it('[C279175] Viewer opens for a file from Search Results', async () => { - await searchInput.clickSearchButton(); - await searchInput.checkFilesAndFolders(); - await searchInput.searchFor(xlsxFile); - await dataTable.waitForBody(); - - await dataTable.doubleClickOnRowByName(xlsxFile); - expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); - expect(await viewer.isViewerToolbarDisplayed()).toBe(true, 'Toolbar not displayed'); - expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed'); - expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed'); - }); + it('[C279175] Viewer opens for a file from Search Results', async () => { + await searchInput.clickSearchButton(); + await searchInput.checkFilesAndFolders(); + await searchInput.searchFor(xlsxFile); + await dataTable.waitForBody(); + await dataTable.doubleClickOnRowByName(xlsxFile); + expect(await viewer.isViewerOpened()).toBe(true, 'Viewer is not opened'); + expect(await viewer.isViewerToolbarDisplayed()).toBe(true, 'Toolbar not displayed'); + expect(await viewer.isCloseButtonDisplayed()).toBe(true, 'Close button is not displayed'); + expect(await viewer.isFileTitleDisplayed()).toBe(true, 'File title is not displayed'); + }); }); diff --git a/e2e/suites/viewer/viewer-protected-file.test.ts b/e2e/suites/viewer/viewer-protected-file.test.ts index c9e327d20..1dab326c9 100755 --- a/e2e/suites/viewer/viewer-protected-file.test.ts +++ b/e2e/suites/viewer/viewer-protected-file.test.ts @@ -23,20 +23,13 @@ * along with Alfresco. If not, see . */ -import { - LoginPage, - BrowsingPage, - FILES, - RepoClient, - Utils, - Viewer, - PasswordDialog -} from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, FILES, RepoClient, Utils, Viewer, PasswordDialog } from '@alfresco/aca-testing-shared'; describe('Viewer - password protected file', () => { const username = `user-${Utils.random()}`; - const parent = `parent-${Utils.random()}`; let parentId; + const parent = `parent-${Utils.random()}`; + let parentId: string; const protectedFile = FILES.protectedFile; diff --git a/e2e/tsconfig.e2e.typecheck.json b/e2e/tsconfig.e2e.typecheck.json index 6e22a100d..16ba2db36 100644 --- a/e2e/tsconfig.e2e.typecheck.json +++ b/e2e/tsconfig.e2e.typecheck.json @@ -2,6 +2,10 @@ "extends": "./tsconfig.e2e.json", "compilerOptions": { "noEmit": true, - "noUnusedLocals": true + "noUnusedLocals": true, + "noImplicitAny": true, + "esModuleInterop": true, + "allowJs": true, + "allowSyntheticDefaultImports": true } } diff --git a/package-lock.json b/package-lock.json index 66b51fb84..3e202f1c9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2683,12 +2683,24 @@ "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", "dev": true }, + "@types/cookiejar": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@types/cookiejar/-/cookiejar-2.1.1.tgz", + "integrity": "sha512-aRnpPa7ysx3aNW60hTiCtLHlQaIFsXFCgQlpakNgDNVFzbtusSY8PwjAQgRWfSk0ekNoBjO51eQRB6upA9uuyw==", + "dev": true + }, "@types/estree": { "version": "0.0.39", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", "dev": true }, + "@types/event-emitter": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/@types/event-emitter/-/event-emitter-0.3.3.tgz", + "integrity": "sha512-UfnOK1pIxO7P+EgPRZXD9jMpimd8QEFcEZ5R67R1UhGbv4zghU5+NE7U8M8G9H5Jc8FI51rqDWQs6FtUfq2e/Q==", + "dev": true + }, "@types/glob": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.1.3.tgz", @@ -2777,6 +2789,16 @@ "integrity": "sha512-K5K+yml8LTo9bWJI/rECfIPrGgxdpeNbj+d53lwN4QjW1MCwlkhUms+gtdzigTeUyBr09+u8BwOIY3MXvHdcsA==", "dev": true }, + "@types/superagent": { + "version": "4.1.8", + "resolved": "https://registry.npmjs.org/@types/superagent/-/superagent-4.1.8.tgz", + "integrity": "sha512-iol9KxQ7SLHatBJUiZ4uABrS4VS1frLjqPednxZz82eoCzo3Uy3TOH0p0ZIBbfBj8E/xqOtvizjBs9h7xi/l2g==", + "dev": true, + "requires": { + "@types/cookiejar": "*", + "@types/node": "*" + } + }, "@types/webpack-sources": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/@types/webpack-sources/-/webpack-sources-0.1.8.tgz", @@ -14144,9 +14166,9 @@ "dev": true }, "prettier": { - "version": "1.19.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz", - "integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==", + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.5.tgz", + "integrity": "sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==", "dev": true }, "process": { diff --git a/package.json b/package.json index fdf3b37b9..86a736283 100644 --- a/package.json +++ b/package.json @@ -73,10 +73,12 @@ "@angular/cli": "^10.0.2", "@angular/compiler-cli": "10.0.3", "@angular/language-service": "10.0.3", + "@types/event-emitter": "^0.3.3", "@types/jasmine": "3.5.11", "@types/jasminewd2": "^2.0.8", "@types/node": "^14.0.23", "@types/selenium-webdriver": "^4.0.9", + "@types/superagent": "^4.1.8", "adf-tslint-rules": "0.0.7", "ajv-cli": "^3.1.0", "chrome-remote-interface": "^0.28.2", @@ -96,7 +98,7 @@ "lint-staged": "^10.2.11", "ng-packagr": "^10.0.1", "node-stream-zip": "^1.9.1", - "prettier": "^1.17.1", + "prettier": "^2.0.5", "protractor": "^7.0.0", "protractor-screenshoter-plugin": "0.10.3", "rxjs-tslint": "^0.1.8", diff --git a/projects/aca-shared/rules/src/app.rules.ts b/projects/aca-shared/rules/src/app.rules.ts index 652ebe8f6..0468070aa 100644 --- a/projects/aca-shared/rules/src/app.rules.ts +++ b/projects/aca-shared/rules/src/app.rules.ts @@ -38,11 +38,7 @@ export interface AcaRuleContext extends RuleContext { * @param context Rule execution context */ export function canCopyNode(context: RuleContext): boolean { - return [ - hasSelection(context), - navigation.isNotTrashcan(context), - navigation.isNotLibraries(context) - ].every(Boolean); + return [hasSelection(context), navigation.isNotTrashcan(context), navigation.isNotLibraries(context)].every(Boolean); } /** @@ -51,14 +47,10 @@ export function canCopyNode(context: RuleContext): boolean { */ export function canAddFavorite(context: RuleContext): boolean { if (!context.selection.isEmpty) { - if ( - navigation.isFavorites(context) || - navigation.isLibraries(context) || - navigation.isTrashcan(context) - ) { + if (navigation.isFavorites(context) || navigation.isLibraries(context) || navigation.isTrashcan(context)) { return false; } - return context.selection.nodes.some(node => !node.entry.isFavorite); + return context.selection.nodes.some((node) => !node.entry.isFavorite); } return false; } @@ -72,7 +64,7 @@ export function canRemoveFavorite(context: RuleContext): boolean { if (navigation.isFavorites(context)) { return true; } - return context.selection.nodes.every(node => node.entry.isFavorite); + return context.selection.nodes.every((node) => node.entry.isFavorite); } return false; } @@ -82,12 +74,7 @@ export function canRemoveFavorite(context: RuleContext): boolean { * JSON ref: `app.selection.file.canShare` */ export function canShareFile(context: RuleContext): boolean { - return [ - context.selection.file, - navigation.isNotTrashcan(context), - repository.hasQuickShareEnabled(context), - !isShared(context) - ].every(Boolean); + return [context.selection.file, navigation.isNotTrashcan(context), repository.hasQuickShareEnabled(context), !isShared(context)].every(Boolean); } /** @@ -95,11 +82,7 @@ export function canShareFile(context: RuleContext): boolean { * JSON ref: `canToggleJoinLibrary` */ export function canToggleJoinLibrary(context: RuleContext): boolean { - return [ - hasLibrarySelected(context), - !isPrivateLibrary(context), - hasNoLibraryRole(context) - ].every(Boolean); + return [hasLibrarySelected(context), !isPrivateLibrary(context), hasNoLibraryRole(context)].every(Boolean); } /** @@ -108,10 +91,7 @@ export function canToggleJoinLibrary(context: RuleContext): boolean { * @param context Rule execution context */ export function canEditFolder(context: RuleContext): boolean { - return [ - canUpdateSelectedFolder(context), - navigation.isNotTrashcan(context) - ].every(Boolean); + return [canUpdateSelectedFolder(context), navigation.isNotTrashcan(context)].every(Boolean); } /** @@ -123,15 +103,8 @@ export function isShared(context: RuleContext): boolean { return true; } - if ( - (navigation.isNotTrashcan(context), - !context.selection.isEmpty && context.selection.file) - ) { - return !!( - context.selection.file.entry && - context.selection.file.entry.properties && - context.selection.file.entry.properties['qshare:sharedId'] - ); + if ((navigation.isNotTrashcan(context), !context.selection.isEmpty && context.selection.file)) { + return !!(context.selection.file.entry && context.selection.file.entry.properties && context.selection.file.entry.properties['qshare:sharedId']); } return false; @@ -225,10 +198,7 @@ export function canUpload(context: RuleContext): boolean { export function canDownloadSelection(context: RuleContext): boolean { if (!context.selection.isEmpty && navigation.isNotTrashcan(context)) { return context.selection.nodes.every((node: any) => { - return ( - node.entry && - (node.entry.isFile || node.entry.isFolder || !!node.entry.nodeId) - ); + return node.entry && (node.entry.isFile || node.entry.isFolder || !!node.entry.nodeId); }); } return false; @@ -258,13 +228,7 @@ export function hasLibrarySelected(context: RuleContext): boolean { */ export function isPrivateLibrary(context: RuleContext): boolean { const library = context.selection.library; - return library - ? !!( - library.entry && - library.entry.visibility && - library.entry.visibility === 'PRIVATE' - ) - : false; + return library ? !!(library.entry && library.entry.visibility && library.entry.visibility === 'PRIVATE') : false; } /** @@ -321,8 +285,7 @@ export function canUpdateSelectedFolder(context: RuleContext): boolean { if (folder) { return ( // workaround for Favorites Api - navigation.isFavorites(context) || - context.permissions.check(folder.entry, ['update']) + navigation.isFavorites(context) || context.permissions.check(folder.entry, ['update']) ); } return false; @@ -334,16 +297,12 @@ export function canUpdateSelectedFolder(context: RuleContext): boolean { */ export function hasLockedFiles(context: RuleContext): boolean { if (context && context.selection && context.selection.nodes) { - return context.selection.nodes.some(node => { + return context.selection.nodes.some((node) => { if (!node.entry.isFile) { return false; } - return ( - node.entry.isLocked || - (node.entry.properties && - node.entry.properties['cm:lockType'] === 'READ_ONLY_LOCK') - ); + return node.entry.isLocked || (node.entry.properties && node.entry.properties['cm:lockType'] === 'READ_ONLY_LOCK'); }); } @@ -362,8 +321,7 @@ export function isWriteLocked(context: RuleContext): boolean { context.selection.file.entry && context.selection.file.entry.properties && (context.selection.file.entry.properties['cm:lockType'] === 'WRITE_LOCK' || - context.selection.file.entry.properties['cm:lockType'] === - 'READ_ONLY_LOCK') + context.selection.file.entry.properties['cm:lockType'] === 'READ_ONLY_LOCK') ); } @@ -376,8 +334,7 @@ export function isUserWriteLockOwner(context: RuleContext): boolean { return ( isWriteLocked(context) && context.selection.file.entry.properties['cm:lockOwner'] && - context.selection.file.entry.properties['cm:lockOwner'].id === - context.profile.id + context.selection.file.entry.properties['cm:lockOwner'].id === context.profile.id ); } @@ -395,11 +352,7 @@ export function canLockFile(context: RuleContext): boolean { */ export function canUnlockFile(context: RuleContext): boolean { const { file } = context.selection; - return ( - isWriteLocked(context) && - (context.permissions.check(file.entry, ['delete']) || - isUserWriteLockOwner(context)) - ); + return isWriteLocked(context) && (context.permissions.check(file.entry, ['delete']) || isUserWriteLockOwner(context)); } /** @@ -414,9 +367,7 @@ export function canUploadVersion(context: RuleContext): boolean { return [ hasFileSelected(context), navigation.isNotTrashcan(context), - isWriteLocked(context) - ? isUserWriteLockOwner(context) - : canUpdateSelectedNode(context) + isWriteLocked(context) ? isUserWriteLockOwner(context) : canUpdateSelectedNode(context) ].every(Boolean); } @@ -435,9 +386,7 @@ export function isTrashcanItemSelected(context: RuleContext): boolean { * @param context Rule execution context */ export function canViewFile(context: RuleContext): boolean { - return [hasFileSelected(context), navigation.isNotTrashcan(context)].every( - Boolean - ); + return [hasFileSelected(context), navigation.isNotTrashcan(context)].every(Boolean); } /** @@ -455,10 +404,7 @@ export function canLeaveLibrary(context: RuleContext): boolean { * @param context Rule execution context */ export function canToggleSharedLink(context: RuleContext): boolean { - return [ - hasFileSelected(context), - [canShareFile(context), isShared(context)].some(Boolean) - ].every(Boolean); + return [hasFileSelected(context), [canShareFile(context), isShared(context)].some(Boolean)].every(Boolean); } /** @@ -467,11 +413,7 @@ export function canToggleSharedLink(context: RuleContext): boolean { * @param context Rule execution context */ export function canShowInfoDrawer(context: RuleContext): boolean { - return [ - hasSelection(context), - navigation.isNotLibraries(context), - navigation.isNotTrashcan(context) - ].every(Boolean); + return [hasSelection(context), navigation.isNotLibraries(context), navigation.isNotTrashcan(context)].every(Boolean); } /** @@ -480,11 +422,7 @@ export function canShowInfoDrawer(context: RuleContext): boolean { * @param context Rule execution context */ export function canManageFileVersions(context: RuleContext): boolean { - return [ - hasFileSelected(context), - navigation.isNotTrashcan(context), - !hasLockedFiles(context) - ].every(Boolean); + return [hasFileSelected(context), navigation.isNotTrashcan(context), !hasLockedFiles(context)].every(Boolean); } /** @@ -493,10 +431,7 @@ export function canManageFileVersions(context: RuleContext): boolean { * @param context Rule execution context */ export function canManagePermissions(context: RuleContext): boolean { - return [ - canUpdateSelectedNode(context), - navigation.isNotTrashcan(context) - ].every(Boolean); + return [canUpdateSelectedNode(context), navigation.isNotTrashcan(context)].every(Boolean); } /** @@ -505,11 +440,7 @@ export function canManagePermissions(context: RuleContext): boolean { * @param context Rule execution context */ export function canToggleEditOffline(context: RuleContext): boolean { - return [ - hasFileSelected(context), - navigation.isNotTrashcan(context), - canLockFile(context) || canUnlockFile(context) - ].every(Boolean); + return [hasFileSelected(context), navigation.isNotTrashcan(context), canLockFile(context) || canUnlockFile(context)].every(Boolean); } /** @@ -520,12 +451,9 @@ export function canToggleEditOffline(context: RuleContext): boolean { export function canToggleFavorite(context: RuleContext): boolean { return [ [canAddFavorite(context), canRemoveFavorite(context)].some(Boolean), - [ - navigation.isRecentFiles(context), - navigation.isSharedFiles(context), - navigation.isSearchResults(context), - navigation.isFavorites(context) - ].some(Boolean) + [navigation.isRecentFiles(context), navigation.isSharedFiles(context), navigation.isSearchResults(context), navigation.isFavorites(context)].some( + Boolean + ) ].every(Boolean); } @@ -553,9 +481,5 @@ export function canShowLogout(context: AcaRuleContext): boolean { * @param context Rule execution context */ export function isLibraryManager(context: RuleContext): boolean { - return ( - hasLibrarySelected(context) && - context.selection.library.entry && - context.selection.library.entry.role === 'SiteManager' - ); + return hasLibrarySelected(context) && context.selection.library.entry && context.selection.library.entry.role === 'SiteManager'; } diff --git a/projects/aca-shared/rules/src/navigation.rules.ts b/projects/aca-shared/rules/src/navigation.rules.ts index 27885fa12..9ebad9a86 100644 --- a/projects/aca-shared/rules/src/navigation.rules.ts +++ b/projects/aca-shared/rules/src/navigation.rules.ts @@ -31,12 +31,7 @@ import { RuleContext } from '@alfresco/adf-extensions'; */ export function isPreview(context: RuleContext): boolean { const { url } = context.navigation; - return ( - url && - (url.includes('/preview/') || - url.includes('viewer:view') || - url.includes('/view/')) - ); + return url && (url.includes('/preview/') || url.includes('viewer:view') || url.includes('/view/')); } /** @@ -114,9 +109,7 @@ export function isLibraryFiles(context: RuleContext): boolean { */ export function isLibraries(context: RuleContext): boolean { const { url } = context.navigation; - return ( - url && (url.endsWith('/libraries') || url.startsWith('/search-libraries')) - ); + return url && (url.endsWith('/libraries') || url.startsWith('/search-libraries')); } /** @@ -148,10 +141,8 @@ export function isNotRecentFiles(context: RuleContext): boolean { * Checks if a **Search Results** route is activated. * JSON ref: `app.navigation.isSearchResults` */ -export function isSearchResults( - context: RuleContext /*, - ...args: RuleParameter[]*/ -): boolean { +export function isSearchResults(context: RuleContext /*, + ...args: RuleParameter[]*/): boolean { const { url } = context.navigation; return url && url.startsWith('/search'); } @@ -170,11 +161,7 @@ export function isNotSearchResults(context: RuleContext): boolean { */ export function isSharedPreview(context: RuleContext): boolean { const { url } = context.navigation; - return ( - url && - (url.startsWith('/shared/preview/') || - (url.startsWith('/shared') && url.includes('viewer:view'))) - ); + return url && (url.startsWith('/shared/preview/') || (url.startsWith('/shared') && url.includes('viewer:view'))); } /** @@ -183,11 +170,7 @@ export function isSharedPreview(context: RuleContext): boolean { */ export function isFavoritesPreview(context: RuleContext): boolean { const { url } = context.navigation; - return ( - url && - (url.startsWith('/favorites/preview/') || - (url.startsWith('/favorites') && url.includes('viewer:view'))) - ); + return url && (url.startsWith('/favorites/preview/') || (url.startsWith('/favorites') && url.includes('viewer:view'))); } /** diff --git a/projects/aca-shared/src/lib/adf-extensions/extensions-data-loader.guard.spec.ts b/projects/aca-shared/src/lib/adf-extensions/extensions-data-loader.guard.spec.ts index 3a9c22e17..bcfb4c64d 100644 --- a/projects/aca-shared/src/lib/adf-extensions/extensions-data-loader.guard.spec.ts +++ b/projects/aca-shared/src/lib/adf-extensions/extensions-data-loader.guard.spec.ts @@ -52,9 +52,7 @@ describe('ExtensionsDataLoaderGuard', () => { it('should emit true and complete in case of only one callback is present, completed', () => { const subject = new Subject(); - const guard = new ExtensionsDataLoaderGuard([ - () => subject.asObservable() - ]); + const guard = new ExtensionsDataLoaderGuard([() => subject.asObservable()]); guard.canActivate(route).subscribe(emittedSpy, erroredSpy, completedSpy); @@ -70,9 +68,7 @@ describe('ExtensionsDataLoaderGuard', () => { }); it('should emit true and complete in case of only one callback is present, errored', () => { - const guard = new ExtensionsDataLoaderGuard([ - () => throwError(new Error()) - ]); + const guard = new ExtensionsDataLoaderGuard([() => throwError(new Error())]); guard.canActivate(route).subscribe(emittedSpy, erroredSpy, completedSpy); expect(emittedSpy).toHaveBeenCalledWith(true); @@ -83,10 +79,7 @@ describe('ExtensionsDataLoaderGuard', () => { it('should NOT complete in case of multiple callbacks are present and not all of them have been completed', () => { const subject1 = new Subject(); const subject2 = new Subject(); - const guard = new ExtensionsDataLoaderGuard([ - () => subject1.asObservable(), - () => subject2.asObservable() - ]); + const guard = new ExtensionsDataLoaderGuard([() => subject1.asObservable(), () => subject2.asObservable()]); guard.canActivate(route).subscribe(emittedSpy, erroredSpy, completedSpy); @@ -101,10 +94,7 @@ describe('ExtensionsDataLoaderGuard', () => { it('should emit true and complete in case of multiple callbacks are present and all of them have been completed', () => { const subject1 = new Subject(); const subject2 = new Subject(); - const guard = new ExtensionsDataLoaderGuard([ - () => subject1.asObservable(), - () => subject2.asObservable() - ]); + const guard = new ExtensionsDataLoaderGuard([() => subject1.asObservable(), () => subject2.asObservable()]); guard.canActivate(route).subscribe(emittedSpy, erroredSpy, completedSpy); @@ -119,10 +109,7 @@ describe('ExtensionsDataLoaderGuard', () => { it('should emit true and complete even if one of the observables are errored, to not block the application loading', () => { const subject1 = new Subject(); - const guard = new ExtensionsDataLoaderGuard([ - () => subject1.asObservable(), - () => throwError(new Error()) - ]); + const guard = new ExtensionsDataLoaderGuard([() => subject1.asObservable(), () => throwError(new Error())]); guard.canActivate(route).subscribe(emittedSpy, erroredSpy, completedSpy); @@ -135,7 +122,7 @@ describe('ExtensionsDataLoaderGuard', () => { it('should call canActivate only once', () => { const subject1 = new Subject(); const extensionLoaders = { - fct1: function() { + fct1: function () { return subject1.asObservable(); } }; diff --git a/projects/aca-shared/src/lib/adf-extensions/extensions-data-loader.guard.ts b/projects/aca-shared/src/lib/adf-extensions/extensions-data-loader.guard.ts index 9097925a4..cf842aae8 100644 --- a/projects/aca-shared/src/lib/adf-extensions/extensions-data-loader.guard.ts +++ b/projects/aca-shared/src/lib/adf-extensions/extensions-data-loader.guard.ts @@ -28,17 +28,13 @@ import { CanActivate, ActivatedRouteSnapshot } from '@angular/router'; import { Observable, forkJoin, of } from 'rxjs'; import { map, catchError } from 'rxjs/operators'; -export type ExtensionLoaderCallback = ( - route: ActivatedRouteSnapshot -) => Observable; +export type ExtensionLoaderCallback = (route: ActivatedRouteSnapshot) => Observable; export function DefaultExtensionLoaderFactory() { return []; } -export const EXTENSION_DATA_LOADERS = new InjectionToken< - ExtensionLoaderCallback[] ->('EXTENSION_DATA_LOADERS', { +export const EXTENSION_DATA_LOADERS = new InjectionToken('EXTENSION_DATA_LOADERS', { providedIn: 'root', factory: DefaultExtensionLoaderFactory }); @@ -60,20 +56,16 @@ export class ExtensionsDataLoaderGuard implements CanActivate { return of(true); } - const dataLoaderCallbacks = this.extensionDataLoaders.map(callback => - callback(route) - ); + const dataLoaderCallbacks = this.extensionDataLoaders.map((callback) => callback(route)); // Undocumented forkJoin behaviour/bug: // https://github.com/ReactiveX/rxjs/issues/3246 // So all callbacks need to emit before completion, otherwise forkJoin will short circuit return forkJoin(...dataLoaderCallbacks).pipe( map(() => true), - catchError(e => { + catchError((e) => { // tslint:disable-next-line - console.error( - 'Some of the extension data loader guards has been errored.' - ); + console.error('Some of the extension data loader guards has been errored.'); // tslint:disable-next-line console.error(e); return of(true); diff --git a/projects/aca-shared/src/lib/components/generic-error/generic-error.component.ts b/projects/aca-shared/src/lib/components/generic-error/generic-error.component.ts index 2b396d4b3..a2dd88781 100644 --- a/projects/aca-shared/src/lib/components/generic-error/generic-error.component.ts +++ b/projects/aca-shared/src/lib/components/generic-error/generic-error.component.ts @@ -23,12 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Component, - ViewEncapsulation, - ChangeDetectionStrategy, - Input -} from '@angular/core'; +import { Component, ViewEncapsulation, ChangeDetectionStrategy, Input } from '@angular/core'; @Component({ selector: 'aca-generic-error', diff --git a/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.spec.ts b/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.spec.ts index 4de63a174..97e95e817 100644 --- a/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.spec.ts +++ b/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.spec.ts @@ -26,10 +26,7 @@ import { ContentActionRef } from '@alfresco/adf-extensions'; import { NO_ERRORS_SCHEMA } from '@angular/core'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { Store } from '@ngrx/store'; -import { - SetInfoDrawerStateAction, - ToggleInfoDrawerAction -} from '@alfresco/aca-shared/store'; +import { SetInfoDrawerStateAction, ToggleInfoDrawerAction } from '@alfresco/aca-shared/store'; import { of, Subject } from 'rxjs'; import { InfoDrawerComponent } from './info-drawer.component'; import { LibTestingModule } from '../../testing/lib-testing-module'; @@ -64,11 +61,7 @@ describe('InfoDrawerComponent', () => { TestBed.configureTestingModule({ imports: [LibTestingModule, SharedToolbarModule], declarations: [InfoDrawerComponent], - providers: [ - ContentApiService, - { provide: AppExtensionService, useValue: extensionServiceMock }, - { provide: Store, useValue: storeMock } - ], + providers: [ContentApiService, { provide: AppExtensionService, useValue: extensionServiceMock }, { provide: Store, useValue: storeMock }], schemas: [NO_ERRORS_SCHEMA] }); @@ -95,9 +88,7 @@ describe('InfoDrawerComponent', () => { fixture.detectChanges(); component.ngOnDestroy(); - expect(storeMock.dispatch).toHaveBeenCalledWith( - new SetInfoDrawerStateAction(false) - ); + expect(storeMock.dispatch).toHaveBeenCalledWith(new SetInfoDrawerStateAction(false)); }); it('should set displayNode when node is library', async(() => { @@ -174,9 +165,7 @@ describe('InfoDrawerComponent', () => { fixture.debugElement.nativeElement.dispatchEvent(event); - expect(storeMock.dispatch).toHaveBeenCalledWith( - new ToggleInfoDrawerAction() - ); + expect(storeMock.dispatch).toHaveBeenCalledWith(new ToggleInfoDrawerAction()); }); it('should show the icons from extension', () => { diff --git a/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.ts b/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.ts index e71f897a4..18e5351b3 100644 --- a/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.ts +++ b/projects/aca-shared/src/lib/components/info-drawer/info-drawer.component.ts @@ -23,26 +23,11 @@ * along with Alfresco. If not, see . */ -import { - Component, - HostListener, - Input, - OnChanges, - OnDestroy, - OnInit -} from '@angular/core'; -import { - MinimalNodeEntity, - MinimalNodeEntryEntity, - SiteEntry -} from '@alfresco/js-api'; +import { Component, HostListener, Input, OnChanges, OnDestroy, OnInit } from '@angular/core'; +import { MinimalNodeEntity, MinimalNodeEntryEntity, SiteEntry } from '@alfresco/js-api'; import { ContentActionRef, SidebarTabRef } from '@alfresco/adf-extensions'; import { Store } from '@ngrx/store'; -import { - getAppSelection, - SetInfoDrawerStateAction, - ToggleInfoDrawerAction -} from '@alfresco/aca-shared/store'; +import { getAppSelection, SetInfoDrawerStateAction, ToggleInfoDrawerAction } from '@alfresco/aca-shared/store'; import { AppExtensionService } from '../../services/app.extension.service'; import { ContentApiService } from '../../services/content-api.service'; import { takeUntil } from 'rxjs/operators'; @@ -69,11 +54,7 @@ export class InfoDrawerComponent implements OnChanges, OnInit, OnDestroy { this.close(); } - constructor( - private store: Store, - private contentApi: ContentApiService, - private extensions: AppExtensionService - ) {} + constructor(private store: Store, private contentApi: ContentApiService, private extensions: AppExtensionService) {} ngOnInit() { this.tabs = this.extensions.getSidebarTabs(); @@ -117,7 +98,7 @@ export class InfoDrawerComponent implements OnChanges, OnInit, OnDestroy { this.isLoading = true; this.contentApi.getNodeInfo(nodeId).subscribe( - entity => { + (entity) => { this.setDisplayNode(entity); this.isLoading = false; }, diff --git a/projects/aca-shared/src/lib/components/info-drawer/shared-info-drawer.module.ts b/projects/aca-shared/src/lib/components/info-drawer/shared-info-drawer.module.ts index 4c756e9a1..c47857c19 100644 --- a/projects/aca-shared/src/lib/components/info-drawer/shared-info-drawer.module.ts +++ b/projects/aca-shared/src/lib/components/info-drawer/shared-info-drawer.module.ts @@ -32,14 +32,7 @@ import { MatProgressBarModule } from '@angular/material/progress-bar'; import { SharedToolbarModule } from '../tool-bar/shared-toolbar.module'; @NgModule({ - imports: [ - CommonModule, - InfoDrawerModule, - MatProgressBarModule, - ExtensionsModule, - ToolbarModule, - SharedToolbarModule - ], + imports: [CommonModule, InfoDrawerModule, MatProgressBarModule, ExtensionsModule, ToolbarModule, SharedToolbarModule], declarations: [InfoDrawerComponent], exports: [InfoDrawerComponent] }) diff --git a/projects/aca-shared/src/lib/components/locked-by/locked-by.component.ts b/projects/aca-shared/src/lib/components/locked-by/locked-by.component.ts index 664dea37c..e12ee05fa 100644 --- a/projects/aca-shared/src/lib/components/locked-by/locked-by.component.ts +++ b/projects/aca-shared/src/lib/components/locked-by/locked-by.component.ts @@ -23,13 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Component, - Input, - OnInit, - ChangeDetectionStrategy, - ViewEncapsulation -} from '@angular/core'; +import { Component, Input, OnInit, ChangeDetectionStrategy, ViewEncapsulation } from '@angular/core'; import { NodeEntry } from '@alfresco/js-api'; @@ -60,10 +54,7 @@ export class LockedByComponent implements OnInit { writeLockedBy() { return ( - this.node && - this.node.entry.properties && - this.node.entry.properties['cm:lockOwner'] && - this.node.entry.properties['cm:lockOwner'].displayName + this.node && this.node.entry.properties && this.node.entry.properties['cm:lockOwner'] && this.node.entry.properties['cm:lockOwner'].displayName ); } } diff --git a/projects/aca-shared/src/lib/components/page-layout/page-layout-content.component.ts b/projects/aca-shared/src/lib/components/page-layout/page-layout-content.component.ts index f38f0c753..4a52c5896 100644 --- a/projects/aca-shared/src/lib/components/page-layout/page-layout-content.component.ts +++ b/projects/aca-shared/src/lib/components/page-layout/page-layout-content.component.ts @@ -23,19 +23,11 @@ * along with Alfresco. If not, see . */ -import { - Component, - ViewEncapsulation, - ChangeDetectionStrategy, - Input, - HostBinding -} from '@angular/core'; +import { Component, ViewEncapsulation, ChangeDetectionStrategy, Input, HostBinding } from '@angular/core'; @Component({ selector: 'aca-page-layout-content', - template: ` - - `, + template: ``, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'aca-page-layout-content' } diff --git a/projects/aca-shared/src/lib/components/page-layout/page-layout-error.component.ts b/projects/aca-shared/src/lib/components/page-layout/page-layout-error.component.ts index 43f278964..9d1052adb 100644 --- a/projects/aca-shared/src/lib/components/page-layout/page-layout-error.component.ts +++ b/projects/aca-shared/src/lib/components/page-layout/page-layout-error.component.ts @@ -23,17 +23,11 @@ * along with Alfresco. If not, see . */ -import { - Component, - ViewEncapsulation, - ChangeDetectionStrategy -} from '@angular/core'; +import { Component, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/core'; @Component({ selector: 'aca-page-layout-error', - template: ` - - `, + template: ``, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'aca-page-layout-error' } diff --git a/projects/aca-shared/src/lib/components/page-layout/page-layout-header.component.ts b/projects/aca-shared/src/lib/components/page-layout/page-layout-header.component.ts index 1b5431d15..f471a5e8f 100644 --- a/projects/aca-shared/src/lib/components/page-layout/page-layout-header.component.ts +++ b/projects/aca-shared/src/lib/components/page-layout/page-layout-header.component.ts @@ -23,11 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Component, - ViewEncapsulation, - ChangeDetectionStrategy -} from '@angular/core'; +import { Component, ViewEncapsulation, ChangeDetectionStrategy } from '@angular/core'; @Component({ selector: 'aca-page-layout-header', diff --git a/projects/aca-shared/src/lib/components/page-layout/page-layout.component.ts b/projects/aca-shared/src/lib/components/page-layout/page-layout.component.ts index 10fdce346..250f210ec 100644 --- a/projects/aca-shared/src/lib/components/page-layout/page-layout.component.ts +++ b/projects/aca-shared/src/lib/components/page-layout/page-layout.component.ts @@ -23,12 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Component, - ViewEncapsulation, - ChangeDetectionStrategy, - Input -} from '@angular/core'; +import { Component, ViewEncapsulation, ChangeDetectionStrategy, Input } from '@angular/core'; @Component({ selector: 'aca-page-layout', diff --git a/projects/aca-shared/src/lib/components/page-layout/page-layout.module.ts b/projects/aca-shared/src/lib/components/page-layout/page-layout.module.ts index f86a22a1b..7ee0ae329 100644 --- a/projects/aca-shared/src/lib/components/page-layout/page-layout.module.ts +++ b/projects/aca-shared/src/lib/components/page-layout/page-layout.module.ts @@ -32,17 +32,7 @@ import { CommonModule } from '@angular/common'; @NgModule({ imports: [CommonModule], - declarations: [ - PageLayoutContentComponent, - PageLayoutErrorComponent, - PageLayoutHeaderComponent, - PageLayoutComponent - ], - exports: [ - PageLayoutContentComponent, - PageLayoutErrorComponent, - PageLayoutHeaderComponent, - PageLayoutComponent - ] + declarations: [PageLayoutContentComponent, PageLayoutErrorComponent, PageLayoutHeaderComponent, PageLayoutComponent], + exports: [PageLayoutContentComponent, PageLayoutErrorComponent, PageLayoutHeaderComponent, PageLayoutComponent] }) export class PageLayoutModule {} diff --git a/projects/aca-shared/src/lib/components/tool-bar/shared-toolbar.module.ts b/projects/aca-shared/src/lib/components/tool-bar/shared-toolbar.module.ts index e671da95b..eedb1eaf9 100644 --- a/projects/aca-shared/src/lib/components/tool-bar/shared-toolbar.module.ts +++ b/projects/aca-shared/src/lib/components/tool-bar/shared-toolbar.module.ts @@ -34,17 +34,7 @@ import { ExtensionsModule } from '@alfresco/adf-extensions'; @NgModule({ imports: [CommonModule, CoreModule, ExtensionsModule], - declarations: [ - ToolbarButtonComponent, - ToolbarActionComponent, - ToolbarMenuItemComponent, - ToolbarMenuComponent - ], - exports: [ - ToolbarButtonComponent, - ToolbarActionComponent, - ToolbarMenuItemComponent, - ToolbarMenuComponent - ] + declarations: [ToolbarButtonComponent, ToolbarActionComponent, ToolbarMenuItemComponent, ToolbarMenuComponent], + exports: [ToolbarButtonComponent, ToolbarActionComponent, ToolbarMenuItemComponent, ToolbarMenuComponent] }) export class SharedToolbarModule {} diff --git a/projects/aca-shared/src/lib/components/tool-bar/toolbar-action/toolbar-action.component.ts b/projects/aca-shared/src/lib/components/tool-bar/toolbar-action/toolbar-action.component.ts index 5df7da924..e42dd9081 100644 --- a/projects/aca-shared/src/lib/components/tool-bar/toolbar-action/toolbar-action.component.ts +++ b/projects/aca-shared/src/lib/components/tool-bar/toolbar-action/toolbar-action.component.ts @@ -23,14 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Component, - ViewEncapsulation, - ChangeDetectionStrategy, - Input, - DoCheck, - ChangeDetectorRef -} from '@angular/core'; +import { Component, ViewEncapsulation, ChangeDetectionStrategy, Input, DoCheck, ChangeDetectorRef } from '@angular/core'; import { ContentActionRef } from '@alfresco/adf-extensions'; @Component({ diff --git a/projects/aca-shared/src/lib/components/tool-bar/toolbar-menu/toolbar-menu.component.ts b/projects/aca-shared/src/lib/components/tool-bar/toolbar-menu/toolbar-menu.component.ts index 936dd7681..4e78b1e07 100644 --- a/projects/aca-shared/src/lib/components/tool-bar/toolbar-menu/toolbar-menu.component.ts +++ b/projects/aca-shared/src/lib/components/tool-bar/toolbar-menu/toolbar-menu.component.ts @@ -40,11 +40,7 @@ export class ToolbarMenuComponent { color = ''; get hasChildren(): boolean { - return ( - this.actionRef && - this.actionRef.children && - this.actionRef.children.length > 0 - ); + return this.actionRef && this.actionRef.children && this.actionRef.children.length > 0; } trackById(_: number, obj: { id: string }) { diff --git a/projects/aca-shared/src/lib/directives/contextmenu/contextmenu.directive.spec.ts b/projects/aca-shared/src/lib/directives/contextmenu/contextmenu.directive.spec.ts index 97d7862d0..b3076806f 100644 --- a/projects/aca-shared/src/lib/directives/contextmenu/contextmenu.directive.spec.ts +++ b/projects/aca-shared/src/lib/directives/contextmenu/contextmenu.directive.spec.ts @@ -48,8 +48,7 @@ describe('ContextActionsDirective', () => { it('should call service to render context menu', fakeAsync(() => { const el = document.createElement('div'); - el.className = - 'adf-datatable-cell adf-datatable-cell--text adf-datatable-row'; + el.className = 'adf-datatable-cell adf-datatable-cell--text adf-datatable-row'; const fragment = document.createDocumentFragment(); fragment.appendChild(el); @@ -62,8 +61,6 @@ describe('ContextActionsDirective', () => { tick(500); - expect(storeMock.dispatch).toHaveBeenCalledWith( - new ContextMenu(mouseEventMock) - ); + expect(storeMock.dispatch).toHaveBeenCalledWith(new ContextMenu(mouseEventMock)); })); }); diff --git a/projects/aca-shared/src/lib/directives/contextmenu/contextmenu.directive.ts b/projects/aca-shared/src/lib/directives/contextmenu/contextmenu.directive.ts index 0ef651b2c..09a820356 100644 --- a/projects/aca-shared/src/lib/directives/contextmenu/contextmenu.directive.ts +++ b/projects/aca-shared/src/lib/directives/contextmenu/contextmenu.directive.ts @@ -23,13 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Directive, - HostListener, - Input, - OnInit, - OnDestroy -} from '@angular/core'; +import { Directive, HostListener, Input, OnInit, OnDestroy } from '@angular/core'; import { debounceTime, takeUntil } from 'rxjs/operators'; import { Subject } from 'rxjs'; import { Store } from '@ngrx/store'; @@ -64,11 +58,9 @@ export class ContextActionsDirective implements OnInit, OnDestroy { constructor(private store: Store) {} ngOnInit() { - this.execute$ - .pipe(debounceTime(300), takeUntil(this.onDestroy$)) - .subscribe((event: MouseEvent) => { - this.store.dispatch(new ContextMenu(event)); - }); + this.execute$.pipe(debounceTime(300), takeUntil(this.onDestroy$)).subscribe((event: MouseEvent) => { + this.store.dispatch(new ContextMenu(event)); + }); } ngOnDestroy() { @@ -94,9 +86,7 @@ export class ContextActionsDirective implements OnInit, OnDestroy { return false; } - return this.findAncestor(target, 'adf-datatable-row').classList.contains( - 'adf-is-selected' - ); + return this.findAncestor(target, 'adf-datatable-row').classList.contains('adf-is-selected'); } private findAncestor(el: Element, className: string): Element { diff --git a/projects/aca-shared/src/lib/directives/pagination.directive.spec.ts b/projects/aca-shared/src/lib/directives/pagination.directive.spec.ts index 24b596573..3c8fff711 100644 --- a/projects/aca-shared/src/lib/directives/pagination.directive.spec.ts +++ b/projects/aca-shared/src/lib/directives/pagination.directive.spec.ts @@ -47,15 +47,8 @@ describe('PaginationDirective', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ - TranslateModule.forRoot(), - LibTestingModule, - SharedDirectivesModule, - CoreTestingModule - ], - providers: [ - { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock } - ] + imports: [TranslateModule.forRoot(), LibTestingModule, SharedDirectivesModule, CoreTestingModule], + providers: [{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }] }); preferences = TestBed.inject(UserPreferencesService); diff --git a/projects/aca-shared/src/lib/directives/pagination.directive.ts b/projects/aca-shared/src/lib/directives/pagination.directive.ts index e8cafb0f2..f57188689 100644 --- a/projects/aca-shared/src/lib/directives/pagination.directive.ts +++ b/projects/aca-shared/src/lib/directives/pagination.directive.ts @@ -24,12 +24,7 @@ */ import { Directive, OnInit, OnDestroy } from '@angular/core'; -import { - PaginationComponent, - UserPreferencesService, - PaginationModel, - AppConfigService -} from '@alfresco/adf-core'; +import { PaginationComponent, UserPreferencesService, PaginationModel, AppConfigService } from '@alfresco/adf-core'; import { Subscription } from 'rxjs'; @Directive({ @@ -38,16 +33,10 @@ import { Subscription } from 'rxjs'; export class PaginationDirective implements OnInit, OnDestroy { private subscriptions: Subscription[] = []; - constructor( - private pagination: PaginationComponent, - private preferences: UserPreferencesService, - private config: AppConfigService - ) {} + constructor(private pagination: PaginationComponent, private preferences: UserPreferencesService, private config: AppConfigService) {} ngOnInit() { - this.pagination.supportedPageSizes = this.config.get( - 'pagination.supportedPageSizes' - ); + this.pagination.supportedPageSizes = this.config.get('pagination.supportedPageSizes'); this.subscriptions.push( this.pagination.changePageSize.subscribe((event: PaginationModel) => { @@ -57,7 +46,7 @@ export class PaginationDirective implements OnInit, OnDestroy { } ngOnDestroy() { - this.subscriptions.forEach(subscription => subscription.unsubscribe()); + this.subscriptions.forEach((subscription) => subscription.unsubscribe()); this.subscriptions = []; } } diff --git a/projects/aca-shared/src/lib/routing/app.routes.strategy.ts b/projects/aca-shared/src/lib/routing/app.routes.strategy.ts index 4bb4ff5b0..eca5e4172 100644 --- a/projects/aca-shared/src/lib/routing/app.routes.strategy.ts +++ b/projects/aca-shared/src/lib/routing/app.routes.strategy.ts @@ -23,11 +23,7 @@ * along with Alfresco. If not, see . */ -import { - RouteReuseStrategy, - DetachedRouteHandle, - ActivatedRouteSnapshot -} from '@angular/router'; +import { RouteReuseStrategy, DetachedRouteHandle, ActivatedRouteSnapshot } from '@angular/router'; import { ComponentRef, Injectable } from '@angular/core'; interface RouteData { @@ -44,7 +40,7 @@ export class AppRouteReuseStrategy implements RouteReuseStrategy { private routeCache = new Map(); resetCache() { - this.routeCache.forEach(value => { + this.routeCache.forEach((value) => { this.deactivateComponent(value.handle); }); this.routeCache.clear(); @@ -60,10 +56,7 @@ export class AppRouteReuseStrategy implements RouteReuseStrategy { } } - shouldReuseRoute( - future: ActivatedRouteSnapshot, - curr: ActivatedRouteSnapshot - ): boolean { + shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean { const ret = future.routeConfig === curr.routeConfig; if (ret) { this.addRedirectsRecursively(future); // update redirects @@ -91,9 +84,7 @@ export class AppRouteReuseStrategy implements RouteReuseStrategy { retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle { const url = this.getFullRouteUrl(route); const data = this.getRouteData(route); - return data && data.reuse && this.routeCache.has(url) - ? this.routeCache.get(url).handle - : null; + return data && data.reuse && this.routeCache.has(url) ? this.routeCache.get(url).handle : null; } private addRedirectsRecursively(route: ActivatedRouteSnapshot): void { @@ -101,40 +92,30 @@ export class AppRouteReuseStrategy implements RouteReuseStrategy { if (config) { if (!config.loadChildren) { const routeFirstChild = route.firstChild; - const routeFirstChildUrl = routeFirstChild - ? this.getRouteUrlPaths(routeFirstChild).join('/') - : ''; + const routeFirstChildUrl = routeFirstChild ? this.getRouteUrlPaths(routeFirstChild).join('/') : ''; const childConfigs = config.children; if (childConfigs) { - const childConfigWithRedirect = childConfigs.find( - c => c.path === '' && !!c.redirectTo - ); + const childConfigWithRedirect = childConfigs.find((c) => c.path === '' && !!c.redirectTo); if (childConfigWithRedirect) { childConfigWithRedirect.redirectTo = routeFirstChildUrl; } } } - route.children.forEach(childRoute => - this.addRedirectsRecursively(childRoute) - ); + route.children.forEach((childRoute) => this.addRedirectsRecursively(childRoute)); } } private getFullRouteUrl(route: ActivatedRouteSnapshot): string { - return this.getFullRouteUrlPaths(route) - .filter(Boolean) - .join('/'); + return this.getFullRouteUrlPaths(route).filter(Boolean).join('/'); } private getFullRouteUrlPaths(route: ActivatedRouteSnapshot): string[] { const paths = this.getRouteUrlPaths(route); - return route.parent - ? [...this.getFullRouteUrlPaths(route.parent), ...paths] - : paths; + return route.parent ? [...this.getFullRouteUrlPaths(route.parent), ...paths] : paths; } private getRouteUrlPaths(route: ActivatedRouteSnapshot): string[] { - return route.url.map(urlSegment => urlSegment.path); + return route.url.map((urlSegment) => urlSegment.path); } private getRouteData(route: ActivatedRouteSnapshot): RouteData { diff --git a/projects/aca-shared/src/lib/routing/shared.guard.ts b/projects/aca-shared/src/lib/routing/shared.guard.ts index ea9b93e32..f5be306c1 100644 --- a/projects/aca-shared/src/lib/routing/shared.guard.ts +++ b/projects/aca-shared/src/lib/routing/shared.guard.ts @@ -39,15 +39,11 @@ export class AppSharedRuleGuard implements CanActivate { this.isQuickShareEnabled$ = store.select(isQuickShareEnabled); } - canActivate( - _: ActivatedRouteSnapshot - ): Observable | Promise | boolean { + canActivate(_: ActivatedRouteSnapshot): Observable | Promise | boolean { return this.isQuickShareEnabled$; } - canActivateChild( - route: ActivatedRouteSnapshot - ): Observable | Promise | boolean { + canActivateChild(route: ActivatedRouteSnapshot): Observable | Promise | boolean { return this.canActivate(route); } } diff --git a/projects/aca-shared/src/lib/services/app.extension.service.spec.ts b/projects/aca-shared/src/lib/services/app.extension.service.spec.ts index 064b73557..14c149d80 100644 --- a/projects/aca-shared/src/lib/services/app.extension.service.spec.ts +++ b/projects/aca-shared/src/lib/services/app.extension.service.spec.ts @@ -567,9 +567,7 @@ describe('AppExtensionService', () => { }); it('should use implicit order', () => { - const sorted = [{ id: '3' }, { id: '2' }, { id: '1', order: 1 }].sort( - sortByOrder - ); + const sorted = [{ id: '3' }, { id: '2' }, { id: '1', order: 1 }].sort(sortByOrder); expect(sorted[0].id).toBe('1'); expect(sorted[1].id).toBe('3'); @@ -579,11 +577,7 @@ describe('AppExtensionService', () => { describe('filtering', () => { it('should filter out disabled items', () => { - const items = [ - { id: 1, disabled: true }, - { id: 2 }, - { id: 3, disabled: true } - ].filter(filterEnabled); + const items = [{ id: 1, disabled: true }, { id: 2 }, { id: 3, disabled: true }].filter(filterEnabled); expect(items.length).toBe(1); expect(items[0].id).toBe(2); @@ -594,11 +588,7 @@ describe('AppExtensionService', () => { { id: '1', disabled: true }, { id: '2', - someItems: [ - { id: '21', disabled: true }, - { id: '22', disabled: false }, - { id: '23' } - ], + someItems: [{ id: '21', disabled: true }, { id: '22', disabled: false }, { id: '23' }], someObjectProp: { innerItems: [{ id: '24' }, { id: '25', disabled: true }] } @@ -700,10 +690,7 @@ describe('AppExtensionService', () => { { items: [{ children: [{ route: 'route3', disabled: true }] }] } ]); - expect(navigation).toEqual([ - { items: [{ route: 'route1', url: '/route1' }] }, - { items: [{ children: [] }] } - ] as NavBarGroupRef[]); + expect(navigation).toEqual([{ items: [{ route: 'route1', url: '/route1' }] }, { items: [{ children: [] }] }] as NavBarGroupRef[]); }); it('should filter out items based on rule', () => { diff --git a/projects/aca-shared/src/lib/services/app.extension.service.ts b/projects/aca-shared/src/lib/services/app.extension.service.ts index 6b69b22ce..bfd769f7b 100644 --- a/projects/aca-shared/src/lib/services/app.extension.service.ts +++ b/projects/aca-shared/src/lib/services/app.extension.service.ts @@ -27,11 +27,7 @@ import { Injectable, Type } from '@angular/core'; import { Store } from '@ngrx/store'; import { MatIconRegistry } from '@angular/material/icon'; import { DomSanitizer } from '@angular/platform-browser'; -import { - AppStore, - getRuleContext, - getLanguagePickerState -} from '@alfresco/aca-shared/store'; +import { AppStore, getRuleContext, getLanguagePickerState } from '@alfresco/aca-shared/store'; import { SelectionState, NavigationState, @@ -53,11 +49,7 @@ import { DocumentListPresetRef, IconRef } from '@alfresco/adf-extensions'; -import { - AppConfigService, - AuthenticationService, - LogService -} from '@alfresco/adf-core'; +import { AppConfigService, AuthenticationService, LogService } from '@alfresco/adf-core'; import { BehaviorSubject, Observable } from 'rxjs'; import { RepositoryInfo, NodeEntry } from '@alfresco/js-api'; import { ViewerRules } from '../models/viewer.rules'; @@ -132,14 +124,14 @@ export class AppExtensionService implements RuleContext { ) { this.references$ = this._references.asObservable(); - this.store.select(getRuleContext).subscribe(result => { + this.store.select(getRuleContext).subscribe((result) => { this.selection = result.selection; this.navigation = result.navigation; this.profile = result.profile; this.repository = result.repository; }); - this.store.select(getLanguagePickerState).subscribe(result => { + this.store.select(getLanguagePickerState).subscribe((result) => { this.languagePicker = result; }); } @@ -155,62 +147,26 @@ export class AppExtensionService implements RuleContext { return; } - this.settingGroups = this.loader.getElements( - config, - 'settings' - ); + this.settingGroups = this.loader.getElements(config, 'settings'); - this.headerActions = this.loader.getContentActions( - config, - 'features.header' - ); - this.sidebarActions = this.loader.getContentActions( - config, - 'features.sidebar.toolbar' - ); - this.toolbarActions = this.loader.getContentActions( - config, - 'features.toolbar' - ); - this.viewerToolbarActions = this.loader.getContentActions( - config, - 'features.viewer.toolbarActions' - ); - this.sharedLinkViewerToolbarActions = this.loader.getContentActions( - config, - 'features.viewer.shared.toolbarActions' - ); + this.headerActions = this.loader.getContentActions(config, 'features.header'); + this.sidebarActions = this.loader.getContentActions(config, 'features.sidebar.toolbar'); + this.toolbarActions = this.loader.getContentActions(config, 'features.toolbar'); + this.viewerToolbarActions = this.loader.getContentActions(config, 'features.viewer.toolbarActions'); + this.sharedLinkViewerToolbarActions = this.loader.getContentActions(config, 'features.viewer.shared.toolbarActions'); - this.contextMenuActions = this.loader.getContentActions( - config, - 'features.contextMenu' - ); - this.openWithActions = this.loader.getContentActions( - config, - 'features.viewer.openWith' - ); - this.createActions = this.loader.getElements( - config, - 'features.create' - ); + this.contextMenuActions = this.loader.getContentActions(config, 'features.contextMenu'); + this.openWithActions = this.loader.getContentActions(config, 'features.viewer.openWith'); + this.createActions = this.loader.getElements(config, 'features.create'); this.navbar = this.loadNavBar(config); - this.sidebarTabs = this.loader.getElements( - config, - 'features.sidebar.tabs' - ); - this.userActions = this.loader.getContentActions( - config, - 'features.userActions' - ); + this.sidebarTabs = this.loader.getElements(config, 'features.sidebar.tabs'); + this.userActions = this.loader.getContentActions(config, 'features.userActions'); this.contentMetadata = this.loadContentMetadata(config); this.documentListPresets = { files: this.getDocumentListPreset(config, 'files'), libraries: this.getDocumentListPreset(config, 'libraries'), - favoriteLibraries: this.getDocumentListPreset( - config, - 'favoriteLibraries' - ), + favoriteLibraries: this.getDocumentListPreset(config, 'favoriteLibraries'), shared: this.getDocumentListPreset(config, 'shared'), recent: this.getDocumentListPreset(config, 'recent'), favorites: this.getDocumentListPreset(config, 'favorites'), @@ -218,10 +174,7 @@ export class AppExtensionService implements RuleContext { searchLibraries: this.getDocumentListPreset(config, 'search-libraries') }; - this.withCredentials = this.appConfig.get( - 'auth.withCredentials', - false - ); + this.withCredentials = this.appConfig.get('auth.withCredentials', false); if (config.features && config.features.viewer) { this.viewerRules = (config.features.viewer['rules'] as ViewerRules) || {}; @@ -229,16 +182,12 @@ export class AppExtensionService implements RuleContext { this.registerIcons(config); - const references = (config.$references || []) - .filter(entry => typeof entry === 'object') - .map(entry => entry as ExtensionRef); + const references = (config.$references || []).filter((entry) => typeof entry === 'object').map((entry) => entry as ExtensionRef); this._references.next(references); } protected registerIcons(config: ExtensionConfig) { - const icons: Array = this.loader - .getElements(config, 'features.icons') - .filter(entry => !entry.disabled); + const icons: Array = this.loader.getElements(config, 'features.icons').filter((entry) => !entry.disabled); for (const icon of icons) { const [ns, id] = icon.id.split(':'); @@ -249,11 +198,7 @@ export class AppExtensionService implements RuleContext { } else if (!ns || !id) { console.warn(`Incorrect icon id format: "${icon.id}".`); } else { - this.matIconRegistry.addSvgIconInNamespace( - ns, - id, - this.sanitizer.bypassSecurityTrustResourceUrl(value) - ); + this.matIconRegistry.addSvgIconInNamespace(ns, id, this.sanitizer.bypassSecurityTrustResourceUrl(value)); } } } @@ -263,31 +208,26 @@ export class AppExtensionService implements RuleContext { } protected getDocumentListPreset(config: ExtensionConfig, key: string) { - return this.loader - .getElements( - config, - `features.documentList.${key}` - ) - .filter(entry => !entry.disabled); + return this.loader.getElements(config, `features.documentList.${key}`).filter((entry) => !entry.disabled); } getApplicationNavigation(elements): Array { return elements - .filter(group => this.filterVisible(group)) - .map(group => { + .filter((group) => this.filterVisible(group)) + .map((group) => { return { ...group, items: (group.items || []) - .filter(entry => !entry.disabled) - .filter(item => this.filterVisible(item)) + .filter((entry) => !entry.disabled) + .filter((item) => this.filterVisible(item)) .sort(sortByOrder) - .map(item => { + .map((item) => { if (item.children && item.children.length > 0) { item.children = item.children - .filter(entry => !entry.disabled) - .filter(child => this.filterVisible(child)) + .filter((entry) => !entry.disabled) + .filter((child) => this.filterVisible(child)) .sort(sortByOrder) - .map(child => { + .map((child) => { if (child.component) { return { ...child @@ -295,12 +235,8 @@ export class AppExtensionService implements RuleContext { } if (!child.click) { - const childRouteRef = this.extensions.getRouteById( - child.route - ); - const childUrl = `/${ - childRouteRef ? childRouteRef.path : child.route - }`; + const childRouteRef = this.extensions.getRouteById(child.route); + const childUrl = `/${childRouteRef ? childRouteRef.path : child.route}`; return { ...child, url: childUrl @@ -342,10 +278,7 @@ export class AppExtensionService implements RuleContext { } loadContentMetadata(config: ExtensionConfig): any { - const elements = this.loader.getElements( - config, - 'features.content-metadata-presets' - ); + const elements = this.loader.getElements(config, 'features.content-metadata-presets'); if (!elements.length) { return null; } @@ -356,10 +289,7 @@ export class AppExtensionService implements RuleContext { try { this.appConfig.config['content-metadata'] = { presets }; } catch (error) { - this.logger.error( - error, - '- could not change content-metadata from app.config -' - ); + this.logger.error(error, '- could not change content-metadata from app.config -'); } return { presets }; @@ -367,12 +297,10 @@ export class AppExtensionService implements RuleContext { filterDisabled(object: Array<{ disabled: boolean }> | { disabled: boolean }) { if (Array.isArray(object)) { - return object - .filter(item => !item.disabled) - .map(item => this.filterDisabled(item)); + return object.filter((item) => !item.disabled).map((item) => this.filterDisabled(item)); } else if (typeof object === 'object') { if (!object.disabled) { - Object.keys(object).forEach(prop => { + Object.keys(object).forEach((prop) => { object[prop] = this.filterDisabled(object[prop]); }); return object; @@ -387,7 +315,7 @@ export class AppExtensionService implements RuleContext { } getSidebarTabs(): Array { - return this.sidebarTabs.filter(action => this.filterVisible(action)); + return this.sidebarTabs.filter((action) => this.filterVisible(action)); } getComponentById(id: string): Type<{}> { @@ -395,10 +323,8 @@ export class AppExtensionService implements RuleContext { } getApplicationRoutes(): Array { - return this.extensions.routes.map(route => { - const guards = this.extensions.getAuthGuards( - route.auth && route.auth.length > 0 ? route.auth : this.defaults.auth - ); + return this.extensions.routes.map((route) => { + const guards = this.extensions.getAuthGuards(route.auth && route.auth.length > 0 ? route.auth : this.defaults.auth); return { path: route.path, @@ -419,10 +345,10 @@ export class AppExtensionService implements RuleContext { getCreateActions(): Array { return this.createActions - .filter(action => this.filterVisible(action)) - .map(action => this.copyAction(action)) - .map(action => this.buildMenu(action)) - .map(action => { + .filter((action) => this.filterVisible(action)) + .map((action) => this.copyAction(action)) + .map((action) => this.buildMenu(action)) + .map((action) => { let disabled = false; if (action.rules && action.rules.enabled) { @@ -437,24 +363,15 @@ export class AppExtensionService implements RuleContext { } private buildMenu(actionRef: ContentActionRef): ContentActionRef { - if ( - actionRef.type === ContentActionType.menu && - actionRef.children && - actionRef.children.length > 0 - ) { - const children = actionRef.children - .filter(action => this.filterVisible(action)) - .map(action => this.buildMenu(action)); + if (actionRef.type === ContentActionType.menu && actionRef.children && actionRef.children.length > 0) { + const children = actionRef.children.filter((action) => this.filterVisible(action)).map((action) => this.buildMenu(action)); actionRef.children = children - .map(action => { + .map((action) => { let disabled = false; if (action.rules && action.rules.enabled) { - disabled = !this.extensions.evaluateRule( - action.rules.enabled, - this - ); + disabled = !this.extensions.evaluateRule(action.rules.enabled, this); } return { @@ -472,14 +389,14 @@ export class AppExtensionService implements RuleContext { private getAllowedActions(actions: ContentActionRef[]): ContentActionRef[] { return (actions || []) - .filter(action => this.filterVisible(action)) - .map(action => { + .filter((action) => this.filterVisible(action)) + .map((action) => { if (action.type === ContentActionType.menu) { const copy = this.copyAction(action); if (copy.children && copy.children.length > 0) { copy.children = copy.children - .filter(entry => !entry.disabled) - .filter(childAction => this.filterVisible(childAction)) + .filter((entry) => !entry.disabled) + .filter((childAction) => this.filterVisible(childAction)) .sort(sortByOrder) .reduce(reduceSeparators, []); } @@ -509,13 +426,13 @@ export class AppExtensionService implements RuleContext { getHeaderActions(): Array { return this.headerActions - .filter(action => this.filterVisible(action)) - .map(action => { + .filter((action) => this.filterVisible(action)) + .map((action) => { if (action.type === ContentActionType.menu) { const copy = this.copyAction(action); if (copy.children && copy.children.length > 0) { copy.children = copy.children - .filter(childAction => this.filterVisible(childAction)) + .filter((childAction) => this.filterVisible(childAction)) .sort(sortByOrder) .reduce(reduceEmptyMenus, []) .reduce(reduceSeparators, []); @@ -535,25 +452,21 @@ export class AppExtensionService implements RuleContext { } getUserActions(): Array { - return this.userActions - .filter(action => this.filterVisible(action)) - .sort(sortByOrder); + return this.userActions.filter((action) => this.filterVisible(action)).sort(sortByOrder); } getSettingsGroups(): Array { - return this.settingGroups.filter(group => this.filterVisible(group)); + return this.settingGroups.filter((group) => this.filterVisible(group)); } copyAction(action: ContentActionRef): ContentActionRef { return { ...action, - children: (action.children || []).map(child => this.copyAction(child)) + children: (action.children || []).map((child) => this.copyAction(child)) }; } - filterVisible( - action: ContentActionRef | SettingsGroupRef | SidebarTabRef - ): boolean { + filterVisible(action: ContentActionRef | SettingsGroupRef | SidebarTabRef): boolean { if (action && action.rules && action.rules.visible) { return this.extensions.evaluateRule(action.rules.visible, this); } diff --git a/projects/aca-shared/src/lib/services/app.service.spec.ts b/projects/aca-shared/src/lib/services/app.service.spec.ts index fe7c6cfea..87f5c3747 100644 --- a/projects/aca-shared/src/lib/services/app.service.spec.ts +++ b/projects/aca-shared/src/lib/services/app.service.spec.ts @@ -61,27 +61,17 @@ describe('AppService', () => { spyOn(routeReuse, 'resetCache').and.stub(); - service = new AppService( - auth, - appConfig, - searchQueryBuilderService, - routeReuse - ); + service = new AppService(auth, appConfig, searchQueryBuilderService, routeReuse); }); - it('should be ready if [withCredentials] mode is used', done => { + it('should be ready if [withCredentials] mode is used', (done) => { appConfig.config = { auth: { withCredentials: true } }; - const instance = new AppService( - auth, - appConfig, - searchQueryBuilderService, - routeReuse - ); + const instance = new AppService(auth, appConfig, searchQueryBuilderService, routeReuse); expect(instance.withCredentials).toBeTruthy(); instance.ready$.subscribe(() => { @@ -101,7 +91,7 @@ describe('AppService', () => { it('should be ready after login', async () => { let isReady = false; - service.ready$.subscribe(value => { + service.ready$.subscribe((value) => { isReady = value; }); auth.onLogin.next(); diff --git a/projects/aca-shared/src/lib/services/content-api.service.ts b/projects/aca-shared/src/lib/services/content-api.service.ts index 74a8fd63b..56459c06f 100644 --- a/projects/aca-shared/src/lib/services/content-api.service.ts +++ b/projects/aca-shared/src/lib/services/content-api.service.ts @@ -49,10 +49,7 @@ import { map } from 'rxjs/operators'; providedIn: 'root' }) export class ContentApiService { - constructor( - private api: AlfrescoApiService, - private preferences: UserPreferencesService - ) {} + constructor(private api: AlfrescoApiService, private preferences: UserPreferencesService) {} /** * Moves a node to the trashcan. @@ -60,10 +57,7 @@ export class ContentApiService { * @param options Optional parameters supported by JS-API * @returns Empty result that notifies when the deletion is complete */ - deleteNode( - nodeId: string, - options: { permanent?: boolean } = {} - ): Observable { + deleteNode(nodeId: string, options: { permanent?: boolean } = {}): Observable { return from(this.api.nodesApi.deleteNode(nodeId, options)); } @@ -101,13 +95,7 @@ export class ContentApiService { const defaults = { maxItems: this.preferences.paginationSize, skipCount: 0, - include: [ - 'isLocked', - 'path', - 'properties', - 'allowableOperations', - 'permissions' - ] + include: ['isLocked', 'path', 'properties', 'allowableOperations', 'permissions'] }; const queryOptions = Object.assign(defaults, options); @@ -140,10 +128,7 @@ export class ContentApiService { * @param personId ID of the target user * @returns User information */ - getPerson( - personId: string, - options?: { fields?: Array } - ): Observable { + getPerson(personId: string, options?: { fields?: Array }): Observable { return from(this.api.peopleApi.getPerson(personId, options)); } @@ -154,15 +139,8 @@ export class ContentApiService { * @param targetParentId The id of the folder-node where the node have to be copied to * @param name The new name for the copy that would be added on the destination folder */ - copyNode( - nodeId: string, - targetParentId: string, - name?: string, - opts?: { include?: Array; fields?: Array } - ): Observable { - return from( - this.api.nodesApi.copyNode(nodeId, { targetParentId, name }, opts) - ); + copyNode(nodeId: string, targetParentId: string, name?: string, opts?: { include?: Array; fields?: Array }): Observable { + return from(this.api.nodesApi.copyNode(nodeId, { targetParentId, name }, opts)); } /** @@ -170,9 +148,7 @@ export class ContentApiService { * @returns ProductVersionModel containing product details */ getRepositoryInformation(): Observable { - return from( - this.api.getInstance().discovery.discoveryApi.getRepositoryInformation() - ); + return from(this.api.getInstance().discovery.discoveryApi.getRepositoryInformation()); } getFavorites( @@ -187,10 +163,7 @@ export class ContentApiService { return from(this.api.favoritesApi.getFavorites(personId, opts)); } - getFavoriteLibraries( - personId: string = '-me-', - opts?: any - ): Observable { + getFavoriteLibraries(personId: string = '-me-', opts?: any): Observable { return this.getFavorites(personId, { ...opts, where: '(EXISTS(target/site))' @@ -246,10 +219,7 @@ export class ContentApiService { return from(this.api.sitesApi.createSite(siteBody, opts)); } - getSite( - siteId?: string, - opts?: { relations?: Array; fields?: Array } - ): Observable { + getSite(siteId?: string, opts?: { relations?: Array; fields?: Array }): Observable { return from(this.api.sitesApi.getSite(siteId, opts)); } @@ -258,7 +228,7 @@ export class ContentApiService { } addFavorite(nodes: Array): Observable { - const payload: FavoriteBody[] = nodes.map(node => { + const payload: FavoriteBody[] = nodes.map((node) => { const { isFolder, nodeId, id } = node.entry as any; const siteId = node.entry['guid']; const type = siteId ? 'site' : isFolder ? 'folder' : 'file'; diff --git a/projects/aca-shared/src/lib/services/node-permission.service.spec.ts b/projects/aca-shared/src/lib/services/node-permission.service.spec.ts index 694d5cd91..a6592fb20 100644 --- a/projects/aca-shared/src/lib/services/node-permission.service.spec.ts +++ b/projects/aca-shared/src/lib/services/node-permission.service.spec.ts @@ -112,9 +112,7 @@ describe('NodePermissionService', () => { } ]; - expect( - permission.check(source, ['update', 'other'], { operation: 'AND' }) - ).toBe(true); + expect(permission.check(source, ['update', 'other'], { operation: 'AND' })).toBe(true); }); it('should return false when source has no `AND` allowableOperations permission', () => { @@ -128,27 +126,17 @@ describe('NodePermissionService', () => { } ]; - expect( - permission.check(source, ['update', 'bogus'], { operation: 'AND' }) - ).toBe(false); + expect(permission.check(source, ['update', 'bogus'], { operation: 'AND' })).toBe(false); }); it('should return false when source has no allowableOperations', () => { - const source = [ - { entry: { allowableOperations: [] } }, - { entry: { allowableOperations: [] } }, - { entry: { allowableOperations: ['update'] } } - ]; + const source = [{ entry: { allowableOperations: [] } }, { entry: { allowableOperations: [] } }, { entry: { allowableOperations: ['update'] } }]; expect(permission.check(source, ['update'])).toBe(false); }); it('should return false when source has no allowableOperations property', () => { - const source = [ - { entry: {} }, - { entry: {} }, - { entry: { allowableOperations: ['update'] } } - ]; + const source = [{ entry: {} }, { entry: {} }, { entry: { allowableOperations: ['update'] } }]; expect(permission.check(source, ['update'])).toBe(false); }); @@ -196,9 +184,7 @@ describe('NodePermissionService', () => { it('should return true when source has `AND` allowableOperations permission', () => { const source = { entry: { allowableOperations: ['update', 'other'] } }; - expect( - permission.check(source, ['update', 'other'], { operation: 'AND' }) - ).toBe(true); + expect(permission.check(source, ['update', 'other'], { operation: 'AND' })).toBe(true); }); it('should return false when source has no `AND` allowableOperations permission', () => { @@ -206,9 +192,7 @@ describe('NodePermissionService', () => { entry: { allowableOperations: ['update', 'updatePermissions', 'other'] } }; - expect( - permission.check(source, ['update', 'bogus'], { operation: 'AND' }) - ).toBe(false); + expect(permission.check(source, ['update', 'bogus'], { operation: 'AND' })).toBe(false); }); it('should return false when source has no allowableOperations', () => { diff --git a/projects/aca-shared/src/lib/services/node-permission.service.ts b/projects/aca-shared/src/lib/services/node-permission.service.ts index e20333b60..5c00e5c40 100644 --- a/projects/aca-shared/src/lib/services/node-permission.service.ts +++ b/projects/aca-shared/src/lib/services/node-permission.service.ts @@ -45,11 +45,7 @@ export class NodePermissionService implements NodePermissions { target: null }; - check( - source: PermissionSource | PermissionSource[], - permissions: string[], - options?: PermissionOptions - ): boolean { + check(source: PermissionSource | PermissionSource[], permissions: string[], options?: PermissionOptions): boolean { const opts = Object.assign({}, this.defaultOptions, options || {}); if (!source) { @@ -57,12 +53,10 @@ export class NodePermissionService implements NodePermissions { } if (Array.isArray(source)) { - source = source.filter(item => item); + source = source.filter((item) => item); if (source.length > 0) { - return source.every(node => - this.isOperationAllowed(node, permissions, opts) - ); + return source.every((node) => this.isOperationAllowed(node, permissions, opts)); } return false; } else { @@ -70,35 +64,21 @@ export class NodePermissionService implements NodePermissions { } } - private isOperationAllowed( - node: PermissionSource, - permissions: string[], - options: PermissionOptions - ): boolean { - const allowableOperations = this.getAllowableOperations( - node, - options.target - ); + private isOperationAllowed(node: PermissionSource, permissions: string[], options: PermissionOptions): boolean { + const allowableOperations = this.getAllowableOperations(node, options.target); if (allowableOperations.length) { if (options.operation === NodePermissionService.DEFAULT_OPERATION) { - return permissions.some(permission => - allowableOperations.includes(permission) - ); + return permissions.some((permission) => allowableOperations.includes(permission)); } else { - return permissions.every(permission => - allowableOperations.includes(permission) - ); + return permissions.every((permission) => allowableOperations.includes(permission)); } } return false; } - private getAllowableOperations( - node: PermissionSource, - property?: string - ): string[] { + private getAllowableOperations(node: PermissionSource, property?: string): string[] { let entry: Node | SharedLink; if ('entry' in node) { diff --git a/projects/aca-shared/src/lib/utils/node.utils.ts b/projects/aca-shared/src/lib/utils/node.utils.ts index 0a473016c..41ce3cd0a 100644 --- a/projects/aca-shared/src/lib/utils/node.utils.ts +++ b/projects/aca-shared/src/lib/utils/node.utils.ts @@ -30,21 +30,12 @@ export function isLocked(node: { entry: Node }): boolean { return ( (entry && entry.isLocked) || - (entry.properties && - (entry.properties['cm:lockType'] === 'READ_ONLY_LOCK' || - entry.properties['cm:lockType'] === 'WRITE_LOCK')) + (entry.properties && (entry.properties['cm:lockType'] === 'READ_ONLY_LOCK' || entry.properties['cm:lockType'] === 'WRITE_LOCK')) ); } export function isLibrary(node: { entry: Node | any }): boolean { const { entry } = node; - return ( - (entry.guid && - entry.id && - entry.preset && - entry.title && - entry.visibility) || - entry.nodeType === 'st:site' - ); + return (entry.guid && entry.id && entry.preset && entry.title && entry.visibility) || entry.nodeType === 'st:site'; } diff --git a/projects/aca-shared/store/src/actions/metadata-aspect.actions.ts b/projects/aca-shared/store/src/actions/metadata-aspect.actions.ts index 03c1d5934..60346340b 100644 --- a/projects/aca-shared/store/src/actions/metadata-aspect.actions.ts +++ b/projects/aca-shared/store/src/actions/metadata-aspect.actions.ts @@ -25,8 +25,7 @@ import { Action } from '@ngrx/store'; -export const SET_INFO_DRAWER_METADATA_ASPECT = - 'SET_INFO_DRAWER_METADATA_ASPECT'; +export const SET_INFO_DRAWER_METADATA_ASPECT = 'SET_INFO_DRAWER_METADATA_ASPECT'; export class SetInfoDrawerMetadataAspectAction implements Action { readonly type = SET_INFO_DRAWER_METADATA_ASPECT; diff --git a/projects/aca-shared/store/src/actions/search.actions.ts b/projects/aca-shared/store/src/actions/search.actions.ts index 19449af0e..2495340b9 100644 --- a/projects/aca-shared/store/src/actions/search.actions.ts +++ b/projects/aca-shared/store/src/actions/search.actions.ts @@ -35,10 +35,7 @@ export enum SearchActionTypes { export class SearchByTermAction implements Action { readonly type = SearchActionTypes.SearchByTerm; - constructor( - public payload: string, - public searchOptions?: SearchOptionModel[] - ) {} + constructor(public payload: string, public searchOptions?: SearchOptionModel[]) {} } export class ToggleSearchFilterAction implements Action { diff --git a/projects/aca-shared/store/src/effects/dialog.effects.ts b/projects/aca-shared/store/src/effects/dialog.effects.ts index f3c5ba48a..929d7884f 100644 --- a/projects/aca-shared/store/src/effects/dialog.effects.ts +++ b/projects/aca-shared/store/src/effects/dialog.effects.ts @@ -27,10 +27,7 @@ import { Effect, Actions, ofType } from '@ngrx/effects'; import { Injectable } from '@angular/core'; import { map } from 'rxjs/operators'; import { MatDialog } from '@angular/material/dialog'; -import { - CloseModalDialogsAction, - AppActionTypes -} from '../actions/app.actions'; +import { CloseModalDialogsAction, AppActionTypes } from '../actions/app.actions'; @Injectable() export class DialogEffects { diff --git a/projects/aca-shared/store/src/effects/router.effects.ts b/projects/aca-shared/store/src/effects/router.effects.ts index b9c4a8da2..f654626d8 100644 --- a/projects/aca-shared/store/src/effects/router.effects.ts +++ b/projects/aca-shared/store/src/effects/router.effects.ts @@ -30,27 +30,17 @@ import { MinimalNodeEntryEntity, PathInfoEntity } from '@alfresco/js-api'; import { map } from 'rxjs/operators'; import { Store } from '@ngrx/store'; import { AppStore } from '../states/app.state'; -import { - NavigateUrlAction, - RouterActionTypes, - NavigateRouteAction, - NavigateToFolder, - NavigateToParentFolder -} from '../actions/router.actions'; +import { NavigateUrlAction, RouterActionTypes, NavigateRouteAction, NavigateToFolder, NavigateToParentFolder } from '../actions/router.actions'; import { SnackbarErrorAction } from '../actions/snackbar.actions'; @Injectable() export class RouterEffects { - constructor( - private store: Store, - private actions$: Actions, - private router: Router - ) {} + constructor(private store: Store, private actions$: Actions, private router: Router) {} @Effect({ dispatch: false }) navigateUrl$ = this.actions$.pipe( ofType(RouterActionTypes.NavigateUrl), - map(action => { + map((action) => { if (action.payload) { this.router.navigateByUrl(action.payload); } @@ -60,7 +50,7 @@ export class RouterEffects { @Effect({ dispatch: false }) navigateRoute$ = this.actions$.pipe( ofType(RouterActionTypes.NavigateRoute), - map(action => { + map((action) => { this.router.navigate(action.payload); }) ); @@ -68,7 +58,7 @@ export class RouterEffects { @Effect({ dispatch: false }) navigateToFolder$ = this.actions$.pipe( ofType(RouterActionTypes.NavigateFolder), - map(action => { + map((action) => { if (action.payload && action.payload.entry) { this.navigateToFolder(action.payload.entry); } @@ -78,7 +68,7 @@ export class RouterEffects { @Effect({ dispatch: false }) navigateToParentFolder$ = this.actions$.pipe( ofType(RouterActionTypes.NavigateParentFolder), - map(action => { + map((action) => { if (action.payload && action.payload.entry) { this.navigateToParentFolder(action.payload.entry); } @@ -131,18 +121,12 @@ export class RouterEffects { this.router.navigate(link); }, 10); } else { - this.store.dispatch( - new SnackbarErrorAction('APP.MESSAGES.ERRORS.CANNOT_NAVIGATE_LOCATION') - ); + this.store.dispatch(new SnackbarErrorAction('APP.MESSAGES.ERRORS.CANNOT_NAVIGATE_LOCATION')); } } private isLibraryContent(path: PathInfoEntity): boolean { - if ( - path && - path.elements.length >= 2 && - path.elements[1].name === 'Sites' - ) { + if (path && path.elements.length >= 2 && path.elements[1].name === 'Sites') { return true; } diff --git a/projects/aca-shared/store/src/effects/snackbar.effects.ts b/projects/aca-shared/store/src/effects/snackbar.effects.ts index 7e7c66144..4b3d1efee 100644 --- a/projects/aca-shared/store/src/effects/snackbar.effects.ts +++ b/projects/aca-shared/store/src/effects/snackbar.effects.ts @@ -30,13 +30,7 @@ import { Actions, Effect, ofType } from '@ngrx/effects'; import { Store } from '@ngrx/store'; import { map } from 'rxjs/operators'; import { AppStore } from '../states/app.state'; -import { - SnackbarInfoAction, - SnackbarActionTypes, - SnackbarWarningAction, - SnackbarErrorAction, - SnackbarAction -} from '../actions/snackbar.actions'; +import { SnackbarInfoAction, SnackbarActionTypes, SnackbarWarningAction, SnackbarErrorAction, SnackbarAction } from '../actions/snackbar.actions'; @Injectable() export class SnackbarEffects { diff --git a/projects/aca-shared/store/src/selectors/app.selectors.ts b/projects/aca-shared/store/src/selectors/app.selectors.ts index cc080cab6..43e2d1ef8 100644 --- a/projects/aca-shared/store/src/selectors/app.selectors.ts +++ b/projects/aca-shared/store/src/selectors/app.selectors.ts @@ -28,80 +28,29 @@ import { createSelector } from '@ngrx/store'; export const selectApp = (state: AppStore) => state.app; -export const getHeaderColor = createSelector( - selectApp, - state => state.headerColor -); +export const getHeaderColor = createSelector(selectApp, (state) => state.headerColor); +export const getAppName = createSelector(selectApp, (state) => state.appName); +export const getLogoPath = createSelector(selectApp, (state) => state.logoPath); +export const getHeaderImagePath = createSelector(selectApp, (state) => state.headerImagePath); +export const getLanguagePickerState = createSelector(selectApp, (state) => state.languagePicker); +export const getUserProfile = createSelector(selectApp, (state) => state.user); +export const getCurrentFolder = createSelector(selectApp, (state) => state.navigation.currentFolder); +export const getAppSelection = createSelector(selectApp, (state) => state.selection); +export const getSharedUrl = createSelector(selectApp, (state) => state.sharedUrl); +export const getNavigationState = createSelector(selectApp, (state) => state.navigation); +export const isInfoDrawerOpened = createSelector(selectApp, (state) => state.infoDrawerOpened); +export const showFacetFilter = createSelector(selectApp, (state) => state.showFacetFilter); +export const getDocumentDisplayMode = createSelector(selectApp, (state) => state.documentDisplayMode); +export const getRepositoryStatus = createSelector(selectApp, (state) => state.repository); +export const isQuickShareEnabled = createSelector(getRepositoryStatus, (info) => info.status.isQuickShareEnabled); +export const isAdmin = createSelector(selectApp, (state) => state.user.isAdmin); -export const getAppName = createSelector(selectApp, state => state.appName); -export const getLogoPath = createSelector(selectApp, state => state.logoPath); - -export const getHeaderImagePath = createSelector( - selectApp, - state => state.headerImagePath -); - -export const getLanguagePickerState = createSelector( - selectApp, - state => state.languagePicker -); - -export const getUserProfile = createSelector(selectApp, state => state.user); - -export const getCurrentFolder = createSelector( - selectApp, - state => state.navigation.currentFolder -); - -export const getAppSelection = createSelector( - selectApp, - state => state.selection -); - -export const getSharedUrl = createSelector(selectApp, state => state.sharedUrl); - -export const getNavigationState = createSelector( - selectApp, - state => state.navigation -); - -export const isInfoDrawerOpened = createSelector( - selectApp, - state => state.infoDrawerOpened -); - -export const showFacetFilter = createSelector( - selectApp, - state => state.showFacetFilter -); - -export const getDocumentDisplayMode = createSelector( - selectApp, - state => state.documentDisplayMode -); - -export const getRepositoryStatus = createSelector( - selectApp, - state => state.repository -); - -export const isQuickShareEnabled = createSelector( - getRepositoryStatus, - info => info.status.isQuickShareEnabled -); - -export const isAdmin = createSelector(selectApp, state => state.user.isAdmin); - -export const getSideNavState = createSelector( - getAppSelection, - getNavigationState, - (selection, navigation) => { - return { - selection, - navigation - }; - } -); +export const getSideNavState = createSelector(getAppSelection, getNavigationState, (selection, navigation) => { + return { + selection, + navigation + }; +}); export const getRuleContext = createSelector( getAppSelection, @@ -118,7 +67,4 @@ export const getRuleContext = createSelector( } ); -export const infoDrawerMetadataAspect = createSelector( - selectApp, - state => state.infoDrawerMetadataAspect -); +export const infoDrawerMetadataAspect = createSelector(selectApp, (state) => state.infoDrawerMetadataAspect); diff --git a/projects/aca-shared/store/src/states/app.state.ts b/projects/aca-shared/store/src/states/app.state.ts index 4579a9a2d..b90144ee0 100644 --- a/projects/aca-shared/store/src/states/app.state.ts +++ b/projects/aca-shared/store/src/states/app.state.ts @@ -23,11 +23,7 @@ * along with Alfresco. If not, see . */ -import { - SelectionState, - ProfileState, - NavigationState -} from '@alfresco/adf-extensions'; +import { SelectionState, ProfileState, NavigationState } from '@alfresco/adf-extensions'; import { RepositoryInfo } from '@alfresco/js-api'; export interface AppState { diff --git a/projects/aca-shared/store/src/store.module.ts b/projects/aca-shared/store/src/store.module.ts index aabdac4e0..4d47baa44 100644 --- a/projects/aca-shared/store/src/store.module.ts +++ b/projects/aca-shared/store/src/store.module.ts @@ -30,8 +30,6 @@ import { DialogEffects } from './effects/dialog.effects'; import { RouterEffects } from './effects/router.effects'; @NgModule({ - imports: [ - EffectsModule.forFeature([SnackbarEffects, DialogEffects, RouterEffects]) - ] + imports: [EffectsModule.forFeature([SnackbarEffects, DialogEffects, RouterEffects])] }) export class SharedStoreModule {} diff --git a/projects/aca-shared/test.ts b/projects/aca-shared/test.ts index bdee7e324..1b4b59913 100644 --- a/projects/aca-shared/test.ts +++ b/projects/aca-shared/test.ts @@ -28,18 +28,12 @@ import 'zone.js/dist/zone'; import 'zone.js/dist/zone-testing'; import { getTestBed } from '@angular/core/testing'; -import { - BrowserDynamicTestingModule, - platformBrowserDynamicTesting -} from '@angular/platform-browser-dynamic/testing'; +import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; declare const require: any; // First, initialize the Angular testing environment. -getTestBed().initTestEnvironment( - BrowserDynamicTestingModule, - platformBrowserDynamicTesting() -); +getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting()); // Then we find all the tests. const context = require.context('./', true, /\.spec\.ts$/); // And load the modules. diff --git a/projects/aca-testing-shared/src/components/breadcrumb/breadcrumb.ts b/projects/aca-testing-shared/src/components/breadcrumb/breadcrumb.ts index 543f7a978..7d8f337b5 100755 --- a/projects/aca-testing-shared/src/components/breadcrumb/breadcrumb.ts +++ b/projects/aca-testing-shared/src/components/breadcrumb/breadcrumb.ts @@ -34,7 +34,7 @@ export class Breadcrumb extends Component { } async getAllItems(): Promise { - const items: string[] = await this.items.map(async elem => { + const items: string[] = await this.items.map(async (elem) => { const str = await elem.getText(); return str.split('\nchevron_right')[0]; }); diff --git a/projects/aca-testing-shared/src/components/breadcrumb/dropdown-breadcrumb.ts b/projects/aca-testing-shared/src/components/breadcrumb/dropdown-breadcrumb.ts index a31740814..7b6fe15cd 100755 --- a/projects/aca-testing-shared/src/components/breadcrumb/dropdown-breadcrumb.ts +++ b/projects/aca-testing-shared/src/components/breadcrumb/dropdown-breadcrumb.ts @@ -39,17 +39,11 @@ export class DropDownBreadcrumb extends Component { } async waitForPathListDropdownToOpen(): Promise { - return waitForPresence( - this.pathItemsContainer, - 'Timeout waiting for breadcrumb dropdown to open' - ); + return waitForPresence(this.pathItemsContainer, 'Timeout waiting for breadcrumb dropdown to open'); } async waitForPathListDropdownToClose(): Promise { - return waitForStaleness( - browser.$(this.pathOptionCss), - 'Timeout waiting for breadcrumb dropdown to close' - ); + return waitForStaleness(browser.$(this.pathOptionCss), 'Timeout waiting for breadcrumb dropdown to close'); } async openPath(): Promise { @@ -58,14 +52,12 @@ export class DropDownBreadcrumb extends Component { } async clickPathItem(name: string): Promise { - const elem = browser.element( - by.cssContainingText(this.pathOptionCss, name) - ); + const elem = browser.element(by.cssContainingText(this.pathOptionCss, name)); await elem.click(); } async getPathItems(): Promise { - const items: string[] = await this.pathItems.map(async elem => { + const items: string[] = await this.pathItems.map(async (elem) => { return elem.getText(); }); return items; diff --git a/projects/aca-testing-shared/src/components/component.ts b/projects/aca-testing-shared/src/components/component.ts index 05727340a..8d803a94f 100755 --- a/projects/aca-testing-shared/src/components/component.ts +++ b/projects/aca-testing-shared/src/components/component.ts @@ -23,57 +23,32 @@ * along with Alfresco. If not, see . */ -import { - ElementFinder, - browser, - by, - ElementArrayFinder, - ProtractorBrowser -} from 'protractor'; +import { ElementFinder, browser, by, ElementArrayFinder, ProtractorBrowser } from 'protractor'; import { waitForPresence } from '../utilities/utils'; export abstract class Component { component: ElementFinder; - protected byCss( - css: string, - root: ElementFinder | ProtractorBrowser = this.component - ): ElementFinder { + protected byCss(css: string, root: ElementFinder | ProtractorBrowser = this.component): ElementFinder { return root.element(by.css(css)); } - protected byCssText( - css: string, - text: string, - root: ElementFinder | ProtractorBrowser = this.component - ): ElementFinder { + protected byCssText(css: string, text: string, root: ElementFinder | ProtractorBrowser = this.component): ElementFinder { return root.element(by.cssContainingText(css, text)); } - protected byId( - css: string, - root: ElementFinder | ProtractorBrowser = this.component - ): ElementFinder { + protected byId(css: string, root: ElementFinder | ProtractorBrowser = this.component): ElementFinder { return root.element(by.id(css)); } - protected allByCss( - css: string, - root: ElementFinder | ProtractorBrowser = this.component - ): ElementArrayFinder { + protected allByCss(css: string, root: ElementFinder | ProtractorBrowser = this.component): ElementArrayFinder { return root.all(by.css(css)); } constructor(selector: string, ancestor?: string) { const locator = selector; - this.component = ancestor - ? browser - .$$(ancestor) - .first() - .$$(locator) - .first() - : browser.$$(locator).first(); + this.component = ancestor ? browser.$$(ancestor).first().$$(locator).first() : browser.$$(locator).first(); } async wait() { diff --git a/projects/aca-testing-shared/src/components/data-table/data-table.ts b/projects/aca-testing-shared/src/components/data-table/data-table.ts index f427da562..e44d8dbed 100755 --- a/projects/aca-testing-shared/src/components/data-table/data-table.ts +++ b/projects/aca-testing-shared/src/components/data-table/data-table.ts @@ -23,27 +23,16 @@ * along with Alfresco. If not, see . */ -import { - ElementFinder, - ElementArrayFinder, - by, - browser, - protractor -} from 'protractor'; +import { ElementFinder, ElementArrayFinder, by, browser, protractor } from 'protractor'; import { Logger } from '@alfresco/adf-testing'; import { BROWSER_WAIT_TIMEOUT } from '../../configs'; import { Component } from '../component'; import { Menu } from '../menu/menu'; -import { - Utils, - waitForPresence, - waitForClickable -} from '../../utilities/utils'; +import { Utils, waitForPresence, waitForClickable } from '../../utilities/utils'; export class DataTable extends Component { private static selectors = { - columnHeader: - '.adf-datatable-row .adf-datatable-cell-header .adf-datatable-cell-value', + columnHeader: '.adf-datatable-row .adf-datatable-cell-header .adf-datatable-cell-value', sortedColumnHeader: ` .adf-datatable__header--sorted-asc .adf-datatable-cell-value, .adf-datatable__header--sorted-desc .adf-datatable-cell-value @@ -58,9 +47,7 @@ export class DataTable extends Component { head = this.byCss('.adf-datatable-header'); body = this.byCss('.adf-datatable-body'); emptyList = this.byCss('div.adf-no-content-container'); - emptyFolderDragAndDrop = this.byCss( - '.adf-empty-list_template .adf-empty-folder' - ); + emptyFolderDragAndDrop = this.byCss('.adf-empty-list_template .adf-empty-folder'); emptyListTitle = this.byCss('.adf-empty-content__title'); emptyListSubtitle = this.byCss('.adf-empty-content__subtitle'); emptySearchText = this.byCss('.empty-search__text'); @@ -94,10 +81,7 @@ export class DataTable extends Component { } getColumnHeaderByLabel(label: string): ElementFinder { - const locator = by.cssContainingText( - DataTable.selectors.columnHeader, - label - ); + const locator = by.cssContainingText(DataTable.selectors.columnHeader, label); return this.head.element(locator); } @@ -111,9 +95,7 @@ export class DataTable extends Component { } async getSortingOrder(): Promise { - const str = await this.getSortedColumnHeader() - .element(by.xpath('..')) - .getAttribute('class'); + const str = await this.getSortedColumnHeader().element(by.xpath('..')).getAttribute('class'); if (str.includes('asc')) { return 'asc'; } @@ -138,7 +120,7 @@ export class DataTable extends Component { } async getSelectedRowsNames(): Promise { - const rowsText: string[] = await this.getSelectedRows().map(row => { + const rowsText: string[] = await this.getSelectedRows().map((row) => { return row.element(by.css('.adf-datatable-cell[title="Name"]')).getText(); }); return rowsText; @@ -152,24 +134,14 @@ export class DataTable extends Component { if (location) { return this.body .all(by.cssContainingText(DataTable.selectors.row, name)) - .filter(async elem => - browser.isElementPresent( - elem.element( - by.cssContainingText(DataTable.selectors.cell, location) - ) - ) - ) + .filter(async (elem) => browser.isElementPresent(elem.element(by.cssContainingText(DataTable.selectors.cell, location)))) .first(); } - return this.body.element( - by.cssContainingText(DataTable.selectors.row, name) - ); + return this.body.element(by.cssContainingText(DataTable.selectors.row, name)); } getRowCells(name: string, location: string = ''): ElementArrayFinder { - return this.getRowByName(name, location).all( - by.css(DataTable.selectors.cell) - ); + return this.getRowByName(name, location).all(by.css(DataTable.selectors.cell)); } async getRowCellsCount(itemName: string): Promise { @@ -184,24 +156,15 @@ export class DataTable extends Component { return this.getRowCells(name, location).get(1); } - private getRowNameCellSpan( - name: string, - location: string = '' - ): ElementFinder { + private getRowNameCellSpan(name: string, location: string = ''): ElementFinder { return this.getRowNameCell(name, location).$('span'); } - async getItemNameTooltip( - name: string, - location: string = '' - ): Promise { + async getItemNameTooltip(name: string, location: string = ''): Promise { return this.getRowNameCellSpan(name, location).getAttribute('title'); } - async hasCheckMarkIcon( - itemName: string, - location: string = '' - ): Promise { + async hasCheckMarkIcon(itemName: string, location: string = ''): Promise { const row = this.getRowByName(itemName, location); return row.element(by.css('.mat-icon[class*="selected"]')).isPresent(); } @@ -211,10 +174,7 @@ export class DataTable extends Component { return row.element(by.css('img[src*="lock"]')).isPresent(); } - private async hasLockOwnerInfo( - itemName: string, - location: string = '' - ): Promise { + private async hasLockOwnerInfo(itemName: string, location: string = ''): Promise { const row = this.getRowByName(itemName, location); return row.element(by.css(DataTable.selectors.lockOwner)).isPresent(); } @@ -222,10 +182,7 @@ export class DataTable extends Component { async getLockOwner(itemName: string, location: string = ''): Promise { if (await this.hasLockOwnerInfo(itemName, location)) { const row = this.getRowByName(itemName, location); - return row - .$(DataTable.selectors.lockOwner) - .$('.locked_by--name') - .getText(); + return row.$(DataTable.selectors.lockOwner).$('.locked_by--name').getText(); } return ''; } @@ -238,21 +195,12 @@ export class DataTable extends Component { return this.getNameLink(itemName).isPresent(); } - async doubleClickOnRowByName( - name: string, - location: string = '' - ): Promise { + async doubleClickOnRowByName(name: string, location: string = ''): Promise { try { const item = this.getRowFirstCell(name, location); await waitForClickable(item); - await browser - .actions() - .mouseMove(item) - .perform(); - await browser - .actions() - .doubleClick() - .perform(); + await browser.actions().mouseMove(item).perform(); + await browser.actions().doubleClick().perform(); } catch (error) { Logger.error('--- catch: doubleClickOnRowByName', error); } @@ -291,10 +239,7 @@ export class DataTable extends Component { await this.getNameLink(itemName).click(); } - async selectMultipleItems( - names: string[], - location: string = '' - ): Promise { + async selectMultipleItems(names: string[], location: string = ''): Promise { await this.clearSelection(); await Utils.pressCmd(); for (const name of names) { @@ -317,26 +262,14 @@ export class DataTable extends Component { async rightClickOnItem(itemName: string): Promise { const item = this.getRowFirstCell(itemName); - await browser - .actions() - .mouseMove(item) - .perform(); - await browser - .actions() - .click(protractor.Button.RIGHT) - .perform(); + await browser.actions().mouseMove(item).perform(); + await browser.actions().click(protractor.Button.RIGHT).perform(); } async rightClickOnMultipleSelection(): Promise { const itemFromSelection = this.getSelectedRows().get(0); - await browser - .actions() - .mouseMove(itemFromSelection) - .perform(); - await browser - .actions() - .click(protractor.Button.RIGHT) - .perform(); + await browser.actions().mouseMove(itemFromSelection).perform(); + await browser.actions().click(protractor.Button.RIGHT).perform(); } private getItemLocationEl(name: string): ElementFinder { @@ -349,13 +282,9 @@ export class DataTable extends Component { async getItemLocationTooltip(name: string): Promise { const location = this.getItemLocationEl(name).$('a'); - const condition = () => - location.getAttribute('title').then(value => value && value.length > 0); + const condition = () => location.getAttribute('title').then((value) => value && value.length > 0); - await browser - .actions() - .mouseMove(location) - .perform(); + await browser.actions().mouseMove(location).perform(); await browser.wait(condition, BROWSER_WAIT_TIMEOUT); return location.getAttribute('title'); @@ -402,10 +331,8 @@ export class DataTable extends Component { } async getCellsContainingName(name: string): Promise { - const rows = this.getRows().all( - by.cssContainingText(DataTable.selectors.cell, name) - ); - const cellsText: string[] = await rows.map(async cell => { + const rows = this.getRows().all(by.cssContainingText(DataTable.selectors.cell, name)); + const cellsText: string[] = await rows.map(async (cell) => { return cell.getText(); }); return cellsText; @@ -417,9 +344,7 @@ export class DataTable extends Component { } async getLibraryRole(name: string): Promise { - return this.getRowByName(name) - .element(by.css('adf-library-role-column')) - .getText(); + return this.getRowByName(name).element(by.css('adf-library-role-column')).getText(); } async isItemPresent(name: string, location?: string): Promise { @@ -427,25 +352,25 @@ export class DataTable extends Component { } private async getEntireDataTableText(): Promise { - const text: string[] = await this.getRows().map(row => { - return row.all(by.css(DataTable.selectors.cell)).map(async cell => { + const text: string[] = await this.getRows().map((row) => { + return row.all(by.css(DataTable.selectors.cell)).map(async (cell) => { return cell.getText(); }); }); return text; } - async getSitesNameAndVisibility(): Promise<{}> { - const data = await this.getEntireDataTableText(); - return data.reduce((acc, cell) => { + async getSitesNameAndVisibility(): Promise { + const data: string[] = await this.getEntireDataTableText(); + return data.reduce((acc: any, cell) => { acc[cell[1]] = cell[4].toUpperCase(); return acc; }, {}); } - async getSitesNameAndRole(): Promise<{}> { - const data = await this.getEntireDataTableText(); - return data.reduce((acc, cell) => { + async getSitesNameAndRole(): Promise { + const data: string[] = await this.getEntireDataTableText(); + return data.reduce((acc: any, cell) => { acc[cell[1]] = cell[3]; return acc; }, {}); @@ -459,100 +384,53 @@ export class DataTable extends Component { return this.getSearchResultsRows().get(nth - 1); } - private getSearchResultsRowByName( - name: string, - location: string = '' - ): ElementFinder { + private getSearchResultsRowByName(name: string, location: string = ''): ElementFinder { if (location) { return this.body .all(by.cssContainingText(DataTable.selectors.searchResultsRow, name)) - .filter(async elem => - browser.isElementPresent( - elem.element( - by.cssContainingText( - DataTable.selectors.searchResultsRowLine, - location - ) - ) - ) - ) + .filter(async (elem) => browser.isElementPresent(elem.element(by.cssContainingText(DataTable.selectors.searchResultsRowLine, location)))) .first(); } - return this.body.element( - by.cssContainingText(DataTable.selectors.searchResultsRow, name) - ); + return this.body.element(by.cssContainingText(DataTable.selectors.searchResultsRow, name)); } - private getSearchResultRowLines( - name: string, - location: string = '' - ): ElementArrayFinder { - return this.getSearchResultsRowByName(name, location).all( - by.css(DataTable.selectors.searchResultsRowLine) - ); + private getSearchResultRowLines(name: string, location: string = ''): ElementArrayFinder { + return this.getSearchResultsRowByName(name, location).all(by.css(DataTable.selectors.searchResultsRowLine)); } - async getSearchResultLinesCount( - name: string, - location: string = '' - ): Promise { + async getSearchResultLinesCount(name: string, location: string = ''): Promise { return this.getSearchResultRowLines(name, location).count(); } - private getSearchResultNthLine( - name: string, - location: string = '', - index: number - ): ElementFinder { + private getSearchResultNthLine(name: string, location: string = '', index: number): ElementFinder { return this.getSearchResultRowLines(name, location).get(index); } - async getSearchResultNameAndTitle( - name: string, - location: string = '' - ): Promise { + async getSearchResultNameAndTitle(name: string, location: string = ''): Promise { return this.getSearchResultNthLine(name, location, 0).getText(); } - async getSearchResultDescription( - name: string, - location: string = '' - ): Promise { + async getSearchResultDescription(name: string, location: string = ''): Promise { return this.getSearchResultNthLine(name, location, 1).getText(); } - async getSearchResultModified( - name: string, - location: string = '' - ): Promise { + async getSearchResultModified(name: string, location: string = ''): Promise { return this.getSearchResultNthLine(name, location, 2).getText(); } - async getSearchResultLocation( - name: string, - location: string = '' - ): Promise { + async getSearchResultLocation(name: string, location: string = ''): Promise { return this.getSearchResultNthLine(name, location, 3).getText(); } - private getSearchResultNameLink( - itemName: string, - location: string = '' - ): ElementFinder { + private getSearchResultNameLink(itemName: string, location: string = ''): ElementFinder { return this.getSearchResultsRowByName(itemName, location).$('.link'); } - async hasLinkOnSearchResultName( - itemName: string, - location: string = '' - ): Promise { + async hasLinkOnSearchResultName(itemName: string, location: string = ''): Promise { return this.getSearchResultNameLink(itemName, location).isPresent(); } - async clickSearchResultNameLink( - itemName: string, - location: string = '' - ): Promise { + async clickSearchResultNameLink(itemName: string, location: string = ''): Promise { await this.getSearchResultNameLink(itemName, location).click(); } } diff --git a/projects/aca-testing-shared/src/components/datetime-picker/datetime-picker.ts b/projects/aca-testing-shared/src/components/datetime-picker/datetime-picker.ts index 6f7b68400..a4d9ac2c0 100755 --- a/projects/aca-testing-shared/src/components/datetime-picker/datetime-picker.ts +++ b/projects/aca-testing-shared/src/components/datetime-picker/datetime-picker.ts @@ -25,8 +25,8 @@ import { by, browser } from 'protractor'; import { Component } from '../component'; -import * as moment from 'moment'; import { isPresentAndDisplayed, waitForStaleness } from '../../utilities/utils'; +const moment = require('moment'); export class DateTimePicker extends Component { calendar = this.byCss('.mat-datetimepicker-popup', browser); @@ -55,11 +55,8 @@ export class DateTimePicker extends Component { const dayOfTomorrow = tomorrow.date(); const date = await this.headerDate.getText(); const year = await this.headerYear.getText(); - const firstActiveDay = - '.mat-datetimepicker-calendar-body-active .mat-datetimepicker-calendar-body-cell-content'; - const elem = this.dayPicker.element( - by.cssContainingText(firstActiveDay, `${dayOfTomorrow}`) - ); + const firstActiveDay = '.mat-datetimepicker-calendar-body-active .mat-datetimepicker-calendar-body-cell-content'; + const elem = this.dayPicker.element(by.cssContainingText(firstActiveDay, `${dayOfTomorrow}`)); await elem.click(); return `${date} ${year}`; } diff --git a/projects/aca-testing-shared/src/components/dialog/content-node-selector-dialog.ts b/projects/aca-testing-shared/src/components/dialog/content-node-selector-dialog.ts index 535fe04b7..8da8982f7 100755 --- a/projects/aca-testing-shared/src/components/dialog/content-node-selector-dialog.ts +++ b/projects/aca-testing-shared/src/components/dialog/content-node-selector-dialog.ts @@ -25,41 +25,18 @@ import { by, browser, protractor } from 'protractor'; import { GenericDialog } from '../dialog/generic-dialog'; -import { - Utils, - isPresentAndDisplayed, - waitForStaleness, - waitForPresence, - isPresentAndEnabled, - waitForClickable -} from '../../utilities/utils'; +import { Utils, isPresentAndDisplayed, waitForStaleness, waitForPresence, isPresentAndEnabled, waitForClickable } from '../../utilities/utils'; import { DropDownBreadcrumb } from '../breadcrumb/dropdown-breadcrumb'; import { DataTable } from '../data-table/data-table'; export class ContentNodeSelectorDialog extends GenericDialog { - cancelButton = this.childElement( - by.css('[data-automation-id="content-node-selector-actions-cancel"]') - ); - copyButton = this.childElement( - by.cssContainingText( - '[data-automation-id="content-node-selector-actions-choose"]', - 'Copy' - ) - ); - moveButton = this.childElement( - by.cssContainingText( - '[data-automation-id="content-node-selector-actions-choose"]', - 'Move' - ) - ); + cancelButton = this.childElement(by.css('[data-automation-id="content-node-selector-actions-cancel"]')); + copyButton = this.childElement(by.cssContainingText('[data-automation-id="content-node-selector-actions-choose"]', 'Copy')); + moveButton = this.childElement(by.cssContainingText('[data-automation-id="content-node-selector-actions-choose"]', 'Move')); locationDropDown = this.rootElem.element(by.id('site-dropdown-container')); - locationPersonalFiles = browser.element( - by.cssContainingText('.mat-option .mat-option-text', 'Personal Files') - ); - locationFileLibraries = browser.element( - by.cssContainingText('.mat-option .mat-option-text', 'My Libraries') - ); + locationPersonalFiles = browser.element(by.cssContainingText('.mat-option .mat-option-text', 'Personal Files')); + locationFileLibraries = browser.element(by.cssContainingText('.mat-option .mat-option-text', 'My Libraries')); searchInput = this.rootElem.element(by.css('#searchInput')); toolbarTitle = this.rootElem.element(by.css('.adf-toolbar-title')); diff --git a/projects/aca-testing-shared/src/components/dialog/create-edit-folder-dialog.ts b/projects/aca-testing-shared/src/components/dialog/create-edit-folder-dialog.ts index 32cab4b6f..cb381472c 100755 --- a/projects/aca-testing-shared/src/components/dialog/create-edit-folder-dialog.ts +++ b/projects/aca-testing-shared/src/components/dialog/create-edit-folder-dialog.ts @@ -25,26 +25,15 @@ import { by } from 'protractor'; import { GenericDialog } from '../dialog/generic-dialog'; -import { - isPresentAndDisplayed, - waitForClickable, - isPresentAndEnabled, - typeText -} from '../../utilities/utils'; +import { isPresentAndDisplayed, waitForClickable, isPresentAndEnabled, typeText } from '../../utilities/utils'; export class CreateOrEditFolderDialog extends GenericDialog { - createButton = this.childElement( - by.cssContainingText('.mat-dialog-actions button', 'Create') - ); + createButton = this.childElement(by.cssContainingText('.mat-dialog-actions button', 'Create')); cancelButton = this.childElement(by.id('adf-folder-cancel-button')); - updateButton = this.childElement( - by.cssContainingText('.mat-dialog-actions button', 'Update') - ); + updateButton = this.childElement(by.cssContainingText('.mat-dialog-actions button', 'Update')); nameInput = this.rootElem.element(by.css('input[placeholder="Name" i]')); - descriptionTextArea = this.rootElem.element( - by.css('textarea[placeholder="Description" i]') - ); + descriptionTextArea = this.rootElem.element(by.css('textarea[placeholder="Description" i]')); validationMessage = this.rootElem.element(by.css('.mat-hint span')); constructor() { diff --git a/projects/aca-testing-shared/src/components/dialog/create-from-template-dialog.ts b/projects/aca-testing-shared/src/components/dialog/create-from-template-dialog.ts index 1b7a6f2e6..ca838c669 100755 --- a/projects/aca-testing-shared/src/components/dialog/create-from-template-dialog.ts +++ b/projects/aca-testing-shared/src/components/dialog/create-from-template-dialog.ts @@ -25,25 +25,15 @@ import { by } from 'protractor'; import { GenericDialog } from '../dialog/generic-dialog'; -import { - isPresentAndDisplayed, - isPresentAndEnabled, - typeText -} from '../../utilities/utils'; +import { isPresentAndDisplayed, isPresentAndEnabled, typeText } from '../../utilities/utils'; export class CreateFromTemplateDialog extends GenericDialog { - createButton = this.childElement( - by.cssContainingText('.mat-dialog-actions button', 'Create') - ); - cancelButton = this.childElement( - by.cssContainingText('.mat-dialog-actions button', 'CANCEL') - ); + createButton = this.childElement(by.cssContainingText('.mat-dialog-actions button', 'Create')); + cancelButton = this.childElement(by.cssContainingText('.mat-dialog-actions button', 'CANCEL')); nameInput = this.childElement(by.css('input[placeholder="Name" i]')); titleInput = this.childElement(by.css('input[placeholder="Title" i]')); - descriptionTextArea = this.childElement( - by.css('textarea[placeholder="Description" i]') - ); + descriptionTextArea = this.childElement(by.css('textarea[placeholder="Description" i]')); validationMessage = this.childElement(by.css('.mat-error')); constructor() { diff --git a/projects/aca-testing-shared/src/components/dialog/create-library-dialog.ts b/projects/aca-testing-shared/src/components/dialog/create-library-dialog.ts index 8b9e5c77b..4a235759a 100755 --- a/projects/aca-testing-shared/src/components/dialog/create-library-dialog.ts +++ b/projects/aca-testing-shared/src/components/dialog/create-library-dialog.ts @@ -25,36 +25,18 @@ import { by, ElementFinder } from 'protractor'; import { GenericDialog } from '../dialog/generic-dialog'; -import { - waitForClickable, - isPresentAndEnabled, - typeText -} from '../../utilities/utils'; +import { waitForClickable, isPresentAndEnabled, typeText } from '../../utilities/utils'; export class CreateLibraryDialog extends GenericDialog { - createButton = this.childElement( - by.cssContainingText('.mat-dialog-actions button', 'Create') - ); - cancelButton = this.childElement( - by.cssContainingText('.mat-dialog-actions button', 'Cancel') - ); + createButton = this.childElement(by.cssContainingText('.mat-dialog-actions button', 'Create')); + cancelButton = this.childElement(by.cssContainingText('.mat-dialog-actions button', 'Cancel')); nameInput = this.rootElem.element(by.css('input[placeholder="Name" i]')); - libraryIdInput = this.rootElem.element( - by.css('input[placeholder="Library ID" i]') - ); - descriptionTextArea = this.rootElem.element( - by.css('textarea[placeholder="Description" i]') - ); - visibilityPublic = this.rootElem.element( - by.cssContainingText('.mat-radio-label', 'Public') - ); - visibilityModerated = this.rootElem.element( - by.cssContainingText('.mat-radio-label', 'Moderated') - ); - visibilityPrivate = this.rootElem.element( - by.cssContainingText('.mat-radio-label', 'Private') - ); + libraryIdInput = this.rootElem.element(by.css('input[placeholder="Library ID" i]')); + descriptionTextArea = this.rootElem.element(by.css('textarea[placeholder="Description" i]')); + visibilityPublic = this.rootElem.element(by.cssContainingText('.mat-radio-label', 'Public')); + visibilityModerated = this.rootElem.element(by.cssContainingText('.mat-radio-label', 'Moderated')); + visibilityPrivate = this.rootElem.element(by.cssContainingText('.mat-radio-label', 'Private')); errorMessage = this.rootElem.element(by.css('.mat-error')); @@ -100,9 +82,7 @@ export class CreateLibraryDialog extends GenericDialog { } private async isChecked(target: ElementFinder): Promise { - const elemClass = await target - .element(by.xpath('..')) - .getAttribute('class'); + const elemClass = await target.element(by.xpath('..')).getAttribute('class'); return elemClass.includes('mat-radio-checked'); } diff --git a/projects/aca-testing-shared/src/components/dialog/generic-dialog.ts b/projects/aca-testing-shared/src/components/dialog/generic-dialog.ts index 65d0c9579..ed2f8151a 100644 --- a/projects/aca-testing-shared/src/components/dialog/generic-dialog.ts +++ b/projects/aca-testing-shared/src/components/dialog/generic-dialog.ts @@ -24,12 +24,7 @@ */ import { ElementFinder, by, browser, Locator } from 'protractor'; -import { - isPresentAndDisplayed, - waitForPresence, - waitForVisibility, - waitForStaleness -} from '../../utilities/utils'; +import { isPresentAndDisplayed, waitForPresence, waitForVisibility, waitForStaleness } from '../../utilities/utils'; export abstract class GenericDialog { constructor(private rootCssSelector?: string) {} diff --git a/projects/aca-testing-shared/src/components/dialog/password-dialog.ts b/projects/aca-testing-shared/src/components/dialog/password-dialog.ts index b06c81cc1..f776c8546 100755 --- a/projects/aca-testing-shared/src/components/dialog/password-dialog.ts +++ b/projects/aca-testing-shared/src/components/dialog/password-dialog.ts @@ -25,19 +25,11 @@ import { by, browser } from 'protractor'; import { GenericDialog } from '../dialog/generic-dialog'; -import { - waitForClickable, - isPresentAndEnabled, - typeText -} from '../../utilities/utils'; +import { waitForClickable, isPresentAndEnabled, typeText } from '../../utilities/utils'; export class PasswordDialog extends GenericDialog { - closeButton = this.childElement( - by.css('[data-automation-id="adf-password-dialog-close"]') - ); - submitButton = this.childElement( - by.css('[data-automation-id="adf-password-dialog-submit"]') - ); + closeButton = this.childElement(by.css('[data-automation-id="adf-password-dialog-close"]')); + submitButton = this.childElement(by.css('[data-automation-id="adf-password-dialog-submit"]')); passwordInput = this.childElement(by.css('input[type="Password"]')); errorMessage = this.childElement(by.css('.mat-error')); @@ -79,10 +71,7 @@ export class PasswordDialog extends GenericDialog { async isErrorDisplayed(): Promise { try { await this.waitForDialogToOpen(); - return ( - (await this.errorMessage.isPresent()) && - (await this.errorMessage.isDisplayed()) - ); + return (await this.errorMessage.isPresent()) && (await this.errorMessage.isDisplayed()); } catch (error) { return false; } diff --git a/projects/aca-testing-shared/src/components/dialog/select-template-dialog.ts b/projects/aca-testing-shared/src/components/dialog/select-template-dialog.ts index 2a3628e7c..ddf6f6d91 100755 --- a/projects/aca-testing-shared/src/components/dialog/select-template-dialog.ts +++ b/projects/aca-testing-shared/src/components/dialog/select-template-dialog.ts @@ -30,13 +30,8 @@ import { DataTable } from '../data-table/data-table'; import { isPresentAndEnabled } from '../../utilities/utils'; export class SelectTemplateDialog extends GenericDialog { - nextButton = this.childElement( - by.css('[data-automation-id="content-node-selector-actions-choose"]') - ); - - cancelButton = this.childElement( - by.css('[data-automation-id="content-node-selector-actions-cancel"]') - ); + nextButton = this.childElement(by.css('[data-automation-id="content-node-selector-actions-choose"]')); + cancelButton = this.childElement(by.css('[data-automation-id="content-node-selector-actions-cancel"]')); breadcrumb = new DropDownBreadcrumb(); dataTable = new DataTable('.aca-template-node-selector-dialog'); diff --git a/projects/aca-testing-shared/src/components/dialog/share-dialog.ts b/projects/aca-testing-shared/src/components/dialog/share-dialog.ts index 69057b5cb..f438b02ab 100755 --- a/projects/aca-testing-shared/src/components/dialog/share-dialog.ts +++ b/projects/aca-testing-shared/src/components/dialog/share-dialog.ts @@ -31,27 +31,17 @@ import { isPresentAndEnabled } from '../../utilities/utils'; export class ShareDialog extends GenericDialog { dateTimePicker = new DateTimePicker(); - dialogTitle = this.childElement( - by.css(`[data-automation-id='adf-share-dialog-title']`) - ); + dialogTitle = this.childElement(by.css(`[data-automation-id='adf-share-dialog-title']`)); infoText = this.childElement(by.css('.adf-share-link__info')); labels = this.rootElem.all(by.css('.adf-share-link__label')); - shareToggle = this.childElement( - by.css(`[data-automation-id='adf-share-toggle']`) - ); + shareToggle = this.childElement(by.css(`[data-automation-id='adf-share-toggle']`)); url = this.childElement(by.css(`[data-automation-id='adf-share-link']`)); urlAction = this.childElement(by.css('.adf-input-action')); - expireToggle = this.childElement( - by.css(`[data-automation-id='adf-expire-toggle']`) - ); + expireToggle = this.childElement(by.css(`[data-automation-id='adf-expire-toggle']`)); expireInput = this.childElement(by.css('input[formcontrolname="time"]')); - datetimePickerButton = this.childElement( - by.css('.mat-datetimepicker-toggle') - ); + datetimePickerButton = this.childElement(by.css('.mat-datetimepicker-toggle')); - closeButton = this.childElement( - by.css(`[data-automation-id='adf-share-dialog-close']`) - ); + closeButton = this.childElement(by.css(`[data-automation-id='adf-share-dialog-close']`)); constructor() { super('.adf-share-dialog'); diff --git a/projects/aca-testing-shared/src/components/dialog/upload-new-version-dialog.ts b/projects/aca-testing-shared/src/components/dialog/upload-new-version-dialog.ts index 966ed7eea..bbe9cf206 100755 --- a/projects/aca-testing-shared/src/components/dialog/upload-new-version-dialog.ts +++ b/projects/aca-testing-shared/src/components/dialog/upload-new-version-dialog.ts @@ -28,18 +28,10 @@ import { GenericDialog } from '../dialog/generic-dialog'; import { isPresentAndEnabled, typeText } from '../../utilities/utils'; export class UploadNewVersionDialog extends GenericDialog { - cancelButton = this.childElement( - by.cssContainingText('.mat-button-wrapper', 'Cancel') - ); - uploadButton = this.childElement( - by.cssContainingText('.mat-button-wrapper', 'Upload') - ); - majorOption = this.childElement( - by.cssContainingText(`.mat-radio-label`, 'major') - ); - minorOption = this.childElement( - by.cssContainingText(`.mat-radio-label`, 'minor') - ); + cancelButton = this.childElement(by.cssContainingText('.mat-button-wrapper', 'Cancel')); + uploadButton = this.childElement(by.cssContainingText('.mat-button-wrapper', 'Upload')); + majorOption = this.childElement(by.cssContainingText(`.mat-radio-label`, 'major')); + minorOption = this.childElement(by.cssContainingText(`.mat-radio-label`, 'minor')); description = this.childElement(by.css('textarea')); constructor() { diff --git a/projects/aca-testing-shared/src/components/info-drawer/info-drawer-comments-tab.ts b/projects/aca-testing-shared/src/components/info-drawer/info-drawer-comments-tab.ts index 3b2175c77..77de76631 100755 --- a/projects/aca-testing-shared/src/components/info-drawer/info-drawer-comments-tab.ts +++ b/projects/aca-testing-shared/src/components/info-drawer/info-drawer-comments-tab.ts @@ -64,18 +64,12 @@ export class CommentsTab extends Component { } private async getCommentListItem() { - return browser.wait( - until.elementLocated(this.commentListItem), - BROWSER_WAIT_TIMEOUT / 2 - ); + return browser.wait(until.elementLocated(this.commentListItem), BROWSER_WAIT_TIMEOUT / 2); } async getCommentById(commentId?: string) { if (commentId) { - return browser.wait( - until.elementLocated(by.id(`adf-comment-${commentId}`)), - BROWSER_WAIT_TIMEOUT / 2 - ); + return browser.wait(until.elementLocated(by.id(`adf-comment-${commentId}`)), BROWSER_WAIT_TIMEOUT / 2); } return this.getCommentListItem(); } @@ -86,9 +80,7 @@ export class CommentsTab extends Component { async isCommentUserAvatarDisplayed(commentId?: string) { const commentElement = await this.getCommentById(commentId); - return browser.isElementPresent( - commentElement.findElement(this.commentUserAvatar) - ); + return browser.isElementPresent(commentElement.findElement(this.commentUserAvatar)); } async getCommentText(commentId?: string) { diff --git a/projects/aca-testing-shared/src/components/info-drawer/info-drawer-metadata-content.ts b/projects/aca-testing-shared/src/components/info-drawer/info-drawer-metadata-content.ts index cec131238..ba7279647 100755 --- a/projects/aca-testing-shared/src/components/info-drawer/info-drawer-metadata-content.ts +++ b/projects/aca-testing-shared/src/components/info-drawer/info-drawer-metadata-content.ts @@ -25,11 +25,7 @@ import { by, browser, ElementFinder } from 'protractor'; import { Component } from '../component'; -import { - isPresentAndEnabled, - isPresentAndDisplayed, - waitForVisibility -} from '../../utilities/utils'; +import { isPresentAndEnabled, isPresentAndDisplayed, waitForVisibility } from '../../utilities/utils'; export class ContentMetadata extends Component { expandedPanel = this.byCss('.mat-expansion-panel.mat-expanded'); @@ -37,20 +33,10 @@ export class ContentMetadata extends Component { propertyListElements = this.allByCss('.adf-property'); propertyValue = this.byCss('.adf-property-value'); editPropertiesButton = this.byCss(`button[title='Edit']`); - lessInfoButton = this.byCssText( - `[data-automation-id='meta-data-card-toggle-expand']`, - 'Less information' - ); - moreInfoButton = this.byCssText( - `[data-automation-id='meta-data-card-toggle-expand']`, - 'More information' - ); - imagePropertiesPanel = this.byCss( - `[data-automation-id='adf-metadata-group-APP.CONTENT_METADATA.EXIF_GROUP_TITLE']` - ); - expandedImagePropertiesPanel = this.byCss( - `[data-automation-id='adf-metadata-group-APP.CONTENT_METADATA.EXIF_GROUP_TITLE'].mat-expanded` - ); + lessInfoButton = this.byCssText(`[data-automation-id='meta-data-card-toggle-expand']`, 'Less information'); + moreInfoButton = this.byCssText(`[data-automation-id='meta-data-card-toggle-expand']`, 'More information'); + imagePropertiesPanel = this.byCss(`[data-automation-id='adf-metadata-group-APP.CONTENT_METADATA.EXIF_GROUP_TITLE']`); + expandedImagePropertiesPanel = this.byCss(`[data-automation-id='adf-metadata-group-APP.CONTENT_METADATA.EXIF_GROUP_TITLE'].mat-expanded`); constructor(ancestor?: string) { super('adf-content-metadata-card', ancestor); @@ -66,14 +52,14 @@ export class ContentMetadata extends Component { async getVisiblePropertiesLabels(): Promise { return this.allByCss('.adf-property-label') - .filter(async elem => elem.isDisplayed()) - .map(async elem => elem.getText()); + .filter(async (elem) => elem.isDisplayed()) + .map(async (elem) => elem.getText()); } async getVisiblePropertiesValues() { return this.allByCss('.adf-property-value') - .filter(async elem => elem.isDisplayed()) - .map(async elem => { + .filter(async (elem) => elem.isDisplayed()) + .map(async (elem) => { if (await elem.isElementPresent(by.css('.mat-checkbox'))) { if (await elem.isElementPresent(by.css('.mat-checkbox-checked'))) { return true; diff --git a/projects/aca-testing-shared/src/components/info-drawer/info-drawer-metadata-library.ts b/projects/aca-testing-shared/src/components/info-drawer/info-drawer-metadata-library.ts index c0fb3a1d8..5661ef3e4 100755 --- a/projects/aca-testing-shared/src/components/info-drawer/info-drawer-metadata-library.ts +++ b/projects/aca-testing-shared/src/components/info-drawer/info-drawer-metadata-library.ts @@ -26,11 +26,7 @@ import { by, browser } from 'protractor'; import { Logger } from '@alfresco/adf-testing'; import { Component } from '../component'; -import { - waitForPresence, - waitForStaleness, - typeText -} from '../../utilities/utils'; +import { waitForPresence, waitForStaleness, typeText } from '../../utilities/utils'; export class LibraryMetadata extends Component { metadataTabContent = this.byCss('.mat-card-content'); @@ -38,21 +34,9 @@ export class LibraryMetadata extends Component { fieldLabelWrapper = this.byCss('.mat-form-field-label-wrapper'); fieldInput = this.byCss('.mat-input-element'); visibilityDropDown = this.component.element(by.css('.mat-select')); - visibilityPublic = this.byCssText( - '.mat-option .mat-option-text', - 'Public', - browser - ); - visibilityPrivate = this.byCssText( - '.mat-option .mat-option-text', - 'Private', - browser - ); - visibilityModerated = this.byCssText( - '.mat-option .mat-option-text', - 'Moderated', - browser - ); + visibilityPublic = this.byCssText('.mat-option .mat-option-text', 'Public', browser); + visibilityPrivate = this.byCssText('.mat-option .mat-option-text', 'Private', browser); + visibilityModerated = this.byCssText('.mat-option .mat-option-text', 'Moderated', browser); hint = this.byCss('.mat-hint'); error = this.byCss('.mat-error'); @@ -66,9 +50,7 @@ export class LibraryMetadata extends Component { private getFieldByName(fieldName: string) { const wrapper = this.getLabelWrapper(fieldName); - return wrapper - .element(by.xpath('..')) - .element(by.css('.mat-input-element')); + return wrapper.element(by.xpath('..')).element(by.css('.mat-input-element')); } private async isFieldDisplayed(fieldName: string) { @@ -158,9 +140,7 @@ export class LibraryMetadata extends Component { async isVisibilityEnabled() { const wrapper = this.getLabelWrapper('Visibility'); - const field = wrapper - .element(by.xpath('..')) - .element(by.css('.mat-select')); + const field = wrapper.element(by.xpath('..')).element(by.css('.mat-select')); return field.isEnabled(); } diff --git a/projects/aca-testing-shared/src/components/info-drawer/info-drawer.ts b/projects/aca-testing-shared/src/components/info-drawer/info-drawer.ts index 1fcef4f61..139ce1265 100755 --- a/projects/aca-testing-shared/src/components/info-drawer/info-drawer.ts +++ b/projects/aca-testing-shared/src/components/info-drawer/info-drawer.ts @@ -29,11 +29,7 @@ import { Component } from '../component'; import { CommentsTab } from './info-drawer-comments-tab'; import { LibraryMetadata } from './info-drawer-metadata-library'; import { ContentMetadata } from './info-drawer-metadata-content'; -import { - waitForVisibility, - waitForInvisibility, - waitForPresence -} from '../../utilities/utils'; +import { waitForVisibility, waitForInvisibility, waitForPresence } from '../../utilities/utils'; export class InfoDrawer extends Component { commentsTab = new CommentsTab('adf-info-drawer'); @@ -44,15 +40,9 @@ export class InfoDrawer extends Component { tabLabel = this.byCss('.mat-tab-label-content'); tabLabelsList = this.allByCss('.mat-tab-label-content'); tabActiveLabel = this.byCss('.mat-tab-label-active'); - tabActiveContent = this.byCss( - '.mat-tab-body-active .mat-tab-body-content adf-dynamic-tab' - ); - nextButton = this.byCss( - '.mat-tab-header-pagination-after .mat-tab-header-pagination-chevron' - ); - previousButton = this.byCss( - '.mat-tab-header-pagination-before .mat-tab-header-pagination-chevron' - ); + tabActiveContent = this.byCss('.mat-tab-body-active .mat-tab-body-content adf-dynamic-tab'); + nextButton = this.byCss('.mat-tab-header-pagination-after .mat-tab-header-pagination-chevron'); + previousButton = this.byCss('.mat-tab-header-pagination-before .mat-tab-header-pagination-chevron'); constructor(ancestor?: string) { super('adf-info-drawer', ancestor); @@ -130,10 +120,7 @@ export class InfoDrawer extends Component { try { await this.getTabByTitle('Comments').click(); await this.commentsTab.waitForCommentsContainer(); - await Promise.all([ - waitForVisibility(this.commentsTab.component), - waitForInvisibility(this.propertiesTab.component) - ]); + await Promise.all([waitForVisibility(this.commentsTab.component), waitForInvisibility(this.propertiesTab.component)]); } catch (error) { Logger.error('--- info-drawer clickCommentsTab catch error: ', error); } diff --git a/projects/aca-testing-shared/src/components/menu/menu.ts b/projects/aca-testing-shared/src/components/menu/menu.ts index 6902bd722..3a497d263 100755 --- a/projects/aca-testing-shared/src/components/menu/menu.ts +++ b/projects/aca-testing-shared/src/components/menu/menu.ts @@ -26,23 +26,14 @@ import { ElementFinder, by, browser } from 'protractor'; import { Logger } from '@alfresco/adf-testing'; import { Component } from '../component'; -import { - Utils, - isPresentAndEnabled, - waitForPresence, - waitForVisibility, - waitForStaleness, - waitForClickable -} from '../../utilities/utils'; +import { Utils, isPresentAndEnabled, waitForPresence, waitForVisibility, waitForStaleness, waitForClickable } from '../../utilities/utils'; export class Menu extends Component { items = this.allByCss('.mat-menu-item'); backdrop = this.byCss('.cdk-overlay-backdrop', browser); uploadFilesInput = this.byId('app-upload-files', browser); - submenus = browser.element.all( - by.css('app-context-menu-item .mat-menu-item') - ); + submenus = browser.element.all(by.css('app-context-menu-item .mat-menu-item')); uploadFileAction = this.byId('app.create.uploadFile'); uploadFolderAction = this.byId('app.create.uploadFolder'); @@ -61,23 +52,14 @@ export class Menu extends Component { favoriteAction = this.byCss(`.mat-menu-item[id$='favorite.add']`); removeFavoriteAction = this.byCss(`.mat-menu-item[id$='favorite.remove']`); toggleFavoriteAction = this.byCssText('.mat-menu-item', 'Favorite'); - toggleRemoveFavoriteAction = this.byCssText( - '.mat-menu-item', - 'Remove Favorite' - ); + toggleRemoveFavoriteAction = this.byCssText('.mat-menu-item', 'Remove Favorite'); joinAction = this.byCssText('.mat-menu-item', 'Join'); leaveAction = this.byCssText('.mat-menu-item', 'Leave'); managePermissionsAction = this.byCssText('.mat-menu-item', 'Permissions'); manageVersionsAction = this.byCssText('.mat-menu-item', 'Manage Versions'); - uploadNewVersionAction = this.byCssText( - '.mat-menu-item', - 'Upload New Version' - ); + uploadNewVersionAction = this.byCssText('.mat-menu-item', 'Upload New Version'); moveAction = this.byCssText('.mat-menu-item', 'Move'); - permanentDeleteAction = this.byCssText( - '.mat-menu-item', - 'Permanently Delete' - ); + permanentDeleteAction = this.byCssText('.mat-menu-item', 'Permanently Delete'); restoreAction = this.byCssText('.mat-menu-item', 'Restore'); shareAction = this.byCssText('.mat-menu-item', 'Share'); shareEditAction = this.byCssText('.mat-menu-item', 'Shared Link Settings'); @@ -89,16 +71,12 @@ export class Menu extends Component { } async waitForMenuToOpen(): Promise { - await waitForPresence( - browser.element(by.css('.cdk-overlay-container .mat-menu-panel')) - ); + await waitForPresence(browser.element(by.css('.cdk-overlay-container .mat-menu-panel'))); await waitForVisibility(this.items.get(0)); } async waitForMenuToClose(): Promise { - await waitForStaleness( - browser.element(by.css('.cdk-overlay-container .mat-menu-panel')) - ); + await waitForStaleness(browser.element(by.css('.cdk-overlay-container .mat-menu-panel'))); } async closeMenu(): Promise { @@ -127,9 +105,7 @@ export class Menu extends Component { } async getItemIconText(menuItem: string): Promise { - return this.getItemByLabel(menuItem) - .element(by.css('.mat-icon')) - .getText(); + return this.getItemByLabel(menuItem).element(by.css('.mat-icon')).getText(); } async getItemIdAttribute(menuItem: string): Promise { @@ -141,7 +117,7 @@ export class Menu extends Component { } async getMenuItems(): Promise { - const items: string[] = await this.items.map(async elem => { + const items: string[] = await this.items.map(async (elem) => { const span = elem.element(by.css('span')); return span.getText(); }); @@ -152,14 +128,8 @@ export class Menu extends Component { try { const elem = this.getNthItem(nth); await waitForClickable(elem); - await browser - .actions() - .mouseMove(elem) - .perform(); - await browser - .actions() - .click() - .perform(); + await browser.actions().mouseMove(elem).perform(); + await browser.actions().click().perform(); await this.waitForMenuToClose(); } catch (e) { Logger.error('____ click nth menu item catch ___', e); @@ -180,10 +150,7 @@ export class Menu extends Component { try { const elem = this.getItemByLabel(menuItem); await waitForClickable(elem); - await browser - .actions() - .mouseMove(elem) - .perform(); + await browser.actions().mouseMove(elem).perform(); await browser.sleep(500); } catch (error) { Logger.error('----- mouse over error: ', error); @@ -213,17 +180,11 @@ export class Menu extends Component { } async isMenuItemPresent(title: string): Promise { - return browser - .element(by.cssContainingText('.mat-menu-item', title)) - .isPresent(); + return browser.element(by.cssContainingText('.mat-menu-item', title)).isPresent(); } async isSubMenuItemPresent(title: string): Promise { - return browser - .element( - by.cssContainingText('app-context-menu-item .mat-menu-item', title) - ) - .isPresent(); + return browser.element(by.cssContainingText('app-context-menu-item .mat-menu-item', title)).isPresent(); } async getSubmenuItemsCount(): Promise { diff --git a/projects/aca-testing-shared/src/components/metadata-card/metadata-card.ts b/projects/aca-testing-shared/src/components/metadata-card/metadata-card.ts index ac568e20c..8e947df23 100644 --- a/projects/aca-testing-shared/src/components/metadata-card/metadata-card.ts +++ b/projects/aca-testing-shared/src/components/metadata-card/metadata-card.ts @@ -28,12 +28,8 @@ import { waitForPresence } from '../../utilities/utils'; export class MetadataCard extends Component { footer = this.byCss('.adf-content-metadata-card-footer'); - expandButton = this.byCss( - '[data-automation-id="meta-data-card-toggle-expand"]' - ); - expansionPanels = this.allByCss( - '.adf-metadata-grouped-properties-container mat-expansion-panel' - ); + expandButton = this.byCss('[data-automation-id="meta-data-card-toggle-expand"]'); + expansionPanels = this.allByCss('.adf-metadata-grouped-properties-container mat-expansion-panel'); constructor(ancestor?: string) { super('adf-content-metadata-card', ancestor); diff --git a/projects/aca-testing-shared/src/components/pagination/pagination.ts b/projects/aca-testing-shared/src/components/pagination/pagination.ts index 931c9713e..fb98f2fea 100755 --- a/projects/aca-testing-shared/src/components/pagination/pagination.ts +++ b/projects/aca-testing-shared/src/components/pagination/pagination.ts @@ -36,12 +36,8 @@ export class Pagination extends Component { totalPages = this.byCss('.adf-pagination__total-pages'); previousButton = this.byCss('.adf-pagination__previous-button'); nextButton = this.byCss('.adf-pagination__next-button'); - maxItemsButton = this.byCss( - '.adf-pagination__max-items + button[mat-icon-button]' - ); - pagesButton = this.byCss( - '.adf-pagination__current-page + button[mat-icon-button]' - ); + maxItemsButton = this.byCss('.adf-pagination__max-items + button[mat-icon-button]'); + pagesButton = this.byCss('.adf-pagination__current-page + button[mat-icon-button]'); menu: Menu = new Menu(); @@ -51,10 +47,7 @@ export class Pagination extends Component { async openMaxItemsMenu() { try { - await waitForClickable( - this.maxItemsButton, - 'timeout waiting for maxItemsButton to be clickable' - ); + await waitForClickable(this.maxItemsButton, 'timeout waiting for maxItemsButton to be clickable'); await this.maxItemsButton.click(); await this.menu.waitForMenuToOpen(); } catch (error) { @@ -64,10 +57,7 @@ export class Pagination extends Component { async openCurrentPageMenu() { try { - await waitForClickable( - this.pagesButton, - 'timeout waiting for pagesButton to be clickable' - ); + await waitForClickable(this.pagesButton, 'timeout waiting for pagesButton to be clickable'); await this.pagesButton.click(); await this.menu.waitForMenuToOpen(); } catch (error) { diff --git a/projects/aca-testing-shared/src/components/search/filters/created-date-filter.ts b/projects/aca-testing-shared/src/components/search/filters/created-date-filter.ts index 6a9b2ddf9..ef98340f0 100755 --- a/projects/aca-testing-shared/src/components/search/filters/created-date-filter.ts +++ b/projects/aca-testing-shared/src/components/search/filters/created-date-filter.ts @@ -32,30 +32,14 @@ export class CreatedDateFilter extends GenericFilterPanel { super('Created date'); } - fromField: ElementFinder = this.panelExpanded.element( - by.cssContainingText('.adf-search-date-range .mat-form-field', 'From') - ); - fromInput: ElementFinder = this.fromField.element( - by.css(`[data-automation-id='date-range-from-input']`) - ); - fromFieldError: ElementFinder = this.fromField.element( - by.css(`[data-automation-id='date-range-from-error']`) - ); - toField: ElementFinder = this.panelExpanded.element( - by.cssContainingText('.adf-search-date-range .mat-form-field', 'To') - ); - toInput: ElementFinder = this.toField.element( - by.css(`[data-automation-id='date-range-to-input']`) - ); - toFieldError: ElementFinder = this.toField.element( - by.css(`[data-automation-id='date-range-to-error']`) - ); - clearButton: ElementFinder = this.panel.element( - by.css('.adf-facet-buttons [data-automation-id="date-range-clear-btn"]') - ); - applyButton: ElementFinder = this.panel.element( - by.css('.adf-facet-buttons [data-automation-id="date-range-apply-btn"]') - ); + fromField: ElementFinder = this.panelExpanded.element(by.cssContainingText('.adf-search-date-range .mat-form-field', 'From')); + fromInput: ElementFinder = this.fromField.element(by.css(`[data-automation-id='date-range-from-input']`)); + fromFieldError: ElementFinder = this.fromField.element(by.css(`[data-automation-id='date-range-from-error']`)); + toField: ElementFinder = this.panelExpanded.element(by.cssContainingText('.adf-search-date-range .mat-form-field', 'To')); + toInput: ElementFinder = this.toField.element(by.css(`[data-automation-id='date-range-to-input']`)); + toFieldError: ElementFinder = this.toField.element(by.css(`[data-automation-id='date-range-to-error']`)); + clearButton: ElementFinder = this.panel.element(by.css('.adf-facet-buttons [data-automation-id="date-range-clear-btn"]')); + applyButton: ElementFinder = this.panel.element(by.css('.adf-facet-buttons [data-automation-id="date-range-apply-btn"]')); async isFromFieldDisplayed(): Promise { return isPresentAndDisplayed(this.fromField); diff --git a/projects/aca-testing-shared/src/components/search/filters/facet-filter.ts b/projects/aca-testing-shared/src/components/search/filters/facet-filter.ts index ebd2d6c9f..47b13f915 100755 --- a/projects/aca-testing-shared/src/components/search/filters/facet-filter.ts +++ b/projects/aca-testing-shared/src/components/search/filters/facet-filter.ts @@ -42,9 +42,7 @@ export class FacetFilter extends GenericFilterPanel { return this.panel.all(by.css(this.locators.checkboxChecked)); } get clearButton(): ElementFinder { - return this.panel.element( - by.cssContainingText(this.locators.button, 'Clear all') - ); + return this.panel.element(by.cssContainingText(this.locators.button, 'Clear all')); } get facetsFilter(): ElementFinder { return this.panelExpanded.element(by.css(this.locators.facetsFilter)); @@ -54,14 +52,14 @@ export class FacetFilter extends GenericFilterPanel { } async getFiltersValues(): Promise { - const list: string[] = await this.facets.map(option => { + const list: string[] = await this.facets.map((option) => { return option.getText(); }); return list; } async getFiltersCheckedValues(): Promise { - const list: string[] = await this.selectedFacets.map(option => { + const list: string[] = await this.selectedFacets.map((option) => { return option.getText(); }); return list; @@ -70,7 +68,7 @@ export class FacetFilter extends GenericFilterPanel { async resetPanel(): Promise { if ((await this.selectedFacets.count()) > 0) { await this.expandPanel(); - await this.selectedFacets.each(async elem => { + await this.selectedFacets.each(async (elem) => { await elem.click(); }); } @@ -96,18 +94,10 @@ export class FacetFilter extends GenericFilterPanel { } async checkCategory(name: string): Promise { - const option = this.facets - .filter(async elem => (await elem.getText()).includes(name)) - .first(); + const option = this.facets.filter(async (elem) => (await elem.getText()).includes(name)).first(); await browser.executeScript(`arguments[0].scrollIntoView();`, option); - await browser - .actions() - .mouseMove(option) - .perform(); - await browser - .actions() - .click() - .perform(); + await browser.actions().mouseMove(option).perform(); + await browser.actions().click().perform(); } async filterCategoriesBy(name: string): Promise { diff --git a/projects/aca-testing-shared/src/components/search/filters/generic-filter-panel.ts b/projects/aca-testing-shared/src/components/search/filters/generic-filter-panel.ts index 0e2113ae9..798d70a82 100755 --- a/projects/aca-testing-shared/src/components/search/filters/generic-filter-panel.ts +++ b/projects/aca-testing-shared/src/components/search/filters/generic-filter-panel.ts @@ -42,14 +42,10 @@ export class GenericFilterPanel { }; get panel(): ElementFinder { - return browser.element( - by.cssContainingText(this.selectors.panel, this.filterName) - ); + return browser.element(by.cssContainingText(this.selectors.panel, this.filterName)); } get panelExpanded(): ElementFinder { - return browser.element( - by.cssContainingText(this.selectors.panelExpanded, this.filterName) - ); + return browser.element(by.cssContainingText(this.selectors.panelExpanded, this.filterName)); } get panelHeader(): ElementFinder { return this.panel.element(by.css(this.selectors.panelHeader)); diff --git a/projects/aca-testing-shared/src/components/search/filters/size-filter.ts b/projects/aca-testing-shared/src/components/search/filters/size-filter.ts index 57828f3c3..ea13918ac 100755 --- a/projects/aca-testing-shared/src/components/search/filters/size-filter.ts +++ b/projects/aca-testing-shared/src/components/search/filters/size-filter.ts @@ -32,22 +32,18 @@ export class SizeFilter extends GenericFilterPanel { } facets: ElementArrayFinder = this.panelExpanded.all(by.css('.mat-checkbox')); - selectedFacets: ElementArrayFinder = this.panel.all( - by.css('.mat-checkbox.mat-checkbox-checked') - ); - clearButton: ElementFinder = this.panel.element( - by.cssContainingText('.adf-facet-buttons button', 'Clear all') - ); + selectedFacets: ElementArrayFinder = this.panel.all(by.css('.mat-checkbox.mat-checkbox-checked')); + clearButton: ElementFinder = this.panel.element(by.cssContainingText('.adf-facet-buttons button', 'Clear all')); async getFiltersValues(): Promise { - const list: string[] = await this.facets.map(option => { + const list: string[] = await this.facets.map((option) => { return option.getText(); }); return list; } async getFiltersCheckedValues(): Promise { - const list: string[] = await this.selectedFacets.map(option => { + const list: string[] = await this.selectedFacets.map((option) => { return option.getText(); }); return list; @@ -56,7 +52,7 @@ export class SizeFilter extends GenericFilterPanel { async resetPanel(): Promise { if ((await this.selectedFacets.count()) > 0) { await this.expandPanel(); - await this.selectedFacets.each(async elem => { + await this.selectedFacets.each(async (elem) => { await elem.click(); }); } @@ -74,30 +70,22 @@ export class SizeFilter extends GenericFilterPanel { } async checkSizeSmall(): Promise { - const small = this.facets - .filter(async elem => (await elem.getText()) === 'Small') - .first(); + const small = this.facets.filter(async (elem) => (await elem.getText()) === 'Small').first(); await small.click(); } async checkSizeMedium(): Promise { - const medium = this.facets - .filter(async elem => (await elem.getText()) === 'Medium') - .first(); + const medium = this.facets.filter(async (elem) => (await elem.getText()) === 'Medium').first(); await medium.click(); } async checkSizeLarge(): Promise { - const large = this.facets - .filter(async elem => (await elem.getText()) === 'Large') - .first(); + const large = this.facets.filter(async (elem) => (await elem.getText()) === 'Large').first(); await large.click(); } async checkSizeHuge(): Promise { - const huge = this.facets - .filter(async elem => (await elem.getText()) === 'Huge') - .first(); + const huge = this.facets.filter(async (elem) => (await elem.getText()) === 'Huge').first(); await huge.click(); } } diff --git a/projects/aca-testing-shared/src/components/search/search-input.ts b/projects/aca-testing-shared/src/components/search/search-input.ts index 9a7d89bf3..7ce179ad7 100755 --- a/projects/aca-testing-shared/src/components/search/search-input.ts +++ b/projects/aca-testing-shared/src/components/search/search-input.ts @@ -25,12 +25,7 @@ import { browser, by, protractor } from 'protractor'; import { Component } from '../component'; -import { - Utils, - waitForPresence, - waitForClickable, - waitElement -} from '../../utilities/utils'; +import { Utils, waitForPresence, waitForClickable, waitElement } from '../../utilities/utils'; export class SearchInput extends Component { searchButton = this.component.element(by.css('.app-search-button')); @@ -38,15 +33,9 @@ export class SearchInput extends Component { searchControl = browser.element(by.css('.app-search-control')); searchInput = browser.element(by.css(`input[id='app-control-input']`)); searchOptionsArea = browser.element(by.id('search-options')); - searchFilesOption = this.searchOptionsArea.element( - by.cssContainingText('.mat-checkbox', 'Files') - ); - searchFoldersOption = this.searchOptionsArea.element( - by.cssContainingText('.mat-checkbox', 'Folders') - ); - searchLibrariesOption = this.searchOptionsArea.element( - by.cssContainingText('.mat-checkbox', 'Libraries') - ); + searchFilesOption = this.searchOptionsArea.element(by.cssContainingText('.mat-checkbox', 'Files')); + searchFoldersOption = this.searchOptionsArea.element(by.cssContainingText('.mat-checkbox', 'Folders')); + searchLibrariesOption = this.searchOptionsArea.element(by.cssContainingText('.mat-checkbox', 'Libraries')); clearSearchButton = this.searchContainer.$('.app-clear-icon'); constructor(ancestor?: string) { diff --git a/projects/aca-testing-shared/src/components/search/search-sorting-picker.ts b/projects/aca-testing-shared/src/components/search/search-sorting-picker.ts index bb56f4f8c..44804a8a2 100755 --- a/projects/aca-testing-shared/src/components/search/search-sorting-picker.ts +++ b/projects/aca-testing-shared/src/components/search/search-sorting-picker.ts @@ -25,40 +25,23 @@ import { by, browser } from 'protractor'; import { Component } from '../component'; -import { - isPresentAndDisplayed, - waitForVisibility -} from '../../utilities/utils'; - -export type SortByType = - | 'Relevance' - | 'Title' - | 'Filename' - | 'Modified date' - | 'Modifier' - | 'Created date' - | 'Size' - | 'Type'; +import { isPresentAndDisplayed, waitForVisibility } from '../../utilities/utils'; +export type SortByType = 'Relevance' | 'Title' | 'Filename' | 'Modified date' | 'Modifier' | 'Created date' | 'Size' | 'Type'; export type SortOrderType = 'ASC' | 'DESC' | ''; export class SearchSortingPicker extends Component { sortOrderButton = this.byCss('button[mat-icon-button]'); sortByDropdownCollapsed = this.byCss('.mat-select'); sortByDropdownExpanded = browser.element(by.css('.mat-select-panel')); - sortByList = this.sortByDropdownExpanded.all( - by.css('.mat-option .mat-option-text') - ); + sortByList = this.sortByDropdownExpanded.all(by.css('.mat-option .mat-option-text')); constructor(ancestor?: string) { super('adf-search-sorting-picker', ancestor); } async waitForSortByDropdownToExpand(): Promise { - await waitForVisibility( - this.sortByDropdownExpanded, - 'Timeout waiting for sortBy dropdown to expand' - ); + await waitForVisibility(this.sortByDropdownExpanded, 'Timeout waiting for sortBy dropdown to expand'); } async isSortOrderButtonDisplayed(): Promise { @@ -95,7 +78,7 @@ export class SearchSortingPicker extends Component { } async getSortByOptionsList(): Promise { - const list: string[] = await this.sortByList.map(async option => { + const list: string[] = await this.sortByList.map(async (option) => { return option.getText(); }); return list; @@ -105,9 +88,7 @@ export class SearchSortingPicker extends Component { if (!(await this.isSortByDropdownExpanded())) { await this.clickSortByDropdown(); } - const elem = browser.element( - by.cssContainingText('.mat-option .mat-option-text', option) - ); + const elem = browser.element(by.cssContainingText('.mat-option .mat-option-text', option)); await elem.click(); } diff --git a/projects/aca-testing-shared/src/components/sidenav/sidenav.ts b/projects/aca-testing-shared/src/components/sidenav/sidenav.ts index 7b5b712b5..ad0656b5c 100755 --- a/projects/aca-testing-shared/src/components/sidenav/sidenav.ts +++ b/projects/aca-testing-shared/src/components/sidenav/sidenav.ts @@ -35,17 +35,9 @@ export class Sidenav extends Component { activeLink = this.byCss('.action-button--active'); newButton = this.allByCss('[data-automation-id="create-button"]'); personalFiles = this.byCss(`[data-automation-id='app.navbar.personalFiles']`); - fileLibraries = this.byCss( - `[data-automation-id='app.navbar.libraries.menu']` - ); - myLibraries = this.byCss( - `[data-automation-id='app.navbar.libraries.files']`, - browser - ); - favoriteLibraries = this.byCss( - `[data-automation-id='app.navbar.libraries.favorite']`, - browser - ); + fileLibraries = this.byCss(`[data-automation-id='app.navbar.libraries.menu']`); + myLibraries = this.byCss(`[data-automation-id='app.navbar.libraries.files']`, browser); + favoriteLibraries = this.byCss(`[data-automation-id='app.navbar.libraries.favorite']`, browser); shared = this.byCss(`[data-automation-id='app.navbar.shared']`); recentFiles = this.byCss(`[data-automation-id='app.navbar.recentFiles']`); favorites = this.byCss(`[data-automation-id='app.navbar.favorites']`); @@ -59,9 +51,7 @@ export class Sidenav extends Component { private async expandMenu(name: string): Promise { try { - if ( - await element(by.cssContainingText('.mat-expanded', name)).isPresent() - ) { + if (await element(by.cssContainingText('.mat-expanded', name)).isPresent()) { return Promise.resolve(); } else { const link = this.getLink(name); @@ -80,9 +70,7 @@ export class Sidenav extends Component { } async closeNewMenu(): Promise { - await BrowserActions.click( - element(by.css('button[data-automation-id="create-button"] span span')) - ); + await BrowserActions.click(element(by.css('button[data-automation-id="create-button"] span span'))); await this.menu.waitForMenuToClose(); } @@ -112,9 +100,7 @@ export class Sidenav extends Component { } async childIsActive(name: string): Promise { - const childClass = await this.getLinkLabel(name) - .element(by.css('span')) - .getAttribute('class'); + const childClass = await this.getLinkLabel(name).element(by.css('span')).getAttribute('class'); return childClass.includes('action-button--active'); } @@ -147,13 +133,9 @@ export class Sidenav extends Component { async getLinkTooltip(name: string): Promise { const link = this.getLinkLabel(name); - const condition = () => - link.getAttribute('title').then(value => value && value.length > 0); + const condition = () => link.getAttribute('title').then((value) => value && value.length > 0); - await browser - .actions() - .mouseMove(link) - .perform(); + await browser.actions().mouseMove(link).perform(); await browser.wait(condition, BROWSER_WAIT_TIMEOUT); return link.getAttribute('title'); @@ -170,9 +152,7 @@ export class Sidenav extends Component { } async isFileLibrariesMenuExpanded(): Promise { - return element( - by.cssContainingText('.mat-expanded', SIDEBAR_LABELS.FILE_LIBRARIES) - ).isPresent(); + return element(by.cssContainingText('.mat-expanded', SIDEBAR_LABELS.FILE_LIBRARIES)).isPresent(); } async expandFileLibraries(): Promise { diff --git a/projects/aca-testing-shared/src/components/toolbar/toolbar.ts b/projects/aca-testing-shared/src/components/toolbar/toolbar.ts index 4fff58305..8604c66ae 100755 --- a/projects/aca-testing-shared/src/components/toolbar/toolbar.ts +++ b/projects/aca-testing-shared/src/components/toolbar/toolbar.ts @@ -34,25 +34,17 @@ export class Toolbar extends Component { buttons = this.allByCss('button'); shareButton = this.byCss(`.mat-icon-button[title='Share']`); - shareEditButton = this.byCss( - `.mat-icon-button[title='Shared Link Settings']` - ); + shareEditButton = this.byCss(`.mat-icon-button[title='Shared Link Settings']`); viewButton = this.byCss(`.mat-icon-button[title='View']`); - searchFiltersToggleButton = this.byCss( - `.mat-icon-button[title='Toggle search filter']` - ); + searchFiltersToggleButton = this.byCss(`.mat-icon-button[title='Toggle search filter']`); downloadButton = this.byCss(`.mat-icon-button[title='Download']`); editFolderButton = this.byId('app.toolbar.editFolder'); viewDetailsButton = this.byCss(`.mat-icon-button[title='View Details']`); printButton = this.byCss(`.mat-icon-button[title='Print']`); - fullScreenButton = this.byCss( - `.mat-icon-button[title='Activate full-screen mode']` - ); + fullScreenButton = this.byCss(`.mat-icon-button[title='Activate full-screen mode']`); joinButton = this.byCss(`.mat-icon-button[title='Join']`); leaveButton = this.byCss(`.mat-icon-button[title='Leave Library']`); - permanentlyDeleteButton = this.byCss( - `.mat-icon-button[title='Permanently Delete']` - ); + permanentlyDeleteButton = this.byCss(`.mat-icon-button[title='Permanently Delete']`); restoreButton = this.byCss(`.mat-icon-button[title='Restore']`); constructor(ancestor?: string) { @@ -65,7 +57,7 @@ export class Toolbar extends Component { } async getButtons(): Promise { - return this.buttons.map(async elem => { + return this.buttons.map(async (elem) => { return elem.getAttribute('title'); }); } diff --git a/projects/aca-testing-shared/src/pages/browsing-page.ts b/projects/aca-testing-shared/src/pages/browsing-page.ts index 6710be4d4..d912778a8 100755 --- a/projects/aca-testing-shared/src/pages/browsing-page.ts +++ b/projects/aca-testing-shared/src/pages/browsing-page.ts @@ -23,14 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Header, - DataTable, - Pagination, - Toolbar, - Breadcrumb, - Sidenav -} from '../components/components'; +import { Header, DataTable, Pagination, Toolbar, Breadcrumb, Sidenav } from '../components/components'; import { SIDEBAR_LABELS } from './../configs'; import { Page } from './page'; diff --git a/projects/aca-testing-shared/src/pages/login-page.ts b/projects/aca-testing-shared/src/pages/login-page.ts index a5ff9bf1e..6fe205e57 100755 --- a/projects/aca-testing-shared/src/pages/login-page.ts +++ b/projects/aca-testing-shared/src/pages/login-page.ts @@ -51,10 +51,7 @@ export class LoginPage extends Page { async loginWithAdmin() { await this.load(); - return this.loginWith( - browser.params.ADMIN_USERNAME, - browser.params.ADMIN_PASSWORD - ); + return this.loginWith(browser.params.ADMIN_USERNAME, browser.params.ADMIN_PASSWORD); } async tryLoginWith(username: string, password?: string) { diff --git a/projects/aca-testing-shared/src/pages/page.ts b/projects/aca-testing-shared/src/pages/page.ts index c074e5a76..3b30951f3 100755 --- a/projects/aca-testing-shared/src/pages/page.ts +++ b/projects/aca-testing-shared/src/pages/page.ts @@ -26,12 +26,7 @@ import { browser, by, ElementFinder } from 'protractor'; import { Logger } from '@alfresco/adf-testing'; import { USE_HASH_STRATEGY } from './../configs'; -import { - Utils, - waitElement, - waitForPresence, - waitForVisibility -} from '../utilities/utils'; +import { Utils, waitElement, waitForPresence, waitForVisibility } from '../utilities/utils'; export abstract class Page { appRoot = 'app-root'; diff --git a/projects/aca-testing-shared/src/pages/search-results-page.ts b/projects/aca-testing-shared/src/pages/search-results-page.ts index ceac9af3c..340b090c9 100755 --- a/projects/aca-testing-shared/src/pages/search-results-page.ts +++ b/projects/aca-testing-shared/src/pages/search-results-page.ts @@ -46,7 +46,7 @@ export class SearchResultsPage extends BrowsingPage { async getResultsChipsValues(): Promise { const chips = this.chipList.all(by.css('.mat-chip')); - const chipsValues: string[] = await chips.map(async elem => { + const chipsValues: string[] = await chips.map(async (elem) => { return (await elem.getText()).replace(`\ncancel`, ''); }); return chipsValues; diff --git a/projects/aca-testing-shared/src/utilities/admin-actions.ts b/projects/aca-testing-shared/src/utilities/admin-actions.ts index f858c0da1..3e050b145 100755 --- a/projects/aca-testing-shared/src/utilities/admin-actions.ts +++ b/projects/aca-testing-shared/src/utilities/admin-actions.ts @@ -51,95 +51,53 @@ export class AdminActions { } async getNodeTemplatesFolderId(): Promise { - return this.adminApi.nodes.getNodeIdFromParent( - 'Node Templates', - await this.getDataDictionaryId() - ); + return this.adminApi.nodes.getNodeIdFromParent('Node Templates', await this.getDataDictionaryId()); } async getSpaceTemplatesFolderId(): Promise { - return this.adminApi.nodes.getNodeIdFromParent( - 'Space Templates', - await this.getDataDictionaryId() - ); + return this.adminApi.nodes.getNodeIdFromParent('Space Templates', await this.getDataDictionaryId()); } async createUser(user: PersonModel): Promise { return this.adminApi.people.createUser(user); } - async createNodeTemplate( - name: string, - title: string = '', - description: string = '', - author: string = '' - ): Promise { + async createNodeTemplate(name: string, title: string = '', description: string = '', author: string = ''): Promise { const templatesRootFolderId: string = await this.getNodeTemplatesFolderId(); - return this.adminApi.nodes.createFile( - name, - templatesRootFolderId, - title, - description, - author - ); + return this.adminApi.nodes.createFile(name, templatesRootFolderId, title, description, author); } async createNodeTemplatesHierarchy(hierarchy: NodeContentTree): Promise { - return this.adminApi.nodes.createContent( - hierarchy, - `Data Dictionary/Node Templates` - ); + return this.adminApi.nodes.createContent(hierarchy, `Data Dictionary/Node Templates`); } - async createSpaceTemplate( - name: string, - title: string = '', - description: string = '' - ): Promise { + async createSpaceTemplate(name: string, title: string = '', description: string = ''): Promise { const templatesRootFolderId: string = await this.getSpaceTemplatesFolderId(); - return this.adminApi.nodes.createFolder( - name, - templatesRootFolderId, - title, - description - ); + return this.adminApi.nodes.createFolder(name, templatesRootFolderId, title, description); } - async createSpaceTemplatesHierarchy( - hierarchy: NodeContentTree - ): Promise { - return this.adminApi.nodes.createContent( - hierarchy, - `Data Dictionary/Space Templates` - ); + async createSpaceTemplatesHierarchy(hierarchy: NodeContentTree): Promise { + return this.adminApi.nodes.createContent(hierarchy, `Data Dictionary/Space Templates`); } async removeUserAccessOnNodeTemplate(nodeName: string): Promise { const templatesRootFolderId = await this.getNodeTemplatesFolderId(); - const nodeId: string = await this.adminApi.nodes.getNodeIdFromParent( - nodeName, - templatesRootFolderId - ); + const nodeId: string = await this.adminApi.nodes.getNodeIdFromParent(nodeName, templatesRootFolderId); return this.adminApi.nodes.setInheritPermissions(nodeId, false); } async removeUserAccessOnSpaceTemplate(nodeName: string): Promise { const templatesRootFolderId = await this.getSpaceTemplatesFolderId(); - const nodeId: string = await this.adminApi.nodes.getNodeIdFromParent( - nodeName, - templatesRootFolderId - ); + const nodeId: string = await this.adminApi.nodes.getNodeIdFromParent(nodeName, templatesRootFolderId); return this.adminApi.nodes.setInheritPermissions(nodeId, false); } async cleanupNodeTemplatesFolder(): Promise { - return this.adminApi.nodes.deleteNodeChildren( - await this.getNodeTemplatesFolderId() - ); + return this.adminApi.nodes.deleteNodeChildren(await this.getNodeTemplatesFolderId()); } async cleanupSpaceTemplatesFolder(): Promise { @@ -147,68 +105,36 @@ export class AdminActions { // folder links are deleted automatically when original folder is deleted // Software Engineering Project is the default folder template coming from ACS, should not be deleted - const nodesToDelete = ( - await this.adminApi.nodes.getNodeChildren(spaceTemplatesNodeId) - ).list.entries - .filter( - node => - node.entry.nodeType !== 'app:folderlink' && - node.entry.name !== 'Software Engineering Project' - ) - .map(node => node.entry.id); + const nodesToDelete = (await this.adminApi.nodes.getNodeChildren(spaceTemplatesNodeId)).list.entries + .filter((node) => node.entry.nodeType !== 'app:folderlink' && node.entry.name !== 'Software Engineering Project') + .map((node) => node.entry.id); return this.adminApi.nodes.deleteNodesById(nodesToDelete); } - async createLinkToFileId( - originalFileId: string, - destinationParentId: string - ): Promise { - return this.adminApi.nodes.createFileLink( - originalFileId, - destinationParentId - ); + async createLinkToFileId(originalFileId: string, destinationParentId: string): Promise { + return this.adminApi.nodes.createFileLink(originalFileId, destinationParentId); } - async createLinkToFileName( - originalFileName: string, - originalFileParentId: string, - destinationParentId?: string - ): Promise { + async createLinkToFileName(originalFileName: string, originalFileParentId: string, destinationParentId?: string): Promise { if (!destinationParentId) { destinationParentId = originalFileParentId; } - const nodeId = await this.adminApi.nodes.getNodeIdFromParent( - originalFileName, - originalFileParentId - ); + const nodeId = await this.adminApi.nodes.getNodeIdFromParent(originalFileName, originalFileParentId); return this.createLinkToFileId(nodeId, destinationParentId); } - async createLinkToFolderId( - originalFolderId: string, - destinationParentId: string - ): Promise { - return this.adminApi.nodes.createFolderLink( - originalFolderId, - destinationParentId - ); + async createLinkToFolderId(originalFolderId: string, destinationParentId: string): Promise { + return this.adminApi.nodes.createFolderLink(originalFolderId, destinationParentId); } - async createLinkToFolderName( - originalFolderName: string, - originalFolderParentId: string, - destinationParentId?: string - ): Promise { + async createLinkToFolderName(originalFolderName: string, originalFolderParentId: string, destinationParentId?: string): Promise { if (!destinationParentId) { destinationParentId = originalFolderParentId; } - const nodeId = await this.adminApi.nodes.getNodeIdFromParent( - originalFolderName, - originalFolderParentId - ); + const nodeId = await this.adminApi.nodes.getNodeIdFromParent(originalFolderName, originalFolderParentId); return this.createLinkToFolderId(nodeId, destinationParentId); } diff --git a/projects/aca-testing-shared/src/utilities/repo-client/apis/authentication/authentication-api.ts b/projects/aca-testing-shared/src/utilities/repo-client/apis/authentication/authentication-api.ts index 6fe9bda83..b92252a4a 100755 --- a/projects/aca-testing-shared/src/utilities/repo-client/apis/authentication/authentication-api.ts +++ b/projects/aca-testing-shared/src/utilities/repo-client/apis/authentication/authentication-api.ts @@ -26,7 +26,7 @@ import { RepoApi } from '../repo-api'; export class AuthenticationApi extends RepoApi { - constructor(username?, password?) { + constructor(username?: string, password?: string) { super(username, password); } diff --git a/projects/aca-testing-shared/src/utilities/repo-client/apis/comments/comments-api.ts b/projects/aca-testing-shared/src/utilities/repo-client/apis/comments/comments-api.ts index 33f7769e0..df7dccff7 100755 --- a/projects/aca-testing-shared/src/utilities/repo-client/apis/comments/comments-api.ts +++ b/projects/aca-testing-shared/src/utilities/repo-client/apis/comments/comments-api.ts @@ -29,7 +29,7 @@ import { CommentsApi as AdfCommentsApi } from '@alfresco/js-api'; export class CommentsApi extends RepoApi { commentsApi = new AdfCommentsApi(this.alfrescoJsApi); - constructor(username?, password?) { + constructor(username?: string, password?: string) { super(username, password); } @@ -38,10 +38,7 @@ export class CommentsApi extends RepoApi { await this.apiAuth(); return await this.commentsApi.listComments(nodeId); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.getNodeComments.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.getNodeComments.name}`, error); return null; } } @@ -51,10 +48,7 @@ export class CommentsApi extends RepoApi { await this.apiAuth(); return await this.commentsApi.createComment(nodeId, { content: comment }); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.addComment.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.addComment.name}`, error); return null; } } @@ -64,10 +58,7 @@ export class CommentsApi extends RepoApi { await this.apiAuth(); return await this.commentsApi.createComment(nodeId, comment); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.addComments.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.addComments.name}`, error); return null; } } diff --git a/projects/aca-testing-shared/src/utilities/repo-client/apis/favorites/favorites-api.ts b/projects/aca-testing-shared/src/utilities/repo-client/apis/favorites/favorites-api.ts index 4a1fd9d7c..1a4cf4eb7 100755 --- a/projects/aca-testing-shared/src/utilities/repo-client/apis/favorites/favorites-api.ts +++ b/projects/aca-testing-shared/src/utilities/repo-client/apis/favorites/favorites-api.ts @@ -27,17 +27,13 @@ import { RepoApi } from '../repo-api'; import { Logger } from '@alfresco/adf-testing'; import { RepoClient } from './../../repo-client'; import { Utils } from '../../../../utilities/utils'; -import { - FavoritesApi as AdfFavoritesApi, - SitesApi as AdfSiteApi, - FavoriteEntry -} from '@alfresco/js-api'; +import { FavoritesApi as AdfFavoritesApi, SitesApi as AdfSiteApi, FavoriteEntry } from '@alfresco/js-api'; export class FavoritesApi extends RepoApi { favoritesApi = new AdfFavoritesApi(this.alfrescoJsApi); sitesApi = new AdfSiteApi(this.alfrescoJsApi); - constructor(username?, password?) { + constructor(username?: string, password?: string) { super(username, password); } @@ -53,18 +49,12 @@ export class FavoritesApi extends RepoApi { }; return await this.favoritesApi.createFavorite('-me-', data); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.addFavorite.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.addFavorite.name}`, error); return null; } } - async addFavoriteById( - nodeType: 'file' | 'folder' | 'site', - id: string - ): Promise { + async addFavoriteById(nodeType: 'file' | 'folder' | 'site', id: string): Promise { let guid; try { await this.apiAuth(); @@ -82,10 +72,7 @@ export class FavoritesApi extends RepoApi { }; return await this.favoritesApi.createFavorite('-me-', data); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.addFavoriteById.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.addFavoriteById.name}`, error); return null; } } @@ -97,10 +84,7 @@ export class FavoritesApi extends RepoApi { await this.addFavoriteById(nodeType, current); }, Promise.resolve()); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.addFavoritesByIds.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.addFavoritesByIds.name}`, error); } } @@ -109,10 +93,7 @@ export class FavoritesApi extends RepoApi { await this.apiAuth(); return await this.favoritesApi.listFavorites(this.getUsername()); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.getFavorites.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.getFavorites.name}`, error); return null; } } @@ -122,24 +103,16 @@ export class FavoritesApi extends RepoApi { await this.apiAuth(); return await this.favoritesApi.getFavorite('-me-', nodeId); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.getFavoriteById.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.getFavoriteById.name}`, error); return null; } } async isFavorite(nodeId: string) { try { - return JSON.stringify((await this.getFavorites()).list.entries).includes( - nodeId - ); + return JSON.stringify((await this.getFavorites()).list.entries).includes(nodeId); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.isFavorite.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.isFavorite.name}`, error); return null; } } @@ -167,10 +140,7 @@ export class FavoritesApi extends RepoApi { await this.apiAuth(); return await this.favoritesApi.deleteFavorite('-me-', nodeId); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.removeFavoriteById.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.removeFavoriteById.name}`, error); } } @@ -181,18 +151,14 @@ export class FavoritesApi extends RepoApi { await this.removeFavoriteById(current); }, Promise.resolve()); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.removeFavoritesByIds.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.removeFavoritesByIds.name}`, error); } } async waitForApi(data: { expect: number }) { try { const favoriteFiles = async () => { - const totalItems = (await this.getFavorites()).list.pagination - .totalItems; + const totalItems = (await this.getFavorites()).list.pagination.totalItems; if (totalItems !== data.expect) { return Promise.reject(totalItems); } else { diff --git a/projects/aca-testing-shared/src/utilities/repo-client/apis/nodes/node-content-tree.ts b/projects/aca-testing-shared/src/utilities/repo-client/apis/nodes/node-content-tree.ts index bcc3d4ede..ca72cb645 100755 --- a/projects/aca-testing-shared/src/utilities/repo-client/apis/nodes/node-content-tree.ts +++ b/projects/aca-testing-shared/src/utilities/repo-client/apis/nodes/node-content-tree.ts @@ -23,13 +23,7 @@ * along with Alfresco. If not, see . */ -import { - NodeBodyCreate, - NODE_TYPE_FILE, - NODE_TYPE_FOLDER, - NODE_TITLE, - NODE_DESCRIPTION -} from './node-body-create'; +import { NodeBodyCreate, NODE_TYPE_FILE, NODE_TYPE_FOLDER, NODE_TITLE, NODE_DESCRIPTION } from './node-body-create'; export interface NodeContentTree { name?: string; @@ -39,10 +33,7 @@ export interface NodeContentTree { description?: string; } -export function flattenNodeContentTree( - content: NodeContentTree, - relativePath: string = '/' -): NodeBodyCreate[] { +export function flattenNodeContentTree(content: NodeContentTree, relativePath: string = '/'): NodeBodyCreate[] { const { name, files, folders, title, description } = content; const aspectNames: string[] = ['cm:versionable']; let data: NodeBodyCreate[] = []; @@ -63,23 +54,17 @@ export function flattenNodeContentTree( } ]); - relativePath = - relativePath === '/' ? `/${name}` : `${relativePath}/${name}`; + relativePath = relativePath === '/' ? `/${name}` : `${relativePath}/${name}`; } if (folders) { const foldersData: NodeBodyCreate[] = folders .map((folder: string | NodeContentTree): NodeBodyCreate[] => { - const folderData: NodeContentTree = - typeof folder === 'string' ? { name: folder } : folder; + const folderData: NodeContentTree = typeof folder === 'string' ? { name: folder } : folder; return flattenNodeContentTree(folderData, relativePath); }) - .reduce( - (nodesData: NodeBodyCreate[], folderData: NodeBodyCreate[]) => - nodesData.concat(folderData), - [] - ); + .reduce((nodesData: NodeBodyCreate[], folderData: NodeBodyCreate[]) => nodesData.concat(folderData), []); data = data.concat(foldersData); } diff --git a/projects/aca-testing-shared/src/utilities/repo-client/apis/nodes/nodes-api.ts b/projects/aca-testing-shared/src/utilities/repo-client/apis/nodes/nodes-api.ts index 3afda95b6..590a71ef6 100755 --- a/projects/aca-testing-shared/src/utilities/repo-client/apis/nodes/nodes-api.ts +++ b/projects/aca-testing-shared/src/utilities/repo-client/apis/nodes/nodes-api.ts @@ -26,18 +26,13 @@ import { RepoApi } from '../repo-api'; import { NodeBodyCreate } from './node-body-create'; import { NodeContentTree, flattenNodeContentTree } from './node-content-tree'; -import { - NodesApi as AdfNodeApi, - NodeBodyLock, - NodeEntry, - NodeChildAssociationPaging -} from '@alfresco/js-api'; +import { NodesApi as AdfNodeApi, NodeBodyLock, NodeEntry, NodeChildAssociationPaging } from '@alfresco/js-api'; import { Utils } from '../../../../utilities/utils'; export class NodesApi extends RepoApi { nodesApi = new AdfNodeApi(this.alfrescoJsApi); - constructor(username?, password?) { + constructor(username?: string, password?: string) { super(username, password); } @@ -46,10 +41,7 @@ export class NodesApi extends RepoApi { await this.apiAuth(); return await this.nodesApi.getNode('-my-', { relativePath }); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.getNodeByPath.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.getNodeByPath.name}`, error); return null; } } @@ -60,10 +52,7 @@ export class NodesApi extends RepoApi { const node = await this.nodesApi.getNode(id); return node; } catch (error) { - this.handleError( - `${this.constructor.name} ${this.getNodeById.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.getNodeById.name}`, error); return null; } } @@ -71,12 +60,9 @@ export class NodesApi extends RepoApi { async getNodeIdFromParent(name: string, parentId: string): Promise { try { const children = (await this.getNodeChildren(parentId)).list.entries; - return children.find(elem => elem.entry.name === name).entry.id || ''; + return children.find((elem) => elem.entry.name === name).entry.id || ''; } catch (error) { - this.handleError( - `${this.constructor.name} ${this.getNodeIdFromParent.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.getNodeIdFromParent.name}`, error); return ''; } } @@ -84,16 +70,9 @@ export class NodesApi extends RepoApi { async getNodeDescription(name: string, parentId: string): Promise { try { const children = (await this.getNodeChildren(parentId)).list.entries; - return ( - children.find(elem => elem.entry.name === name).entry.properties[ - 'cm:description' - ] || '' - ); + return children.find((elem) => elem.entry.name === name).entry.properties['cm:description'] || ''; } catch (error) { - this.handleError( - `${this.constructor.name} ${this.getNodeDescription.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.getNodeDescription.name}`, error); return ''; } } @@ -101,16 +80,9 @@ export class NodesApi extends RepoApi { async getNodeTitle(name: string, parentId: string): Promise { try { const children = (await this.getNodeChildren(parentId)).list.entries; - return ( - children.find(elem => elem.entry.name === name).entry.properties[ - 'cm:title' - ] || '' - ); + return children.find((elem) => elem.entry.name === name).entry.properties['cm:title'] || ''; } catch (error) { - this.handleError( - `${this.constructor.name} ${this.getNodeTitle.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.getNodeTitle.name}`, error); return ''; } } @@ -120,10 +92,7 @@ export class NodesApi extends RepoApi { const node = await this.getNodeById(nodeId); return (node.entry.properties && node.entry.properties[property]) || ''; } catch (error) { - this.handleError( - `${this.constructor.name} ${this.getNodeProperty.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.getNodeProperty.name}`, error); return ''; } } @@ -133,10 +102,7 @@ export class NodesApi extends RepoApi { const prop = await this.getNodeProperty(nodeId, 'cm:versionType'); return prop || ''; } catch (error) { - this.handleError( - `${this.constructor.name} ${this.getFileVersionType.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.getFileVersionType.name}`, error); return ''; } } @@ -146,10 +112,7 @@ export class NodesApi extends RepoApi { const prop = await this.getNodeProperty(nodeId, 'cm:versionLabel'); return prop || ''; } catch (error) { - this.handleError( - `${this.constructor.name} ${this.getFileVersionLabel.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.getFileVersionLabel.name}`, error); return ''; } } @@ -159,26 +122,17 @@ export class NodesApi extends RepoApi { const sharedId = await this.getNodeProperty(nodeId, 'qshare:sharedId'); return sharedId || ''; } catch (error) { - this.handleError( - `${this.constructor.name} ${this.getSharedId.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.getSharedId.name}`, error); return ''; } } async getSharedExpiryDate(nodeId: string): Promise { try { - const expiryDate = await this.getNodeProperty( - nodeId, - 'qshare:expiryDate' - ); + const expiryDate = await this.getNodeProperty(nodeId, 'qshare:expiryDate'); return expiryDate || ''; } catch (error) { - this.handleError( - `${this.constructor.name} ${this.getSharedExpiryDate.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.getSharedExpiryDate.name}`, error); return ''; } } @@ -188,10 +142,7 @@ export class NodesApi extends RepoApi { const sharedId = await this.getSharedId(nodeId); return sharedId !== ''; } catch (error) { - this.handleError( - `${this.constructor.name} ${this.isFileShared.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.isFileShared.name}`, error); return null; } } @@ -201,69 +152,42 @@ export class NodesApi extends RepoApi { await this.apiAuth(); await this.nodesApi.deleteNode(id, { permanent }); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.deleteNodeById.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.deleteNodeById.name}`, error); } } - async deleteNodeByPath( - path: string, - permanent: boolean = true - ): Promise { + async deleteNodeByPath(path: string, permanent: boolean = true): Promise { try { const id = (await this.getNodeByPath(path)).entry.id; await this.deleteNodeById(id, permanent); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.deleteNodeByPath.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.deleteNodeByPath.name}`, error); } } - async deleteNodes( - names: string[], - relativePath: string = '', - permanent: boolean = true - ): Promise { + async deleteNodes(names: string[], relativePath: string = '', permanent: boolean = true): Promise { try { await names.reduce(async (previous, current) => { await previous; - const req = await this.deleteNodeByPath( - `${relativePath}/${current}`, - permanent - ); + const req = await this.deleteNodeByPath(`${relativePath}/${current}`, permanent); return req; }, Promise.resolve()); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.deleteNodes.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.deleteNodes.name}`, error); } } - async deleteNodesById( - ids: string[], - permanent: boolean = true - ): Promise { + async deleteNodesById(ids: string[], permanent: boolean = true): Promise { try { for (const id of ids) { await this.deleteNodeById(id, permanent); } } catch (error) { - this.handleError( - `${this.constructor.name} ${this.deleteNodesById.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.deleteNodesById.name}`, error); } } - async getNodeChildren( - nodeId: string - ): Promise { + async getNodeChildren(nodeId: string): Promise { try { const opts = { include: ['properties'] @@ -271,61 +195,35 @@ export class NodesApi extends RepoApi { await this.apiAuth(); return await this.nodesApi.listNodeChildren(nodeId, opts); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.getNodeChildren.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.getNodeChildren.name}`, error); return null; } } - async deleteNodeChildren( - parentId: string, - exceptNodesNamed?: string[] - ): Promise { + async deleteNodeChildren(parentId: string, exceptNodesNamed?: string[]): Promise { try { const listEntries = (await this.getNodeChildren(parentId)).list.entries; let nodeIds: string[]; if (exceptNodesNamed) { - nodeIds = listEntries - .filter(entries => !exceptNodesNamed.includes(entries.entry.name)) - .map(entries => entries.entry.id); + nodeIds = listEntries.filter((entries) => !exceptNodesNamed.includes(entries.entry.name)).map((entries) => entries.entry.id); } else { - nodeIds = listEntries.map(entries => entries.entry.id); + nodeIds = listEntries.map((entries) => entries.entry.id); } await this.deleteNodesById(nodeIds); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.deleteNodeChildren.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.deleteNodeChildren.name}`, error); } } - async createImageNode( - name: string, - parentId: string = '-my-', - title: string = '', - description: string = '' - ): Promise { + async createImageNode(name: string, parentId: string = '-my-', title: string = '', description: string = ''): Promise { const imageProps = { 'exif:pixelXDimension': 1000, 'exif:pixelYDimension': 1200 }; try { - return await this.createNode( - 'cm:content', - name, - parentId, - title, - description, - imageProps - ); + return await this.createNode('cm:content', name, parentId, title, description, imageProps); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.createImageNode.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.createImageNode.name}`, error); return null; } } @@ -364,10 +262,7 @@ export class NodesApi extends RepoApi { majorVersion }); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.createNode.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.createNode.name}`, error); return null; } } @@ -382,39 +277,18 @@ export class NodesApi extends RepoApi { aspectNames: string[] = null ): Promise { try { - return await this.createNode( - 'cm:content', - name, - parentId, - title, - description, - null, - author, - majorVersion, - aspectNames - ); + return await this.createNode('cm:content', name, parentId, title, description, null, author, majorVersion, aspectNames); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.createFile.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.createFile.name}`, error); return null; } } - async createImage( - name: string, - parentId: string = '-my-', - title: string = '', - description: string = '' - ): Promise { + async createImage(name: string, parentId: string = '-my-', title: string = '', description: string = ''): Promise { try { return await this.createImageNode(name, parentId, title, description); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.createImage.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.createImage.name}`, error); return null; } } @@ -428,22 +302,9 @@ export class NodesApi extends RepoApi { aspectNames: string[] = null ): Promise { try { - return await this.createNode( - 'cm:folder', - name, - parentId, - title, - description, - null, - author, - null, - aspectNames - ); + return await this.createNode('cm:folder', name, parentId, title, description, null, author, null, aspectNames); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.createFolder.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.createFolder.name}`, error); return null; } } @@ -453,54 +314,31 @@ export class NodesApi extends RepoApi { await this.apiAuth(); return await this.nodesApi.createNode('-my-', data as any); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.createChildren.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.createChildren.name}`, error); } } - async createContent( - content: NodeContentTree, - relativePath: string = '/' - ): Promise { + async createContent(content: NodeContentTree, relativePath: string = '/'): Promise { try { - return await this.createChildren( - flattenNodeContentTree(content, relativePath) - ); + return await this.createChildren(flattenNodeContentTree(content, relativePath)); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.createContent.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.createContent.name}`, error); } } - async createFolders( - names: string[], - relativePath: string = '/' - ): Promise { + async createFolders(names: string[], relativePath: string = '/'): Promise { try { return await this.createContent({ folders: names }, relativePath); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.createFolders.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.createFolders.name}`, error); } } - async createFiles( - names: string[], - relativePath: string = '/' - ): Promise { + async createFiles(names: string[], relativePath: string = '/'): Promise { try { return await this.createContent({ files: names }, relativePath); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.createFiles.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.createFiles.name}`, error); } } @@ -509,18 +347,12 @@ export class NodesApi extends RepoApi { await this.apiAuth(); return this.nodesApi.updateNode(nodeId, { aspectNames }); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.addAspects.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.addAspects.name}`, error); return null; } } - async createFileLink( - originalNodeId: string, - destinationId: string - ): Promise { + async createFileLink(originalNodeId: string, destinationId: string): Promise { const name = (await this.getNodeById(originalNodeId)).entry.name; const nodeBody = { name: `Link to ${name}.url`, @@ -536,18 +368,12 @@ export class NodesApi extends RepoApi { await this.addAspects(originalNodeId, ['app:linked']); return link; } catch (error) { - this.handleError( - `${this.constructor.name} ${this.createFileLink.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.createFileLink.name}`, error); return null; } } - async createFolderLink( - originalNodeId: string, - destinationId: string - ): Promise { + async createFolderLink(originalNodeId: string, destinationId: string): Promise { const name = (await this.getNodeById(originalNodeId)).entry.name; const nodeBody = { name: `Link to ${name}.url`, @@ -566,10 +392,7 @@ export class NodesApi extends RepoApi { await this.addAspects(originalNodeId, ['app:linked']); return link; } catch (error) { - this.handleError( - `${this.constructor.name} ${this.createFolderLink.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.createFolderLink.name}`, error); return null; } } @@ -580,25 +403,16 @@ export class NodesApi extends RepoApi { await this.apiAuth(); return await this.nodesApi.getNodeContent(nodeId); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.getNodeContent.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.getNodeContent.name}`, error); } } - async editNodeContent( - nodeId: string, - content: string - ): Promise { + async editNodeContent(nodeId: string, content: string): Promise { try { await this.apiAuth(); return await this.nodesApi.updateNodeContent(nodeId, content); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.editNodeContent.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.editNodeContent.name}`, error); return null; } } @@ -608,19 +422,13 @@ export class NodesApi extends RepoApi { await this.apiAuth(); return this.nodesApi.updateNode(nodeId, { name: newName }); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.renameNode.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.renameNode.name}`, error); return null; } } // node permissions - async setInheritPermissions( - nodeId: string, - inheritPermissions: boolean - ): Promise { + async setInheritPermissions(nodeId: string, inheritPermissions: boolean): Promise { const data = { permissions: { isInheritanceEnabled: inheritPermissions @@ -631,20 +439,12 @@ export class NodesApi extends RepoApi { await this.apiAuth(); return await this.nodesApi.updateNode(nodeId, data); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.setGranularPermission.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.setGranularPermission.name}`, error); return null; } } - async setGranularPermission( - nodeId: string, - inheritPermissions: boolean = false, - username: string, - role: string - ): Promise { + async setGranularPermission(nodeId: string, inheritPermissions: boolean = false, username: string, role: string): Promise { const data = { permissions: { isInheritanceEnabled: inheritPermissions, @@ -661,19 +461,13 @@ export class NodesApi extends RepoApi { await this.apiAuth(); return await this.nodesApi.updateNode(nodeId, data); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.setGranularPermission.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.setGranularPermission.name}`, error); return null; } } // lock node - async lockFile( - nodeId: string, - lockType: string = 'ALLOW_OWNER_CHANGES' - ): Promise { + async lockFile(nodeId: string, lockType: string = 'ALLOW_OWNER_CHANGES'): Promise { const data = { type: lockType } as NodeBodyLock; @@ -692,10 +486,7 @@ export class NodesApi extends RepoApi { await this.apiAuth(); return await this.nodesApi.unlockNode(nodeId); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.unlockFile.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.unlockFile.name}`, error); return null; } } @@ -705,10 +496,7 @@ export class NodesApi extends RepoApi { const lockType = await this.getNodeProperty(nodeId, 'cm:lockType'); return lockType || ''; } catch (error) { - this.handleError( - `${this.constructor.name} ${this.getLockType.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.getLockType.name}`, error); return ''; } } @@ -718,10 +506,7 @@ export class NodesApi extends RepoApi { const lockOwner = await this.getNodeProperty(nodeId, 'cm:lockOwner'); return lockOwner || ''; } catch (error) { - this.handleError( - `${this.constructor.name} ${this.getLockOwner.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.getLockOwner.name}`, error); return ''; } } @@ -730,18 +515,12 @@ export class NodesApi extends RepoApi { try { return (await this.getLockType(nodeId)) === 'WRITE_LOCK'; } catch (error) { - this.handleError( - `${this.constructor.name} ${this.isFileLockedWrite.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.isFileLockedWrite.name}`, error); return null; } } - async isFileLockedWriteWithRetry( - nodeId: string, - expect: boolean - ): Promise { + async isFileLockedWriteWithRetry(nodeId: string, expect: boolean): Promise { const data = { expect: expect, retry: 5 @@ -758,26 +537,17 @@ export class NodesApi extends RepoApi { }; return await Utils.retryCall(locked, data.retry); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.isFileLockedWriteWithRetry.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.isFileLockedWriteWithRetry.name}`, error); } return isLocked; } - async isFileLockedByName( - fileName: string, - parentId: string - ): Promise { + async isFileLockedByName(fileName: string, parentId: string): Promise { try { const id = await this.getNodeIdFromParent(fileName, parentId); return await this.isFileLockedWrite(id); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.isFileLockedByName.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.isFileLockedByName.name}`, error); return null; } } diff --git a/projects/aca-testing-shared/src/utilities/repo-client/apis/people/people-api.ts b/projects/aca-testing-shared/src/utilities/repo-client/apis/people/people-api.ts index 97de5ab04..db310e3b3 100755 --- a/projects/aca-testing-shared/src/utilities/repo-client/apis/people/people-api.ts +++ b/projects/aca-testing-shared/src/utilities/repo-client/apis/people/people-api.ts @@ -40,10 +40,7 @@ export class PeopleApi extends RepoApi { await this.apiAuth(); return await this.peopleApi.createPerson(person); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.createUser.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.createUser.name}`, error); return null; } } @@ -63,10 +60,7 @@ export class PeopleApi extends RepoApi { await this.apiAuth(); return this.peopleApi.updatePerson(username, userDetails); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.updateUser.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.updateUser.name}`, error); return null; } } @@ -75,10 +69,7 @@ export class PeopleApi extends RepoApi { try { return await this.updateUser(username, { enabled: false }); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.disableUser.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.disableUser.name}`, error); return null; } } @@ -87,10 +78,7 @@ export class PeopleApi extends RepoApi { try { return await this.updateUser(username, { password: newPassword }); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.changePassword.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.changePassword.name}`, error); return null; } } diff --git a/projects/aca-testing-shared/src/utilities/repo-client/apis/queries/queries-api.ts b/projects/aca-testing-shared/src/utilities/repo-client/apis/queries/queries-api.ts index 8ffcff9c9..d9a605fcc 100755 --- a/projects/aca-testing-shared/src/utilities/repo-client/apis/queries/queries-api.ts +++ b/projects/aca-testing-shared/src/utilities/repo-client/apis/queries/queries-api.ts @@ -45,10 +45,7 @@ export class QueriesApi extends RepoApi { await this.apiAuth(); return this.queriesApi.findSites(searchTerm, data); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.findSites.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.findSites.name}`, error); return null; } } @@ -63,10 +60,7 @@ export class QueriesApi extends RepoApi { await this.apiAuth(); return this.queriesApi.findNodes(searchTerm, data); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.findNodes.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.findNodes.name}`, error); return null; } } @@ -74,8 +68,7 @@ export class QueriesApi extends RepoApi { async waitForSites(searchTerm: string, data: { expect: number }) { try { const sites = async () => { - const totalItems = (await this.findSites(searchTerm)).list.pagination - .totalItems; + const totalItems = (await this.findSites(searchTerm)).list.pagination.totalItems; if (totalItems !== data.expect) { return Promise.reject(totalItems); } else { @@ -85,9 +78,7 @@ export class QueriesApi extends RepoApi { return await Utils.retryCall(sites); } catch (error) { - Logger.error( - `${this.constructor.name} ${this.waitForSites.name} catch: ` - ); + Logger.error(`${this.constructor.name} ${this.waitForSites.name} catch: `); Logger.error(`\tExpected: ${data.expect} items, but found ${error}`); } } @@ -95,8 +86,7 @@ export class QueriesApi extends RepoApi { async waitForFilesAndFolders(searchTerm: string, data: { expect: number }) { try { const nodes = async () => { - const totalItems = (await this.findNodes(searchTerm)).list.pagination - .totalItems; + const totalItems = (await this.findNodes(searchTerm)).list.pagination.totalItems; if (totalItems !== data.expect) { return Promise.reject(totalItems); } else { @@ -106,9 +96,7 @@ export class QueriesApi extends RepoApi { return await Utils.retryCall(nodes); } catch (error) { - Logger.error( - `${this.constructor.name} ${this.waitForFilesAndFolders.name} catch: ` - ); + Logger.error(`${this.constructor.name} ${this.waitForFilesAndFolders.name} catch: `); Logger.error(`\tExpected: ${data.expect} items, but found ${error}`); } } diff --git a/projects/aca-testing-shared/src/utilities/repo-client/apis/repo-api.ts b/projects/aca-testing-shared/src/utilities/repo-client/apis/repo-api.ts index 6a59cf76d..0da29219d 100644 --- a/projects/aca-testing-shared/src/utilities/repo-client/apis/repo-api.ts +++ b/projects/aca-testing-shared/src/utilities/repo-client/apis/repo-api.ts @@ -30,10 +30,7 @@ import { Logger } from '@alfresco/adf-testing'; export abstract class RepoApi { alfrescoJsApi = new AlfrescoApi(); - constructor( - private username: string = browser.params.ADMIN_USERNAME, - private password: string = browser.params.ADMIN_PASSWORD - ) { + constructor(private username: string = browser.params.ADMIN_USERNAME, private password: string = browser.params.ADMIN_PASSWORD) { this.alfrescoJsApi.setConfig(browser.params.config); } diff --git a/projects/aca-testing-shared/src/utilities/repo-client/apis/search/search-api.ts b/projects/aca-testing-shared/src/utilities/repo-client/apis/search/search-api.ts index 8772afe37..9bea4b313 100755 --- a/projects/aca-testing-shared/src/utilities/repo-client/apis/search/search-api.ts +++ b/projects/aca-testing-shared/src/utilities/repo-client/apis/search/search-api.ts @@ -31,7 +31,7 @@ import { SearchApi as AdfSearchApi } from '@alfresco/js-api'; export class SearchApi extends RepoApi { searchApi = new AdfSearchApi(this.alfrescoJsApi); - constructor(username?, password?) { + constructor(username?: string, password?: string) { super(username, password); } @@ -52,10 +52,7 @@ export class SearchApi extends RepoApi { await this.apiAuth(); return this.searchApi.search(data); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.queryRecentFiles.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.queryRecentFiles.name}`, error); return null; } } @@ -73,10 +70,7 @@ export class SearchApi extends RepoApi { await this.apiAuth(); return this.searchApi.search(data); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.queryNodesNames.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.queryNodesNames.name}`, error); return null; } } @@ -94,10 +88,7 @@ export class SearchApi extends RepoApi { await this.apiAuth(); return this.searchApi.search(data); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.queryNodesExactNames.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.queryNodesExactNames.name}`, error); return null; } } @@ -105,8 +96,7 @@ export class SearchApi extends RepoApi { async waitForApi(username: string, data: { expect: number }) { try { const recentFiles = async () => { - const totalItems = (await this.queryRecentFiles(username)).list - .pagination.totalItems; + const totalItems = (await this.queryRecentFiles(username)).list.pagination.totalItems; if (totalItems !== data.expect) { return Promise.reject(totalItems); } else { @@ -124,8 +114,7 @@ export class SearchApi extends RepoApi { async waitForNodes(searchTerm: string, data: { expect: number }) { try { const nodes = async () => { - const totalItems = (await this.queryNodesNames(searchTerm)).list - .pagination.totalItems; + const totalItems = (await this.queryNodesNames(searchTerm)).list.pagination.totalItems; if (totalItems !== data.expect) { return Promise.reject(totalItems); } else { @@ -135,9 +124,7 @@ export class SearchApi extends RepoApi { return await Utils.retryCall(nodes); } catch (error) { - Logger.error( - `${this.constructor.name} ${this.waitForNodes.name} catch: ` - ); + Logger.error(`${this.constructor.name} ${this.waitForNodes.name} catch: `); Logger.error(`\tExpected: ${data.expect} items, but found ${error}`); } } diff --git a/projects/aca-testing-shared/src/utilities/repo-client/apis/shared-links/shared-links-api.ts b/projects/aca-testing-shared/src/utilities/repo-client/apis/shared-links/shared-links-api.ts index 74d60afe8..a7ef65bc1 100755 --- a/projects/aca-testing-shared/src/utilities/repo-client/apis/shared-links/shared-links-api.ts +++ b/projects/aca-testing-shared/src/utilities/repo-client/apis/shared-links/shared-links-api.ts @@ -26,22 +26,16 @@ import { RepoApi } from '../repo-api'; import { Logger } from '@alfresco/adf-testing'; import { Utils } from '../../../../utilities/utils'; -import { - SharedlinksApi as AdfSharedlinksApi, - SharedLinkEntry -} from '@alfresco/js-api'; +import { SharedlinksApi as AdfSharedlinksApi, SharedLinkEntry } from '@alfresco/js-api'; export class SharedLinksApi extends RepoApi { sharedlinksApi = new AdfSharedlinksApi(this.alfrescoJsApi); - constructor(username?, password?) { + constructor(username?: string, password?: string) { super(username, password); } - async shareFileById( - id: string, - expireDate?: Date - ): Promise { + async shareFileById(id: string, expireDate?: Date): Promise { try { await this.apiAuth(); const data = { @@ -50,10 +44,7 @@ export class SharedLinksApi extends RepoApi { }; return await this.sharedlinksApi.createSharedLink(data); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.shareFileById.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.shareFileById.name}`, error); return null; } } @@ -65,25 +56,17 @@ export class SharedLinksApi extends RepoApi { return this.shareFileById(current); }, Promise.resolve()); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.shareFilesByIds.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.shareFilesByIds.name}`, error); } } async getSharedIdOfNode(name: string) { try { const sharedLinks = (await this.getSharedLinks()).list.entries; - const found = sharedLinks.find( - sharedLink => sharedLink.entry.name === name - ); + const found = sharedLinks.find((sharedLink) => sharedLink.entry.name === name); return (found || { entry: { id: null } }).entry.id; } catch (error) { - this.handleError( - `${this.constructor.name} ${this.getSharedIdOfNode.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.getSharedIdOfNode.name}`, error); return null; } } @@ -93,10 +76,7 @@ export class SharedLinksApi extends RepoApi { const id = await this.getSharedIdOfNode(name); return await this.sharedlinksApi.deleteSharedLink(id); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.unshareFile.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.unshareFile.name}`, error); } } @@ -105,10 +85,7 @@ export class SharedLinksApi extends RepoApi { await this.apiAuth(); return await this.sharedlinksApi.listSharedLinks(); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.getSharedLinks.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.getSharedLinks.name}`, error); return null; } } @@ -116,8 +93,7 @@ export class SharedLinksApi extends RepoApi { async waitForApi(data: { expect: number }) { try { const sharedFiles = async () => { - const totalItems = (await this.getSharedLinks()).list.pagination - .totalItems; + const totalItems = (await this.getSharedLinks()).list.pagination.totalItems; if (totalItems !== data.expect) { return Promise.reject(totalItems); } else { diff --git a/projects/aca-testing-shared/src/utilities/repo-client/apis/sites/sites-api.ts b/projects/aca-testing-shared/src/utilities/repo-client/apis/sites/sites-api.ts index 120ba3f2f..a103cb22d 100755 --- a/projects/aca-testing-shared/src/utilities/repo-client/apis/sites/sites-api.ts +++ b/projects/aca-testing-shared/src/utilities/repo-client/apis/sites/sites-api.ts @@ -40,7 +40,7 @@ import { Utils } from '../../../../utilities/utils'; export class SitesApi extends RepoApi { sitesApi = new AdfSiteApi(this.alfrescoJsApi); - constructor(username?, password?) { + constructor(username?: string, password?: string) { super(username, password); } @@ -57,9 +57,7 @@ export class SitesApi extends RepoApi { async getSites() { try { await this.apiAuth(); - return await this.sitesApi.listSiteMembershipsForPerson( - this.getUsername() - ); + return await this.sitesApi.listSiteMembershipsForPerson(this.getUsername()); } catch (error) { this.handleError(`${this.constructor.name} ${this.getSites.name}`, error); return null; @@ -69,13 +67,9 @@ export class SitesApi extends RepoApi { async getDocLibId(siteId: string) { try { await this.apiAuth(); - return (await this.sitesApi.listSiteContainers(siteId)).list.entries[0] - .entry.id; + return (await this.sitesApi.listSiteContainers(siteId)).list.entries[0].entry.id; } catch (error) { - this.handleError( - `${this.constructor.name} ${this.getDocLibId.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.getDocLibId.name}`, error); return null; } } @@ -85,10 +79,7 @@ export class SitesApi extends RepoApi { const site = await this.getSite(siteId); return site.entry.visibility; } catch (error) { - this.handleError( - `${this.constructor.name} ${this.getVisibility.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.getVisibility.name}`, error); return null; } } @@ -98,10 +89,7 @@ export class SitesApi extends RepoApi { const site = await this.getSite(siteId); return site.entry.description; } catch (error) { - this.handleError( - `${this.constructor.name} ${this.getDescription.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.getDescription.name}`, error); return null; } } @@ -116,12 +104,7 @@ export class SitesApi extends RepoApi { } } - async createSite( - title: string, - visibility?: string, - description?: string, - siteId?: string - ): Promise { + async createSite(title: string, visibility?: string, description?: string, siteId?: string): Promise { const site = { title, visibility: visibility || SITE_VISIBILITY.PUBLIC, @@ -133,33 +116,17 @@ export class SitesApi extends RepoApi { await this.apiAuth(); return await this.sitesApi.createSite(site); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.createSite.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.createSite.name}`, error); return null; } } - async createSitePrivate( - title: string, - description?: string, - siteId?: string - ): Promise { + async createSitePrivate(title: string, description?: string, siteId?: string): Promise { return this.createSite(title, SITE_VISIBILITY.PRIVATE, description, siteId); } - async createSiteModerated( - title: string, - description?: string, - siteId?: string - ): Promise { - return this.createSite( - title, - SITE_VISIBILITY.MODERATED, - description, - siteId - ); + async createSiteModerated(title: string, description?: string, siteId?: string): Promise { + return this.createSite(title, SITE_VISIBILITY.MODERATED, description, siteId); } async createSites(titles: string[], visibility?: string): Promise { @@ -169,10 +136,7 @@ export class SitesApi extends RepoApi { return this.createSite(current, visibility); }, Promise.resolve()); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.createSites.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.createSites.name}`, error); } } @@ -185,10 +149,7 @@ export class SitesApi extends RepoApi { await this.apiAuth(); return await this.sitesApi.deleteSite(siteId, { permanent }); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.deleteSite.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.deleteSite.name}`, error); } } @@ -199,28 +160,20 @@ export class SitesApi extends RepoApi { return this.deleteSite(current, permanent); }, Promise.resolve()); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.deleteSites.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.deleteSites.name}`, error); } } async deleteAllUserSites(permanent: boolean = true) { try { - const siteIds = (await this.getSites()).list.entries.map( - entries => entries.entry.id - ); + const siteIds = (await this.getSites()).list.entries.map((entries) => entries.entry.id); return await siteIds.reduce(async (previous, current) => { await previous; return this.deleteSite(current, permanent); }, Promise.resolve()); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.deleteAllUserSites.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.deleteAllUserSites.name}`, error); } } @@ -233,10 +186,7 @@ export class SitesApi extends RepoApi { await this.apiAuth(); return await this.sitesApi.updateSiteMembership(siteId, userId, siteRole); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.updateSiteMember.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.updateSiteMember.name}`, error); return null; } } @@ -251,43 +201,24 @@ export class SitesApi extends RepoApi { await this.apiAuth(); return await this.sitesApi.createSiteMembership(siteId, memberBody); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.addSiteMember.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.addSiteMember.name}`, error); return null; } } - async addSiteConsumer( - siteId: string, - userId: string - ): Promise { + async addSiteConsumer(siteId: string, userId: string): Promise { return this.addSiteMember(siteId, userId, SITE_ROLES.SITE_CONSUMER.ROLE); } - async addSiteContributor( - siteId: string, - userId: string - ): Promise { + async addSiteContributor(siteId: string, userId: string): Promise { return this.addSiteMember(siteId, userId, SITE_ROLES.SITE_CONTRIBUTOR.ROLE); } - async addSiteCollaborator( - siteId: string, - userId: string - ): Promise { - return this.addSiteMember( - siteId, - userId, - SITE_ROLES.SITE_COLLABORATOR.ROLE - ); + async addSiteCollaborator(siteId: string, userId: string): Promise { + return this.addSiteMember(siteId, userId, SITE_ROLES.SITE_COLLABORATOR.ROLE); } - async addSiteManager( - siteId: string, - userId: string - ): Promise { + async addSiteManager(siteId: string, userId: string): Promise { return this.addSiteMember(siteId, userId, SITE_ROLES.SITE_MANAGER.ROLE); } @@ -296,31 +227,20 @@ export class SitesApi extends RepoApi { await this.apiAuth(); return await this.sitesApi.deleteSiteMembership(siteId, userId); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.deleteSiteMember.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.deleteSiteMember.name}`, error); } } - async requestToJoin( - siteId: string - ): Promise { + async requestToJoin(siteId: string): Promise { const body = { id: siteId }; try { await this.apiAuth(); - return await this.sitesApi.createSiteMembershipRequestForPerson( - '-me-', - body - ); + return await this.sitesApi.createSiteMembershipRequestForPerson('-me-', body); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.requestToJoin.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.requestToJoin.name}`, error); return null; } } @@ -328,15 +248,10 @@ export class SitesApi extends RepoApi { async hasMembershipRequest(siteId: string) { try { await this.apiAuth(); - const requests = ( - await this.sitesApi.getSiteMembershipRequests('-me-') - ).list.entries.map(e => e.entry.id); + const requests = (await this.sitesApi.getSiteMembershipRequests('-me-')).list.entries.map((e) => e.entry.id); return requests.includes(siteId); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.hasMembershipRequest.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.hasMembershipRequest.name}`, error); return null; } } diff --git a/projects/aca-testing-shared/src/utilities/repo-client/apis/trashcan/trashcan-api.ts b/projects/aca-testing-shared/src/utilities/repo-client/apis/trashcan/trashcan-api.ts index 15846d192..d5625fc73 100644 --- a/projects/aca-testing-shared/src/utilities/repo-client/apis/trashcan/trashcan-api.ts +++ b/projects/aca-testing-shared/src/utilities/repo-client/apis/trashcan/trashcan-api.ts @@ -40,10 +40,7 @@ export class TrashcanApi extends RepoApi { await this.apiAuth(); return await this.trashcanApi.deleteDeletedNode(id); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.permanentlyDelete.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.permanentlyDelete.name}`, error); } } @@ -65,37 +62,28 @@ export class TrashcanApi extends RepoApi { await this.apiAuth(); return await this.trashcanApi.listDeletedNodes(opts); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.getDeletedNodes.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.getDeletedNodes.name}`, error); return null; } } async emptyTrash() { try { - const ids = (await this.getDeletedNodes()).list.entries.map( - entries => entries.entry.id - ); + const ids = (await this.getDeletedNodes()).list.entries.map((entries) => entries.entry.id); return await ids.reduce(async (previous, current) => { await previous; return this.permanentlyDelete(current); }, Promise.resolve()); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.emptyTrash.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.emptyTrash.name}`, error); } } async waitForApi(data: { expect: number }) { try { const deletedFiles = async () => { - const totalItems = (await this.getDeletedNodes()).list.pagination - .totalItems; + const totalItems = (await this.getDeletedNodes()).list.pagination.totalItems; if (totalItems !== data.expect) { return Promise.reject(totalItems); } else { diff --git a/projects/aca-testing-shared/src/utilities/repo-client/apis/upload/upload-api.ts b/projects/aca-testing-shared/src/utilities/repo-client/apis/upload/upload-api.ts index e98acaa17..0597c4bb3 100644 --- a/projects/aca-testing-shared/src/utilities/repo-client/apis/upload/upload-api.ts +++ b/projects/aca-testing-shared/src/utilities/repo-client/apis/upload/upload-api.ts @@ -26,23 +26,20 @@ import { RepoApi } from '../repo-api'; import { UploadApi as AdfUploadApi } from '@alfresco/js-api'; import { browser } from 'protractor'; - -const fs = require('fs'); +import * as fs from 'fs'; export class UploadApi extends RepoApi { upload = new AdfUploadApi(this.alfrescoJsApi); e2eRootPath = browser.params.e2eRootPath; - constructor(username?, password?) { + constructor(username?: string, password?: string) { super(username, password); } async uploadFile(fileName: string, parentFolderId: string = '-my-') { - const file = fs.createReadStream( - `${this.e2eRootPath}/resources/test-files/${fileName}` - ); + const file = fs.createReadStream(`${this.e2eRootPath}/resources/test-files/${fileName}`); const opts = { - name: file.name, + name: fileName, nodeType: 'cm:content' }; @@ -50,23 +47,12 @@ export class UploadApi extends RepoApi { await this.apiAuth(); return await this.upload.uploadFile(file, '', parentFolderId, null, opts); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.uploadFile.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.uploadFile.name}`, error); } } - async uploadFileWithRename( - fileName: string, - parentId: string = '-my-', - newName: string, - title: string = '', - description: string = '' - ) { - const file = fs.createReadStream( - `${this.e2eRootPath}/resources/test-files/${fileName}` - ); + async uploadFileWithRename(fileName: string, parentId: string = '-my-', newName: string, title: string = '', description: string = '') { + const file = fs.createReadStream(`${this.e2eRootPath}/resources/test-files/${fileName}`); const nodeProps = { properties: { 'cm:title': title, @@ -83,10 +69,7 @@ export class UploadApi extends RepoApi { await this.apiAuth(); return await this.upload.uploadFile(file, '', parentId, nodeProps, opts); } catch (error) { - this.handleError( - `${this.constructor.name} ${this.uploadFileWithRename.name}`, - error - ); + this.handleError(`${this.constructor.name} ${this.uploadFileWithRename.name}`, error); } } } diff --git a/projects/aca-testing-shared/src/utilities/repo-client/repo-client.ts b/projects/aca-testing-shared/src/utilities/repo-client/repo-client.ts index e1e280b73..6e02fa3d4 100755 --- a/projects/aca-testing-shared/src/utilities/repo-client/repo-client.ts +++ b/projects/aca-testing-shared/src/utilities/repo-client/repo-client.ts @@ -37,10 +37,7 @@ import { UploadApi } from './apis/upload/upload-api'; import { AuthenticationApi } from './apis/authentication/authentication-api'; export class RepoClient { - constructor( - private username: string = browser.params.ADMIN_USERNAME, - private password: string = browser.params.ADMIN_PASSWORD - ) {} + constructor(private username: string = browser.params.ADMIN_USERNAME, private password: string = browser.params.ADMIN_PASSWORD) {} private get auth() { const { username, password } = this; diff --git a/projects/aca-testing-shared/src/utilities/utils.ts b/projects/aca-testing-shared/src/utilities/utils.ts index 1d7875824..25bd7aafe 100644 --- a/projects/aca-testing-shared/src/utilities/utils.ts +++ b/projects/aca-testing-shared/src/utilities/utils.ts @@ -23,116 +23,57 @@ * along with Alfresco. If not, see . */ -import { - browser, - protractor, - ElementFinder, - ExpectedConditions as EC, - by, - logging, - until, - WebElement -} from 'protractor'; +import { browser, protractor, ElementFinder, ExpectedConditions as EC, by, logging, until, WebElement } from 'protractor'; import { Logger } from '@alfresco/adf-testing'; import { BROWSER_WAIT_TIMEOUT } from '../configs'; +import * as path from 'path'; +import * as fs from 'fs'; -const path = require('path'); -const fs = require('fs'); const StreamZip = require('node-stream-zip'); -export async function typeText( - element: ElementFinder, - text: string -): Promise { +export async function typeText(element: ElementFinder, text: string): Promise { await element.clear(); await element.sendKeys(text); } -export async function clearTextWithBackspace( - element: ElementFinder -): Promise { +export async function clearTextWithBackspace(element: ElementFinder): Promise { await element.clear(); - await element.sendKeys( - ' ', - protractor.Key.CONTROL, - 'a', - protractor.Key.NULL, - protractor.Key.BACK_SPACE - ); + await element.sendKeys(' ', protractor.Key.CONTROL, 'a', protractor.Key.NULL, protractor.Key.BACK_SPACE); } -export async function waitElement( - css: string, - errorMessage?: string -): Promise { - return browser.wait( - until.elementLocated(by.css(css)), - BROWSER_WAIT_TIMEOUT, - errorMessage || `Timeout waiting for element: ${css}` - ); +export async function waitElement(css: string, errorMessage?: string): Promise { + return browser.wait(until.elementLocated(by.css(css)), BROWSER_WAIT_TIMEOUT, errorMessage || `Timeout waiting for element: ${css}`); } -export async function waitForClickable( - element: ElementFinder, - errorMessage?: string -): Promise { +export async function waitForClickable(element: ElementFinder, errorMessage?: string): Promise { await browser.wait( EC.elementToBeClickable(element), BROWSER_WAIT_TIMEOUT, - errorMessage || - `Timeout waiting for element to be clickable: ${element.locator()}` + errorMessage || `Timeout waiting for element to be clickable: ${element.locator()}` ); } -export async function waitForVisibility( - element: ElementFinder, - errorMessage?: string -): Promise { - await browser.wait( - EC.visibilityOf(element), - BROWSER_WAIT_TIMEOUT, - errorMessage || - `Timeout waiting for element visibility: ${element.locator()}` - ); +export async function waitForVisibility(element: ElementFinder, errorMessage?: string): Promise { + await browser.wait(EC.visibilityOf(element), BROWSER_WAIT_TIMEOUT, errorMessage || `Timeout waiting for element visibility: ${element.locator()}`); } -export async function waitForInvisibility( - element: ElementFinder, - errorMessage?: string -): Promise { +export async function waitForInvisibility(element: ElementFinder, errorMessage?: string): Promise { await browser.wait( EC.invisibilityOf(element), BROWSER_WAIT_TIMEOUT, - errorMessage || - `Timeout waiting for element visibility: ${element.locator()}` + errorMessage || `Timeout waiting for element visibility: ${element.locator()}` ); } -export async function waitForPresence( - element: ElementFinder, - errorMessage?: string -): Promise { - await browser.wait( - EC.presenceOf(element), - BROWSER_WAIT_TIMEOUT, - errorMessage || `Timeout waiting for element presence: ${element.locator()}` - ); +export async function waitForPresence(element: ElementFinder, errorMessage?: string): Promise { + await browser.wait(EC.presenceOf(element), BROWSER_WAIT_TIMEOUT, errorMessage || `Timeout waiting for element presence: ${element.locator()}`); } -export async function waitForStaleness( - element: ElementFinder, - errorMessage?: string -): Promise { - await browser.wait( - EC.stalenessOf(element), - BROWSER_WAIT_TIMEOUT, - errorMessage || `Timeout waiting element staleness: ${element.locator()}` - ); +export async function waitForStaleness(element: ElementFinder, errorMessage?: string): Promise { + await browser.wait(EC.stalenessOf(element), BROWSER_WAIT_TIMEOUT, errorMessage || `Timeout waiting element staleness: ${element.locator()}`); } -export const isPresentAndEnabled = async ( - element: ElementFinder -): Promise => { +export const isPresentAndEnabled = async (element: ElementFinder): Promise => { const isPresent = await element.isPresent(); if (isPresent) { @@ -142,9 +83,7 @@ export const isPresentAndEnabled = async ( return false; }; -export const isPresentAndDisplayed = async ( - element: ElementFinder -): Promise => { +export const isPresentAndDisplayed = async (element: ElementFinder): Promise => { const isPresent = await element.isPresent(); if (isPresent) { @@ -166,42 +105,25 @@ export class Utils { lighter track cinema tread tick climate lend summit singer radical flower visual negotiation promises cooperative live'; static random(): string { - return Math.random() - .toString(36) - .substring(5, 10) - .toLowerCase(); + return Math.random().toString(36).substring(5, 10).toLowerCase(); } static async clearLocalStorage(): Promise { await browser.executeScript('window.localStorage.clear();'); } - static async setSessionStorageFromConfig( - configFileName: string - ): Promise { + static async setSessionStorageFromConfig(configFileName: string): Promise { const configFile = `${browser.params.e2eRootPath}/resources/extensibility-configs/${configFileName}`; - const fileContent = JSON.stringify( - fs.readFileSync(configFile, { encoding: 'utf8' }) - ); + const fileContent = JSON.stringify(fs.readFileSync(configFile, { encoding: 'utf8' })); - await browser.executeScript( - `window.sessionStorage.setItem('app.extension.config', ${fileContent});` - ); + await browser.executeScript(`window.sessionStorage.setItem('app.extension.config', ${fileContent});`); } - static retryCall( - fn: () => Promise, - retry: number = 30, - delay: number = 1000 - ): Promise { - const pause = duration => new Promise(res => setTimeout(res, duration)); + static retryCall(fn: () => Promise, retry: number = 30, delay: number = 1000): Promise { + const pause = (duration: number) => new Promise((res) => setTimeout(res, duration)); - const run = retries => { - return fn().catch(err => - retries > 1 - ? pause(delay).then(() => run(retries - 1)) - : Promise.reject(err) - ); + const run = (retries: number): Promise => { + return fn().catch((err) => (retries > 1 ? pause(delay).then(() => run(retries - 1)) : Promise.reject(err))); }; return run(retry); @@ -214,24 +136,15 @@ export class Utils { } } - static async fileExistsOnOS( - fileName: string, - folderName: string = '', - subFolderName: string = '' - ): Promise { + static async fileExistsOnOS(fileName: string, folderName: string = '', subFolderName: string = ''): Promise { const config = await browser.getProcessedConfig(); - const filePath = path.join( - config.params.downloadFolder, - folderName, - subFolderName, - fileName - ); + const filePath = path.join(config.params.downloadFolder, folderName, subFolderName, fileName); let tries = 15; - return new Promise(function(resolve) { + return new Promise(function (resolve) { const checkExist = setInterval(() => { - fs.access(filePath, function(error) { + fs.access(filePath, function (error: any) { tries--; if (error && tries === 0) { @@ -256,7 +169,7 @@ export class Utils { const fileExists = await this.fileExistsOnOS(oldName); if (fileExists) { - fs.rename(oldFilePath, newFilePath, function(err) { + fs.rename(oldFilePath, newFilePath, function (err: any) { if (err) { Logger.error('==== rename err: ', err); } @@ -264,23 +177,17 @@ export class Utils { } } - static async unzip( - filename: string, - unzippedName: string = '' - ): Promise { + static async unzip(filename: string, unzippedName: string = ''): Promise { const config = await browser.getProcessedConfig(); const filePath = path.join(config.params.downloadFolder, filename); - const output = path.join( - config.params.downloadFolder, - unzippedName ? unzippedName : '' - ); + const output = path.join(config.params.downloadFolder, unzippedName ? unzippedName : ''); const zip = new StreamZip({ file: filePath, storeEntries: true }); - await zip.on('error', err => { + await zip.on('error', (err: any) => { Logger.error('=== unzip err: ', err); }); @@ -295,38 +202,23 @@ export class Utils { } static async pressEscape(): Promise { - await browser - .actions() - .sendKeys(protractor.Key.ESCAPE) - .perform(); + await browser.actions().sendKeys(protractor.Key.ESCAPE).perform(); } static async pressTab(): Promise { - await browser - .actions() - .sendKeys(protractor.Key.TAB) - .perform(); + await browser.actions().sendKeys(protractor.Key.TAB).perform(); } static async pressCmd(): Promise { - await browser - .actions() - .sendKeys(protractor.Key.COMMAND) - .perform(); + await browser.actions().sendKeys(protractor.Key.COMMAND).perform(); } static async releaseKeyPressed(): Promise { - await browser - .actions() - .sendKeys(protractor.Key.NULL) - .perform(); + await browser.actions().sendKeys(protractor.Key.NULL).perform(); } static async getBrowserLog(): Promise { - return browser - .manage() - .logs() - .get('browser'); + return browser.manage().logs().get('browser'); } static formatDate(date: string): string { @@ -335,8 +227,6 @@ export class Utils { static async uploadFileNewVersion(fileFromOS: string): Promise { const el = browser.element(by.id('app-upload-file-version')); - await el.sendKeys( - `${browser.params.e2eRootPath}/resources/test-files/${fileFromOS}` - ); + await el.sendKeys(`${browser.params.e2eRootPath}/resources/test-files/${fileFromOS}`); } } diff --git a/projects/aca-testing-shared/tsconfig.lib.json b/projects/aca-testing-shared/tsconfig.lib.json index fba5c463c..3fd17214b 100644 --- a/projects/aca-testing-shared/tsconfig.lib.json +++ b/projects/aca-testing-shared/tsconfig.lib.json @@ -12,10 +12,7 @@ "experimentalDecorators": true, "importHelpers": true, "types": [], - "lib": [ - "dom", - "es2018" - ] + "lib": ["dom", "es2018"] }, "angularCompilerOptions": { "skipTemplateCodegen": true, @@ -24,8 +21,5 @@ "strictInjectionParameters": true, "enableResourceInlining": true }, - "exclude": [ - "src/test.ts", - "**/*.spec.ts" - ] + "exclude": ["node_modules", "src/test.ts", "**/*.spec.ts"] } diff --git a/projects/adf-office-services-ext/src/lib/aos-extension.module.ts b/projects/adf-office-services-ext/src/lib/aos-extension.module.ts index b5a6c512f..1b2da35de 100644 --- a/projects/adf-office-services-ext/src/lib/aos-extension.module.ts +++ b/projects/adf-office-services-ext/src/lib/aos-extension.module.ts @@ -39,10 +39,7 @@ import { TranslationService } from '@alfresco/adf-core'; }) export class AosExtensionModule { constructor(extensions: ExtensionService, translation: TranslationService) { - translation.addTranslationFolder( - 'adf-office-services-ext', - 'assets/adf-office-services-ext' - ); + translation.addTranslationFolder('adf-office-services-ext', 'assets/adf-office-services-ext'); extensions.setEvaluators({ 'aos.canOpenWithOffice': canOpenWithOffice }); diff --git a/projects/adf-office-services-ext/src/lib/aos-extension.service.ts b/projects/adf-office-services-ext/src/lib/aos-extension.service.ts index 94aaed4a8..e2a71b366 100644 --- a/projects/adf-office-services-ext/src/lib/aos-extension.service.ts +++ b/projects/adf-office-services-ext/src/lib/aos-extension.service.ts @@ -24,11 +24,7 @@ */ /* cspell:disable */ -import { - AppConfigService, - AuthenticationService, - NotificationService -} from '@alfresco/adf-core'; +import { AppConfigService, AuthenticationService, NotificationService } from '@alfresco/adf-core'; import { Injectable } from '@angular/core'; import { MinimalNodeEntryEntity } from '@alfresco/js-api'; import { supportedExtensions, getFileExtension } from './utils'; @@ -49,12 +45,9 @@ export class AosEditOnlineService { // const checkedOut = node.aspectNames.find( // (aspect: string) => aspect === 'cm:checkedOut' // ); - const checkedOut = - node.properties['cm:lockType'] === 'WRITE_LOCK' || - node.properties['cm:lockType'] === 'READ_ONLY_LOCK'; + const checkedOut = node.properties['cm:lockType'] === 'WRITE_LOCK' || node.properties['cm:lockType'] === 'READ_ONLY_LOCK'; const lockOwner = node.properties['cm:lockOwner']; - const differentLockOwner = - lockOwner.id !== this.alfrescoAuthenticationService.getEcmUsername(); + const differentLockOwner = lockOwner.id !== this.alfrescoAuthenticationService.getEcmUsername(); if (checkedOut && differentLockOwner) { this.onAlreadyLockedNotification(node.id, lockOwner); @@ -80,10 +73,7 @@ export class AosEditOnlineService { } private onAlreadyLockedNotification(nodeId: string, lockOwner: string) { - this.notificationService.openSnackMessage( - `Document ${nodeId} locked by ${lockOwner}`, - 3000 - ); + this.notificationService.openSnackMessage(`Document ${nodeId} locked by ${lockOwner}`, 3000); } private getProtocolForFileExtension(fileExtension: string) { @@ -93,14 +83,10 @@ export class AosEditOnlineService { private triggerEditOnlineAos(node: MinimalNodeEntryEntity): void { const aosHost = this.appConfigService.get('aosHost'); let url: string; - const pathElements = (node.path.elements || []).map( - segment => segment.name - ); + const pathElements = (node.path.elements || []).map((segment) => segment.name); if (!pathElements.length) { - url = `${aosHost}/Company Home/_aos_nodeid/${this.getNodeId( - node - )}/${encodeURIComponent(node.name)}`; + url = `${aosHost}/Company Home/_aos_nodeid/${this.getNodeId(node)}/${encodeURIComponent(node.name)}`; } if (pathElements.length === 1) { @@ -109,36 +95,25 @@ export class AosEditOnlineService { if (pathElements.length > 1) { const root = pathElements[1]; - url = `${aosHost}/${root}/_aos_nodeid/${this.getNodeId( - node - )}/${encodeURIComponent(node.name)}`; + url = `${aosHost}/${root}/_aos_nodeid/${this.getNodeId(node)}/${encodeURIComponent(node.name)}`; } const fileExtension = getFileExtension(node.name); const protocolHandler = this.getProtocolForFileExtension(fileExtension); if (protocolHandler === undefined) { - this.notificationService.openSnackMessage( - `No protocol handler found for {fileExtension}`, - 3000 - ); + this.notificationService.openSnackMessage(`No protocol handler found for {fileExtension}`, 3000); return; } if (!this.isWindows() && !this.isMacOs()) { - this.notificationService.openSnackMessage( - 'Only supported for Windows and Mac', - 3000 - ); + this.notificationService.openSnackMessage('Only supported for Windows and Mac', 3000); } else { this.aos_tryToLaunchOfficeByMsProtocolHandler(protocolHandler, url); } } - private aos_tryToLaunchOfficeByMsProtocolHandler( - protocolHandler: string, - url: string - ) { + private aos_tryToLaunchOfficeByMsProtocolHandler(protocolHandler: string, url: string) { const protocolUrl = protocolHandler + ':ofe%7Cu%7C' + url; const iframe = document.createElement('iframe'); diff --git a/projects/adf-office-services-ext/src/lib/effects/aos.effects.ts b/projects/adf-office-services-ext/src/lib/effects/aos.effects.ts index 6b009377b..3fbecd8cf 100755 --- a/projects/adf-office-services-ext/src/lib/effects/aos.effects.ts +++ b/projects/adf-office-services-ext/src/lib/effects/aos.effects.ts @@ -32,15 +32,12 @@ import { AosEditOnlineService } from '../aos-extension.service'; @Injectable() export class AosEffects { - constructor( - private actions$: Actions, - private aosEditOnlineService: AosEditOnlineService - ) {} + constructor(private actions$: Actions, private aosEditOnlineService: AosEditOnlineService) {} @Effect({ dispatch: false }) openOffice$ = this.actions$.pipe( ofType(AOS_ACTION), - map(action => { + map((action) => { if (action.payload) { this.aosEditOnlineService.onActionEditOnlineAos(action.payload); } diff --git a/projects/adf-office-services-ext/src/lib/evaluators.ts b/projects/adf-office-services-ext/src/lib/evaluators.ts index 15d390fe3..42cb801f4 100644 --- a/projects/adf-office-services-ext/src/lib/evaluators.ts +++ b/projects/adf-office-services-ext/src/lib/evaluators.ts @@ -27,11 +27,7 @@ import { RuleContext } from '@alfresco/adf-extensions'; import { getFileExtension, supportedExtensions } from './utils'; export function canOpenWithOffice(context: RuleContext): boolean { - if ( - context.navigation && - context.navigation.url && - context.navigation.url.startsWith('/trashcan') - ) { + if (context.navigation && context.navigation.url && context.navigation.url.startsWith('/trashcan')) { return false; } @@ -70,10 +66,7 @@ export function canOpenWithOffice(context: RuleContext): boolean { } */ - if ( - file.entry.properties['cm:lockType'] === 'WRITE_LOCK' || - file.entry.properties['cm:lockType'] === 'READ_ONLY_LOCK' - ) { + if (file.entry.properties['cm:lockType'] === 'WRITE_LOCK' || file.entry.properties['cm:lockType'] === 'READ_ONLY_LOCK') { return false; } @@ -83,20 +76,12 @@ export function canOpenWithOffice(context: RuleContext): boolean { } // check if record - if ( - file.entry.aspectNames && - (file.entry.aspectNames.includes('rma:declaredRecord') || - file.entry.aspectNames.includes('rma:record')) - ) { + if (file.entry.aspectNames && (file.entry.aspectNames.includes('rma:declaredRecord') || file.entry.aspectNames.includes('rma:record'))) { return false; } // workaround for Shared files - if ( - context.navigation && - context.navigation.url && - context.navigation.url.startsWith('/shared') - ) { + if (context.navigation && context.navigation.url && context.navigation.url.startsWith('/shared')) { if (file.entry.hasOwnProperty('allowableOperationsOnTarget')) { return context.permissions.check(file, ['update'], { target: 'allowableOperationsOnTarget' diff --git a/projects/adf-office-services-ext/src/test.ts b/projects/adf-office-services-ext/src/test.ts index bdee7e324..1b4b59913 100644 --- a/projects/adf-office-services-ext/src/test.ts +++ b/projects/adf-office-services-ext/src/test.ts @@ -28,18 +28,12 @@ import 'zone.js/dist/zone'; import 'zone.js/dist/zone-testing'; import { getTestBed } from '@angular/core/testing'; -import { - BrowserDynamicTestingModule, - platformBrowserDynamicTesting -} from '@angular/platform-browser-dynamic/testing'; +import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; declare const require: any; // First, initialize the Angular testing environment. -getTestBed().initTestEnvironment( - BrowserDynamicTestingModule, - platformBrowserDynamicTesting() -); +getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting()); // Then we find all the tests. const context = require.context('./', true, /\.spec\.ts$/); // And load the modules. diff --git a/src/app/app.component.spec.ts b/src/app/app.component.spec.ts index 13ade46ad..7c0dbc297 100644 --- a/src/app/app.component.spec.ts +++ b/src/app/app.component.spec.ts @@ -28,10 +28,7 @@ import { SetInitialStateAction } from '@alfresco/aca-shared/store'; import { Router } from '@angular/router'; import { TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; -import { - mockRoutesWithoutParentRoute, - mockRoutesWithParentRoute -} from './mock/extension-routes.mock'; +import { mockRoutesWithoutParentRoute, mockRoutesWithParentRoute } from './mock/extension-routes.mock'; describe('AppComponent', () => { let component: AppComponent; @@ -58,37 +55,19 @@ describe('AppComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ - RouterTestingModule.withRoutes([{ path: 'fake-path', children: [] }]) - ] + imports: [RouterTestingModule.withRoutes([{ path: 'fake-path', children: [] }])] }); router = TestBed.inject(Router); - component = new AppComponent( - null, - router, - null, - storeMock, - configMock, - null, - null, - null, - null, - null, - null, - null, - storageMock - ); + component = new AppComponent(null, router, null, storeMock, configMock, null, null, null, null, null, null, null, storageMock); storeMock.dispatch = jasmine.createSpy('dispatch'); }); - it('should setup baseShareUrl as per config', done => { + it('should setup baseShareUrl as per config', (done) => { storeMock.dispatch.and.callFake((action: SetInitialStateAction) => { - expect(action.payload.sharedUrl).toBe( - 'http://localhost:4200/#/preview/s/' - ); + expect(action.payload.sharedUrl).toBe('http://localhost:4200/#/preview/s/'); done(); }); @@ -98,44 +77,32 @@ describe('AppComponent', () => { describe('onFileUploadedError', () => { it('should dispatch 403 error message', () => { component.onFileUploadedError({ error: { status: 403 } } as any); - expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe( - 'APP.MESSAGES.UPLOAD.ERROR.403' - ); + expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe('APP.MESSAGES.UPLOAD.ERROR.403'); }); it('should dispatch 404 error message', () => { component.onFileUploadedError({ error: { status: 404 } } as any); - expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe( - 'APP.MESSAGES.UPLOAD.ERROR.404' - ); + expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe('APP.MESSAGES.UPLOAD.ERROR.404'); }); it('should dispatch 409 error message', () => { component.onFileUploadedError({ error: { status: 409 } } as any); - expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe( - 'APP.MESSAGES.UPLOAD.ERROR.CONFLICT' - ); + expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe('APP.MESSAGES.UPLOAD.ERROR.CONFLICT'); }); it('should dispatch 500 error message', () => { component.onFileUploadedError({ error: { status: 500 } } as any); - expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe( - 'APP.MESSAGES.UPLOAD.ERROR.500' - ); + expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe('APP.MESSAGES.UPLOAD.ERROR.500'); }); it('should dispatch 504 error message', () => { component.onFileUploadedError({ error: { status: 504 } } as any); - expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe( - 'APP.MESSAGES.UPLOAD.ERROR.504' - ); + expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe('APP.MESSAGES.UPLOAD.ERROR.504'); }); it('should dispatch generic error message', () => { component.onFileUploadedError({ error: { status: 999 } } as any); - expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe( - 'APP.MESSAGES.UPLOAD.ERROR.GENERIC' - ); + expect(storeMock.dispatch['calls'].argsFor(0)[0].payload).toBe('APP.MESSAGES.UPLOAD.ERROR.GENERIC'); }); }); diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 7048e9fb8..1ff2451ac 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -47,12 +47,7 @@ import { SetRepositoryInfoAction } from '@alfresco/aca-shared/store'; import { filter, takeUntil } from 'rxjs/operators'; -import { - AppExtensionService, - AppService, - ContentApiService, - ExtensionRoute -} from '@alfresco/aca-shared'; +import { AppExtensionService, AppService, ContentApiService, ExtensionRoute } from '@alfresco/aca-shared'; import { DiscoveryEntry, GroupsApi, Group } from '@alfresco/js-api'; import { Subject } from 'rxjs'; import { INITIAL_APP_STATE } from './store/initial-state'; @@ -83,37 +78,29 @@ export class AppComponent implements OnInit, OnDestroy { ) {} ngOnInit() { - this.alfrescoApiService - .getInstance() - .on('error', (error: { status: number }) => { - if (error.status === 401) { - if (!this.authenticationService.isLoggedIn()) { - this.store.dispatch(new CloseModalDialogsAction()); + this.alfrescoApiService.getInstance().on('error', (error: { status: number }) => { + if (error.status === 401) { + if (!this.authenticationService.isLoggedIn()) { + this.store.dispatch(new CloseModalDialogsAction()); - let redirectUrl = this.route.snapshot.queryParams['redirectUrl']; - if (!redirectUrl) { - redirectUrl = this.router.url; - } - - this.router.navigate(['/login'], { - queryParams: { redirectUrl: redirectUrl } - }); + let redirectUrl = this.route.snapshot.queryParams['redirectUrl']; + if (!redirectUrl) { + redirectUrl = this.router.url; } + + this.router.navigate(['/login'], { + queryParams: { redirectUrl: redirectUrl } + }); } - }); + } + }); this.loadAppSettings(); const { router, pageTitle } = this; this.router.events - .pipe( - filter( - event => - event instanceof ActivationEnd && - event.snapshot.children.length === 0 - ) - ) + .pipe(filter((event) => event instanceof ActivationEnd && event.snapshot.children.length === 0)) .subscribe((event: ActivationEnd) => { const snapshot: any = event.snapshot || {}; const data: any = snapshot.data || {}; @@ -126,24 +113,18 @@ export class AppComponent implements OnInit, OnDestroy { const extensionRoutes = this.extensions.getApplicationRoutes(); this.mapExtensionRoutes(extensionRoutes); - this.uploadService.fileUploadError.subscribe(error => - this.onFileUploadedError(error) - ); + this.uploadService.fileUploadError.subscribe((error) => this.onFileUploadedError(error)); - this.sharedLinksApiService.error - .pipe(takeUntil(this.onDestroy$)) - .subscribe((err: { message: string }) => { - this.store.dispatch(new SnackbarErrorAction(err.message)); - }); + this.sharedLinksApiService.error.pipe(takeUntil(this.onDestroy$)).subscribe((err: { message: string }) => { + this.store.dispatch(new SnackbarErrorAction(err.message)); + }); - this.appService.ready$ - .pipe(takeUntil(this.onDestroy$)) - .subscribe(isReady => { - if (isReady) { - this.loadRepositoryStatus(); - this.loadUserProfile(); - } - }); + this.appService.ready$.pipe(takeUntil(this.onDestroy$)).subscribe((isReady) => { + if (isReady) { + this.loadRepositoryStatus(); + this.loadUserProfile(); + } + }); } ngOnDestroy() { @@ -152,13 +133,9 @@ export class AppComponent implements OnInit, OnDestroy { } private loadRepositoryStatus() { - this.contentApi - .getRepositoryInformation() - .subscribe((response: DiscoveryEntry) => { - this.store.dispatch( - new SetRepositoryInfoAction(response.entry.repository) - ); - }); + this.contentApi.getRepositoryInformation().subscribe((response: DiscoveryEntry) => { + this.store.dispatch(new SetRepositoryInfoAction(response.entry.repository)); + }); } private extensionRouteHasChild(route: ExtensionRoute): boolean { @@ -174,9 +151,7 @@ export class AppComponent implements OnInit, OnDestroy { const routesWithoutParent = []; extensionRoutes.forEach((extensionRoute: ExtensionRoute) => { if (this.extensionRouteHasChild(extensionRoute)) { - const routeIndex = this.router.config.findIndex( - route => route.path === extensionRoute.parentRoute - ); + const routeIndex = this.router.config.findIndex((route) => route.path === extensionRoute.parentRoute); this.convertExtensionRouteToRoute(extensionRoute); this.router.config[routeIndex].children.unshift(extensionRoute); } else { @@ -193,13 +168,11 @@ export class AppComponent implements OnInit, OnDestroy { const groups: Group[] = []; if (paging && paging.list && paging.list.entries) { - groups.push(...paging.list.entries.map(obj => obj.entry)); + groups.push(...paging.list.entries.map((obj) => obj.entry)); } - this.contentApi.getPerson('-me-').subscribe(person => { - this.store.dispatch( - new SetUserProfileAction({ person: person.entry, groups }) - ); + this.contentApi.getPerson('-me-').subscribe((person) => { + this.store.dispatch(new SetUserProfileAction({ person: person.entry, groups })); }); } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index e10431aa0..98d7ad446 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -26,17 +26,9 @@ import { BrowserModule, HammerModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { RouterModule, RouteReuseStrategy } from '@angular/router'; -import { - BrowserAnimationsModule, - NoopAnimationsModule -} from '@angular/platform-browser/animations'; +import { BrowserAnimationsModule, NoopAnimationsModule } from '@angular/platform-browser/animations'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; -import { - TRANSLATION_PROVIDER, - CoreModule, - AppConfigService, - DebugAppConfigService -} from '@alfresco/adf-core'; +import { TRANSLATION_PROVIDER, CoreModule, AppConfigService, DebugAppConfigService } from '@alfresco/adf-core'; import { ContentModule } from '@alfresco/adf-content-services'; import { AppRouteReuseStrategy, SharedModule } from '@alfresco/aca-shared'; diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 322ee7118..66d4c8ebf 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -31,11 +31,7 @@ import { FavoriteLibrariesComponent } from './components/favorite-libraries/favo import { SearchResultsComponent } from './components/search/search-results/search-results.component'; import { SearchLibrariesResultsComponent } from './components/search/search-libraries-results/search-libraries-results.component'; import { LoginComponent } from './components/login/login.component'; -import { - AppSharedRuleGuard, - GenericErrorComponent, - ExtensionsDataLoaderGuard -} from '@alfresco/aca-shared'; +import { AppSharedRuleGuard, GenericErrorComponent, ExtensionsDataLoaderGuard } from '@alfresco/aca-shared'; import { AuthGuardEcm } from '@alfresco/adf-core'; import { FavoritesComponent } from './components/favorites/favorites.component'; import { RecentFilesComponent } from './components/recent-files/recent-files.component'; @@ -51,17 +47,11 @@ export const APP_ROUTES: Routes = [ }, { path: 'settings', - loadChildren: () => - import('./components/settings/settings.module').then( - m => m.AppSettingsModule - ) + loadChildren: () => import('./components/settings/settings.module').then((m) => m.AppSettingsModule) }, { path: 'preview/s/:id', - loadChildren: () => - import('./components/shared-link-view/shared-link-view.module').then( - m => m.AppSharedLinkViewModule - ) + loadChildren: () => import('./components/shared-link-view/shared-link-view.module').then((m) => m.AppSharedLinkViewModule) }, { path: 'view', @@ -73,10 +63,7 @@ export const APP_ROUTES: Routes = [ children: [ { path: '', - loadChildren: () => - import('./components/viewer/viewer.module').then( - m => m.AppViewerModule - ) + loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) } ] } @@ -107,10 +94,7 @@ export const APP_ROUTES: Routes = [ // deprecated, backwards compatibility with ACA 1.8 { path: 'preview/:nodeId', - loadChildren: () => - import('./components/preview/preview.module').then( - m => m.PreviewModule - ), + loadChildren: () => import('./components/preview/preview.module').then((m) => m.PreviewModule), data: { navigateSource: 'personal-files' } @@ -124,10 +108,7 @@ export const APP_ROUTES: Routes = [ data: { navigateSource: 'personal-files' }, - loadChildren: () => - import('./components/viewer/viewer.module').then( - m => m.AppViewerModule - ) + loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) } ] } @@ -147,10 +128,7 @@ export const APP_ROUTES: Routes = [ // deprecated, backwards compatibility with ACA 1.8 { path: 'preview/:nodeId', - loadChildren: () => - import('./components/preview/preview.module').then( - m => m.PreviewModule - ), + loadChildren: () => import('./components/preview/preview.module').then((m) => m.PreviewModule), data: { navigateSource: 'personal-files' } @@ -158,10 +136,7 @@ export const APP_ROUTES: Routes = [ // deprecated, backwards compatibility with ACA 1.8 { path: ':folderId/preview/:nodeId', - loadChildren: () => - import('./components/preview/preview.module').then( - m => m.PreviewModule - ), + loadChildren: () => import('./components/preview/preview.module').then((m) => m.PreviewModule), data: { navigateSource: 'personal-files' } @@ -175,10 +150,7 @@ export const APP_ROUTES: Routes = [ data: { navigateSource: 'personal-files' }, - loadChildren: () => - import('./components/viewer/viewer.module').then( - m => m.AppViewerModule - ) + loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) } ] } @@ -211,10 +183,7 @@ export const APP_ROUTES: Routes = [ // deprecated, backwards compatibility with ACA 1.8 { path: 'preview/:nodeId', - loadChildren: () => - import('./components/preview/preview.module').then( - m => m.PreviewModule - ), + loadChildren: () => import('./components/preview/preview.module').then((m) => m.PreviewModule), data: { navigateSource: 'libraries' } @@ -228,10 +197,7 @@ export const APP_ROUTES: Routes = [ data: { navigateSource: 'libraries' }, - loadChildren: () => - import('./components/viewer/viewer.module').then( - m => m.AppViewerModule - ) + loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) } ] } @@ -275,10 +241,7 @@ export const APP_ROUTES: Routes = [ data: { navigateSource: 'libraries' }, - loadChildren: () => - import('./components/viewer/viewer.module').then( - m => m.AppViewerModule - ) + loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) } ] } @@ -303,10 +266,7 @@ export const APP_ROUTES: Routes = [ // deprecated, backwards compatibility with ACA 1.8 { path: 'preview/:nodeId', - loadChildren: () => - import('./components/preview/preview.module').then( - m => m.PreviewModule - ), + loadChildren: () => import('./components/preview/preview.module').then((m) => m.PreviewModule), data: { navigateSource: 'favorites' } @@ -320,10 +280,7 @@ export const APP_ROUTES: Routes = [ data: { navigateSource: 'favorites' }, - loadChildren: () => - import('./components/viewer/viewer.module').then( - m => m.AppViewerModule - ) + loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) } ] } @@ -347,10 +304,7 @@ export const APP_ROUTES: Routes = [ // deprecated, backwards compatibility with ACA 1.8 { path: 'preview/:nodeId', - loadChildren: () => - import('./components/preview/preview.module').then( - m => m.PreviewModule - ), + loadChildren: () => import('./components/preview/preview.module').then((m) => m.PreviewModule), data: { navigateSource: 'recent-files' } @@ -364,10 +318,7 @@ export const APP_ROUTES: Routes = [ data: { navigateSource: 'recent-files' }, - loadChildren: () => - import('./components/viewer/viewer.module').then( - m => m.AppViewerModule - ) + loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) } ] } @@ -389,10 +340,7 @@ export const APP_ROUTES: Routes = [ // deprecated, backwards compatibility with ACA 1.8 { path: 'preview/:nodeId', - loadChildren: () => - import('./components/preview/preview.module').then( - m => m.PreviewModule - ), + loadChildren: () => import('./components/preview/preview.module').then((m) => m.PreviewModule), data: { navigateSource: 'shared' } @@ -406,10 +354,7 @@ export const APP_ROUTES: Routes = [ data: { navigateSource: 'shared' }, - loadChildren: () => - import('./components/viewer/viewer.module').then( - m => m.AppViewerModule - ) + loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) } ] } @@ -419,15 +364,11 @@ export const APP_ROUTES: Routes = [ }, { path: 'trashcan', - loadChildren: () => - import('./components/trashcan/trashcan.module').then( - m => m.AppTrashcanModule - ) + loadChildren: () => import('./components/trashcan/trashcan.module').then((m) => m.AppTrashcanModule) }, { path: 'about', - loadChildren: () => - import('./components/about/about.module').then(m => m.AboutModule) + loadChildren: () => import('./components/about/about.module').then((m) => m.AboutModule) }, { path: 'search', @@ -442,10 +383,7 @@ export const APP_ROUTES: Routes = [ // deprecated, backwards compatibility with ACA 1.8 { path: 'preview/:nodeId', - loadChildren: () => - import('./components/preview/preview.module').then( - m => m.PreviewModule - ), + loadChildren: () => import('./components/preview/preview.module').then((m) => m.PreviewModule), data: { navigateSource: 'search' } @@ -459,10 +397,7 @@ export const APP_ROUTES: Routes = [ data: { navigateSource: 'search' }, - loadChildren: () => - import('./components/viewer/viewer.module').then( - m => m.AppViewerModule - ) + loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) } ] } @@ -487,10 +422,7 @@ export const APP_ROUTES: Routes = [ data: { navigateSource: 'search' }, - loadChildren: () => - import('./components/viewer/viewer.module').then( - m => m.AppViewerModule - ) + loadChildren: () => import('./components/viewer/viewer.module').then((m) => m.AppViewerModule) } ] } diff --git a/src/app/components/about/about.component.ts b/src/app/components/about/about.component.ts index a77e53186..8754cd392 100644 --- a/src/app/components/about/about.component.ts +++ b/src/app/components/about/about.component.ts @@ -48,15 +48,12 @@ export class AboutComponent implements OnInit { adfVersion = ''; appVersion = version; - constructor( - private contentApi: ContentApiService, - appExtensions: AppExtensionService - ) { + constructor(private contentApi: ContentApiService, appExtensions: AppExtensionService) { this.extensions$ = appExtensions.references$; } ngOnInit() { - this.dependencyEntries = Object.keys(dependencies).map(key => { + this.dependencyEntries = Object.keys(dependencies).map((key) => { if (key === '@alfresco/adf-core') { this.adfVersion = dependencies[key].split('-')[0]; const adfCurrentCommit = dependencies[key].split('-')[1] || ''; @@ -70,11 +67,11 @@ export class AboutComponent implements OnInit { this.contentApi .getRepositoryInformation() - .pipe(map(node => node.entry.repository)) - .subscribe(repository => { + .pipe(map((node) => node.entry.repository)) + .subscribe((repository) => { this.repository = repository; - this.statusEntries = Object.keys(repository.status).map(key => { + this.statusEntries = Object.keys(repository.status).map((key) => { return { property: key, value: repository.status[key] @@ -82,7 +79,7 @@ export class AboutComponent implements OnInit { }); if (repository.license) { - this.licenseEntries = Object.keys(repository.license).map(key => { + this.licenseEntries = Object.keys(repository.license).map((key) => { return { property: key, value: repository.license[key] diff --git a/src/app/components/about/about.module.ts b/src/app/components/about/about.module.ts index b5b80f050..f062cb782 100644 --- a/src/app/components/about/about.module.ts +++ b/src/app/components/about/about.module.ts @@ -47,20 +47,7 @@ const routes: Routes = [ ]; @NgModule({ - imports: [ - CommonModule, - CoreModule.forChild(), - RouterModule.forChild(routes), - AppLayoutModule, - MatTableModule - ], - declarations: [ - AboutComponent, - PackageListComponent, - ExtensionListComponent, - StatusListComponent, - ModuleListComponent, - LicenseListComponent - ] + imports: [CommonModule, CoreModule.forChild(), RouterModule.forChild(routes), AppLayoutModule, MatTableModule], + declarations: [AboutComponent, PackageListComponent, ExtensionListComponent, StatusListComponent, ModuleListComponent, LicenseListComponent] }) export class AboutModule {} diff --git a/src/app/components/about/extension-list/extension-list.component.ts b/src/app/components/about/extension-list/extension-list.component.ts index ac74173e8..ae5643550 100644 --- a/src/app/components/about/extension-list/extension-list.component.ts +++ b/src/app/components/about/extension-list/extension-list.component.ts @@ -23,12 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Component, - ViewEncapsulation, - ChangeDetectionStrategy, - Input -} from '@angular/core'; +import { Component, ViewEncapsulation, ChangeDetectionStrategy, Input } from '@angular/core'; import { ExtensionRef } from '@alfresco/adf-extensions'; @Component({ @@ -71,7 +66,7 @@ export class ExtensionListComponent { } ]; - displayedColumns = this.columns.map(x => x.columnDef); + displayedColumns = this.columns.map((x) => x.columnDef); @Input() data: Array = []; diff --git a/src/app/components/about/license-list/license-list.component.ts b/src/app/components/about/license-list/license-list.component.ts index 5282a34de..2f0721e16 100644 --- a/src/app/components/about/license-list/license-list.component.ts +++ b/src/app/components/about/license-list/license-list.component.ts @@ -28,12 +28,7 @@ export interface LicenseData { value: string; } -import { - Component, - ViewEncapsulation, - ChangeDetectionStrategy, - Input -} from '@angular/core'; +import { Component, ViewEncapsulation, ChangeDetectionStrategy, Input } from '@angular/core'; @Component({ selector: 'app-license-list', @@ -55,7 +50,7 @@ export class LicenseListComponent { } ]; - displayedColumns = this.columns.map(x => x.columnDef); + displayedColumns = this.columns.map((x) => x.columnDef); @Input() data: Array = []; diff --git a/src/app/components/about/module-list/module-list.component.ts b/src/app/components/about/module-list/module-list.component.ts index 3db1b7c30..59a1636f3 100644 --- a/src/app/components/about/module-list/module-list.component.ts +++ b/src/app/components/about/module-list/module-list.component.ts @@ -23,12 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Component, - ViewEncapsulation, - ChangeDetectionStrategy, - Input -} from '@angular/core'; +import { Component, ViewEncapsulation, ChangeDetectionStrategy, Input } from '@angular/core'; import { ModuleInfo } from '@alfresco/js-api'; @Component({ @@ -56,7 +51,7 @@ export class ModuleListComponent { } ]; - displayedColumns = this.columns.map(x => x.columnDef); + displayedColumns = this.columns.map((x) => x.columnDef); @Input() data: Array = []; diff --git a/src/app/components/about/package-list/package-list.component.ts b/src/app/components/about/package-list/package-list.component.ts index a499258ab..ad97012e6 100644 --- a/src/app/components/about/package-list/package-list.component.ts +++ b/src/app/components/about/package-list/package-list.component.ts @@ -23,12 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Component, - ViewEncapsulation, - ChangeDetectionStrategy, - Input -} from '@angular/core'; +import { Component, ViewEncapsulation, ChangeDetectionStrategy, Input } from '@angular/core'; export interface PackageInfo { name: string; @@ -55,7 +50,7 @@ export class PackageListComponent { } ]; - displayedColumns = this.columns.map(x => x.columnDef); + displayedColumns = this.columns.map((x) => x.columnDef); @Input() data: Array = []; diff --git a/src/app/components/about/status-list/status-list.component.ts b/src/app/components/about/status-list/status-list.component.ts index f2c7b9982..a2a55e680 100644 --- a/src/app/components/about/status-list/status-list.component.ts +++ b/src/app/components/about/status-list/status-list.component.ts @@ -23,12 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Component, - ViewEncapsulation, - ChangeDetectionStrategy, - Input -} from '@angular/core'; +import { Component, ViewEncapsulation, ChangeDetectionStrategy, Input } from '@angular/core'; export interface StatusData { property: string; @@ -55,7 +50,7 @@ export class StatusListComponent { } ]; - displayedColumns = this.columns.map(x => x.columnDef); + displayedColumns = this.columns.map((x) => x.columnDef); @Input() data: Array = []; diff --git a/src/app/components/common/common.module.ts b/src/app/components/common/common.module.ts index 41e6289e8..e92a2c295 100644 --- a/src/app/components/common/common.module.ts +++ b/src/app/components/common/common.module.ts @@ -34,25 +34,8 @@ import { LanguagePickerComponent } from './language-picker/language-picker.compo import { LogoutComponent } from './logout/logout.component'; @NgModule({ - imports: [ - CommonModule, - CoreModule.forChild(), - ExtensionsModule, - GenericErrorModule - ], - declarations: [ - LocationLinkComponent, - ToggleSharedComponent, - LanguagePickerComponent, - LogoutComponent - ], - exports: [ - ExtensionsModule, - LocationLinkComponent, - GenericErrorModule, - ToggleSharedComponent, - LanguagePickerComponent, - LogoutComponent - ] + imports: [CommonModule, CoreModule.forChild(), ExtensionsModule, GenericErrorModule], + declarations: [LocationLinkComponent, ToggleSharedComponent, LanguagePickerComponent, LogoutComponent], + exports: [ExtensionsModule, LocationLinkComponent, GenericErrorModule, ToggleSharedComponent, LanguagePickerComponent, LogoutComponent] }) export class AppCommonModule {} diff --git a/src/app/components/common/location-link/location-link.component.ts b/src/app/components/common/location-link/location-link.component.ts index 20b18122b..e84733897 100644 --- a/src/app/components/common/location-link/location-link.component.ts +++ b/src/app/components/common/location-link/location-link.component.ts @@ -23,14 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Component, - Input, - ChangeDetectionStrategy, - OnInit, - ViewEncapsulation, - HostListener -} from '@angular/core'; +import { Component, Input, ChangeDetectionStrategy, OnInit, ViewEncapsulation, HostListener } from '@angular/core'; import { PathInfo, MinimalNodeEntity } from '@alfresco/js-api'; import { Observable, BehaviorSubject, of } from 'rxjs'; @@ -42,12 +35,7 @@ import { TranslationService } from '@alfresco/adf-core'; @Component({ selector: 'aca-location-link', template: ` - + {{ displayText | async | translate }} `, @@ -79,11 +67,7 @@ export class LocationLinkComponent implements OnInit { this.getTooltip(this._path); } - constructor( - private store: Store, - private contentApi: ContentApiService, - private translationService: TranslationService - ) {} + constructor(private store: Store, private contentApi: ContentApiService, private translationService: TranslationService) {} goToLocation() { if (this.context) { @@ -110,7 +94,7 @@ export class LocationLinkComponent implements OnInit { // todo: review once 5.2.3 is out private getDisplayText(path: PathInfo): Observable { - const elements = path.elements.map(e => e.name); + const elements = path.elements.map((e) => e.name); // for admin users if (elements.length === 1 && elements[0] === 'Company Home') { @@ -118,11 +102,7 @@ export class LocationLinkComponent implements OnInit { } // for non-admin users - if ( - elements.length === 3 && - elements[0] === 'Company Home' && - elements[1] === 'User Homes' - ) { + if (elements.length === 3 && elements[0] === 'Company Home' && elements[1] === 'User Homes') { return of('APP.BROWSE.PERSONAL.TITLE'); } @@ -131,12 +111,10 @@ export class LocationLinkComponent implements OnInit { if (result === 'documentLibrary') { const fragment = path.elements[path.elements.length - 2]; - return new Observable(observer => { + return new Observable((observer) => { this.contentApi.getNodeInfo(fragment.id).subscribe( - node => { - observer.next( - node.properties['cm:title'] || node.name || fragment.name - ); + (node) => { + observer.next(node.properties['cm:title'] || node.name || fragment.name); observer.complete(); }, () => { @@ -158,13 +136,9 @@ export class LocationLinkComponent implements OnInit { let result: string = null; - const elements = path.elements.map(e => Object.assign({}, e)); - const personalFiles = this.translationService.instant( - 'APP.BROWSE.PERSONAL.TITLE' - ); - const fileLibraries = this.translationService.instant( - 'APP.BROWSE.LIBRARIES.TITLE' - ); + const elements = path.elements.map((e) => Object.assign({}, e)); + const personalFiles = this.translationService.instant('APP.BROWSE.PERSONAL.TITLE'); + const fileLibraries = this.translationService.instant('APP.BROWSE.LIBRARIES.TITLE'); if (elements[0].name === 'Company Home') { elements[0].name = personalFiles; @@ -173,14 +147,13 @@ export class LocationLinkComponent implements OnInit { if (elements[1].name === 'Sites') { const fragment = elements[2]; this.contentApi.getNodeInfo(fragment.id).subscribe( - node => { + (node) => { elements.splice(0, 2); - elements[0].name = - node.properties['cm:title'] || node.name || fragment.name; + elements[0].name = node.properties['cm:title'] || node.name || fragment.name; elements.splice(1, 1); elements.unshift({ id: null, name: fileLibraries }); - result = elements.map(e => e.name).join('/'); + result = elements.map((e) => e.name).join('/'); this.nodeLocation$.next(result); }, () => { @@ -188,7 +161,7 @@ export class LocationLinkComponent implements OnInit { elements.unshift({ id: null, name: fileLibraries }); elements.splice(2, 1); - result = elements.map(e => e.name).join('/'); + result = elements.map((e) => e.name).join('/'); this.nodeLocation$.next(result); } ); @@ -201,7 +174,7 @@ export class LocationLinkComponent implements OnInit { } } - result = elements.map(e => e.name).join('/'); + result = elements.map((e) => e.name).join('/'); this.nodeLocation$.next(result); } } diff --git a/src/app/components/common/logout/logout.component.spec.ts b/src/app/components/common/logout/logout.component.spec.ts index 1b2f17e67..bcf87fe68 100644 --- a/src/app/components/common/logout/logout.component.spec.ts +++ b/src/app/components/common/logout/logout.component.spec.ts @@ -24,11 +24,7 @@ */ import { TestBed, ComponentFixture } from '@angular/core/testing'; -import { - TranslateModule, - TranslateLoader, - TranslateFakeLoader -} from '@ngx-translate/core'; +import { TranslateModule, TranslateLoader, TranslateFakeLoader } from '@ngx-translate/core'; import { LogoutComponent } from './logout.component'; import { Store } from '@ngrx/store'; import { SetSelectedNodesAction } from '@alfresco/aca-shared/store'; diff --git a/src/app/components/common/toggle-shared/toggle-shared.component.spec.ts b/src/app/components/common/toggle-shared/toggle-shared.component.spec.ts index 7b0a38253..65754048b 100644 --- a/src/app/components/common/toggle-shared/toggle-shared.component.spec.ts +++ b/src/app/components/common/toggle-shared/toggle-shared.component.spec.ts @@ -45,10 +45,10 @@ describe('ToggleSharedComponent', () => { component = new ToggleSharedComponent(storeMock); }); - it('should get Store selection entry on initialization', done => { + it('should get Store selection entry on initialization', (done) => { component.ngOnInit(); - component.selection$.subscribe(selection => { + component.selection$.subscribe((selection) => { expect(selection.first.entry).toEqual(entry); done(); }); diff --git a/src/app/components/common/toggle-shared/toggle-shared.component.ts b/src/app/components/common/toggle-shared/toggle-shared.component.ts index 2aef33132..af7011ff9 100644 --- a/src/app/components/common/toggle-shared/toggle-shared.component.ts +++ b/src/app/components/common/toggle-shared/toggle-shared.component.ts @@ -27,11 +27,7 @@ import { Component, OnInit, Input } from '@angular/core'; import { Observable } from 'rxjs'; import { Store } from '@ngrx/store'; import { SelectionState } from '@alfresco/adf-extensions'; -import { - AppStore, - ShareNodeAction, - getAppSelection -} from '@alfresco/aca-shared/store'; +import { AppStore, ShareNodeAction, getAppSelection } from '@alfresco/aca-shared/store'; @Component({ selector: 'app-toggle-shared', @@ -50,20 +46,11 @@ export class ToggleSharedComponent implements OnInit { isShared(selection: SelectionState) { // workaround for shared files - if ( - selection.first && - selection.first.entry && - (selection.first.entry as any).sharedByUser - ) { + if (selection.first && selection.first.entry && (selection.first.entry as any).sharedByUser) { return true; } - return ( - selection.first && - selection.first.entry && - selection.first.entry.properties && - !!selection.first.entry.properties['qshare:sharedId'] - ); + return selection.first && selection.first.entry && selection.first.entry.properties && !!selection.first.entry.properties['qshare:sharedId']; } editSharedNode(selection: SelectionState) { diff --git a/src/app/components/context-menu/context-menu-item.component.spec.ts b/src/app/components/context-menu/context-menu-item.component.spec.ts index 668fbb330..55f2933e6 100644 --- a/src/app/components/context-menu/context-menu-item.component.spec.ts +++ b/src/app/components/context-menu/context-menu-item.component.spec.ts @@ -27,11 +27,7 @@ import { TestBed, ComponentFixture } from '@angular/core/testing'; import { AppTestingModule } from '../../testing/app-testing.module'; import { ContextMenuItemComponent } from './context-menu-item.component'; import { ContextMenuModule } from './context-menu.module'; -import { - TranslateModule, - TranslateLoader, - TranslateFakeLoader -} from '@ngx-translate/core'; +import { TranslateModule, TranslateLoader, TranslateFakeLoader } from '@ngx-translate/core'; import { AppExtensionService } from '@alfresco/aca-shared'; describe('ContextMenuComponent', () => { @@ -75,9 +71,7 @@ describe('ContextMenuComponent', () => { fixture.detectChanges(); const buttonElement = fixture.nativeElement.querySelector('button'); - expect(buttonElement.querySelector('span').innerText.trim()).toBe( - contextItem.title - ); + expect(buttonElement.querySelector('span').innerText.trim()).toBe(contextItem.title); }); it('should not run action when entry has no click attribute defined', () => { @@ -86,9 +80,7 @@ describe('ContextMenuComponent', () => { component.actionRef = contextItem; fixture.detectChanges(); - fixture.nativeElement - .querySelector('#action-button') - .dispatchEvent(new MouseEvent('click')); + fixture.nativeElement.querySelector('#action-button').dispatchEvent(new MouseEvent('click')); expect(extensionsService.runActionById).not.toHaveBeenCalled(); }); @@ -98,12 +90,8 @@ describe('ContextMenuComponent', () => { component.actionRef = contextItem; fixture.detectChanges(); - fixture.nativeElement - .querySelector('#action-button') - .dispatchEvent(new MouseEvent('click')); + fixture.nativeElement.querySelector('#action-button').dispatchEvent(new MouseEvent('click')); - expect(extensionsService.runActionById).toHaveBeenCalledWith( - contextItem.actions.click - ); + expect(extensionsService.runActionById).toHaveBeenCalledWith(contextItem.actions.click); }); }); diff --git a/src/app/components/context-menu/context-menu-outside-event.directive.ts b/src/app/components/context-menu/context-menu-outside-event.directive.ts index d432295f6..1ff8bf047 100644 --- a/src/app/components/context-menu/context-menu-outside-event.directive.ts +++ b/src/app/components/context-menu/context-menu-outside-event.directive.ts @@ -23,13 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Directive, - Output, - EventEmitter, - OnInit, - OnDestroy -} from '@angular/core'; +import { Directive, Output, EventEmitter, OnInit, OnDestroy } from '@angular/core'; import { fromEvent, Subscription } from 'rxjs'; import { filter } from 'rxjs/operators'; @@ -47,13 +41,13 @@ export class OutsideEventDirective implements OnInit, OnDestroy { ngOnInit() { this.subscriptions = this.subscriptions.concat([ fromEvent(document.body, 'click') - .pipe(filter(event => !this.findAncestor(event.target as Element))) + .pipe(filter((event) => !this.findAncestor(event.target as Element))) .subscribe(() => this.clickOutside.next()) ]); } ngOnDestroy() { - this.subscriptions.forEach(subscription => subscription.unsubscribe()); + this.subscriptions.forEach((subscription) => subscription.unsubscribe()); this.subscriptions = []; } diff --git a/src/app/components/context-menu/context-menu.component.spec.ts b/src/app/components/context-menu/context-menu.component.spec.ts index f6c1fe157..b0e43b695 100644 --- a/src/app/components/context-menu/context-menu.component.spec.ts +++ b/src/app/components/context-menu/context-menu.component.spec.ts @@ -23,21 +23,12 @@ * along with Alfresco. If not, see . */ -import { - TestBed, - ComponentFixture, - fakeAsync, - tick -} from '@angular/core/testing'; +import { TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing'; import { AppTestingModule } from '../../testing/app-testing.module'; import { ContextMenuComponent } from './context-menu.component'; import { ContextMenuModule } from './context-menu.module'; import { ContextMenuOverlayRef } from './context-menu-overlay'; -import { - TranslateModule, - TranslateLoader, - TranslateFakeLoader -} from '@ngx-translate/core'; +import { TranslateModule, TranslateLoader, TranslateFakeLoader } from '@ngx-translate/core'; import { of } from 'rxjs'; import { Store } from '@ngrx/store'; @@ -90,9 +81,7 @@ describe('ContextMenuComponent', () => { contextMenuOverlayRef = TestBed.inject(ContextMenuOverlayRef); extensionsService = TestBed.inject(AppExtensionService); - spyOn(extensionsService, 'getAllowedContextMenuActions').and.returnValue([ - contextItem - ]); + spyOn(extensionsService, 'getAllowedContextMenuActions').and.returnValue([contextItem]); fixture.detectChanges(); }); @@ -106,14 +95,10 @@ describe('ContextMenuComponent', () => { component.ngAfterViewInit(); tick(500); - const contextMenuElements = document.body - .querySelector('.aca-context-menu') - .querySelectorAll('button'); + const contextMenuElements = document.body.querySelector('.aca-context-menu').querySelectorAll('button'); expect(contextMenuElements.length).toBe(1); - expect(contextMenuElements[0].querySelector('span').innerText).toBe( - contextItem.title - ); + expect(contextMenuElements[0].querySelector('span').innerText).toBe(contextItem.title); })); it('should run action with provided action id', fakeAsync(() => { @@ -121,8 +106,6 @@ describe('ContextMenuComponent', () => { component.runAction(contextItem.actions.click); - expect(extensionsService.runActionById).toHaveBeenCalledWith( - contextItem.actions.click - ); + expect(extensionsService.runActionById).toHaveBeenCalledWith(contextItem.actions.click); })); }); diff --git a/src/app/components/context-menu/context-menu.component.ts b/src/app/components/context-menu/context-menu.component.ts index 0f112317c..fa5fda00e 100644 --- a/src/app/components/context-menu/context-menu.component.ts +++ b/src/app/components/context-menu/context-menu.component.ts @@ -23,16 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Component, - ViewEncapsulation, - OnInit, - OnDestroy, - HostListener, - ViewChild, - AfterViewInit, - Inject -} from '@angular/core'; +import { Component, ViewEncapsulation, OnInit, OnDestroy, HostListener, ViewChild, AfterViewInit, Inject } from '@angular/core'; import { MatMenuTrigger } from '@angular/material/menu'; import { AppStore, getAppSelection } from '@alfresco/aca-shared/store'; import { Store } from '@ngrx/store'; @@ -95,7 +86,7 @@ export class ContextMenuComponent implements OnInit, OnDestroy, AfterViewInit { this.store .select(getAppSelection) .pipe(takeUntil(this.onDestroy$)) - .subscribe(selection => { + .subscribe((selection) => { if (selection.count) { this.actions = this.extensions.getAllowedContextMenuActions(); } diff --git a/src/app/components/context-menu/context-menu.module.ts b/src/app/components/context-menu/context-menu.module.ts index b9895157d..627a405f8 100644 --- a/src/app/components/context-menu/context-menu.module.ts +++ b/src/app/components/context-menu/context-menu.module.ts @@ -49,16 +49,7 @@ import { ContextActionsModule } from '@alfresco/aca-shared'; ExtensionsModule, ContextActionsModule ], - declarations: [ - ContextMenuComponent, - ContextMenuItemComponent, - OutsideEventDirective - ], - exports: [ - OutsideEventDirective, - ContextMenuComponent, - ContextMenuItemComponent, - ContextActionsModule - ] + declarations: [ContextMenuComponent, ContextMenuItemComponent, OutsideEventDirective], + exports: [OutsideEventDirective, ContextMenuComponent, ContextMenuItemComponent, ContextActionsModule] }) export class ContextMenuModule {} diff --git a/src/app/components/context-menu/context-menu.service.spec.ts b/src/app/components/context-menu/context-menu.service.spec.ts index 2f118a48c..63f05b2e1 100644 --- a/src/app/components/context-menu/context-menu.service.spec.ts +++ b/src/app/components/context-menu/context-menu.service.spec.ts @@ -50,16 +50,8 @@ describe('ContextMenuService', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ - TranslateModule.forRoot(), - CoreModule.forRoot(), - ContextMenuModule - ], - providers: [ - Overlay, - { provide: Store, useValue: { select: () => of() } }, - UserPreferencesService - ] + imports: [TranslateModule.forRoot(), CoreModule.forRoot(), ContextMenuModule], + providers: [Overlay, { provide: Store, useValue: { select: () => of() } }, UserPreferencesService] }); injector = TestBed.inject(Injector); @@ -68,11 +60,7 @@ describe('ContextMenuService', () => { }); it('should create a custom overlay', () => { - contextMenuService = new ContextMenuService( - injector, - overlay, - userPreferencesService - ); + contextMenuService = new ContextMenuService(injector, overlay, userPreferencesService); contextMenuService.open(overlayConfig); @@ -80,11 +68,7 @@ describe('ContextMenuService', () => { }); it('should render component', () => { - contextMenuService = new ContextMenuService( - injector, - overlay, - userPreferencesService - ); + contextMenuService = new ContextMenuService(injector, overlay, userPreferencesService); contextMenuService.open(overlayConfig); @@ -92,11 +76,7 @@ describe('ContextMenuService', () => { }); it('should have default LTR direction value', () => { - contextMenuService = new ContextMenuService( - injector, - overlay, - userPreferencesService - ); + contextMenuService = new ContextMenuService(injector, overlay, userPreferencesService); contextMenuService.open(overlayConfig); @@ -106,11 +86,7 @@ describe('ContextMenuService', () => { it('should change direction on textOrientation event', () => { spyOn(userPreferencesService, 'select').and.returnValue(of('rtl')); - contextMenuService = new ContextMenuService( - injector, - overlay, - userPreferencesService - ); + contextMenuService = new ContextMenuService(injector, overlay, userPreferencesService); contextMenuService.open(overlayConfig); diff --git a/src/app/components/context-menu/context-menu.service.ts b/src/app/components/context-menu/context-menu.service.ts index 38f685028..64e079220 100644 --- a/src/app/components/context-menu/context-menu.service.ts +++ b/src/app/components/context-menu/context-menu.service.ts @@ -39,16 +39,10 @@ import { CONTEXT_MENU_DIRECTION } from './direction.token'; export class ContextMenuService { private direction: Directionality; - constructor( - private injector: Injector, - private overlay: Overlay, - private userPreferenceService: UserPreferencesService - ) { - this.userPreferenceService - .select('textOrientation') - .subscribe(textOrientation => { - this.direction = textOrientation; - }); + constructor(private injector: Injector, private overlay: Overlay, private userPreferenceService: UserPreferencesService) { + this.userPreferenceService.select('textOrientation').subscribe((textOrientation) => { + this.direction = textOrientation; + }); } open(config: ContextmenuOverlayConfig): ContextMenuOverlayRef { @@ -65,27 +59,16 @@ export class ContextMenuService { return this.overlay.create(overlayConfig); } - private attachDialogContainer( - overlay: OverlayRef, - contextmenuOverlayRef: ContextMenuOverlayRef - ): ContextMenuComponent { + private attachDialogContainer(overlay: OverlayRef, contextmenuOverlayRef: ContextMenuOverlayRef): ContextMenuComponent { const injector = this.createInjector(contextmenuOverlayRef); - const containerPortal = new ComponentPortal( - ContextMenuComponent, - null, - injector - ); - const containerRef: ComponentRef = overlay.attach( - containerPortal - ); + const containerPortal = new ComponentPortal(ContextMenuComponent, null, injector); + const containerRef: ComponentRef = overlay.attach(containerPortal); return containerRef.instance; } - private createInjector( - contextmenuOverlayRef: ContextMenuOverlayRef - ): PortalInjector { + private createInjector(contextmenuOverlayRef: ContextMenuOverlayRef): PortalInjector { const injectionTokens = new WeakMap(); injectionTokens.set(ContextMenuOverlayRef, contextmenuOverlayRef); diff --git a/src/app/components/context-menu/direction.token.ts b/src/app/components/context-menu/direction.token.ts index 4186c92cb..100ebd95b 100644 --- a/src/app/components/context-menu/direction.token.ts +++ b/src/app/components/context-menu/direction.token.ts @@ -25,10 +25,7 @@ import { InjectionToken } from '@angular/core'; -export const CONTEXT_MENU_DIRECTION = new InjectionToken( - 'CONTEXT_MENU_DIRECTION', - { - providedIn: 'root', - factory: () => 'ltr' - } -); +export const CONTEXT_MENU_DIRECTION = new InjectionToken('CONTEXT_MENU_DIRECTION', { + providedIn: 'root', + factory: () => 'ltr' +}); diff --git a/src/app/components/create-menu/create-menu.component.ts b/src/app/components/create-menu/create-menu.component.ts index d7df31809..c2f6e9286 100644 --- a/src/app/components/create-menu/create-menu.component.ts +++ b/src/app/components/create-menu/create-menu.component.ts @@ -23,13 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Component, - Input, - OnInit, - OnDestroy, - ViewEncapsulation -} from '@angular/core'; +import { Component, Input, OnInit, OnDestroy, ViewEncapsulation } from '@angular/core'; import { ContentActionRef } from '@alfresco/adf-extensions'; import { AppStore, getCurrentFolder } from '@alfresco/aca-shared/store'; import { Store } from '@ngrx/store'; @@ -54,10 +48,7 @@ export class CreateMenuComponent implements OnInit, OnDestroy { @Input() expanded: boolean; - constructor( - private store: Store, - private extensions: AppExtensionService - ) {} + constructor(private store: Store, private extensions: AppExtensionService) {} ngOnInit() { this.store diff --git a/src/app/components/current-user/current-user.component.spec.ts b/src/app/components/current-user/current-user.component.spec.ts index 9a4c8c739..7c6618bdc 100644 --- a/src/app/components/current-user/current-user.component.spec.ts +++ b/src/app/components/current-user/current-user.component.spec.ts @@ -28,11 +28,7 @@ import { TestBed, ComponentFixture } from '@angular/core/testing'; import { AppTestingModule } from '../../testing/app-testing.module'; import { NO_ERRORS_SCHEMA } from '@angular/core'; import { Store } from '@ngrx/store'; -import { - AppState, - SetUserProfileAction, - SetSettingsParameterAction -} from '@alfresco/aca-shared/store'; +import { AppState, SetUserProfileAction, SetSettingsParameterAction } from '@alfresco/aca-shared/store'; import { AppExtensionService } from '@alfresco/aca-shared'; describe('CurrentUserComponent', () => { @@ -66,7 +62,7 @@ describe('CurrentUserComponent', () => { component = fixture.componentInstance; }); - it('should get profile data', done => { + it('should get profile data', (done) => { const expectedProfile = { firstName: 'Test', lastName: 'User', @@ -78,9 +74,7 @@ describe('CurrentUserComponent', () => { fixture.detectChanges(); - store.dispatch( - new SetUserProfileAction({ person: person.entry, groups: [] }) - ); + store.dispatch(new SetUserProfileAction({ person: person.entry, groups: [] })); component.profile$.subscribe((profile: any) => { expect(profile).toEqual(jasmine.objectContaining(expectedProfile)); @@ -88,12 +82,10 @@ describe('CurrentUserComponent', () => { }); }); - it('should set language picker state', done => { + it('should set language picker state', (done) => { fixture.detectChanges(); - store.dispatch( - new SetSettingsParameterAction({ name: 'languagePicker', value: true }) - ); + store.dispatch(new SetSettingsParameterAction({ name: 'languagePicker', value: true })); component.languagePicker$.subscribe((languagePicker: boolean) => { expect(languagePicker).toBe(true); diff --git a/src/app/components/current-user/current-user.component.ts b/src/app/components/current-user/current-user.component.ts index 9fd292336..98fbfde6d 100644 --- a/src/app/components/current-user/current-user.component.ts +++ b/src/app/components/current-user/current-user.component.ts @@ -27,11 +27,7 @@ import { Component, ViewEncapsulation, OnInit } from '@angular/core'; import { Store } from '@ngrx/store'; import { Observable } from 'rxjs'; import { ProfileState, ContentActionRef } from '@alfresco/adf-extensions'; -import { - AppStore, - getUserProfile, - getLanguagePickerState -} from '@alfresco/aca-shared/store'; +import { AppStore, getUserProfile, getLanguagePickerState } from '@alfresco/aca-shared/store'; import { AppExtensionService } from '@alfresco/aca-shared'; @Component({ @@ -45,10 +41,7 @@ export class CurrentUserComponent implements OnInit { languagePicker$: Observable; actions: Array = []; - constructor( - private store: Store, - private extensions: AppExtensionService - ) {} + constructor(private store: Store, private extensions: AppExtensionService) {} ngOnInit() { this.profile$ = this.store.select(getUserProfile); diff --git a/src/app/components/current-user/current-user.module.ts b/src/app/components/current-user/current-user.module.ts index daae25067..a16783118 100644 --- a/src/app/components/current-user/current-user.module.ts +++ b/src/app/components/current-user/current-user.module.ts @@ -32,12 +32,7 @@ import { UserMenuItemComponent } from './user-menu-item.component'; import { RouterModule } from '@angular/router'; @NgModule({ - imports: [ - CommonModule, - CoreModule.forChild(), - RouterModule, - ExtensionsModule - ], + imports: [CommonModule, CoreModule.forChild(), RouterModule, ExtensionsModule], declarations: [CurrentUserComponent, UserMenuItemComponent], exports: [CurrentUserComponent, UserMenuItemComponent] }) diff --git a/src/app/components/current-user/user-menu-item.component.spec.ts b/src/app/components/current-user/user-menu-item.component.spec.ts index b4a1e2f05..c050a23ae 100644 --- a/src/app/components/current-user/user-menu-item.component.spec.ts +++ b/src/app/components/current-user/user-menu-item.component.spec.ts @@ -26,11 +26,7 @@ import { TestBed, ComponentFixture } from '@angular/core/testing'; import { AppTestingModule } from '../../testing/app-testing.module'; import { UserMenuItemComponent } from './user-menu-item.component'; -import { - TranslateModule, - TranslateLoader, - TranslateFakeLoader -} from '@ngx-translate/core'; +import { TranslateModule, TranslateLoader, TranslateFakeLoader } from '@ngx-translate/core'; import { NO_ERRORS_SCHEMA } from '@angular/core'; import { ContentActionRef } from '@alfresco/adf-extensions'; import { AppExtensionService } from '@alfresco/aca-shared'; @@ -99,9 +95,7 @@ describe('UserMenuItemComponent', () => { } as ContentActionRef; fixture.detectChanges(); - const componentElement = fixture.nativeElement.querySelector( - '#custom-component' - ); + const componentElement = fixture.nativeElement.querySelector('#custom-component'); expect(componentElement).not.toBe(null); }); @@ -119,8 +113,6 @@ describe('UserMenuItemComponent', () => { const buttonElement = fixture.nativeElement.querySelector('#action-button'); buttonElement.dispatchEvent(new MouseEvent('click')); - expect(appExtensionService.runActionById).toHaveBeenCalledWith( - 'TEST_EVENT' - ); + expect(appExtensionService.runActionById).toHaveBeenCalledWith('TEST_EVENT'); }); }); diff --git a/src/app/components/dl-custom-components/document-list-custom-components.module.ts b/src/app/components/dl-custom-components/document-list-custom-components.module.ts index 4ccbe8e24..54f3b0ca3 100644 --- a/src/app/components/dl-custom-components/document-list-custom-components.module.ts +++ b/src/app/components/dl-custom-components/document-list-custom-components.module.ts @@ -32,13 +32,7 @@ import { MaterialModule } from '../../material.module'; import { CoreModule } from '@alfresco/adf-core'; @NgModule({ - imports: [ - BrowserModule, - CoreModule.forChild(), - ContentModule.forChild(), - MaterialModule, - LockedByModule - ], + imports: [BrowserModule, CoreModule.forChild(), ContentModule.forChild(), MaterialModule, LockedByModule], declarations: [CustomNameColumnComponent], exports: [CustomNameColumnComponent] }) diff --git a/src/app/components/dl-custom-components/name-column/name-column.component.spec.ts b/src/app/components/dl-custom-components/name-column/name-column.component.spec.ts index 1cf820341..aa9bef1f4 100644 --- a/src/app/components/dl-custom-components/name-column/name-column.component.spec.ts +++ b/src/app/components/dl-custom-components/name-column/name-column.component.spec.ts @@ -64,9 +64,7 @@ describe('CustomNameColumnComponent', () => { fixture.detectChanges(); - expect( - fixture.debugElement.nativeElement.querySelector('aca-locked-by') - ).toBe(null); + expect(fixture.debugElement.nativeElement.querySelector('aca-locked-by')).toBe(null); }); it('should not render lock element if node is not a file', () => { @@ -83,9 +81,7 @@ describe('CustomNameColumnComponent', () => { fixture.detectChanges(); - expect( - fixture.debugElement.nativeElement.querySelector('aca-locked-by') - ).toBe(null); + expect(fixture.debugElement.nativeElement.querySelector('aca-locked-by')).toBe(null); }); it('should render lock element if file is locked', () => { @@ -103,9 +99,7 @@ describe('CustomNameColumnComponent', () => { fixture.detectChanges(); - expect( - fixture.debugElement.nativeElement.querySelector('aca-locked-by') - ).not.toBe(null); + expect(fixture.debugElement.nativeElement.querySelector('aca-locked-by')).not.toBe(null); }); it('should call parent component onClick method', () => { diff --git a/src/app/components/dl-custom-components/name-column/name-column.component.ts b/src/app/components/dl-custom-components/name-column/name-column.component.ts index e23ce9723..70b8532de 100644 --- a/src/app/components/dl-custom-components/name-column/name-column.component.ts +++ b/src/app/components/dl-custom-components/name-column/name-column.component.ts @@ -25,14 +25,7 @@ import { NameColumnComponent } from '@alfresco/adf-content-services'; import { AlfrescoApiService } from '@alfresco/adf-core'; -import { - ChangeDetectorRef, - Component, - ElementRef, - OnDestroy, - OnInit, - ViewEncapsulation -} from '@angular/core'; +import { ChangeDetectorRef, Component, ElementRef, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core'; import { Actions, ofType } from '@ngrx/effects'; import { Subject } from 'rxjs'; import { filter, takeUntil } from 'rxjs/operators'; @@ -48,43 +41,35 @@ import { isLocked } from '@alfresco/aca-shared'; class: ' adf-datatable-content-cell adf-datatable-link adf-name-column' } }) -export class CustomNameColumnComponent extends NameColumnComponent - implements OnInit, OnDestroy { +export class CustomNameColumnComponent extends NameColumnComponent implements OnInit, OnDestroy { private onDestroy$$ = new Subject(); - constructor( - element: ElementRef, - private cd: ChangeDetectorRef, - private actions$: Actions, - private apiService: AlfrescoApiService - ) { + constructor(element: ElementRef, private cd: ChangeDetectorRef, private actions$: Actions, private apiService: AlfrescoApiService) { super(element, apiService); } ngOnInit() { this.updateValue(); - this.apiService.nodeUpdated - .pipe(takeUntil(this.onDestroy$$)) - .subscribe((node: any) => { - const row = this.context.row; - if (row) { - const { entry } = row.node; - const currentId = entry.nodeId || entry.id; - const updatedId = node.nodeId || node.id; + this.apiService.nodeUpdated.pipe(takeUntil(this.onDestroy$$)).subscribe((node: any) => { + const row = this.context.row; + if (row) { + const { entry } = row.node; + const currentId = entry.nodeId || entry.id; + const updatedId = node.nodeId || node.id; - if (currentId === updatedId) { - entry.name = node.name; - row.node = { entry }; - this.updateValue(); - } + if (currentId === updatedId) { + entry.name = node.name; + row.node = { entry }; + this.updateValue(); } - }); + } + }); this.actions$ .pipe( ofType(NodeActionTypes.EditOffline), - filter(val => { + filter((val) => { return this.node.entry.id === val.payload.entry.id; }), takeUntil(this.onDestroy$$) diff --git a/src/app/components/favorite-libraries/favorite-libraries.component.spec.ts b/src/app/components/favorite-libraries/favorite-libraries.component.spec.ts index e4c56b0ea..56bc5d307 100644 --- a/src/app/components/favorite-libraries/favorite-libraries.component.spec.ts +++ b/src/app/components/favorite-libraries/favorite-libraries.component.spec.ts @@ -26,13 +26,7 @@ import { TestBed, ComponentFixture } from '@angular/core/testing'; import { NO_ERRORS_SCHEMA } from '@angular/core'; import { Router } from '@angular/router'; -import { - AlfrescoApiService, - NodeFavoriteDirective, - DataTableComponent, - AppConfigPipe, - UserPreferencesService -} from '@alfresco/adf-core'; +import { AlfrescoApiService, NodeFavoriteDirective, DataTableComponent, AppConfigPipe, UserPreferencesService } from '@alfresco/adf-core'; import { DocumentListComponent } from '@alfresco/adf-content-services'; import { FavoriteLibrariesComponent } from './favorite-libraries.component'; import { AppTestingModule } from '../../testing/app-testing.module'; @@ -65,17 +59,8 @@ describe('FavoriteLibrariesComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ - AppTestingModule, - EffectsModule.forRoot([RouterEffects, LibraryEffects]) - ], - declarations: [ - DataTableComponent, - NodeFavoriteDirective, - DocumentListComponent, - FavoriteLibrariesComponent, - AppConfigPipe - ], + imports: [AppTestingModule, EffectsModule.forRoot([RouterEffects, LibraryEffects])], + declarations: [DataTableComponent, NodeFavoriteDirective, DocumentListComponent, FavoriteLibrariesComponent, AppConfigPipe], providers: [ContentManagementService, UserPreferencesService], schemas: [NO_ERRORS_SCHEMA] }); @@ -90,16 +75,12 @@ describe('FavoriteLibrariesComponent', () => { alfrescoApi.reset(); router = TestBed.inject(Router); - spyOn(contentApiService, 'getNode').and.returnValue( - of({ entry: { id: 'libraryId' } } as NodeEntry) - ); + spyOn(contentApiService, 'getNode').and.returnValue(of({ entry: { id: 'libraryId' } } as NodeEntry)); }); describe('on initialization', () => { it('should set data', () => { - spyOn(contentApiService, 'getFavoriteLibraries').and.returnValue( - of(page) - ); + spyOn(contentApiService, 'getFavoriteLibraries').and.returnValue(of(page)); fixture.detectChanges(); expect(component.list).toBe(page); @@ -108,24 +89,17 @@ describe('FavoriteLibrariesComponent', () => { it('should get data with user preference pagination size', () => { userPreference.paginationSize = 1; - spyOn(contentApiService, 'getFavoriteLibraries').and.returnValue( - of(page) - ); + spyOn(contentApiService, 'getFavoriteLibraries').and.returnValue(of(page)); fixture.detectChanges(); - expect(contentApiService.getFavoriteLibraries).toHaveBeenCalledWith( - '-me-', - { - maxItems: userPreference.paginationSize - } - ); + expect(contentApiService.getFavoriteLibraries).toHaveBeenCalledWith('-me-', { + maxItems: userPreference.paginationSize + }); }); it('should set data on error', () => { - spyOn(contentApiService, 'getFavoriteLibraries').and.returnValue( - throwError('error') - ); + spyOn(contentApiService, 'getFavoriteLibraries').and.returnValue(throwError('error')); fixture.detectChanges(); expect(component.list).toBe(null); @@ -146,18 +120,13 @@ describe('FavoriteLibrariesComponent', () => { spyOn(router, 'navigate').and.stub(); component.navigateTo({ entry: { guid: 'guid' } } as any); - expect(router.navigate).toHaveBeenCalledWith([ - 'favorite/libraries', - 'libraryId' - ]); + expect(router.navigate).toHaveBeenCalledWith(['favorite/libraries', 'libraryId']); }); }); describe('Reload on actions', () => { beforeEach(() => { - spyOn(contentApiService, 'getFavoriteLibraries').and.returnValue( - of(page) - ); + spyOn(contentApiService, 'getFavoriteLibraries').and.returnValue(of(page)); fixture.detectChanges(); }); @@ -201,35 +170,23 @@ describe('FavoriteLibrariesComponent', () => { }); it('should get list with pagination data onChange event', () => { - spyOn(contentApiService, 'getFavoriteLibraries').and.returnValue( - of(page) - ); + spyOn(contentApiService, 'getFavoriteLibraries').and.returnValue(of(page)); component.onChange(pagination); - expect(contentApiService.getFavoriteLibraries).toHaveBeenCalledWith( - '-me-', - pagination - ); + expect(contentApiService.getFavoriteLibraries).toHaveBeenCalledWith('-me-', pagination); }); it('should get list with pagination data onChangePageSize event', () => { - spyOn(contentApiService, 'getFavoriteLibraries').and.returnValue( - of(page) - ); + spyOn(contentApiService, 'getFavoriteLibraries').and.returnValue(of(page)); component.onChangePageSize(pagination); - expect(contentApiService.getFavoriteLibraries).toHaveBeenCalledWith( - '-me-', - pagination - ); + expect(contentApiService.getFavoriteLibraries).toHaveBeenCalledWith('-me-', pagination); }); it('should set preference page size onChangePageSize event', () => { - spyOn(contentApiService, 'getFavoriteLibraries').and.returnValue( - of(page) - ); + spyOn(contentApiService, 'getFavoriteLibraries').and.returnValue(of(page)); component.onChangePageSize(pagination); diff --git a/src/app/components/favorite-libraries/favorite-libraries.component.ts b/src/app/components/favorite-libraries/favorite-libraries.component.ts index fd8d615dd..94841e830 100644 --- a/src/app/components/favorite-libraries/favorite-libraries.component.ts +++ b/src/app/components/favorite-libraries/favorite-libraries.component.ts @@ -35,8 +35,7 @@ import { UserPreferencesService } from '@alfresco/adf-core'; @Component({ templateUrl: './favorite-libraries.component.html' }) -export class FavoriteLibrariesComponent extends PageComponent - implements OnInit { +export class FavoriteLibrariesComponent extends PageComponent implements OnInit { pagination: Pagination = new Pagination({ skipCount: 0, maxItems: 25, @@ -71,20 +70,16 @@ export class FavoriteLibrariesComponent extends PageComponent this.content.libraryLeft.subscribe(() => this.reloadList()), this.content.favoriteLibraryToggle.subscribe(() => this.reloadList()), - this.breakpointObserver - .observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]) - .subscribe(result => { - this.isSmallScreen = result.matches; - }) + this.breakpointObserver.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]).subscribe((result) => { + this.isSmallScreen = result.matches; + }) ]); this.columns = this.extensions.documentListPresets.favoriteLibraries || []; } navigateTo(node: SiteEntry) { if (node && node.entry && node.entry.guid) { - this.store.dispatch( - new NavigateLibraryAction(node.entry.guid, 'favorite/libraries') - ); + this.store.dispatch(new NavigateLibraryAction(node.entry.guid, 'favorite/libraries')); } } diff --git a/src/app/components/favorites/favorites.component.spec.ts b/src/app/components/favorites/favorites.component.spec.ts index eff14388f..574464669 100644 --- a/src/app/components/favorites/favorites.component.spec.ts +++ b/src/app/components/favorites/favorites.component.spec.ts @@ -25,19 +25,8 @@ import { NO_ERRORS_SCHEMA } from '@angular/core'; import { Router } from '@angular/router'; -import { - TestBed, - ComponentFixture, - fakeAsync, - tick -} from '@angular/core/testing'; -import { - AlfrescoApiService, - NodeFavoriteDirective, - DataTableComponent, - AppConfigPipe, - UploadService -} from '@alfresco/adf-core'; +import { TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing'; +import { AlfrescoApiService, NodeFavoriteDirective, DataTableComponent, AppConfigPipe, UploadService } from '@alfresco/adf-core'; import { DocumentListComponent } from '@alfresco/adf-content-services'; import { of } from 'rxjs'; import { FavoritesComponent } from './favorites.component'; @@ -61,10 +50,7 @@ describe('FavoritesComponent', () => { beforeEach(() => { page = { list: { - entries: [ - { entry: { id: 1, target: { file: {} } } }, - { entry: { id: 2, target: { folder: {} } } } - ], + entries: [{ entry: { id: 1, target: { file: {} } } }, { entry: { id: 2, target: { folder: {} } } }], pagination: { data: 'data' } } }; @@ -82,13 +68,7 @@ describe('FavoritesComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [AppTestingModule], - declarations: [ - DataTableComponent, - NodeFavoriteDirective, - DocumentListComponent, - FavoritesComponent, - AppConfigPipe - ], + declarations: [DataTableComponent, NodeFavoriteDirective, DocumentListComponent, FavoritesComponent, AppConfigPipe], providers: [ { provide: Router, @@ -103,9 +83,7 @@ describe('FavoritesComponent', () => { alfrescoApi = TestBed.inject(AlfrescoApiService); alfrescoApi.reset(); - spyOn(alfrescoApi.favoritesApi, 'getFavorites').and.returnValue( - Promise.resolve(page) - ); + spyOn(alfrescoApi.favoritesApi, 'getFavorites').and.returnValue(Promise.resolve(page)); contentApi = TestBed.inject(ContentApiService); uploadService = TestBed.inject(UploadService); @@ -124,10 +102,7 @@ describe('FavoritesComponent', () => { component.navigate(node); - expect(router.navigate).toHaveBeenCalledWith([ - '/libraries', - 'folder-node' - ]); + expect(router.navigate).toHaveBeenCalledWith(['/libraries', 'folder-node']); }); it('navigates to `/personal-files` if node path has no `Sites`', () => { @@ -135,10 +110,7 @@ describe('FavoritesComponent', () => { component.navigate(node); - expect(router.navigate).toHaveBeenCalledWith([ - '/personal-files', - 'folder-node' - ]); + expect(router.navigate).toHaveBeenCalledWith(['/personal-files', 'folder-node']); }); it('does not navigate when node is not folder', () => { diff --git a/src/app/components/favorites/favorites.component.ts b/src/app/components/favorites/favorites.component.ts index 33a937d03..9ccb173a4 100644 --- a/src/app/components/favorites/favorites.component.ts +++ b/src/app/components/favorites/favorites.component.ts @@ -26,12 +26,7 @@ import { AppExtensionService, ContentApiService } from '@alfresco/aca-shared'; import { AppStore } from '@alfresco/aca-shared/store'; import { UploadService } from '@alfresco/adf-core'; -import { - MinimalNodeEntity, - MinimalNodeEntryEntity, - PathElementEntity, - PathInfo -} from '@alfresco/js-api'; +import { MinimalNodeEntity, MinimalNodeEntryEntity, PathElementEntity, PathInfo } from '@alfresco/js-api'; import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout'; import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; @@ -64,18 +59,12 @@ export class FavoritesComponent extends PageComponent implements OnInit { super.ngOnInit(); this.subscriptions = this.subscriptions.concat([ - this.uploadService.fileUploadComplete - .pipe(debounceTime(300)) - .subscribe(_ => this.reload()), - this.uploadService.fileUploadDeleted - .pipe(debounceTime(300)) - .subscribe(_ => this.reload()), + this.uploadService.fileUploadComplete.pipe(debounceTime(300)).subscribe((_) => this.reload()), + this.uploadService.fileUploadDeleted.pipe(debounceTime(300)).subscribe((_) => this.reload()), - this.breakpointObserver - .observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]) - .subscribe(result => { - this.isSmallScreen = result.matches; - }) + this.breakpointObserver.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]).subscribe((result) => { + this.isSmallScreen = result.matches; + }) ]); this.columns = this.extensions.documentListPresets.favorites; @@ -86,17 +75,13 @@ export class FavoritesComponent extends PageComponent implements OnInit { // TODO: rework as it will fail on non-English setups const isSitePath = (path: PathInfo): boolean => { - return ( - path && - path.elements && - path.elements.some(({ name }: PathElementEntity) => name === 'Sites') - ); + return path && path.elements && path.elements.some(({ name }: PathElementEntity) => name === 'Sites'); }; if (isFolder) { this.contentApi .getNode(id) - .pipe(map(node => node.entry)) + .pipe(map((node) => node.entry)) .subscribe(({ path }: MinimalNodeEntryEntity) => { const routeUrl = isSitePath(path) ? '/libraries' : '/personal-files'; this.router.navigate([routeUrl, id]); diff --git a/src/app/components/files/files.component.spec.ts b/src/app/components/files/files.component.spec.ts index aa86437e3..85216fab4 100644 --- a/src/app/components/files/files.component.spec.ts +++ b/src/app/components/files/files.component.spec.ts @@ -23,12 +23,7 @@ * along with Alfresco. If not, see . */ -import { - TestBed, - fakeAsync, - tick, - ComponentFixture -} from '@angular/core/testing'; +import { TestBed, fakeAsync, tick, ComponentFixture } from '@angular/core/testing'; import { NO_ERRORS_SCHEMA } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; import { @@ -61,13 +56,7 @@ describe('FilesComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [AppTestingModule], - declarations: [ - FilesComponent, - DataTableComponent, - NodeFavoriteDirective, - DocumentListComponent, - AppConfigPipe - ], + declarations: [FilesComponent, DataTableComponent, NodeFavoriteDirective, DocumentListComponent, AppConfigPipe], providers: [ { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }, { @@ -138,16 +127,11 @@ describe('FilesComponent', () => { it('should navigate to parent if node is not a folder', () => { const nodeEntry = { isFolder: false, parentId: 'parent-id' }; - spyOn(contentApi, 'getNode').and.returnValue( - of({ entry: nodeEntry } as any) - ); + spyOn(contentApi, 'getNode').and.returnValue(of({ entry: nodeEntry } as any)); fixture.detectChanges(); - expect(router.navigate['calls'].argsFor(0)[0]).toEqual([ - '/personal-files', - 'parent-id' - ]); + expect(router.navigate['calls'].argsFor(0)[0]).toEqual(['/personal-files', 'parent-id']); }); }); @@ -160,10 +144,7 @@ describe('FilesComponent', () => { }); it('should call refresh onContentCopied event if parent is the same', () => { - const nodes: any[] = [ - { entry: { parentId: '1' } }, - { entry: { parentId: '2' } } - ]; + const nodes: any[] = [{ entry: { parentId: '1' } }, { entry: { parentId: '2' } }]; component.node = { id: '1' } as any; @@ -173,10 +154,7 @@ describe('FilesComponent', () => { }); it('should not call refresh onContentCopied event when parent mismatch', () => { - const nodes: any[] = [ - { entry: { parentId: '1' } }, - { entry: { parentId: '2' } } - ]; + const nodes: any[] = [{ entry: { parentId: '1' } }, { entry: { parentId: '2' } }]; component.node = { id: '3' } as any; @@ -256,10 +234,7 @@ describe('FilesComponent', () => { router.url = '/personal-files'; component.navigate(node.id); - expect(router.navigate).toHaveBeenCalledWith([ - '/personal-files', - node.id - ]); + expect(router.navigate).toHaveBeenCalledWith(['/personal-files', node.id]); }); it('should navigates to home when id not provided', () => { diff --git a/src/app/components/files/files.component.ts b/src/app/components/files/files.component.ts index 932db1626..f5d989fca 100644 --- a/src/app/components/files/files.component.ts +++ b/src/app/components/files/files.component.ts @@ -27,29 +27,15 @@ import { FileUploadEvent, UploadService } from '@alfresco/adf-core'; import { Component, OnDestroy, OnInit } from '@angular/core'; import { ActivatedRoute, Params, Router } from '@angular/router'; import { Store } from '@ngrx/store'; -import { - MinimalNodeEntity, - MinimalNodeEntryEntity, - PathElement, - PathElementEntity -} from '@alfresco/js-api'; +import { MinimalNodeEntity, MinimalNodeEntryEntity, PathElement, PathElementEntity } from '@alfresco/js-api'; import { ContentManagementService } from '../../services/content-management.service'; import { NodeActionsService } from '../../services/node-actions.service'; import { PageComponent } from '../page.component'; import { AppExtensionService, ContentApiService } from '@alfresco/aca-shared'; -import { - SetCurrentFolderAction, - isAdmin, - AppStore, - UploadFileVersionAction -} from '@alfresco/aca-shared/store'; +import { SetCurrentFolderAction, isAdmin, AppStore, UploadFileVersionAction } from '@alfresco/aca-shared/store'; import { BreakpointObserver, Breakpoints } from '@angular/cdk/layout'; import { debounceTime, takeUntil } from 'rxjs/operators'; -import { - ShareDataRow, - SEARCH_QUERY_SERVICE_TOKEN, - SearchHeaderQueryBuilderService -} from '@alfresco/adf-content-services'; +import { ShareDataRow, SEARCH_QUERY_SERVICE_TOKEN, SearchHeaderQueryBuilderService } from '@alfresco/adf-content-services'; @Component({ templateUrl: './files.component.html', @@ -96,7 +82,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy { const nodeId = folderId || data.defaultNodeId; this.contentApi.getNode(nodeId).subscribe( - node => { + (node) => { this.isValidPath = true; if (node.entry && node.entry.isFolder) { @@ -112,27 +98,19 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy { }); this.subscriptions = this.subscriptions.concat([ - nodeActionsService.contentCopied.subscribe(nodes => - this.onContentCopied(nodes) - ), - uploadService.fileUploadComplete - .pipe(debounceTime(300)) - .subscribe(file => this.onFileUploadedEvent(file)), - uploadService.fileUploadDeleted - .pipe(debounceTime(300)) - .subscribe(file => this.onFileUploadedEvent(file)), + nodeActionsService.contentCopied.subscribe((nodes) => this.onContentCopied(nodes)), + uploadService.fileUploadComplete.pipe(debounceTime(300)).subscribe((file) => this.onFileUploadedEvent(file)), + uploadService.fileUploadDeleted.pipe(debounceTime(300)).subscribe((file) => this.onFileUploadedEvent(file)), - this.breakpointObserver - .observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]) - .subscribe(result => { - this.isSmallScreen = result.matches; - }) + this.breakpointObserver.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]).subscribe((result) => { + this.isSmallScreen = result.matches; + }) ]); this.store .select(isAdmin) .pipe(takeUntil(this.onDestroy$)) - .subscribe(value => { + .subscribe((value) => { this.isAdmin = value; }); @@ -177,10 +155,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy { onBreadcrumbNavigate(route: PathElementEntity) { // todo: review this approach once 5.2.3 is out if (this.nodePath && this.nodePath.length > 2) { - if ( - this.nodePath[1].name === 'Sites' && - this.nodePath[2].id === route.id - ) { + if (this.nodePath[1].name === 'Sites' && this.nodePath[2].id === route.id) { return this.navigate(this.nodePath[3].id); } } @@ -204,14 +179,11 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy { if (event && event.file.options.parentId) { if (this.nodePath) { - const correspondingNodePath = this.nodePath.find( - pathItem => pathItem.id === event.file.options.parentId - ); + const correspondingNodePath = this.nodePath.find((pathItem) => pathItem.id === event.file.options.parentId); // check if the current folder has the 'trigger-upload-folder' as one of its parents if (correspondingNodePath) { - const correspondingIndex = - this.nodePath.length - this.nodePath.indexOf(correspondingNodePath); + const correspondingIndex = this.nodePath.length - this.nodePath.indexOf(correspondingNodePath); this.displayFolderParent(event.file.options.path, correspondingIndex); } } @@ -220,12 +192,9 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy { displayFolderParent(filePath = '', index: number) { const parentName = filePath.split('/')[index]; - const currentFoldersDisplayed = - (this.documentList.data.getRows() as ShareDataRow[]) || []; + const currentFoldersDisplayed = (this.documentList.data.getRows() as ShareDataRow[]) || []; - const alreadyDisplayedParentFolder = currentFoldersDisplayed.find( - row => row.node.entry.isFolder && row.node.entry.name === parentName - ); + const alreadyDisplayedParentFolder = currentFoldersDisplayed.find((row) => row.node.entry.isFolder && row.node.entry.name === parentName); if (alreadyDisplayedParentFolder) { return; @@ -234,10 +203,8 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy { } onContentCopied(nodes: MinimalNodeEntity[]) { - const newNode = nodes.find(node => { - return ( - node && node.entry && node.entry.parentId === this.getParentNodeId() - ); + const newNode = nodes.find((node) => { + return node && node.entry && node.entry.parentId === this.getParentNodeId(); }); if (newNode) { this.reload(this.selectedNode); @@ -251,7 +218,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy { if (node && node.path && node.path.elements) { const elements = node.path.elements; - this.nodePath = elements.map(pathElement => { + this.nodePath = elements.map((pathElement) => { return Object.assign({}, pathElement); }); @@ -280,21 +247,17 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy { if (this.isSiteContainer(node)) { // rename 'documentLibrary' entry to the target site display name // clicking on the breadcrumb entry loads the site content - const parentNode = await this.contentApi - .getNodeInfo(node.parentId) - .toPromise(); + const parentNode = await this.contentApi.getNodeInfo(node.parentId).toPromise(); node.name = parentNode.properties['cm:title'] || parentNode.name; // remove the site entry elements.splice(1, 1); } else { // remove 'documentLibrary' in the middle of the path - const docLib = elements.findIndex(el => el.name === 'documentLibrary'); + const docLib = elements.findIndex((el) => el.name === 'documentLibrary'); if (docLib > -1) { const siteFragment = elements[docLib - 1]; - const siteNode = await this.contentApi - .getNodeInfo(siteFragment.id) - .toPromise(); + const siteNode = await this.contentApi.getNodeInfo(siteFragment.id).toPromise(); // apply Site Name to the parent fragment siteFragment.name = siteNode.properties['cm:title'] || siteNode.name; @@ -311,12 +274,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy { } isRootNode(nodeId: string): boolean { - if ( - this.node && - this.node.path && - this.node.path.elements && - this.node.path.elements.length > 0 - ) { + if (this.node && this.node.path && this.node.path.elements && this.node.path.elements.length > 0) { return this.node.path.elements[0].id === nodeId; } return false; diff --git a/src/app/components/header/header.component.spec.ts b/src/app/components/header/header.component.spec.ts index 2671f63e7..f7caf548e 100644 --- a/src/app/components/header/header.component.spec.ts +++ b/src/app/components/header/header.component.spec.ts @@ -52,7 +52,7 @@ describe('AppHeaderComponent', () => { } as AppState; beforeEach(() => { - store.select.and.callFake(memoizeFn => { + store.select.and.callFake((memoizeFn) => { return of(memoizeFn({ app })); }); @@ -60,9 +60,9 @@ describe('AppHeaderComponent', () => { }); it('should set header color, name and logo', async(() => { - component.appName$.subscribe(val => expect(val).toBe(app.appName)); - component.logo$.subscribe(val => expect(val).toBe(app.logoPath)); - component.headerColor$.subscribe(val => expect(val).toBe(app.headerColor)); + component.appName$.subscribe((val) => expect(val).toBe(app.appName)); + component.logo$.subscribe((val) => expect(val).toBe(app.logoPath)); + component.headerColor$.subscribe((val) => expect(val).toBe(app.headerColor)); })); it('should get header actions', () => { diff --git a/src/app/components/header/header.component.ts b/src/app/components/header/header.component.ts index 6d5933790..d737d56c5 100644 --- a/src/app/components/header/header.component.ts +++ b/src/app/components/header/header.component.ts @@ -23,24 +23,11 @@ * along with Alfresco. If not, see . */ -import { - Component, - ViewEncapsulation, - Output, - EventEmitter, - OnInit, - Input -} from '@angular/core'; +import { Component, ViewEncapsulation, Output, EventEmitter, OnInit, Input } from '@angular/core'; import { Store } from '@ngrx/store'; import { Observable } from 'rxjs'; import { ContentActionRef } from '@alfresco/adf-extensions'; -import { - AppStore, - getHeaderColor, - getAppName, - getLogoPath, - getHeaderImagePath -} from '@alfresco/aca-shared/store'; +import { AppStore, getHeaderColor, getAppName, getLogoPath, getHeaderImagePath } from '@alfresco/aca-shared/store'; import { AppExtensionService } from '@alfresco/aca-shared'; @Component({ @@ -62,19 +49,13 @@ export class AppHeaderComponent implements OnInit { actions: Array = []; - constructor( - store: Store, - private appExtensions: AppExtensionService - ) { + constructor(store: Store, private appExtensions: AppExtensionService) { this.headerColor$ = store.select(getHeaderColor); this.appName$ = store.select(getAppName); this.logo$ = store.select(getLogoPath); - store.select(getHeaderImagePath).subscribe(path => { - document.body.style.setProperty( - '--header-background-image', - `url('${path}')` - ); + store.select(getHeaderImagePath).subscribe((path) => { + document.body.style.setProperty('--header-background-image', `url('${path}')`); }); } diff --git a/src/app/components/header/header.module.ts b/src/app/components/header/header.module.ts index ea81301fb..65cb4b020 100644 --- a/src/app/components/header/header.module.ts +++ b/src/app/components/header/header.module.ts @@ -32,13 +32,7 @@ import { AppSearchInputModule } from '../search/search-input.module'; import { AppToolbarModule } from '../toolbar/toolbar.module'; @NgModule({ - imports: [ - CommonModule, - CoreModule.forChild(), - AppCurrentUserModule, - AppSearchInputModule, - AppToolbarModule - ], + imports: [CommonModule, CoreModule.forChild(), AppCurrentUserModule, AppSearchInputModule, AppToolbarModule], declarations: [AppHeaderComponent], exports: [AppHeaderComponent] }) diff --git a/src/app/components/info-drawer/comments-tab/comments-tab.component.spec.ts b/src/app/components/info-drawer/comments-tab/comments-tab.component.spec.ts index 7b716c708..e4e51443f 100644 --- a/src/app/components/info-drawer/comments-tab/comments-tab.component.spec.ts +++ b/src/app/components/info-drawer/comments-tab/comments-tab.component.spec.ts @@ -41,9 +41,7 @@ describe('CommentsTabComponent', () => { TestBed.configureTestingModule({ imports: [AppTestingModule], declarations: [CommentsTabComponent], - providers: [ - { provide: NodePermissionService, useValue: permissionsMock } - ], + providers: [{ provide: NodePermissionService, useValue: permissionsMock }], schemas: [NO_ERRORS_SCHEMA] }); diff --git a/src/app/components/info-drawer/comments-tab/comments-tab.component.ts b/src/app/components/info-drawer/comments-tab/comments-tab.component.ts index 4a42d4f8f..9adb4d6ab 100644 --- a/src/app/components/info-drawer/comments-tab/comments-tab.component.ts +++ b/src/app/components/info-drawer/comments-tab/comments-tab.component.ts @@ -29,12 +29,7 @@ import { NodePermissionService, isLocked } from '@alfresco/aca-shared'; @Component({ selector: 'app-comments-tab', - template: ` - - ` + template: `` }) export class CommentsTabComponent { @Input() @@ -47,10 +42,7 @@ export class CommentsTabComponent { return false; } - if ( - this.node.isFolder || - (this.node.isFile && !isLocked({ entry: this.node })) - ) { + if (this.node.isFolder || (this.node.isFile && !isLocked({ entry: this.node }))) { return this.permission.check(this.node, ['update']); } return false; diff --git a/src/app/components/info-drawer/info.drawer.module.ts b/src/app/components/info-drawer/info.drawer.module.ts index fde6ba2d1..0a7ca0c58 100644 --- a/src/app/components/info-drawer/info.drawer.module.ts +++ b/src/app/components/info-drawer/info.drawer.module.ts @@ -23,10 +23,7 @@ * along with Alfresco. If not, see . */ -import { - ContentMetadataModule, - VersionManagerModule -} from '@alfresco/adf-content-services'; +import { ContentMetadataModule, VersionManagerModule } from '@alfresco/adf-content-services'; import { CoreModule } from '@alfresco/adf-core'; import { ExtensionsModule } from '@alfresco/adf-extensions'; import { CommonModule } from '@angular/common'; @@ -42,13 +39,7 @@ import { A11yModule } from '@angular/cdk/a11y'; import { SharedInfoDrawerModule } from '@alfresco/aca-shared'; export function components() { - return [ - MetadataTabComponent, - CommentsTabComponent, - VersionsTabComponent, - LibraryMetadataTabComponent, - LibraryMetadataFormComponent - ]; + return [MetadataTabComponent, CommentsTabComponent, VersionsTabComponent, LibraryMetadataTabComponent, LibraryMetadataFormComponent]; } @NgModule({ diff --git a/src/app/components/info-drawer/library-metadata-tab/library-metadata-form.component.spec.ts b/src/app/components/info-drawer/library-metadata-tab/library-metadata-form.component.spec.ts index 9f41e7c05..a464e1283 100644 --- a/src/app/components/info-drawer/library-metadata-tab/library-metadata-form.component.spec.ts +++ b/src/app/components/info-drawer/library-metadata-tab/library-metadata-form.component.spec.ts @@ -23,12 +23,7 @@ * along with Alfresco. If not, see . */ import { LibraryMetadataFormComponent } from './library-metadata-form.component'; -import { - TestBed, - ComponentFixture, - fakeAsync, - tick -} from '@angular/core/testing'; +import { TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing'; import { Store } from '@ngrx/store'; import { UpdateLibraryAction } from '@alfresco/aca-shared/store'; import { AppTestingModule } from '../../../testing/app-testing.module'; @@ -135,9 +130,7 @@ describe('LibraryMetadataFormComponent', () => { component.update(); - expect(storeMock.dispatch).toHaveBeenCalledWith( - new UpdateLibraryAction(siteEntryModel) - ); + expect(storeMock.dispatch).toHaveBeenCalledWith(new UpdateLibraryAction(siteEntryModel)); }); it('should not update library node if it has no permission', () => { @@ -158,9 +151,7 @@ describe('LibraryMetadataFormComponent', () => { component.update(); - expect(storeMock.dispatch).not.toHaveBeenCalledWith( - new UpdateLibraryAction(siteEntryModel) - ); + expect(storeMock.dispatch).not.toHaveBeenCalledWith(new UpdateLibraryAction(siteEntryModel)); }); it('should not update library node if form is invalid', () => { @@ -183,9 +174,7 @@ describe('LibraryMetadataFormComponent', () => { component.update(); - expect(storeMock.dispatch).not.toHaveBeenCalledWith( - new UpdateLibraryAction(siteEntryModel) - ); + expect(storeMock.dispatch).not.toHaveBeenCalledWith(new UpdateLibraryAction(siteEntryModel)); }); it('should toggle edit mode', () => { @@ -225,10 +214,7 @@ describe('LibraryMetadataFormComponent', () => { it('should warn if library name input is used by another library', fakeAsync(() => { const title = 'some-title'; - spyOn( - alfrescoApiService.getInstance().core.queriesApi, - 'findSites' - ).and.returnValue( + spyOn(alfrescoApiService.getInstance().core.queriesApi, 'findSites').and.returnValue( Promise.resolve({ list: { entries: [{ entry: { title } }] } } as SitePaging) @@ -256,10 +242,7 @@ describe('LibraryMetadataFormComponent', () => { })); it('should not warn if library name input is the same with library node data', fakeAsync(() => { - spyOn( - alfrescoApiService.getInstance().core.queriesApi, - 'findSites' - ).and.returnValue( + spyOn(alfrescoApiService.getInstance().core.queriesApi, 'findSites').and.returnValue( Promise.resolve({ list: { entries: [{ entry: { title: 'libraryTitle' } }] } } as SitePaging) @@ -287,10 +270,7 @@ describe('LibraryMetadataFormComponent', () => { })); it('should not warn if library name is unique', fakeAsync(() => { - spyOn( - alfrescoApiService.getInstance().core.queriesApi, - 'findSites' - ).and.returnValue( + spyOn(alfrescoApiService.getInstance().core.queriesApi, 'findSites').and.returnValue( Promise.resolve({ list: { entries: [] } } as SitePaging) diff --git a/src/app/components/info-drawer/library-metadata-tab/library-metadata-form.component.ts b/src/app/components/info-drawer/library-metadata-tab/library-metadata-form.component.ts index 70b8d2016..db247d473 100644 --- a/src/app/components/info-drawer/library-metadata-tab/library-metadata-form.component.ts +++ b/src/app/components/info-drawer/library-metadata-tab/library-metadata-form.component.ts @@ -36,8 +36,7 @@ import { Observable, from, Subject } from 'rxjs'; selector: 'app-library-metadata-form', templateUrl: './library-metadata-form.component.html' }) -export class LibraryMetadataFormComponent - implements OnInit, OnChanges, OnDestroy { +export class LibraryMetadataFormComponent implements OnInit, OnChanges, OnDestroy { @Input() node: SiteEntry; @@ -52,29 +51,21 @@ export class LibraryMetadataFormComponent form: FormGroup = new FormGroup({ id: new FormControl({ value: '', disabled: true }), - title: new FormControl({ value: '' }, [ - Validators.required, - Validators.maxLength(256) - ]), + title: new FormControl({ value: '' }, [Validators.required, Validators.maxLength(256)]), description: new FormControl({ value: '' }, [Validators.maxLength(512)]), visibility: new FormControl(this.libraryType[0].value) }); onDestroy$: Subject = new Subject(); - constructor( - private alfrescoApiService: AlfrescoApiService, - protected store: Store - ) {} + constructor(private alfrescoApiService: AlfrescoApiService, protected store: Store) {} get canUpdateLibrary() { - return ( - this.node && this.node.entry && this.node.entry.role === 'SiteManager' - ); + return this.node && this.node.entry && this.node.entry.role === 'SiteManager'; } getVisibilityLabel(value: string) { - return this.libraryType.find(type => type.value === value).label; + return this.libraryType.find((type) => type.value === value).label; } toggleEdit() { @@ -92,18 +83,17 @@ export class LibraryMetadataFormComponent this.form.controls['title'].valueChanges .pipe( debounceTime(300), - mergeMap(title => this.findLibraryByTitle(title)), + mergeMap((title) => this.findLibraryByTitle(title)), takeUntil(this.onDestroy$) ) - .subscribe(result => { + .subscribe((result) => { const { entries } = result.list; if (entries.length) { if (this.form.controls.title.value === this.node.entry.title) { this.libraryTitleExists = false; } else { - this.libraryTitleExists = - this.form.controls.title.value === entries[0].entry.title; + this.libraryTitleExists = this.form.controls.title.value === entries[0].entry.title; } } else { this.libraryTitleExists = false; @@ -137,9 +127,7 @@ export class LibraryMetadataFormComponent }); } - private findLibraryByTitle( - libraryTitle: string - ): Observable { + private findLibraryByTitle(libraryTitle: string): Observable { return from( this.alfrescoApiService .getInstance() diff --git a/src/app/components/info-drawer/library-metadata-tab/library-metadata-tab.component.ts b/src/app/components/info-drawer/library-metadata-tab/library-metadata-tab.component.ts index a783b9a72..b834b1e29 100644 --- a/src/app/components/info-drawer/library-metadata-tab/library-metadata-tab.component.ts +++ b/src/app/components/info-drawer/library-metadata-tab/library-metadata-tab.component.ts @@ -28,8 +28,7 @@ import { SiteEntry } from '@alfresco/js-api'; @Component({ selector: 'app-metadata-tab', - template: - '', + template: '', host: { class: 'app-metadata-tab' } }) export class LibraryMetadataTabComponent { diff --git a/src/app/components/info-drawer/metadata-tab/metadata-tab.component.spec.ts b/src/app/components/info-drawer/metadata-tab/metadata-tab.component.spec.ts index b8a69975c..7d053c13b 100644 --- a/src/app/components/info-drawer/metadata-tab/metadata-tab.component.spec.ts +++ b/src/app/components/info-drawer/metadata-tab/metadata-tab.component.spec.ts @@ -30,10 +30,7 @@ import { AppTestingModule } from '../../../testing/app-testing.module'; import { AppConfigService, setupTestBed, CoreModule } from '@alfresco/adf-core'; import { ContentMetadataModule } from '@alfresco/adf-content-services'; import { Store } from '@ngrx/store'; -import { - SetInfoDrawerMetadataAspectAction, - AppState -} from '@alfresco/aca-shared/store'; +import { SetInfoDrawerMetadataAspectAction, AppState } from '@alfresco/aca-shared/store'; import { By } from '@angular/platform-browser'; import { AppExtensionService } from '@alfresco/aca-shared'; @@ -74,12 +71,8 @@ describe('MetadataTabComponent', () => { fixture = TestBed.createComponent(MetadataTabComponent); - expect(appConfig.config['content-metadata']).not.toEqual( - 'initial config' - ); - expect(appConfig.config['content-metadata']).toEqual( - extensions.contentMetadata - ); + expect(appConfig.config['content-metadata']).not.toEqual('initial config'); + expect(appConfig.config['content-metadata']).toEqual(extensions.contentMetadata); }); }); @@ -141,21 +134,17 @@ describe('MetadataTabComponent', () => { }); it('show pass empty when store is in initial state', () => { - const initialState = fixture.debugElement.query( - By.css('adf-content-metadata-card') - ); + const initialState = fixture.debugElement.query(By.css('adf-content-metadata-card')); expect(initialState.componentInstance.displayAspect).toBeFalsy(); }); it('should update the exif if store got updated', () => { store.dispatch(new SetInfoDrawerMetadataAspectAction('EXIF')); - component.displayAspect$.subscribe(aspect => { + component.displayAspect$.subscribe((aspect) => { expect(aspect).toBe('EXIF'); }); fixture.detectChanges(); - const initialState = fixture.debugElement.query( - By.css('adf-content-metadata-card') - ); + const initialState = fixture.debugElement.query(By.css('adf-content-metadata-card')); expect(initialState.componentInstance.displayAspect).toBe('EXIF'); }); }); diff --git a/src/app/components/info-drawer/metadata-tab/metadata-tab.component.ts b/src/app/components/info-drawer/metadata-tab/metadata-tab.component.ts index 3a802501a..786bdbf30 100644 --- a/src/app/components/info-drawer/metadata-tab/metadata-tab.component.ts +++ b/src/app/components/info-drawer/metadata-tab/metadata-tab.component.ts @@ -23,19 +23,9 @@ * along with Alfresco. If not, see . */ -import { - Component, - Input, - ViewEncapsulation, - OnInit, - OnDestroy -} from '@angular/core'; +import { Component, Input, ViewEncapsulation, OnInit, OnDestroy } from '@angular/core'; import { MinimalNodeEntryEntity } from '@alfresco/js-api'; -import { - NodePermissionService, - isLocked, - AppExtensionService -} from '@alfresco/aca-shared'; +import { NodePermissionService, isLocked, AppExtensionService } from '@alfresco/aca-shared'; import { AppStore, infoDrawerMetadataAspect } from '@alfresco/aca-shared/store'; import { AppConfigService, NotificationService } from '@alfresco/adf-core'; import { Observable, Subject } from 'rxjs'; @@ -46,12 +36,7 @@ import { takeUntil } from 'rxjs/operators'; @Component({ selector: 'app-metadata-tab', template: ` - + `, encapsulation: ViewEncapsulation.None, @@ -74,9 +59,7 @@ export class MetadataTabComponent implements OnInit, OnDestroy { private contentMetadataService: ContentMetadataService ) { if (this.extensions.contentMetadata) { - this.appConfig.config[ - 'content-metadata' - ] = this.extensions.contentMetadata; + this.appConfig.config['content-metadata'] = this.extensions.contentMetadata; } this.displayAspect$ = this.store.select(infoDrawerMetadataAspect); } @@ -90,11 +73,9 @@ export class MetadataTabComponent implements OnInit, OnDestroy { } ngOnInit() { - this.contentMetadataService.error - .pipe(takeUntil(this.onDestroy$)) - .subscribe((err: { message: string }) => { - this.notificationService.showError(err.message); - }); + this.contentMetadataService.error.pipe(takeUntil(this.onDestroy$)).subscribe((err: { message: string }) => { + this.notificationService.showError(err.message); + }); } ngOnDestroy() { diff --git a/src/app/components/info-drawer/versions-tab/versions-tab.component.ts b/src/app/components/info-drawer/versions-tab/versions-tab.component.ts index 8d0f25520..67a268d90 100644 --- a/src/app/components/info-drawer/versions-tab/versions-tab.component.ts +++ b/src/app/components/info-drawer/versions-tab/versions-tab.component.ts @@ -31,12 +31,8 @@ import { MinimalNodeEntryEntity } from '@alfresco/js-api'; template: ` diff --git a/src/app/components/layout/app-layout/app-layout.component.spec.ts b/src/app/components/layout/app-layout/app-layout.component.spec.ts index f4a90527b..28115c683 100644 --- a/src/app/components/layout/app-layout/app-layout.component.spec.ts +++ b/src/app/components/layout/app-layout/app-layout.component.spec.ts @@ -29,11 +29,7 @@ import { AppConfigService, UserPreferencesService } from '@alfresco/adf-core'; import { AppLayoutComponent } from './app-layout.component'; import { AppTestingModule } from '../../../testing/app-testing.module'; import { Store } from '@ngrx/store'; -import { - AppStore, - SetSelectedNodesAction, - ResetSelectionAction -} from '@alfresco/aca-shared/store'; +import { AppStore, SetSelectedNodesAction, ResetSelectionAction } from '@alfresco/aca-shared/store'; import { Router, NavigationStart } from '@angular/router'; import { Subject } from 'rxjs'; @@ -110,7 +106,7 @@ describe('AppLayoutComponent', () => { preserveState: true }; - spyOn(userPreference, 'get').and.callFake(key => { + spyOn(userPreference, 'get').and.callFake((key) => { if (key === 'expandedSidenav') { return 'true'; } @@ -128,7 +124,7 @@ describe('AppLayoutComponent', () => { preserveState: true }; - spyOn(userPreference, 'get').and.callFake(key => { + spyOn(userPreference, 'get').and.callFake((key) => { if (key === 'expandedSidenav') { return 'false'; } @@ -149,9 +145,7 @@ describe('AppLayoutComponent', () => { router.navigateByUrl('somewhere/over/the/rainbow'); fixture.detectChanges(); - expect(store.dispatch['calls'].mostRecent().args).toEqual([ - new ResetSelectionAction() - ]); + expect(store.dispatch['calls'].mostRecent().args).toEqual([new ResetSelectionAction()]); }); it('should close menu on mobile screen size', () => { diff --git a/src/app/components/layout/app-layout/app-layout.component.ts b/src/app/components/layout/app-layout/app-layout.component.ts index c57cda28b..6bce62f9a 100644 --- a/src/app/components/layout/app-layout/app-layout.component.ts +++ b/src/app/components/layout/app-layout/app-layout.component.ts @@ -23,29 +23,15 @@ * along with Alfresco. If not, see . */ -import { - AppConfigService, - SidenavLayoutComponent, - UserPreferencesService -} from '@alfresco/adf-core'; -import { - Component, - OnDestroy, - OnInit, - ViewChild, - ViewEncapsulation -} from '@angular/core'; +import { AppConfigService, SidenavLayoutComponent, UserPreferencesService } from '@alfresco/adf-core'; +import { Component, OnDestroy, OnInit, ViewChild, ViewEncapsulation } from '@angular/core'; import { NavigationEnd, Router, NavigationStart } from '@angular/router'; import { Store } from '@ngrx/store'; import { Subject, Observable } from 'rxjs'; import { filter, takeUntil, map, withLatestFrom } from 'rxjs/operators'; import { NodePermissionService } from '@alfresco/aca-shared'; import { BreakpointObserver } from '@angular/cdk/layout'; -import { - AppStore, - getCurrentFolder, - ResetSelectionAction -} from '@alfresco/aca-shared/store'; +import { AppStore, getCurrentFolder, ResetSelectionAction } from '@alfresco/aca-shared/store'; import { Directionality } from '@angular/cdk/bidi'; @Component({ @@ -82,17 +68,11 @@ export class AppLayoutComponent implements OnInit, OnDestroy { ) {} ngOnInit() { - this.isSmallScreen$ = this.breakpointObserver - .observe(['(max-width: 600px)']) - .pipe(map(result => result.matches)); + this.isSmallScreen$ = this.breakpointObserver.observe(['(max-width: 600px)']).pipe(map((result) => result.matches)); - this.hideSidenav = this.hideConditions.some(el => - this.router.routerState.snapshot.url.includes(el) - ); + this.hideSidenav = this.hideConditions.some((el) => this.router.routerState.snapshot.url.includes(el)); - this.minimizeSidenav = this.minimizeConditions.some(el => - this.router.routerState.snapshot.url.includes(el) - ); + this.minimizeSidenav = this.minimizeConditions.some((el) => this.router.routerState.snapshot.url.includes(el)); if (!this.minimizeSidenav) { this.expandedSidenav = this.getSidenavState(); @@ -103,7 +83,7 @@ export class AppLayoutComponent implements OnInit, OnDestroy { this.store .select(getCurrentFolder) .pipe(takeUntil(this.onDestroy$)) - .subscribe(node => { + .subscribe((node) => { this.currentFolderId = node ? node.id : null; this.canUpload = node && this.permission.check(node, ['create']); }); @@ -111,10 +91,7 @@ export class AppLayoutComponent implements OnInit, OnDestroy { this.router.events .pipe( withLatestFrom(this.isSmallScreen$), - filter( - ([event, isSmallScreen]) => - isSmallScreen && event instanceof NavigationEnd - ), + filter(([event, isSmallScreen]) => isSmallScreen && event instanceof NavigationEnd), takeUntil(this.onDestroy$) ) .subscribe(() => { @@ -123,23 +100,19 @@ export class AppLayoutComponent implements OnInit, OnDestroy { this.router.events .pipe( - filter(event => event instanceof NavigationEnd), + filter((event) => event instanceof NavigationEnd), takeUntil(this.onDestroy$) ) .subscribe((event: NavigationEnd) => { - this.minimizeSidenav = this.minimizeConditions.some(el => - event.urlAfterRedirects.includes(el) - ); - this.hideSidenav = this.hideConditions.some(el => - event.urlAfterRedirects.includes(el) - ); + this.minimizeSidenav = this.minimizeConditions.some((el) => event.urlAfterRedirects.includes(el)); + this.hideSidenav = this.hideConditions.some((el) => event.urlAfterRedirects.includes(el)); this.updateState(); }); this.router.events .pipe( - filter(event => event instanceof NavigationStart), + filter((event) => event instanceof NavigationStart), takeUntil(this.onDestroy$) ) .subscribe(() => { @@ -176,29 +149,17 @@ export class AppLayoutComponent implements OnInit, OnDestroy { } onExpanded(state: boolean) { - if ( - !this.minimizeSidenav && - this.appConfigService.get('sideNav.preserveState') - ) { + if (!this.minimizeSidenav && this.appConfigService.get('sideNav.preserveState')) { this.userPreferenceService.set('expandedSidenav', state); } } private getSidenavState(): boolean { - const expand = this.appConfigService.get( - 'sideNav.expandedSidenav', - true - ); - const preserveState = this.appConfigService.get( - 'sideNav.preserveState', - true - ); + const expand = this.appConfigService.get('sideNav.expandedSidenav', true); + const preserveState = this.appConfigService.get('sideNav.preserveState', true); if (preserveState) { - return ( - this.userPreferenceService.get('expandedSidenav', expand.toString()) === - 'true' - ); + return this.userPreferenceService.get('expandedSidenav', expand.toString()) === 'true'; } return expand; diff --git a/src/app/components/libraries/libraries.component.spec.ts b/src/app/components/libraries/libraries.component.spec.ts index 3404756b7..523c8a666 100644 --- a/src/app/components/libraries/libraries.component.spec.ts +++ b/src/app/components/libraries/libraries.component.spec.ts @@ -26,12 +26,7 @@ import { TestBed, ComponentFixture } from '@angular/core/testing'; import { NO_ERRORS_SCHEMA } from '@angular/core'; import { Router } from '@angular/router'; -import { - AlfrescoApiService, - NodeFavoriteDirective, - DataTableComponent, - AppConfigPipe -} from '@alfresco/adf-core'; +import { AlfrescoApiService, NodeFavoriteDirective, DataTableComponent, AppConfigPipe } from '@alfresco/adf-core'; import { DocumentListComponent } from '@alfresco/adf-content-services'; import { LibrariesComponent } from './libraries.component'; import { AppTestingModule } from '../../testing/app-testing.module'; @@ -57,13 +52,7 @@ describe('LibrariesComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [AppTestingModule, EffectsModule.forRoot([LibraryEffects])], - declarations: [ - DataTableComponent, - NodeFavoriteDirective, - DocumentListComponent, - LibrariesComponent, - AppConfigPipe - ], + declarations: [DataTableComponent, NodeFavoriteDirective, DocumentListComponent, LibrariesComponent, AppConfigPipe], schemas: [NO_ERRORS_SCHEMA] }); @@ -74,12 +63,8 @@ describe('LibrariesComponent', () => { alfrescoApi.reset(); router = TestBed.inject(Router); - spyOn(alfrescoApi.sitesApi, 'getSites').and.returnValue( - Promise.resolve(page) - ); - spyOn(alfrescoApi.peopleApi, 'getSiteMembership').and.returnValue( - Promise.resolve({}) - ); + spyOn(alfrescoApi.sitesApi, 'getSites').and.returnValue(Promise.resolve(page)); + spyOn(alfrescoApi.peopleApi, 'getSiteMembership').and.returnValue(Promise.resolve({})); }); describe('Node navigation', () => { diff --git a/src/app/components/libraries/libraries.component.ts b/src/app/components/libraries/libraries.component.ts index 240f665ad..7e8d7b779 100644 --- a/src/app/components/libraries/libraries.component.ts +++ b/src/app/components/libraries/libraries.component.ts @@ -57,11 +57,9 @@ export class LibrariesComponent extends PageComponent implements OnInit { this.content.libraryUpdated.subscribe(() => this.reload()), this.content.libraryLeft.subscribe(() => this.reload()), - this.breakpointObserver - .observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]) - .subscribe(result => { - this.isSmallScreen = result.matches; - }) + this.breakpointObserver.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]).subscribe((result) => { + this.isSmallScreen = result.matches; + }) ); this.columns = this.extensions.documentListPresets.libraries || []; diff --git a/src/app/components/node-version/node-version-form.component.spec.ts b/src/app/components/node-version/node-version-form.component.spec.ts index 40c93bd08..547c17501 100644 --- a/src/app/components/node-version/node-version-form.component.spec.ts +++ b/src/app/components/node-version/node-version-form.component.spec.ts @@ -34,11 +34,7 @@ describe('AppNodeVersionFormComponent', () => { let component; setupTestBed({ - imports: [ - TranslateModule.forRoot(), - CoreModule.forRoot(), - NoopAnimationsModule - ], + imports: [TranslateModule.forRoot(), CoreModule.forRoot(), NoopAnimationsModule], declarations: [AppNodeVersionFormComponent] }); @@ -49,9 +45,7 @@ describe('AppNodeVersionFormComponent', () => { }); it('should have minor version option selected', () => { - const isSelected = fixture.debugElement.nativeElement - .querySelectorAll('.form__version--option')[0] - .classList.contains('mat-radio-checked'); + const isSelected = fixture.debugElement.nativeElement.querySelectorAll('.form__version--option')[0].classList.contains('mat-radio-checked'); expect(isSelected).toBe(true); }); diff --git a/src/app/components/node-version/node-version-form.component.ts b/src/app/components/node-version/node-version-form.component.ts index 1845a46f7..51ef5e054 100644 --- a/src/app/components/node-version/node-version-form.component.ts +++ b/src/app/components/node-version/node-version-form.component.ts @@ -23,14 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Component, - OnDestroy, - OnInit, - ViewEncapsulation, - Output, - EventEmitter -} from '@angular/core'; +import { Component, OnDestroy, OnInit, ViewEncapsulation, Output, EventEmitter } from '@angular/core'; import { FormBuilder, FormGroup } from '@angular/forms'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; @@ -67,11 +60,9 @@ export class AppNodeVersionFormComponent implements OnInit, OnDestroy { version: [this.versionOptions[0].value] }); - this.form.valueChanges - .pipe(takeUntil(this.onDestroy$)) - .subscribe((values: VersionFormEntry) => { - this.update.emit(values); - }); + this.form.valueChanges.pipe(takeUntil(this.onDestroy$)).subscribe((values: VersionFormEntry) => { + this.update.emit(values); + }); } get versions() { diff --git a/src/app/components/page.component.spec.ts b/src/app/components/page.component.spec.ts index fce3192da..361ace8db 100644 --- a/src/app/components/page.component.spec.ts +++ b/src/app/components/page.component.spec.ts @@ -25,13 +25,7 @@ import { TestBed, ComponentFixture } from '@angular/core/testing'; import { PageComponent } from './page.component'; -import { - ReloadDocumentListAction, - SetSelectedNodesAction, - SetInfoDrawerStateAction, - AppState, - AppStore -} from '@alfresco/aca-shared/store'; +import { ReloadDocumentListAction, SetSelectedNodesAction, SetInfoDrawerStateAction, AppState, AppStore } from '@alfresco/aca-shared/store'; import { AppExtensionService } from '@alfresco/aca-shared'; import { MinimalNodeEntity } from '@alfresco/js-api'; import { ContentManagementService } from '../services/content-management.service'; @@ -48,11 +42,7 @@ import { Component } from '@angular/core'; class TestComponent extends PageComponent { node: any; - constructor( - store: Store, - extensions: AppExtensionService, - content: ContentManagementService - ) { + constructor(store: Store, extensions: AppExtensionService, content: ContentManagementService) { super(store, extensions, content); } } @@ -95,12 +85,12 @@ describe('PageComponent', () => { window.history.pushState({}, null, locationHref); }); - it('should open info drawer on action event', done => { + it('should open info drawer on action event', (done) => { window.history.pushState({}, null, `${locationHref}#test`); fixture.detectChanges(); fixture.whenStable().then(() => { - component.infoDrawerOpened$.subscribe(state => { + component.infoDrawerOpened$.subscribe((state) => { expect(state).toBe(true); done(); }); @@ -109,12 +99,12 @@ describe('PageComponent', () => { store.dispatch(new SetInfoDrawerStateAction(true)); }); - it('should not open info drawer if viewer outlet is active', done => { + it('should not open info drawer if viewer outlet is active', (done) => { window.history.pushState({}, null, `${locationHref}#test(viewer:view)`); fixture.detectChanges(); fixture.whenStable().then(() => { - component.infoDrawerOpened$.subscribe(state => { + component.infoDrawerOpened$.subscribe((state) => { expect(state).toBe(false); done(); }); @@ -143,9 +133,7 @@ describe('PageComponent', () => { spyOn(store, 'dispatch'); component.reload(); - expect(store.dispatch).toHaveBeenCalledWith( - new ReloadDocumentListAction() - ); + expect(store.dispatch).toHaveBeenCalledWith(new ReloadDocumentListAction()); }); it('should set selection after reload if node is passed', () => { @@ -157,9 +145,7 @@ describe('PageComponent', () => { spyOn(store, 'dispatch'); component.reload(node); - expect(store.dispatch['calls'].mostRecent().args[0]).toEqual( - new SetSelectedNodesAction([node]) - ); + expect(store.dispatch['calls'].mostRecent().args[0]).toEqual(new SetSelectedNodesAction([node])); }); }); }); diff --git a/src/app/components/page.component.ts b/src/app/components/page.component.ts index f12c392d7..e93bac287 100644 --- a/src/app/components/page.component.ts +++ b/src/app/components/page.component.ts @@ -23,27 +23,12 @@ * along with Alfresco. If not, see . */ -import { - DocumentListComponent, - ShareDataRow -} from '@alfresco/adf-content-services'; +import { DocumentListComponent, ShareDataRow } from '@alfresco/adf-content-services'; import { ShowHeaderMode } from '@alfresco/adf-core'; import { ContentActionRef, SelectionState } from '@alfresco/adf-extensions'; -import { - OnDestroy, - OnInit, - OnChanges, - ViewChild, - SimpleChanges, - Directive -} from '@angular/core'; +import { OnDestroy, OnInit, OnChanges, ViewChild, SimpleChanges, Directive } from '@angular/core'; import { Store } from '@ngrx/store'; -import { - MinimalNodeEntity, - MinimalNodeEntryEntity, - Pagination, - NodePaging -} from '@alfresco/js-api'; +import { MinimalNodeEntity, MinimalNodeEntryEntity, Pagination, NodePaging } from '@alfresco/js-api'; import { Observable, Subject, Subscription } from 'rxjs'; import { takeUntil, map } from 'rxjs/operators'; import { ContentManagementService } from '../services/content-management.service'; @@ -85,16 +70,12 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges { protected subscriptions: Subscription[] = []; - constructor( - protected store: Store, - protected extensions: AppExtensionService, - protected content: ContentManagementService - ) {} + constructor(protected store: Store, protected extensions: AppExtensionService, protected content: ContentManagementService) {} ngOnInit() { this.sharedPreviewUrl$ = this.store.select(getSharedUrl); this.infoDrawerOpened$ = this.store.select(isInfoDrawerOpened).pipe( - map(infoDrawerState => { + map((infoDrawerState) => { return !this.isOutletPreviewUrl() && infoDrawerState; }) ); @@ -104,28 +85,24 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges { this.store .select(getAppSelection) .pipe(takeUntil(this.onDestroy$)) - .subscribe(selection => { + .subscribe((selection) => { this.selection = selection; this.actions = this.extensions.getAllowedToolbarActions(); this.viewerToolbarActions = this.extensions.getViewerToolbarActions(); - this.canUpdateNode = - this.selection.count === 1 && - this.content.canUpdateNode(selection.first); + this.canUpdateNode = this.selection.count === 1 && this.content.canUpdateNode(selection.first); }); this.store .select(getCurrentFolder) .pipe(takeUntil(this.onDestroy$)) - .subscribe(node => { + .subscribe((node) => { this.canUpload = node && this.content.canUploadContent(node); }); if (this.documentList && this.documentList.pagination) { - this.documentList.pagination - .pipe(takeUntil(this.onDestroy$)) - .subscribe((newPagination: Pagination) => { - this.pagination = newPagination; - }); + this.documentList.pagination.pipe(takeUntil(this.onDestroy$)).subscribe((newPagination: Pagination) => { + this.pagination = newPagination; + }); } } @@ -136,7 +113,7 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges { } ngOnDestroy() { - this.subscriptions.forEach(subscription => subscription.unsubscribe()); + this.subscriptions.forEach((subscription) => subscription.unsubscribe()); this.subscriptions = []; this.onDestroy$.next(true); @@ -145,8 +122,7 @@ export abstract class PageComponent implements OnInit, OnDestroy, OnChanges { showPreview(node: MinimalNodeEntity, extras?: ViewNodeExtras) { if (node && node.entry) { - const id = - (node as any).entry.nodeId || (node as any).entry.guid || node.entry.id; + const id = (node as any).entry.nodeId || (node as any).entry.guid || node.entry.id; this.store.dispatch(new ViewNodeAction(id, extras)); } diff --git a/src/app/components/permissions/permission-manager/permission-manager.component.ts b/src/app/components/permissions/permission-manager/permission-manager.component.ts index 611197efa..05eb075ec 100644 --- a/src/app/components/permissions/permission-manager/permission-manager.component.ts +++ b/src/app/components/permissions/permission-manager/permission-manager.component.ts @@ -24,10 +24,7 @@ */ import { AppStore, SnackbarErrorAction } from '@alfresco/aca-shared/store'; -import { - NodePermissionDialogService, - PermissionListComponent -} from '@alfresco/adf-content-services'; +import { NodePermissionDialogService, PermissionListComponent } from '@alfresco/adf-content-services'; import { MinimalNodeEntryEntity } from '@alfresco/js-api'; import { Component, Input, OnInit, ViewChild } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; @@ -56,11 +53,9 @@ export class PermissionsManagerComponent implements OnInit { ) {} ngOnInit() { - this.contentApi - .getNodeInfo(this.nodeId, { include: ['permissions'] }) - .subscribe((currentNode: MinimalNodeEntryEntity) => { - this.toggleStatus = currentNode.permissions.isInheritanceEnabled; - }); + this.contentApi.getNodeInfo(this.nodeId, { include: ['permissions'] }).subscribe((currentNode: MinimalNodeEntryEntity) => { + this.toggleStatus = currentNode.permissions.isInheritanceEnabled; + }); } onError(errorMessage: string) { @@ -77,19 +72,17 @@ export class PermissionsManagerComponent implements OnInit { } openAddPermissionDialog() { - this.nodePermissionDialogService - .updateNodePermissionByDialog(this.nodeId) - .subscribe( - () => { - this.dialog.open(NodePermissionsDialogComponent, { - data: { nodeId: this.nodeId }, - panelClass: 'aca-permissions-dialog-panel', - width: '800px' - }); - }, - error => { - this.store.dispatch(new SnackbarErrorAction(error)); - } - ); + this.nodePermissionDialogService.updateNodePermissionByDialog(this.nodeId).subscribe( + () => { + this.dialog.open(NodePermissionsDialogComponent, { + data: { nodeId: this.nodeId }, + panelClass: 'aca-permissions-dialog-panel', + width: '800px' + }); + }, + (error) => { + this.store.dispatch(new SnackbarErrorAction(error)); + } + ); } } diff --git a/src/app/components/preview/preview.component.spec.ts b/src/app/components/preview/preview.component.spec.ts index ef7705c07..6a0a9ca39 100644 --- a/src/app/components/preview/preview.component.spec.ts +++ b/src/app/components/preview/preview.component.spec.ts @@ -25,20 +25,8 @@ import { NO_ERRORS_SCHEMA } from '@angular/core'; import { Router, ActivatedRoute } from '@angular/router'; -import { - TestBed, - ComponentFixture, - async, - fakeAsync, - tick -} from '@angular/core/testing'; -import { - UserPreferencesService, - AppConfigPipe, - NodeFavoriteDirective, - UploadService, - AlfrescoApiService -} from '@alfresco/adf-core'; +import { TestBed, ComponentFixture, async, fakeAsync, tick } from '@angular/core/testing'; +import { UserPreferencesService, AppConfigPipe, NodeFavoriteDirective, UploadService, AlfrescoApiService } from '@alfresco/adf-core'; import { ClosePreviewAction } from '@alfresco/aca-shared/store'; import { PreviewComponent } from './preview.component'; import { of, throwError } from 'rxjs'; @@ -48,14 +36,7 @@ import { AppTestingModule } from '../../testing/app-testing.module'; import { ContentApiService } from '@alfresco/aca-shared'; import { ContentManagementService } from '../../services/content-management.service'; import { Store } from '@ngrx/store'; -import { - Node, - NodePaging, - FavoritePaging, - SharedLinkPaging, - PersonEntry, - ResultSetPaging -} from '@alfresco/js-api'; +import { Node, NodePaging, FavoritePaging, SharedLinkPaging, PersonEntry, ResultSetPaging } from '@alfresco/js-api'; describe('PreviewComponent', () => { let fixture: ComponentFixture; @@ -106,12 +87,7 @@ describe('PreviewComponent', () => { component.previousNodeId = 'previous1'; component.onNavigateBefore(clickEvent); - expect(router.navigate).toHaveBeenCalledWith([ - 'personal-files', - 'folder1', - 'preview', - 'previous1' - ]); + expect(router.navigate).toHaveBeenCalledWith(['personal-files', 'folder1', 'preview', 'previous1']); }); it('should navigate back to previous node in the root path', () => { @@ -123,11 +99,7 @@ describe('PreviewComponent', () => { component.previousNodeId = 'previous1'; component.onNavigateBefore(clickEvent); - expect(router.navigate).toHaveBeenCalledWith([ - 'personal-files', - 'preview', - 'previous1' - ]); + expect(router.navigate).toHaveBeenCalledWith(['personal-files', 'preview', 'previous1']); }); it('should not navigate back if node unset', () => { @@ -149,12 +121,7 @@ describe('PreviewComponent', () => { component.nextNodeId = 'next1'; component.onNavigateNext(clickEvent); - expect(router.navigate).toHaveBeenCalledWith([ - 'personal-files', - 'folder1', - 'preview', - 'next1' - ]); + expect(router.navigate).toHaveBeenCalledWith(['personal-files', 'folder1', 'preview', 'next1']); }); it('should navigate to next node in the root path', () => { @@ -166,11 +133,7 @@ describe('PreviewComponent', () => { component.nextNodeId = 'next1'; component.onNavigateNext(clickEvent); - expect(router.navigate).toHaveBeenCalledWith([ - 'personal-files', - 'preview', - 'next1' - ]); + expect(router.navigate).toHaveBeenCalledWith(['personal-files', 'preview', 'next1']); }); it('should not navigate back if node unset', () => { @@ -186,31 +149,19 @@ describe('PreviewComponent', () => { it('should generate preview path for a folder only', () => { component.previewLocation = 'personal-files'; - expect(component.getPreviewPath('folder1', null)).toEqual([ - 'personal-files', - 'folder1' - ]); + expect(component.getPreviewPath('folder1', null)).toEqual(['personal-files', 'folder1']); }); it('should generate preview path for a folder and a node', () => { component.previewLocation = 'personal-files'; - expect(component.getPreviewPath('folder1', 'node1')).toEqual([ - 'personal-files', - 'folder1', - 'preview', - 'node1' - ]); + expect(component.getPreviewPath('folder1', 'node1')).toEqual(['personal-files', 'folder1', 'preview', 'node1']); }); it('should generate preview path for a node only', () => { component.previewLocation = 'personal-files'; - expect(component.getPreviewPath(null, 'node1')).toEqual([ - 'personal-files', - 'preview', - 'node1' - ]); + expect(component.getPreviewPath(null, 'node1')).toEqual(['personal-files', 'preview', 'node1']); }); it('should generate preview for the location only', () => { @@ -351,9 +302,7 @@ describe('PreviewComponent', () => { }); it('should return nearest nodes', async () => { - spyOn(component, 'getFileIds').and.returnValue( - Promise.resolve(['node1', 'node2', 'node3', 'node4', 'node5']) - ); + spyOn(component, 'getFileIds').and.returnValue(Promise.resolve(['node1', 'node2', 'node3', 'node4', 'node5'])); let nearest = await component.getNearestNodes('node1', 'folder1'); expect(nearest).toEqual({ left: null, right: 'node2' }); @@ -366,9 +315,7 @@ describe('PreviewComponent', () => { }); it('should return empty nearest nodes if node is already deleted', async () => { - spyOn(component, 'getFileIds').and.returnValue( - Promise.resolve(['node1', 'node2', 'node3', 'node4', 'node5']) - ); + spyOn(component, 'getFileIds').and.returnValue(Promise.resolve(['node1', 'node2', 'node3', 'node4', 'node5'])); const nearest = await component.getNearestNodes('node9', 'folder1'); expect(nearest).toEqual({ left: null, right: null }); @@ -429,9 +376,7 @@ describe('PreviewComponent', () => { isFile: true } as Node) ); - spyOn(component, 'getNearestNodes').and.returnValue( - Promise.reject('error') - ); + spyOn(component, 'getNearestNodes').and.returnValue(Promise.reject('error')); component.previewLocation = 'personal-files'; await component.displayNode('folder1'); @@ -471,10 +416,7 @@ describe('PreviewComponent', () => { spyOn(contentApi, 'getNodeChildren').and.returnValue( of({ list: { - entries: [ - { entry: { id: 'node1', name: 'node 1' } }, - { entry: { id: 'node2', name: 'node 2' } } - ] + entries: [{ entry: { id: 'node1', name: 'node 1' } }, { entry: { id: 'node2', name: 'node 2' } }] } } as NodePaging) ); @@ -490,10 +432,7 @@ describe('PreviewComponent', () => { spyOn(contentApi, 'getNodeChildren').and.returnValue( of({ list: { - entries: [ - { entry: { id: 'node1', name: 'node 1' } }, - { entry: { id: 'node2', name: 'node 2' } } - ] + entries: [{ entry: { id: 'node1', name: 'node 1' } }, { entry: { id: 'node2', name: 'node 2' } }] } } as NodePaging) ); @@ -532,10 +471,7 @@ describe('PreviewComponent', () => { spyOn(contentApi, 'getNodeChildren').and.returnValue( of({ list: { - entries: [ - { entry: { id: 'node1', name: 'node 1' } }, - { entry: { id: 'node2', name: 'node 2' } } - ] + entries: [{ entry: { id: 'node1', name: 'node 1' } }, { entry: { id: 'node2', name: 'node 2' } }] } } as NodePaging) ); @@ -776,7 +712,7 @@ describe('PreviewComponent', () => { parent.className = 'adf-viewer__sidebar'; const child = document.createElement('button'); - child.addEventListener('keyup', function(e) { + child.addEventListener('keyup', function (e) { component.onNavigateNext(e); }); parent.appendChild(child); @@ -792,7 +728,7 @@ describe('PreviewComponent', () => { parent.className = 'cdk-overlay-container'; const child = document.createElement('button'); - child.addEventListener('keyup', function(e) { + child.addEventListener('keyup', function (e) { component.onNavigateNext(e); }); parent.appendChild(child); diff --git a/src/app/components/preview/preview.component.ts b/src/app/components/preview/preview.component.ts index 1dcbf873c..44e3b8f0f 100644 --- a/src/app/components/preview/preview.component.ts +++ b/src/app/components/preview/preview.component.ts @@ -23,35 +23,12 @@ * along with Alfresco. If not, see . */ -import { - Component, - OnInit, - OnDestroy, - ViewEncapsulation, - HostListener -} from '@angular/core'; -import { - ActivatedRoute, - Router, - UrlTree, - UrlSegmentGroup, - UrlSegment, - PRIMARY_OUTLET -} from '@angular/router'; +import { Component, OnInit, OnDestroy, ViewEncapsulation, HostListener } from '@angular/core'; +import { ActivatedRoute, Router, UrlTree, UrlSegmentGroup, UrlSegment, PRIMARY_OUTLET } from '@angular/router'; import { debounceTime, map, takeUntil } from 'rxjs/operators'; -import { - UserPreferencesService, - ObjectUtils, - UploadService, - AlfrescoApiService -} from '@alfresco/adf-core'; +import { UserPreferencesService, ObjectUtils, UploadService, AlfrescoApiService } from '@alfresco/adf-core'; import { Store } from '@ngrx/store'; -import { - AppStore, - ClosePreviewAction, - ViewerActionTypes, - SetSelectedNodesAction -} from '@alfresco/aca-shared/store'; +import { AppStore, ClosePreviewAction, ViewerActionTypes, SetSelectedNodesAction } from '@alfresco/aca-shared/store'; import { PageComponent } from '../page.component'; import { AppExtensionService, ContentApiService } from '@alfresco/aca-shared'; import { ContentManagementService } from '../../services/content-management.service'; @@ -67,18 +44,11 @@ import { Actions, ofType } from '@ngrx/effects'; encapsulation: ViewEncapsulation.None, host: { class: 'app-preview' } }) -export class PreviewComponent extends PageComponent - implements OnInit, OnDestroy { +export class PreviewComponent extends PageComponent implements OnInit, OnDestroy { previewLocation: string = null; routesSkipNavigation = ['shared', 'recent-files', 'favorites']; navigateSource: string = null; - navigationSources = [ - 'favorites', - 'libraries', - 'personal-files', - 'recent-files', - 'shared' - ]; + navigationSources = ['favorites', 'libraries', 'personal-files', 'recent-files', 'shared']; folderId: string = null; nodeId: string = null; previousNodeId: string; @@ -112,11 +82,7 @@ export class PreviewComponent extends PageComponent '-TYPE:"lnk:link"' ]; - private containersSkipNavigation = [ - 'adf-viewer__sidebar', - 'cdk-overlay-container', - 'adf-image-viewer' - ]; + private containersSkipNavigation = ['adf-viewer__sidebar', 'cdk-overlay-container', 'adf-image-viewer']; constructor( private contentApi: ContentApiService, @@ -138,13 +104,11 @@ export class PreviewComponent extends PageComponent from(this.infoDrawerOpened$) .pipe(takeUntil(this.onDestroy$)) - .subscribe(val => { + .subscribe((val) => { this.showRightSide = val; }); - this.previewLocation = this.router.url - .substr(0, this.router.url.indexOf('/', 1)) - .replace(/\//g, ''); + this.previewLocation = this.router.url.substr(0, this.router.url.indexOf('/', 1)).replace(/\//g, ''); const routeData = this.route.snapshot.data; @@ -159,7 +123,7 @@ export class PreviewComponent extends PageComponent } } - this.route.params.subscribe(params => { + this.route.params.subscribe((params) => { this.folderId = params.folderId; const id = params.nodeId; if (id) { @@ -168,17 +132,11 @@ export class PreviewComponent extends PageComponent }); this.subscriptions = this.subscriptions.concat([ - this.content.nodesDeleted.subscribe(() => - this.navigateToFileLocation(true) - ), + this.content.nodesDeleted.subscribe(() => this.navigateToFileLocation(true)), - this.uploadService.fileUploadDeleted.subscribe(() => - this.navigateToFileLocation(true) - ), + this.uploadService.fileUploadDeleted.subscribe(() => this.navigateToFileLocation(true)), - this.uploadService.fileUploadComplete - .pipe(debounceTime(300)) - .subscribe(file => this.apiService.nodeUpdated.next(file.data.entry)), + this.uploadService.fileUploadComplete.pipe(debounceTime(300)).subscribe((file) => this.apiService.nodeUpdated.next(file.data.entry)), this.actions$ .pipe( @@ -206,10 +164,7 @@ export class PreviewComponent extends PageComponent this.store.dispatch(new SetSelectedNodesAction([{ entry: this.node }])); if (this.node && this.node.isFile) { - const nearest = await this.getNearestNodes( - this.node.id, - this.node.parentId - ); + const nearest = await this.getNearestNodes(this.node.id, this.node.parentId); this.previousNodeId = nearest.left; this.nextNodeId = nearest.right; @@ -247,9 +202,7 @@ export class PreviewComponent extends PageComponent } navigateToFileLocation(shouldNavigate: boolean) { - const shouldSkipNavigation = this.routesSkipNavigation.includes( - this.previewLocation - ); + const shouldSkipNavigation = this.routesSkipNavigation.includes(this.previewLocation); if (shouldNavigate) { const route = this.getNavigationCommands(this.previewLocation); @@ -264,26 +217,18 @@ export class PreviewComponent extends PageComponent /** Handles navigation to a previous document */ onNavigateBefore(event: MouseEvent | KeyboardEvent): void { - if ( - event.type !== 'click' && - this.shouldNavigate(event.target as HTMLElement) - ) { + if (event.type !== 'click' && this.shouldNavigate(event.target as HTMLElement)) { return; } if (this.previousNodeId) { - this.router.navigate( - this.getPreviewPath(this.folderId, this.previousNodeId) - ); + this.router.navigate(this.getPreviewPath(this.folderId, this.previousNodeId)); } } /** Handles navigation to a next document */ onNavigateNext(event: MouseEvent | KeyboardEvent): void { - if ( - event.type !== 'click' && - this.shouldNavigate(event.target as HTMLElement) - ) { + if (event.type !== 'click' && this.shouldNavigate(event.target as HTMLElement)) { return; } @@ -316,10 +261,7 @@ export class PreviewComponent extends PageComponent * @param nodeId Unique identifier of the document node * @param folderId Unique identifier of the containing folder node. */ - async getNearestNodes( - nodeId: string, - folderId: string - ): Promise<{ left: string; right: string }> { + async getNearestNodes(nodeId: string, folderId: string): Promise<{ left: string; right: string }> { const empty = { left: null, right: null @@ -353,10 +295,8 @@ export class PreviewComponent extends PageComponent */ async getFileIds(source: string, folderId?: string): Promise { if ((source === 'personal-files' || source === 'libraries') && folderId) { - const sortKey = - this.preferences.get('personal-files.sorting.key') || 'modifiedAt'; - const sortDirection = - this.preferences.get('personal-files.sorting.direction') || 'desc'; + const sortKey = this.preferences.get('personal-files.sorting.key') || 'modifiedAt'; + const sortDirection = this.preferences.get('personal-files.sorting.direction') || 'desc'; const nodes = await this.contentApi .getNodeChildren(folderId, { // orderBy: `${sortKey} ${sortDirection}`, @@ -365,10 +305,10 @@ export class PreviewComponent extends PageComponent }) .toPromise(); - const entries = nodes.list.entries.map(obj => obj.entry); + const entries = nodes.list.entries.map((obj) => obj.entry); this.sort(entries, sortKey, sortDirection); - return entries.map(obj => obj.id); + return entries.map((obj) => obj.id); } if (source === 'favorites') { @@ -379,21 +319,17 @@ export class PreviewComponent extends PageComponent }) .toPromise(); - const sortKey = - this.preferences.get('favorites.sorting.key') || 'modifiedAt'; - const sortDirection = - this.preferences.get('favorites.sorting.direction') || 'desc'; - const files = nodes.list.entries.map(obj => obj.entry.target.file); + const sortKey = this.preferences.get('favorites.sorting.key') || 'modifiedAt'; + const sortDirection = this.preferences.get('favorites.sorting.direction') || 'desc'; + const files = nodes.list.entries.map((obj) => obj.entry.target.file); this.sort(files, sortKey, sortDirection); - return files.map(f => f.id); + return files.map((f) => f.id); } if (source === 'shared') { - const sortingKey = - this.preferences.get('shared.sorting.key') || 'modifiedAt'; - const sortingDirection = - this.preferences.get('shared.sorting.direction') || 'desc'; + const sortingKey = this.preferences.get('shared.sorting.key') || 'modifiedAt'; + const sortingDirection = this.preferences.get('shared.sorting.direction') || 'desc'; const nodes = await this.contentApi .findSharedLinks({ @@ -401,19 +337,17 @@ export class PreviewComponent extends PageComponent }) .toPromise(); - const entries = nodes.list.entries.map(obj => obj.entry); + const entries = nodes.list.entries.map((obj) => obj.entry); this.sort(entries, sortingKey, sortingDirection); - return entries.map(obj => obj.nodeId); + return entries.map((obj) => obj.nodeId); } if (source === 'recent-files') { const person = await this.contentApi.getPerson('-me-').toPromise(); const username = person.entry.id; - const sortingKey = - this.preferences.get('recent-files.sorting.key') || 'modifiedAt'; - const sortingDirection = - this.preferences.get('recent-files.sorting.direction') || 'desc'; + const sortingKey = this.preferences.get('recent-files.sorting.key') || 'modifiedAt'; + const sortingDirection = this.preferences.get('recent-files.sorting.direction') || 'desc'; const query: SearchRequest = { query: { @@ -439,10 +373,10 @@ export class PreviewComponent extends PageComponent }; const nodes = await this.contentApi.search(query).toPromise(); - const entries = nodes.list.entries.map(obj => obj.entry); + const entries = nodes.list.entries.map((obj) => obj.entry); this.sort(entries, sortingKey, sortingDirection); - return entries.map(obj => obj.id); + return entries.map((obj) => obj.id); } return []; @@ -458,23 +392,19 @@ export class PreviewComponent extends PageComponent items.sort((a: any, b: any) => { let left = ObjectUtils.getValue(a, key); if (left) { - left = - left instanceof Date ? left.valueOf().toString() : left.toString(); + left = left instanceof Date ? left.valueOf().toString() : left.toString(); } else { left = ''; } let right = ObjectUtils.getValue(b, key); if (right) { - right = - right instanceof Date ? right.valueOf().toString() : right.toString(); + right = right instanceof Date ? right.valueOf().toString() : right.toString(); } else { right = ''; } - return direction === 'asc' - ? left.localeCompare(right, undefined, options) - : right.localeCompare(left, undefined, options); + return direction === 'asc' ? left.localeCompare(right, undefined, options) : right.localeCompare(left, undefined, options); }); } @@ -492,8 +422,7 @@ export class PreviewComponent extends PageComponent private getNavigationCommands(url: string): any[] { const urlTree: UrlTree = this.router.parseUrl(url); - const urlSegmentGroup: UrlSegmentGroup = - urlTree.root.children[PRIMARY_OUTLET]; + const urlSegmentGroup: UrlSegmentGroup = urlTree.root.children[PRIMARY_OUTLET]; if (!urlSegmentGroup) { return [url]; @@ -501,7 +430,7 @@ export class PreviewComponent extends PageComponent const urlSegments: UrlSegment[] = urlSegmentGroup.segments; - return urlSegments.reduce(function(acc, item) { + return urlSegments.reduce(function (acc, item) { acc.push(item.path, item.parameters); return acc; }, []); @@ -518,8 +447,6 @@ export class PreviewComponent extends PageComponent } private isChild(list: DOMTokenList): boolean { - return Array.from(list).some((className: string) => - this.containersSkipNavigation.includes(className) - ); + return Array.from(list).some((className: string) => this.containersSkipNavigation.includes(className)); } } diff --git a/src/app/components/recent-files/recent-files.component.spec.ts b/src/app/components/recent-files/recent-files.component.spec.ts index 094daf32a..a9e85f9ae 100644 --- a/src/app/components/recent-files/recent-files.component.spec.ts +++ b/src/app/components/recent-files/recent-files.component.spec.ts @@ -23,20 +23,9 @@ * along with Alfresco. If not, see . */ -import { - TestBed, - ComponentFixture, - fakeAsync, - tick -} from '@angular/core/testing'; +import { TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing'; import { NO_ERRORS_SCHEMA } from '@angular/core'; -import { - AlfrescoApiService, - NodeFavoriteDirective, - DataTableComponent, - AppConfigPipe, - UploadService -} from '@alfresco/adf-core'; +import { AlfrescoApiService, NodeFavoriteDirective, DataTableComponent, AppConfigPipe, UploadService } from '@alfresco/adf-core'; import { DocumentListComponent } from '@alfresco/adf-content-services'; import { RecentFilesComponent } from './recent-files.component'; import { AppTestingModule } from '../../testing/app-testing.module'; @@ -65,13 +54,7 @@ describe('RecentFilesComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [AppTestingModule], - declarations: [ - DataTableComponent, - NodeFavoriteDirective, - DocumentListComponent, - RecentFilesComponent, - AppConfigPipe - ], + declarations: [DataTableComponent, NodeFavoriteDirective, DocumentListComponent, RecentFilesComponent, AppConfigPipe], providers: [ { provide: Router, @@ -94,9 +77,7 @@ describe('RecentFilesComponent', () => { } as PersonEntry) ); - spyOn(alfrescoApi.searchApi, 'search').and.returnValue( - Promise.resolve(page) - ); + spyOn(alfrescoApi.searchApi, 'search').and.returnValue(Promise.resolve(page)); }); it('should call document list reload on fileUploadComplete event', fakeAsync(() => { diff --git a/src/app/components/recent-files/recent-files.component.ts b/src/app/components/recent-files/recent-files.component.ts index b37f86985..0438ba4e3 100644 --- a/src/app/components/recent-files/recent-files.component.ts +++ b/src/app/components/recent-files/recent-files.component.ts @@ -58,18 +58,12 @@ export class RecentFilesComponent extends PageComponent implements OnInit { super.ngOnInit(); this.subscriptions = this.subscriptions.concat([ - this.uploadService.fileUploadComplete - .pipe(debounceTime(300)) - .subscribe(() => this.onFileUploadedEvent()), - this.uploadService.fileUploadDeleted - .pipe(debounceTime(300)) - .subscribe(() => this.onFileUploadedEvent()), + this.uploadService.fileUploadComplete.pipe(debounceTime(300)).subscribe(() => this.onFileUploadedEvent()), + this.uploadService.fileUploadDeleted.pipe(debounceTime(300)).subscribe(() => this.onFileUploadedEvent()), - this.breakpointObserver - .observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]) - .subscribe(result => { - this.isSmallScreen = result.matches; - }) + this.breakpointObserver.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]).subscribe((result) => { + this.isSmallScreen = result.matches; + }) ]); this.columns = this.extensions.documentListPresets.recent || []; diff --git a/src/app/components/search/search-input-control/search-input-control.component.spec.ts b/src/app/components/search/search-input-control/search-input-control.component.spec.ts index 5c305ec13..2915ff8bb 100644 --- a/src/app/components/search/search-input-control/search-input-control.component.spec.ts +++ b/src/app/components/search/search-input-control/search-input-control.component.spec.ts @@ -50,7 +50,7 @@ describe('SearchInputControlComponent', () => { const keyboardEvent = { target: { value: 'a' } }; let eventArgs = null; - component.submit.subscribe(args => (eventArgs = args)); + component.submit.subscribe((args) => (eventArgs = args)); await component.searchSubmit(keyboardEvent); expect(eventArgs).toBe(keyboardEvent); @@ -60,7 +60,7 @@ describe('SearchInputControlComponent', () => { const searchTerm = 'b'; let eventArgs = null; - component.searchChange.subscribe(args => (eventArgs = args)); + component.searchChange.subscribe((args) => (eventArgs = args)); await component.inputChange(searchTerm); expect(eventArgs).toBe(searchTerm); @@ -68,7 +68,7 @@ describe('SearchInputControlComponent', () => { it('should emit searchChange event on clear', async () => { let eventArgs = null; - component.searchChange.subscribe(args => (eventArgs = args)); + component.searchChange.subscribe((args) => (eventArgs = args)); await component.clear(); expect(eventArgs).toBe(''); diff --git a/src/app/components/search/search-input-control/search-input-control.component.ts b/src/app/components/search/search-input-control/search-input-control.component.ts index fd4abc198..e8771f829 100644 --- a/src/app/components/search/search-input-control/search-input-control.component.ts +++ b/src/app/components/search/search-input-control/search-input-control.component.ts @@ -23,16 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Component, - EventEmitter, - Input, - OnDestroy, - Output, - ViewEncapsulation, - ViewChild, - ElementRef -} from '@angular/core'; +import { Component, EventEmitter, Input, OnDestroy, Output, ViewEncapsulation, ViewChild, ElementRef } from '@angular/core'; import { Subject } from 'rxjs'; @Component({ diff --git a/src/app/components/search/search-input.module.ts b/src/app/components/search/search-input.module.ts index 7ffe74145..65ddd2456 100644 --- a/src/app/components/search/search-input.module.ts +++ b/src/app/components/search/search-input.module.ts @@ -32,12 +32,7 @@ import { ContentModule } from '@alfresco/adf-content-services'; import { A11yModule } from '@angular/cdk/a11y'; @NgModule({ - imports: [ - CommonModule, - CoreModule.forChild(), - ContentModule.forChild(), - A11yModule - ], + imports: [CommonModule, CoreModule.forChild(), ContentModule.forChild(), A11yModule], declarations: [SearchInputComponent, SearchInputControlComponent], exports: [SearchInputComponent, SearchInputControlComponent] }) diff --git a/src/app/components/search/search-input/search-input.component.spec.ts b/src/app/components/search/search-input/search-input.component.spec.ts index 875381882..124dd53de 100644 --- a/src/app/components/search/search-input/search-input.component.spec.ts +++ b/src/app/components/search/search-input/search-input.component.spec.ts @@ -24,21 +24,11 @@ */ import { NO_ERRORS_SCHEMA } from '@angular/core'; -import { - TestBed, - async, - ComponentFixture, - fakeAsync, - tick -} from '@angular/core/testing'; - +import { TestBed, async, ComponentFixture, fakeAsync, tick } from '@angular/core/testing'; import { SearchInputComponent } from './search-input.component'; import { AppTestingModule } from '../../../testing/app-testing.module'; import { Actions, ofType } from '@ngrx/effects'; -import { - SearchByTermAction, - SearchActionTypes -} from '@alfresco/aca-shared/store'; +import { SearchByTermAction, SearchActionTypes } from '@alfresco/aca-shared/store'; import { map } from 'rxjs/operators'; import { SearchQueryBuilderService } from '@alfresco/adf-content-services'; import { SearchLibrariesQueryBuilderService } from '../search-libraries-results/search-libraries-query-builder.service'; @@ -79,9 +69,7 @@ describe('SearchInputComponent', () => { }); it('should have library constraint on 400 error received', () => { - const libItem = component.searchOptions.find( - item => item.key.toLowerCase().indexOf('libraries') > 0 - ); + const libItem = component.searchOptions.find((item) => item.key.toLowerCase().indexOf('libraries') > 0); libItem.value = true; content.library400Error.next(); @@ -89,12 +77,12 @@ describe('SearchInputComponent', () => { }); describe('onSearchSubmit()', () => { - it('should call search action with correct search options', fakeAsync(done => { + it('should call search action with correct search options', fakeAsync((done) => { const searchedTerm = 's'; const currentSearchOptions = [{ key: 'test' }]; actions$.pipe( ofType(SearchActionTypes.SearchByTerm), - map(action => { + map((action) => { expect(action.searchOptions[0].key).toBe(currentSearchOptions[0].key); done(); }) @@ -103,11 +91,11 @@ describe('SearchInputComponent', () => { tick(); })); - it('should call search action with correct searched term', fakeAsync(done => { + it('should call search action with correct searched term', fakeAsync((done) => { const searchedTerm = 's'; actions$.pipe( ofType(SearchActionTypes.SearchByTerm), - map(action => { + map((action) => { expect(action.payload).toBe(searchedTerm); done(); }) @@ -118,12 +106,12 @@ describe('SearchInputComponent', () => { }); describe('onSearchChange()', () => { - it('should call search action with correct search options', fakeAsync(done => { + it('should call search action with correct search options', fakeAsync((done) => { const searchedTerm = 's'; const currentSearchOptions = [{ key: 'test' }]; actions$.pipe( ofType(SearchActionTypes.SearchByTerm), - map(action => { + map((action) => { expect(action.searchOptions[0].key).toBe(currentSearchOptions[0].key); done(); }) @@ -132,11 +120,11 @@ describe('SearchInputComponent', () => { tick(1000); })); - it('should call search action with correct searched term', fakeAsync(done => { + it('should call search action with correct searched term', fakeAsync((done) => { const searchedTerm = 's'; actions$.pipe( ofType(SearchActionTypes.SearchByTerm), - map(action => { + map((action) => { expect(action.payload).toBe(searchedTerm); done(); }) @@ -152,9 +140,7 @@ describe('SearchInputComponent', () => { }); it('should return true when libraries checked', () => { - const libItem = component.searchOptions.find( - item => item.key.toLowerCase().indexOf('libraries') > 0 - ); + const libItem = component.searchOptions.find((item) => item.key.toLowerCase().indexOf('libraries') > 0); libItem.value = true; expect(component.isLibrariesChecked()).toBe(true); }); @@ -166,29 +152,21 @@ describe('SearchInputComponent', () => { }); it('should return true when files checked', () => { - const filesItem = component.searchOptions.find( - item => item.key.toLowerCase().indexOf('files') > 0 - ); + const filesItem = component.searchOptions.find((item) => item.key.toLowerCase().indexOf('files') > 0); filesItem.value = true; expect(component.isContentChecked()).toBe(true); }); it('should return true when folders checked', () => { - const foldersItem = component.searchOptions.find( - item => item.key.toLowerCase().indexOf('folders') > 0 - ); + const foldersItem = component.searchOptions.find((item) => item.key.toLowerCase().indexOf('folders') > 0); foldersItem.value = true; expect(component.isContentChecked()).toBe(true); }); it('should return true when both files and folders checked', () => { - const filesItem = component.searchOptions.find( - item => item.key.toLowerCase().indexOf('files') > 0 - ); + const filesItem = component.searchOptions.find((item) => item.key.toLowerCase().indexOf('files') > 0); filesItem.value = true; - const foldersItem = component.searchOptions.find( - item => item.key.toLowerCase().indexOf('folders') > 0 - ); + const foldersItem = component.searchOptions.find((item) => item.key.toLowerCase().indexOf('folders') > 0); foldersItem.value = true; expect(component.isContentChecked()).toBe(true); }); diff --git a/src/app/components/search/search-input/search-input.component.ts b/src/app/components/search/search-input/search-input.component.ts index 38e0d78f3..691a8b707 100644 --- a/src/app/components/search/search-input/search-input.component.ts +++ b/src/app/components/search/search-input/search-input.component.ts @@ -23,31 +23,12 @@ * along with Alfresco. If not, see . */ -import { - AppStore, - SearchByTermAction, - SearchOptionIds, - SearchOptionModel -} from '@alfresco/aca-shared/store'; +import { AppStore, SearchByTermAction, SearchOptionIds, SearchOptionModel } from '@alfresco/aca-shared/store'; import { SearchQueryBuilderService } from '@alfresco/adf-content-services'; import { AppConfigService } from '@alfresco/adf-core'; -import { - Component, - OnDestroy, - OnInit, - ViewChild, - ViewEncapsulation -} from '@angular/core'; +import { Component, OnDestroy, OnInit, ViewChild, ViewEncapsulation } from '@angular/core'; import { MatMenuTrigger } from '@angular/material/menu'; -import { - NavigationEnd, - PRIMARY_OUTLET, - Router, - RouterEvent, - UrlSegment, - UrlSegmentGroup, - UrlTree -} from '@angular/router'; +import { NavigationEnd, PRIMARY_OUTLET, Router, RouterEvent, UrlSegment, UrlSegmentGroup, UrlTree } from '@angular/router'; import { Store } from '@ngrx/store'; import { Subject } from 'rxjs'; import { filter, takeUntil } from 'rxjs/operators'; @@ -105,10 +86,7 @@ export class SearchInputComponent implements OnInit, OnDestroy { private router: Router, private store: Store ) { - this.searchOnChange = this.config.get( - 'search.aca:triggeredOnChange', - true - ); + this.searchOnChange = this.config.get('search.aca:triggeredOnChange', true); } ngOnInit() { @@ -116,18 +94,16 @@ export class SearchInputComponent implements OnInit, OnDestroy { this.router.events .pipe(takeUntil(this.onDestroy$)) - .pipe(filter(e => e instanceof RouterEvent)) - .subscribe(event => { + .pipe(filter((e) => e instanceof RouterEvent)) + .subscribe((event) => { if (event instanceof NavigationEnd) { this.showInputValue(); } }); - this.content.library400Error - .pipe(takeUntil(this.onDestroy$)) - .subscribe(() => { - this.has400LibraryError = true; - }); + this.content.library400Error.pipe(takeUntil(this.onDestroy$)).subscribe(() => { + this.has400LibraryError = true; + }); } showInputValue() { @@ -155,9 +131,7 @@ export class SearchInputComponent implements OnInit, OnDestroy { * @param event Parameters relating to the search */ onSearchSubmit(event: any) { - const searchTerm = event.target - ? (event.target as HTMLInputElement).value - : event; + const searchTerm = event.target ? (event.target as HTMLInputElement).value : event; if (searchTerm) { this.searchedWord = searchTerm; @@ -187,9 +161,7 @@ export class SearchInputComponent implements OnInit, OnDestroy { this.navigationTimer = setTimeout(() => { if (searchTerm) { - this.store.dispatch( - new SearchByTermAction(searchTerm, this.searchOptions) - ); + this.store.dispatch(new SearchByTermAction(searchTerm, this.searchOptions)); } this.hasOneChange = false; }, 1000); @@ -202,9 +174,7 @@ export class SearchInputComponent implements OnInit, OnDestroy { if (this.onLibrariesSearchResults && this.isSameSearchTerm()) { this.queryLibrariesBuilder.update(); } else if (this.searchedWord) { - this.store.dispatch( - new SearchByTermAction(this.searchedWord, this.searchOptions) - ); + this.store.dispatch(new SearchByTermAction(this.searchedWord, this.searchOptions)); } } else { if (this.isFoldersChecked() && !this.isFilesChecked()) { @@ -218,9 +188,7 @@ export class SearchInputComponent implements OnInit, OnDestroy { if (this.onSearchResults && this.isSameSearchTerm()) { this.queryBuilder.update(); } else if (this.searchedWord) { - this.store.dispatch( - new SearchByTermAction(this.searchedWord, this.searchOptions) - ); + this.store.dispatch(new SearchByTermAction(this.searchedWord, this.searchOptions)); } } } @@ -230,9 +198,7 @@ export class SearchInputComponent implements OnInit, OnDestroy { } get onSearchResults() { - return ( - !this.onLibrariesSearchResults && this.router.url.indexOf('/search') === 0 - ); + return !this.onLibrariesSearchResults && this.router.url.indexOf('/search') === 0; } isFilesChecked(): boolean { @@ -248,7 +214,7 @@ export class SearchInputComponent implements OnInit, OnDestroy { } isOptionChecked(optionId: string): boolean { - const libItem = this.searchOptions.find(item => item.id === optionId); + const libItem = this.searchOptions.find((item) => item.id === optionId); return !!libItem && libItem.value; } @@ -258,18 +224,13 @@ export class SearchInputComponent implements OnInit, OnDestroy { hasLibraryConstraint(): boolean { if (this.isLibrariesChecked()) { - return ( - this.has400LibraryError || this.searchInputControl.isTermTooShort() - ); + return this.has400LibraryError || this.searchInputControl.isTermTooShort(); } return false; } filterContent(option: SearchOptionIds.Folders | SearchOptionIds.Files) { - const oppositeOption = - option === SearchOptionIds.Folders - ? SearchOptionIds.Files - : SearchOptionIds.Folders; + const oppositeOption = option === SearchOptionIds.Folders ? SearchOptionIds.Files : SearchOptionIds.Folders; this.queryBuilder.addFilterQuery(`+TYPE:'cm:${option}'`); this.queryBuilder.removeFilterQuery(`+TYPE:'cm:${oppositeOption}'`); @@ -277,9 +238,7 @@ export class SearchInputComponent implements OnInit, OnDestroy { removeContentFilters() { this.queryBuilder.removeFilterQuery(`+TYPE:'cm:${SearchOptionIds.Files}'`); - this.queryBuilder.removeFilterQuery( - `+TYPE:'cm:${SearchOptionIds.Folders}'` - ); + this.queryBuilder.removeFilterQuery(`+TYPE:'cm:${SearchOptionIds.Folders}'`); } syncInputValues() { @@ -296,14 +255,11 @@ export class SearchInputComponent implements OnInit, OnDestroy { let searchTerm = ''; if (this.onSearchResults || this.onLibrariesSearchResults) { const urlTree: UrlTree = this.router.parseUrl(this.router.url); - const urlSegmentGroup: UrlSegmentGroup = - urlTree.root.children[PRIMARY_OUTLET]; + const urlSegmentGroup: UrlSegmentGroup = urlTree.root.children[PRIMARY_OUTLET]; if (urlSegmentGroup) { const urlSegments: UrlSegment[] = urlSegmentGroup.segments; - searchTerm = urlSegments[0].parameters['q'] - ? decodeURIComponent(urlSegments[0].parameters['q']) - : ''; + searchTerm = urlSegments[0].parameters['q'] ? decodeURIComponent(urlSegments[0].parameters['q']) : ''; } } diff --git a/src/app/components/search/search-libraries-results/search-libraries-query-builder.service.spec.ts b/src/app/components/search/search-libraries-results/search-libraries-query-builder.service.spec.ts index 9742c733e..3634e0bc3 100644 --- a/src/app/components/search/search-libraries-results/search-libraries-query-builder.service.spec.ts +++ b/src/app/components/search/search-libraries-results/search-libraries-query-builder.service.spec.ts @@ -26,10 +26,7 @@ import { TestBed } from '@angular/core/testing'; import { AppTestingModule } from '../../../testing/app-testing.module'; import { AlfrescoApiService } from '@alfresco/adf-core'; -import { - SearchLibrariesQueryBuilderService, - LibrarySearchQuery -} from './search-libraries-query-builder.service'; +import { SearchLibrariesQueryBuilderService, LibrarySearchQuery } from './search-libraries-query-builder.service'; describe('SearchLibrariesQueryBuilderService', () => { let apiService: AlfrescoApiService; @@ -61,7 +58,7 @@ describe('SearchLibrariesQueryBuilderService', () => { spyOn(builder, 'buildQuery').and.returnValue(query); let eventArgs = null; - builder.updated.subscribe(args => (eventArgs = args)); + builder.updated.subscribe((args) => (eventArgs = args)); await builder.update(); expect(eventArgs).toBe(query); @@ -74,7 +71,7 @@ describe('SearchLibrariesQueryBuilderService', () => { spyOn(builder, 'buildQuery').and.returnValue(query); let eventArgs = null; - builder.executed.subscribe(args => (eventArgs = args)); + builder.executed.subscribe((args) => (eventArgs = args)); await builder.execute(); expect(eventArgs).toBe(data); @@ -111,7 +108,7 @@ describe('SearchLibrariesQueryBuilderService', () => { spyOn(builder, 'buildQuery').and.returnValue(query); let eventArgs = null; - builder.hadError.subscribe(args => (eventArgs = args)); + builder.hadError.subscribe((args) => (eventArgs = args)); await builder.execute(); expect(eventArgs).toBe(err); diff --git a/src/app/components/search/search-libraries-results/search-libraries-query-builder.service.ts b/src/app/components/search/search-libraries-results/search-libraries-query-builder.service.ts index da852a5f7..4c1e6fe71 100644 --- a/src/app/components/search/search-libraries-results/search-libraries-query-builder.service.ts +++ b/src/app/components/search/search-libraries-results/search-libraries-query-builder.service.ts @@ -92,7 +92,7 @@ export class SearchLibrariesQueryBuilderService { return this.alfrescoApiService .getInstance() .core.queriesApi.findSites(libraryQuery.term, libraryQuery.opts) - .catch(err => { + .catch((err) => { this.hadError.next(err); return { list: { pagination: { totalItems: 0 }, entries: [] } }; }); diff --git a/src/app/components/search/search-libraries-results/search-libraries-results.component.spec.ts b/src/app/components/search/search-libraries-results/search-libraries-results.component.spec.ts index 669bff593..17d38a0f9 100644 --- a/src/app/components/search/search-libraries-results/search-libraries-results.component.spec.ts +++ b/src/app/components/search/search-libraries-results/search-libraries-results.component.spec.ts @@ -40,12 +40,7 @@ describe('SearchLibrariesResultsComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [AppTestingModule], - declarations: [ - DataTableComponent, - DocumentListComponent, - SearchLibrariesResultsComponent, - AppConfigPipe - ], + declarations: [DataTableComponent, DocumentListComponent, SearchLibrariesResultsComponent, AppConfigPipe], schemas: [NO_ERRORS_SCHEMA], providers: [SearchLibrariesQueryBuilderService] }); diff --git a/src/app/components/search/search-libraries-results/search-libraries-results.component.ts b/src/app/components/search/search-libraries-results/search-libraries-results.component.ts index 93350b478..a615bdf35 100644 --- a/src/app/components/search/search-libraries-results/search-libraries-results.component.ts +++ b/src/app/components/search/search-libraries-results/search-libraries-results.component.ts @@ -39,8 +39,7 @@ import { AppExtensionService } from '@alfresco/aca-shared'; templateUrl: './search-libraries-results.component.html', styleUrls: ['./search-libraries-results.component.scss'] }) -export class SearchLibrariesResultsComponent extends PageComponent - implements OnInit { +export class SearchLibrariesResultsComponent extends PageComponent implements OnInit { isSmallScreen = false; searchedWord: string; queryParamName = 'q'; @@ -71,15 +70,9 @@ export class SearchLibrariesResultsComponent extends PageComponent this.columns = this.extensions.documentListPresets.searchLibraries || []; this.subscriptions.push( - this.content.libraryJoined.subscribe(() => - this.librariesQueryBuilder.update() - ), - this.content.libraryDeleted.subscribe(() => - this.librariesQueryBuilder.update() - ), - this.content.libraryLeft.subscribe(() => - this.librariesQueryBuilder.update() - ), + this.content.libraryJoined.subscribe(() => this.librariesQueryBuilder.update()), + this.content.libraryDeleted.subscribe(() => this.librariesQueryBuilder.update()), + this.content.libraryLeft.subscribe(() => this.librariesQueryBuilder.update()), this.librariesQueryBuilder.updated.subscribe(() => { this.isLoading = true; @@ -87,12 +80,12 @@ export class SearchLibrariesResultsComponent extends PageComponent this.librariesQueryBuilder.execute(); }), - this.librariesQueryBuilder.executed.subscribe(data => { + this.librariesQueryBuilder.executed.subscribe((data) => { this.onSearchResultLoaded(data); this.isLoading = false; }), - this.librariesQueryBuilder.hadError.subscribe(err => { + this.librariesQueryBuilder.hadError.subscribe((err) => { try { const { error: { statusCode } @@ -103,18 +96,14 @@ export class SearchLibrariesResultsComponent extends PageComponent } catch (e) {} }), - this.breakpointObserver - .observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]) - .subscribe(result => { - this.isSmallScreen = result.matches; - }) + this.breakpointObserver.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]).subscribe((result) => { + this.isSmallScreen = result.matches; + }) ); if (this.route) { this.route.params.forEach((params: Params) => { - this.searchedWord = params.hasOwnProperty(this.queryParamName) - ? params[this.queryParamName] - : null; + this.searchedWord = params.hasOwnProperty(this.queryParamName) ? params[this.queryParamName] : null; const query = this.formatSearchQuery(this.searchedWord); if (query && query.length > 1) { diff --git a/src/app/components/search/search-results-row/search-results-row.component.ts b/src/app/components/search/search-results-row/search-results-row.component.ts index d0540a216..2bd812e8c 100644 --- a/src/app/components/search/search-results-row/search-results-row.component.ts +++ b/src/app/components/search/search-results-row/search-results-row.component.ts @@ -23,14 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Component, - Input, - OnInit, - ViewEncapsulation, - ChangeDetectionStrategy, - OnDestroy -} from '@angular/core'; +import { Component, Input, OnInit, ViewEncapsulation, ChangeDetectionStrategy, OnDestroy } from '@angular/core'; import { MinimalNodeEntity } from '@alfresco/js-api'; import { ViewNodeAction, NavigateToFolder } from '@alfresco/aca-shared/store'; import { Store } from '@ngrx/store'; @@ -57,30 +50,24 @@ export class SearchResultsRowComponent implements OnInit, OnDestroy { name$ = new BehaviorSubject(''); title$ = new BehaviorSubject(''); - constructor( - private store: Store, - private alfrescoApiService: AlfrescoApiService, - private router: Router - ) {} + constructor(private store: Store, private alfrescoApiService: AlfrescoApiService, private router: Router) {} ngOnInit() { this.updateValues(); - this.alfrescoApiService.nodeUpdated - .pipe(takeUntil(this.onDestroy$)) - .subscribe((node: any) => { - const row = this.context.row; - if (row) { - const { entry } = row.node; + this.alfrescoApiService.nodeUpdated.pipe(takeUntil(this.onDestroy$)).subscribe((node: any) => { + const row = this.context.row; + if (row) { + const { entry } = row.node; - if (entry.id === node.id) { - entry.name = node.name; - entry.properties = Object.assign({}, node.properties); + if (entry.id === node.id) { + entry.name = node.name; + entry.properties = Object.assign({}, node.properties); - this.updateValues(); - } + this.updateValues(); } - }); + } + }); } private updateValues() { @@ -125,9 +112,7 @@ export class SearchResultsRowComponent implements OnInit, OnDestroy { showPreview(event: MouseEvent) { event.stopPropagation(); - this.store.dispatch( - new ViewNodeAction(this.node.entry.id, { location: this.router.url }) - ); + this.store.dispatch(new ViewNodeAction(this.node.entry.id, { location: this.router.url })); } navigate(event: MouseEvent) { diff --git a/src/app/components/search/search-results.module.ts b/src/app/components/search/search-results.module.ts index db43d59fd..6749ffde9 100644 --- a/src/app/components/search/search-results.module.ts +++ b/src/app/components/search/search-results.module.ts @@ -49,15 +49,7 @@ import { ContextMenuModule } from '../context-menu/context-menu.module'; AppLayoutModule, ContextMenuModule ], - declarations: [ - SearchResultsComponent, - SearchLibrariesResultsComponent, - SearchResultsRowComponent - ], - exports: [ - SearchResultsComponent, - SearchLibrariesResultsComponent, - SearchResultsRowComponent - ] + declarations: [SearchResultsComponent, SearchLibrariesResultsComponent, SearchResultsRowComponent], + exports: [SearchResultsComponent, SearchLibrariesResultsComponent, SearchResultsRowComponent] }) export class AppSearchResultsModule {} diff --git a/src/app/components/search/search-results/search-results.component.spec.ts b/src/app/components/search/search-results/search-results.component.spec.ts index 85191ba48..8949042ba 100644 --- a/src/app/components/search/search-results/search-results.component.spec.ts +++ b/src/app/components/search/search-results/search-results.component.spec.ts @@ -23,28 +23,13 @@ * along with Alfresco. If not, see . */ -import { - ComponentFixture, - TestBed, - fakeAsync, - tick -} from '@angular/core/testing'; - +import { ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing'; import { SearchResultsComponent } from './search-results.component'; import { AppTestingModule } from '../../../testing/app-testing.module'; import { AppSearchResultsModule } from '../search-results.module'; -import { - CoreModule, - AppConfigService, - AlfrescoApiService, - AlfrescoApiServiceMock, - TranslationService -} from '@alfresco/adf-core'; +import { CoreModule, AppConfigService, AlfrescoApiService, AlfrescoApiServiceMock, TranslationService } from '@alfresco/adf-core'; import { Store } from '@ngrx/store'; -import { - NavigateToFolder, - SnackbarErrorAction -} from '@alfresco/aca-shared/store'; +import { NavigateToFolder, SnackbarErrorAction } from '@alfresco/aca-shared/store'; import { Pagination, SearchRequest } from '@alfresco/js-api'; import { SearchQueryBuilderService } from '@alfresco/adf-content-services'; import { ActivatedRoute, Router } from '@angular/router'; @@ -63,12 +48,7 @@ describe('SearchComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ - TranslateModule.forRoot(), - CoreModule.forRoot(), - AppTestingModule, - AppSearchResultsModule - ], + imports: [TranslateModule.forRoot(), CoreModule.forRoot(), AppTestingModule, AppSearchResultsModule], providers: [ { provide: AlfrescoApiService, @@ -84,8 +64,7 @@ describe('SearchComponent', () => { }, params: [ { - q: - 'TYPE: "cm:folder" AND %28=cm: name: email OR cm: name: budget%29' + q: 'TYPE: "cm:folder" AND %28=cm: name: email OR cm: name: budget%29' } ] } @@ -121,9 +100,7 @@ describe('SearchComponent', () => { queryBuilder.execute(); tick(); - expect(store.dispatch).toHaveBeenCalledWith( - new SnackbarErrorAction('APP.BROWSE.SEARCH.ERRORS.GENERIC') - ); + expect(store.dispatch).toHaveBeenCalledWith(new SnackbarErrorAction('APP.BROWSE.SEARCH.ERRORS.GENERIC')); })); it('should raise a known error if search fails', fakeAsync(() => { @@ -146,9 +123,7 @@ describe('SearchComponent', () => { queryBuilder.execute(); tick(); - expect(store.dispatch).toHaveBeenCalledWith( - new SnackbarErrorAction('Known Error') - ); + expect(store.dispatch).toHaveBeenCalledWith(new SnackbarErrorAction('Known Error')); })); it('should raise a generic error if search fails', fakeAsync(() => { @@ -171,15 +146,11 @@ describe('SearchComponent', () => { queryBuilder.execute(); tick(); - expect(store.dispatch).toHaveBeenCalledWith( - new SnackbarErrorAction('Generic Error') - ); + expect(store.dispatch).toHaveBeenCalledWith(new SnackbarErrorAction('Generic Error')); })); it('should decode encoded URI', () => { - expect(queryBuilder.userQuery).toEqual( - '(TYPE: "cm:folder" AND (=cm: name: email OR cm: name: budget))' - ); + expect(queryBuilder.userQuery).toEqual('(TYPE: "cm:folder" AND (=cm: name: email OR cm: name: budget))'); }); it('should return null if formatting invalid query', () => { @@ -228,9 +199,7 @@ describe('SearchComponent', () => { const query = component.formatSearchQuery('big yellow banana'); - expect(query).toBe( - `(cm:name:"big*") AND (cm:name:"yellow*") AND (cm:name:"banana*")` - ); + expect(query).toBe(`(cm:name:"big*") AND (cm:name:"yellow*") AND (cm:name:"banana*")`); }); it('should support conjunctions with AND operator', () => { @@ -282,9 +251,7 @@ describe('SearchComponent', () => { const query = component.formatSearchQuery('=test1.pdf or =test2.pdf'); - expect(query).toBe( - `(=cm:name:"test1.pdf" OR =cm:title:"test1.pdf") or (=cm:name:"test2.pdf" OR =cm:title:"test2.pdf")` - ); + expect(query).toBe(`(=cm:name:"test1.pdf" OR =cm:title:"test1.pdf") or (=cm:name:"test2.pdf" OR =cm:title:"test2.pdf")`); }); it('should navigate to folder on double click', () => { diff --git a/src/app/components/search/search-results/search-results.component.ts b/src/app/components/search/search-results/search-results.component.ts index e56011141..2b536dbb2 100644 --- a/src/app/components/search/search-results/search-results.component.ts +++ b/src/app/components/search/search-results/search-results.component.ts @@ -24,24 +24,12 @@ */ import { Component, OnInit, ViewChild, ViewEncapsulation } from '@angular/core'; -import { - Pagination, - MinimalNodeEntity, - ResultSetPaging -} from '@alfresco/js-api'; +import { Pagination, MinimalNodeEntity, ResultSetPaging } from '@alfresco/js-api'; import { ActivatedRoute, Params, Router } from '@angular/router'; -import { - SearchQueryBuilderService, - SearchFilterComponent -} from '@alfresco/adf-content-services'; +import { SearchQueryBuilderService, SearchFilterComponent } from '@alfresco/adf-content-services'; import { PageComponent } from '../../page.component'; import { Store } from '@ngrx/store'; -import { - AppStore, - NavigateToFolder, - SnackbarErrorAction, - showFacetFilter -} from '@alfresco/aca-shared/store'; +import { AppStore, NavigateToFolder, SnackbarErrorAction, showFacetFilter } from '@alfresco/aca-shared/store'; import { ContentManagementService } from '../../../services/content-management.service'; import { AppConfigService, TranslationService } from '@alfresco/adf-core'; import { Observable } from 'rxjs'; @@ -93,14 +81,14 @@ export class SearchResultsComponent extends PageComponent implements OnInit { this.sorting = this.getSorting(); this.subscriptions.push( - this.queryBuilder.updated.subscribe(query => { + this.queryBuilder.updated.subscribe((query) => { if (query) { this.sorting = this.getSorting(); this.isLoading = true; } }), - this.queryBuilder.executed.subscribe(data => { + this.queryBuilder.executed.subscribe((data) => { this.queryBuilder.paging.skipCount = 0; this.onSearchResultLoaded(data); @@ -114,9 +102,7 @@ export class SearchResultsComponent extends PageComponent implements OnInit { if (this.route) { this.route.params.forEach((params: Params) => { - this.searchedWord = params.hasOwnProperty(this.queryParamName) - ? params[this.queryParamName] - : null; + this.searchedWord = params.hasOwnProperty(this.queryParamName) ? params[this.queryParamName] : null; const query = this.formatSearchQuery(this.searchedWord); if (query) { @@ -139,9 +125,7 @@ export class SearchResultsComponent extends PageComponent implements OnInit { let translated = this.translationService.instant(messageKey); if (translated === messageKey) { - translated = this.translationService.instant( - `APP.BROWSE.SEARCH.ERRORS.GENERIC` - ); + translated = this.translationService.instant(`APP.BROWSE.SEARCH.ERRORS.GENERIC`); } this.store.dispatch(new SnackbarErrorAction(translated)); @@ -167,11 +151,7 @@ export class SearchResultsComponent extends PageComponent implements OnInit { term = term.substring(1); } - return ( - '(' + - fields.map(field => `${prefix}${field}:"${term}${suffix}"`).join(' OR ') + - ')' - ); + return '(' + fields.map((field) => `${prefix}${field}:"${term}${suffix}"`).join(' OR ') + ')'; } formatSearchQuery(userInput: string) { @@ -192,7 +172,7 @@ export class SearchResultsComponent extends PageComponent implements OnInit { const separator = words.some(this.isOperator) ? ' ' : ' AND '; return words - .map(term => { + .map((term) => { if (this.isOperator(term)) { return term; } @@ -219,16 +199,11 @@ export class SearchResultsComponent extends PageComponent implements OnInit { } isFiltered(): boolean { - return ( - this.searchFilter.selectedBuckets.length > 0 || - this.hasCheckedCategories() - ); + return this.searchFilter.selectedBuckets.length > 0 || this.hasCheckedCategories(); } hasCheckedCategories() { - const checkedCategory = this.queryBuilder.categories.find( - category => !!this.queryBuilder.queryFragments[category.id] - ); + const checkedCategory = this.queryBuilder.categories.find((category) => !!this.queryBuilder.queryFragments[category.id]); return !!checkedCategory; } diff --git a/src/app/components/settings/settings.component.spec.ts b/src/app/components/settings/settings.component.spec.ts index 4e2a21023..d92b7fd47 100644 --- a/src/app/components/settings/settings.component.spec.ts +++ b/src/app/components/settings/settings.component.spec.ts @@ -29,15 +29,8 @@ import { setupTestBed, StorageService } from '@alfresco/adf-core'; import { AppSettingsModule } from './settings.module'; import { AppTestingModule } from '../../testing/app-testing.module'; import { By } from '@angular/platform-browser'; -import { - TranslateModule, - TranslateLoader, - TranslateFakeLoader -} from '@ngx-translate/core'; -import { - AppExtensionService, - SettingsParameterRef -} from '@alfresco/aca-shared'; +import { TranslateModule, TranslateLoader, TranslateFakeLoader } from '@ngx-translate/core'; +import { AppExtensionService, SettingsParameterRef } from '@alfresco/aca-shared'; describe('SettingsComponent', () => { let fixture: ComponentFixture; @@ -100,10 +93,7 @@ describe('SettingsComponent', () => { component.setParamValue(stringParam, 'test'); expect(stringParam.value).toBe('test'); - expect(storage.setItem).toHaveBeenCalledWith( - stringParam.key, - stringParam.value - ); + expect(storage.setItem).toHaveBeenCalledWith(stringParam.key, stringParam.value); }); it('should save param value only if changed', () => { @@ -148,9 +138,7 @@ describe('SettingsComponent', () => { fixture.detectChanges(); await fixture.whenStable(); - const panels = fixture.debugElement.queryAll( - By.css('.mat-expansion-panel') - ); + const panels = fixture.debugElement.queryAll(By.css('.mat-expansion-panel')); expect(panels.length).toBe(3); }); }); diff --git a/src/app/components/settings/settings.component.ts b/src/app/components/settings/settings.component.ts index 59bec90a7..f6db19ca1 100644 --- a/src/app/components/settings/settings.component.ts +++ b/src/app/components/settings/settings.component.ts @@ -24,27 +24,13 @@ */ import { Component, ViewEncapsulation, OnInit } from '@angular/core'; -import { - AppConfigService, - StorageService, - OauthConfigModel -} from '@alfresco/adf-core'; +import { AppConfigService, StorageService, OauthConfigModel } from '@alfresco/adf-core'; import { Validators, FormGroup, FormBuilder } from '@angular/forms'; import { Observable } from 'rxjs'; import { Store } from '@ngrx/store'; -import { - AppStore, - getHeaderColor, - getAppName, - getUserProfile, - SetSettingsParameterAction -} from '@alfresco/aca-shared/store'; +import { AppStore, getHeaderColor, getAppName, getUserProfile, SetSettingsParameterAction } from '@alfresco/aca-shared/store'; import { ProfileState } from '@alfresco/adf-extensions'; -import { - AppExtensionService, - SettingsGroupRef, - SettingsParameterRef -} from '@alfresco/aca-shared'; +import { AppExtensionService, SettingsGroupRef, SettingsParameterRef } from '@alfresco/aca-shared'; interface RepositoryConfig { ecmHost: string; @@ -89,14 +75,8 @@ export class SettingsComponent implements OnInit { ngOnInit() { this.form = this.fb.group({ - ecmHost: [ - '', - [Validators.required, Validators.pattern('^(http|https)://.*[^/]$')] - ], - aisHost: [ - '', - [Validators.required, Validators.pattern('^(http|https)://.*[^/]$')] - ], + ecmHost: ['', [Validators.required, Validators.pattern('^(http|https)://.*[^/]$')]], + aisHost: ['', [Validators.required, Validators.pattern('^(http|https)://.*[^/]$')]], authType: [''] }); @@ -108,10 +88,7 @@ export class SettingsComponent implements OnInit { this.storage.setItem('ecmHost', model.ecmHost); this.storage.setItem('authType', model.authType); - const config: OauthConfigModel = this.appConfig.get( - 'oauth2', - null - ); + const config: OauthConfigModel = this.appConfig.get('oauth2', null); config.host = model.aisHost; this.storage.setItem('oauth2', JSON.stringify(config)); @@ -120,15 +97,10 @@ export class SettingsComponent implements OnInit { } reset() { - const config: OauthConfigModel = this.appConfig.get( - 'oauth2', - null - ); + const config: OauthConfigModel = this.appConfig.get('oauth2', null); this.form.reset({ - ecmHost: - this.storage.getItem('ecmHost') || - this.appConfig.get('ecmHost'), + ecmHost: this.storage.getItem('ecmHost') || this.appConfig.get('ecmHost'), aisHost: config.host, authType: this.appConfig.get('authType') }); @@ -157,12 +129,7 @@ export class SettingsComponent implements OnInit { } private saveToStorage(param: SettingsParameterRef) { - this.storage.setItem( - param.key, - param.value ? param.value.toString() : param.value - ); - this.store.dispatch( - new SetSettingsParameterAction({ name: param.key, value: param.value }) - ); + this.storage.setItem(param.key, param.value ? param.value.toString() : param.value); + this.store.dispatch(new SetSettingsParameterAction({ name: param.key, value: param.value })); } } diff --git a/src/app/components/shared-files/shared-files.component.spec.ts b/src/app/components/shared-files/shared-files.component.spec.ts index 2c313a3e9..ad7e9eee4 100644 --- a/src/app/components/shared-files/shared-files.component.spec.ts +++ b/src/app/components/shared-files/shared-files.component.spec.ts @@ -23,12 +23,7 @@ * along with Alfresco. If not, see . */ -import { - TestBed, - ComponentFixture, - fakeAsync, - tick -} from '@angular/core/testing'; +import { TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing'; import { NO_ERRORS_SCHEMA } from '@angular/core'; import { AlfrescoApiService, @@ -67,13 +62,7 @@ describe('SharedFilesComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [AppTestingModule], - declarations: [ - DataTableComponent, - NodeFavoriteDirective, - DocumentListComponent, - SharedFilesComponent, - AppConfigPipe - ], + declarations: [DataTableComponent, NodeFavoriteDirective, DocumentListComponent, SharedFilesComponent, AppConfigPipe], providers: [ { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }, { @@ -92,9 +81,7 @@ describe('SharedFilesComponent', () => { alfrescoApi = TestBed.inject(AlfrescoApiService); alfrescoApi.reset(); - spyOn(alfrescoApi.sharedLinksApi, 'findSharedLinks').and.returnValue( - Promise.resolve(page) - ); + spyOn(alfrescoApi.sharedLinksApi, 'findSharedLinks').and.returnValue(Promise.resolve(page)); }); it('should call document list reload on linksUnshared event', fakeAsync(() => { diff --git a/src/app/components/shared-files/shared-files.component.ts b/src/app/components/shared-files/shared-files.component.ts index 65bd2febd..89cae80a9 100644 --- a/src/app/components/shared-files/shared-files.component.ts +++ b/src/app/components/shared-files/shared-files.component.ts @@ -57,22 +57,14 @@ export class SharedFilesComponent extends PageComponent implements OnInit { super.ngOnInit(); this.subscriptions = this.subscriptions.concat([ - this.content.linksUnshared - .pipe(debounceTime(300)) - .subscribe(() => this.reload()), + this.content.linksUnshared.pipe(debounceTime(300)).subscribe(() => this.reload()), - this.uploadService.fileUploadComplete - .pipe(debounceTime(300)) - .subscribe(_ => this.reload()), - this.uploadService.fileUploadDeleted - .pipe(debounceTime(300)) - .subscribe(_ => this.reload()), + this.uploadService.fileUploadComplete.pipe(debounceTime(300)).subscribe((_) => this.reload()), + this.uploadService.fileUploadDeleted.pipe(debounceTime(300)).subscribe((_) => this.reload()), - this.breakpointObserver - .observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]) - .subscribe(result => { - this.isSmallScreen = result.matches; - }) + this.breakpointObserver.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]).subscribe((result) => { + this.isSmallScreen = result.matches; + }) ]); this.columns = this.extensions.documentListPresets.shared || []; diff --git a/src/app/components/shared-link-view/shared-link-view.component.spec.ts b/src/app/components/shared-link-view/shared-link-view.component.spec.ts index 5c985ce7b..818ef69f4 100644 --- a/src/app/components/shared-link-view/shared-link-view.component.spec.ts +++ b/src/app/components/shared-link-view/shared-link-view.component.spec.ts @@ -24,12 +24,7 @@ */ import { SharedLinkViewComponent } from './shared-link-view.component'; -import { - TestBed, - ComponentFixture, - fakeAsync, - tick -} from '@angular/core/testing'; +import { TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing'; import { Store } from '@ngrx/store'; import { AppTestingModule } from '../../testing/app-testing.module'; import { ActivatedRoute } from '@angular/router'; @@ -81,10 +76,7 @@ describe('SharedLinkViewComponent', () => { alfrescoApiService = TestBed.inject(AlfrescoApiService); appExtensionService = TestBed.inject(AppExtensionService); - spyGetSharedLink = spyOn( - alfrescoApiService.sharedLinksApi, - 'getSharedLink' - ); + spyGetSharedLink = spyOn(alfrescoApiService.sharedLinksApi, 'getSharedLink'); storeMock.dispatch.calls.reset(); }); @@ -94,16 +86,12 @@ describe('SharedLinkViewComponent', () => { }); it('should update store selection', fakeAsync(() => { - spyGetSharedLink.and.returnValue( - Promise.resolve({ entry: { id: 'shared-id' } }) - ); + spyGetSharedLink.and.returnValue(Promise.resolve({ entry: { id: 'shared-id' } })); fixture.detectChanges(); tick(); - expect(storeMock.dispatch).toHaveBeenCalledWith( - new SetSelectedNodesAction([{ entry: { id: 'shared-id' } } as any]) - ); + expect(storeMock.dispatch).toHaveBeenCalledWith(new SetSelectedNodesAction([{ entry: { id: 'shared-id' } } as any])); })); it('should not update store on error', fakeAsync(() => { @@ -118,9 +106,7 @@ describe('SharedLinkViewComponent', () => { it('should not update actions reference if selection is empty', fakeAsync(() => { spyOn(storeMock, 'select').and.returnValue(of({ isEmpty: true })); - spyGetSharedLink.and.returnValue( - Promise.resolve({ entry: { id: 'shared-id' } }) - ); + spyGetSharedLink.and.returnValue(Promise.resolve({ entry: { id: 'shared-id' } })); fixture.detectChanges(); tick(); @@ -131,22 +117,16 @@ describe('SharedLinkViewComponent', () => { it('should update actions reference if selection is not empty', fakeAsync(() => { spyOn(storeMock, 'select').and.returnValue(of({ isEmpty: false })); spyOn(appExtensionService, 'getSharedLinkViewerToolbarActions'); - spyGetSharedLink.and.returnValue( - Promise.resolve({ entry: { id: 'shared-id' } }) - ); + spyGetSharedLink.and.returnValue(Promise.resolve({ entry: { id: 'shared-id' } })); fixture.detectChanges(); tick(); - expect( - appExtensionService.getSharedLinkViewerToolbarActions - ).toHaveBeenCalled(); + expect(appExtensionService.getSharedLinkViewerToolbarActions).toHaveBeenCalled(); })); it('should fetch link id from the active route', fakeAsync(() => { - spyGetSharedLink.and.returnValue( - Promise.resolve({ entry: { id: 'shared-id' } }) - ); + spyGetSharedLink.and.returnValue(Promise.resolve({ entry: { id: 'shared-id' } })); fixture.detectChanges(); tick(); diff --git a/src/app/components/shared-link-view/shared-link-view.component.ts b/src/app/components/shared-link-view/shared-link-view.component.ts index 5fb1b651a..e790075ea 100644 --- a/src/app/components/shared-link-view/shared-link-view.component.ts +++ b/src/app/components/shared-link-view/shared-link-view.component.ts @@ -23,11 +23,7 @@ * along with Alfresco. If not, see . */ -import { - AppStore, - SetSelectedNodesAction, - getAppSelection -} from '@alfresco/aca-shared/store'; +import { AppStore, SetSelectedNodesAction, getAppSelection } from '@alfresco/aca-shared/store'; import { AlfrescoApiService } from '@alfresco/adf-core'; import { ContentActionRef } from '@alfresco/adf-extensions'; import { SharedLinkEntry } from '@alfresco/js-api'; @@ -59,13 +55,8 @@ export class SharedLinkViewComponent implements OnInit { ngOnInit() { this.route.params .pipe( - flatMap(params => - forkJoin( - from( - this.alfrescoApiService.sharedLinksApi.getSharedLink(params.id) - ), - of(params.id) - ).pipe(catchError(() => of([null, params.id]))) + flatMap((params) => + forkJoin(from(this.alfrescoApiService.sharedLinksApi.getSharedLink(params.id)), of(params.id)).pipe(catchError(() => of([null, params.id]))) ) ) .subscribe(([sharedEntry, sharedId]: [SharedLinkEntry, string]) => { @@ -75,9 +66,8 @@ export class SharedLinkViewComponent implements OnInit { this.sharedLinkId = sharedId; }); - this.store.select(getAppSelection).subscribe(selection => { - if (!selection.isEmpty) - this.viewerToolbarActions = this.extensions.getSharedLinkViewerToolbarActions(); + this.store.select(getAppSelection).subscribe((selection) => { + if (!selection.isEmpty) this.viewerToolbarActions = this.extensions.getSharedLinkViewerToolbarActions(); }); } diff --git a/src/app/components/sidenav/components/button-menu.component.spec.ts b/src/app/components/sidenav/components/button-menu.component.spec.ts index 9c9e6268f..aaa06e59d 100644 --- a/src/app/components/sidenav/components/button-menu.component.spec.ts +++ b/src/app/components/sidenav/components/button-menu.component.spec.ts @@ -27,11 +27,7 @@ import { ButtonMenuComponent } from './button-menu.component'; import { TestBed, ComponentFixture } from '@angular/core/testing'; import { AppTestingModule } from '../../../testing/app-testing.module'; import { Router } from '@angular/router'; -import { - TranslateModule, - TranslateLoader, - TranslateFakeLoader -} from '@ngx-translate/core'; +import { TranslateModule, TranslateLoader, TranslateFakeLoader } from '@ngx-translate/core'; import { AppSidenavModule } from '../sidenav.module'; describe('ButtonMenuComponent', () => { @@ -88,9 +84,7 @@ describe('ButtonMenuComponent', () => { fixture.detectChanges(); - const actionButton = document.body.querySelector( - '[id="test-action-button"]' - ); + const actionButton = document.body.querySelector('[id="test-action-button"]'); actionButton.dispatchEvent(new Event('click')); expect(document.querySelector('[id="child-1"]')).not.toBeNull(); diff --git a/src/app/components/sidenav/components/button-menu.component.ts b/src/app/components/sidenav/components/button-menu.component.ts index 1a7532623..b38a11dfc 100644 --- a/src/app/components/sidenav/components/button-menu.component.ts +++ b/src/app/components/sidenav/components/button-menu.component.ts @@ -23,13 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Component, - Input, - ViewEncapsulation, - OnInit, - ChangeDetectorRef -} from '@angular/core'; +import { Component, Input, ViewEncapsulation, OnInit, ChangeDetectorRef } from '@angular/core'; import { OverlayContainer } from '@angular/cdk/overlay'; @Component({ @@ -41,10 +35,7 @@ import { OverlayContainer } from '@angular/cdk/overlay'; export class ButtonMenuComponent implements OnInit { @Input() item; - constructor( - private cd: ChangeDetectorRef, - private overlayContainer: OverlayContainer - ) { + constructor(private cd: ChangeDetectorRef, private overlayContainer: OverlayContainer) { this.overlayContainer.getContainerElement().classList.add('aca-menu-panel'); } diff --git a/src/app/components/sidenav/components/expand-menu.component.spec.ts b/src/app/components/sidenav/components/expand-menu.component.spec.ts index 21ffe7b9d..2ef90ead2 100644 --- a/src/app/components/sidenav/components/expand-menu.component.spec.ts +++ b/src/app/components/sidenav/components/expand-menu.component.spec.ts @@ -27,11 +27,7 @@ import { ExpandMenuComponent } from './expand-menu.component'; import { TestBed, ComponentFixture } from '@angular/core/testing'; import { AppTestingModule } from '../../../testing/app-testing.module'; import { Router } from '@angular/router'; -import { - TranslateModule, - TranslateLoader, - TranslateFakeLoader -} from '@ngx-translate/core'; +import { TranslateModule, TranslateLoader, TranslateFakeLoader } from '@ngx-translate/core'; import { AppSidenavModule } from '../sidenav.module'; describe('ExpandMenuComponent', () => { @@ -88,9 +84,7 @@ describe('ExpandMenuComponent', () => { fixture.detectChanges(); - const actionButton = document.body.querySelector( - '[id="test-action-button"]' - ); + const actionButton = document.body.querySelector('[id="test-action-button"]'); actionButton.dispatchEvent(new Event('click')); expect(document.querySelector('[id="child-1"]')).not.toBeNull(); diff --git a/src/app/components/sidenav/components/expand-menu.component.ts b/src/app/components/sidenav/components/expand-menu.component.ts index 326227f12..3c3c482a5 100644 --- a/src/app/components/sidenav/components/expand-menu.component.ts +++ b/src/app/components/sidenav/components/expand-menu.component.ts @@ -23,13 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Component, - OnInit, - Input, - ViewEncapsulation, - ChangeDetectorRef -} from '@angular/core'; +import { Component, OnInit, Input, ViewEncapsulation, ChangeDetectorRef } from '@angular/core'; @Component({ selector: 'app-expand-menu', diff --git a/src/app/components/sidenav/directives/action.directive.ts b/src/app/components/sidenav/directives/action.directive.ts index e6a6a2eb2..6ee2b7ed2 100644 --- a/src/app/components/sidenav/directives/action.directive.ts +++ b/src/app/components/sidenav/directives/action.directive.ts @@ -60,7 +60,7 @@ export class ActionDirective { const urlSegments = urlSegmentGroup.segments; - return urlSegments.reduce(function(acc, item) { + return urlSegments.reduce(function (acc, item) { acc.push(item.path, item.parameters); return acc; }, []); diff --git a/src/app/components/sidenav/directives/active-link.directive.spec.ts b/src/app/components/sidenav/directives/active-link.directive.spec.ts index 825ff882e..4537196e3 100644 --- a/src/app/components/sidenav/directives/active-link.directive.spec.ts +++ b/src/app/components/sidenav/directives/active-link.directive.spec.ts @@ -32,13 +32,7 @@ import { Subject } from 'rxjs'; @Component({ selector: 'app-test-component', - template: ` - - ` + template: ` ` }) class TestComponent { item = { @@ -81,29 +75,17 @@ describe('ActionDirective', () => { fixture.detectChanges(); router.navigateByUrl('/dummy'); // fixture.detectChanges(); - expect( - document.body - .querySelector('#test-element') - .className.includes('active-link-class') - ).toBe(true); + expect(document.body.querySelector('#test-element').className.includes('active-link-class')).toBe(true); }); it('should remove class name if route not active', () => { fixture.detectChanges(); router.navigateByUrl('/dummy'); - expect( - document.body - .querySelector('#test-element') - .className.includes('active-link-class') - ).toBe(true); + expect(document.body.querySelector('#test-element').className.includes('active-link-class')).toBe(true); router.navigateByUrl('/other'); - expect( - document.body - .querySelector('#test-element') - .className.includes('active-link-class') - ).not.toBe(true); + expect(document.body.querySelector('#test-element').className.includes('active-link-class')).not.toBe(true); }); }); diff --git a/src/app/components/sidenav/directives/active-link.directive.ts b/src/app/components/sidenav/directives/active-link.directive.ts index beacbfd1a..9bb553a20 100644 --- a/src/app/components/sidenav/directives/active-link.directive.ts +++ b/src/app/components/sidenav/directives/active-link.directive.ts @@ -23,17 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Directive, - OnInit, - Input, - ElementRef, - Renderer2, - ContentChildren, - QueryList, - AfterContentInit, - Optional -} from '@angular/core'; +import { Directive, OnInit, Input, ElementRef, Renderer2, ContentChildren, QueryList, AfterContentInit, Optional } from '@angular/core'; import { Router, NavigationEnd } from '@angular/router'; import { filter, takeUntil } from 'rxjs/operators'; import { Subject } from 'rxjs'; @@ -51,17 +41,12 @@ export class ActiveLinkDirective implements OnInit, AfterContentInit { private onDestroy$: Subject = new Subject(); - constructor( - private router: Router, - private element: ElementRef, - private renderer: Renderer2, - @Optional() private action?: ActionDirective - ) {} + constructor(private router: Router, private element: ElementRef, private renderer: Renderer2, @Optional() private action?: ActionDirective) {} ngOnInit() { this.router.events .pipe( - filter(event => event instanceof NavigationEnd), + filter((event) => event instanceof NavigationEnd), takeUntil(this.onDestroy$) ) .subscribe((event: NavigationEnd) => { @@ -75,7 +60,7 @@ export class ActiveLinkDirective implements OnInit, AfterContentInit { this.render(url, itemUrl); } - this.links.map(item => { + this.links.map((item) => { const itemUrl = this.resolveUrl(item); this.render(url, itemUrl); }); @@ -97,9 +82,6 @@ export class ActiveLinkDirective implements OnInit, AfterContentInit { } private resolveUrl(item): string { - return ( - (item.action && item.action.click && item.action.click.payload) || - item.action.route - ); + return (item.action && item.action.click && item.action.click.payload) || item.action.route; } } diff --git a/src/app/components/sidenav/directives/expansion-panel.directive.spec.ts b/src/app/components/sidenav/directives/expansion-panel.directive.spec.ts index 778e03aaf..5571b0f88 100644 --- a/src/app/components/sidenav/directives/expansion-panel.directive.spec.ts +++ b/src/app/components/sidenav/directives/expansion-panel.directive.spec.ts @@ -65,11 +65,7 @@ describe('AcaExpansionPanel', () => { const item = { children: [{ url: 'dummy-route-1' }, { url: 'dummy-route-2' }] }; - const directive = new ExpansionPanelDirective( - mockStore, - router, - mockMatExpansionPanel - ); + const directive = new ExpansionPanelDirective(mockStore, router, mockMatExpansionPanel); directive.acaExpansionPanel = item; @@ -80,11 +76,7 @@ describe('AcaExpansionPanel', () => { const item = { children: [{ url: 'dummy-route-1' }, { url: 'dummy-route-2' }] }; - const directive = new ExpansionPanelDirective( - mockStore, - router, - mockMatExpansionPanel - ); + const directive = new ExpansionPanelDirective(mockStore, router, mockMatExpansionPanel); directive.acaExpansionPanel = item; @@ -102,11 +94,7 @@ describe('AcaExpansionPanel', () => { mockMatExpansionPanel.expanded = true; - const directive = new ExpansionPanelDirective( - mockStore, - router, - mockMatExpansionPanel - ); + const directive = new ExpansionPanelDirective(mockStore, router, mockMatExpansionPanel); directive.acaExpansionPanel = item; @@ -122,11 +110,7 @@ describe('AcaExpansionPanel', () => { children: [{ url: 'dummy-route-1' }, { url: 'dummy-route-2' }] }; - const directive = new ExpansionPanelDirective( - mockStore, - router, - mockMatExpansionPanel - ); + const directive = new ExpansionPanelDirective(mockStore, router, mockMatExpansionPanel); directive.acaExpansionPanel = item; mockMatExpansionPanel.expanded = true; diff --git a/src/app/components/sidenav/directives/expansion-panel.directive.ts b/src/app/components/sidenav/directives/expansion-panel.directive.ts index 68c7371de..f8a6ce323 100644 --- a/src/app/components/sidenav/directives/expansion-panel.directive.ts +++ b/src/app/components/sidenav/directives/expansion-panel.directive.ts @@ -23,13 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Directive, - Input, - HostListener, - OnInit, - OnDestroy -} from '@angular/core'; +import { Directive, Input, HostListener, OnInit, OnDestroy } from '@angular/core'; import { Router, NavigationEnd, PRIMARY_OUTLET } from '@angular/router'; import { filter, takeUntil } from 'rxjs/operators'; import { Subject } from 'rxjs'; @@ -61,15 +55,11 @@ export class ExpansionPanelDirective implements OnInit, OnDestroy { } } - constructor( - private store: Store, - private router: Router, - private expansionPanel: MatExpansionPanel - ) {} + constructor(private store: Store, private router: Router, private expansionPanel: MatExpansionPanel) {} hasActiveLinks() { if (this.acaExpansionPanel && this.acaExpansionPanel.children) { - return this.acaExpansionPanel.children.some(child => { + return this.acaExpansionPanel.children.some((child) => { return this.router.url.startsWith(child.url || child.action.payload); }); } @@ -81,7 +71,7 @@ export class ExpansionPanelDirective implements OnInit, OnDestroy { this.router.events .pipe( - filter(event => event instanceof NavigationEnd), + filter((event) => event instanceof NavigationEnd), takeUntil(this.onDestroy$) ) .subscribe(() => { @@ -104,7 +94,7 @@ export class ExpansionPanelDirective implements OnInit, OnDestroy { const urlSegments = urlSegmentGroup.segments; - return urlSegments.reduce(function(acc, item) { + return urlSegments.reduce(function (acc, item) { acc.push(item.path, item.parameters); return acc; }, []); diff --git a/src/app/components/sidenav/directives/menu-panel.directive.ts b/src/app/components/sidenav/directives/menu-panel.directive.ts index 612a30eb3..18d90008a 100644 --- a/src/app/components/sidenav/directives/menu-panel.directive.ts +++ b/src/app/components/sidenav/directives/menu-panel.directive.ts @@ -23,13 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Directive, - Input, - OnInit, - OnDestroy, - HostListener -} from '@angular/core'; +import { Directive, Input, OnInit, OnDestroy, HostListener } from '@angular/core'; import { Router, NavigationEnd, PRIMARY_OUTLET } from '@angular/router'; import { filter, takeUntil } from 'rxjs/operators'; import { Subject } from 'rxjs'; @@ -64,7 +58,7 @@ export class MenuPanelDirective implements OnInit, OnDestroy { hasActiveLinks() { if (this.acaMenuPanel && this.acaMenuPanel.children) { - return this.acaMenuPanel.children.some(child => { + return this.acaMenuPanel.children.some((child) => { return this.router.url.startsWith(child.url || child.action.payload); }); } @@ -76,7 +70,7 @@ export class MenuPanelDirective implements OnInit, OnDestroy { this.router.events .pipe( - filter(event => event instanceof NavigationEnd), + filter((event) => event instanceof NavigationEnd), takeUntil(this.onDestroy$) ) .subscribe(() => { @@ -99,7 +93,7 @@ export class MenuPanelDirective implements OnInit, OnDestroy { const urlSegments = urlSegmentGroup.segments; - return urlSegments.reduce(function(acc, item) { + return urlSegments.reduce(function (acc, item) { acc.push(item.path, item.parameters); return acc; }, []); diff --git a/src/app/components/sidenav/sidenav.component.ts b/src/app/components/sidenav/sidenav.component.ts index 591c6a598..3b9efc3de 100755 --- a/src/app/components/sidenav/sidenav.component.ts +++ b/src/app/components/sidenav/sidenav.component.ts @@ -23,15 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Component, - ContentChild, - Input, - TemplateRef, - OnInit, - ViewEncapsulation, - OnDestroy -} from '@angular/core'; +import { Component, ContentChild, Input, TemplateRef, OnInit, ViewEncapsulation, OnDestroy } from '@angular/core'; import { CollapsedTemplateDirective } from './directives/collapsed-template.directive'; import { ExpandedTemplateDirective } from './directives/expanded-template.directive'; import { NavBarGroupRef } from '@alfresco/adf-extensions'; @@ -50,7 +42,8 @@ import { AppExtensionService } from '@alfresco/aca-shared'; host: { class: 'app-sidenav' } }) export class SidenavComponent implements OnInit, OnDestroy { - @Input() mode: 'collapsed' | 'expanded' = 'expanded'; + @Input() + mode: 'collapsed' | 'expanded' = 'expanded'; @ContentChild(ExpandedTemplateDirective, { read: TemplateRef }) expandedTemplate; @@ -63,24 +56,14 @@ export class SidenavComponent implements OnInit, OnDestroy { groups: Array = []; private onDestroy$: Subject = new Subject(); - constructor( - private store: Store, - private extensions: AppExtensionService, - private authService: AuthenticationService - ) {} + constructor(private store: Store, private extensions: AppExtensionService, private authService: AuthenticationService) {} ngOnInit() { this.store .select(getSideNavState) - .pipe( - debounceTime(300), - distinctUntilChanged(), - takeUntil(this.onDestroy$) - ) + .pipe(debounceTime(300), distinctUntilChanged(), takeUntil(this.onDestroy$)) .subscribe(() => { - this.groups = this.extensions.getApplicationNavigation( - this.extensions.navbar - ); + this.groups = this.extensions.getApplicationNavigation(this.extensions.navbar); }); } diff --git a/src/app/components/sidenav/sidenav.module.ts b/src/app/components/sidenav/sidenav.module.ts index f351794df..469c29812 100644 --- a/src/app/components/sidenav/sidenav.module.ts +++ b/src/app/components/sidenav/sidenav.module.ts @@ -40,14 +40,7 @@ import { ExpandMenuComponent } from './components/expand-menu.component'; import { ButtonMenuComponent } from './components/button-menu.component'; import { ActionDirective } from './directives/action.directive'; @NgModule({ - imports: [ - CommonModule, - CoreModule.forChild(), - CoreExtensionsModule.forChild(), - ExtensionsModule.forChild(), - RouterModule, - AppCreateMenuModule - ], + imports: [CommonModule, CoreModule.forChild(), CoreExtensionsModule.forChild(), ExtensionsModule.forChild(), RouterModule, AppCreateMenuModule], declarations: [ MenuPanelDirective, ExpansionPanelDirective, diff --git a/src/app/components/toolbar/document-display-mode/document-display-mode.component.ts b/src/app/components/toolbar/document-display-mode/document-display-mode.component.ts index e1b255d63..a599bf566 100644 --- a/src/app/components/toolbar/document-display-mode/document-display-mode.component.ts +++ b/src/app/components/toolbar/document-display-mode/document-display-mode.component.ts @@ -26,11 +26,7 @@ import { Component, ViewEncapsulation } from '@angular/core'; import { Observable } from 'rxjs'; import { Store } from '@ngrx/store'; -import { - AppStore, - ToggleDocumentDisplayMode, - getDocumentDisplayMode -} from '@alfresco/aca-shared/store'; +import { AppStore, ToggleDocumentDisplayMode, getDocumentDisplayMode } from '@alfresco/aca-shared/store'; @Component({ selector: 'app-document-display-mode', @@ -59,9 +55,7 @@ export class DocumentDisplayModeComponent { } getTitle(displayMode: string): string { - return displayMode === 'list' - ? 'APP.ACTIONS.LIST_MODE' - : 'APP.ACTIONS.GALLERY_MODE'; + return displayMode === 'list' ? 'APP.ACTIONS.LIST_MODE' : 'APP.ACTIONS.GALLERY_MODE'; } onClick() { diff --git a/src/app/components/toolbar/toggle-edit-offline/toggle-edit-offline.component.spec.ts b/src/app/components/toolbar/toggle-edit-offline/toggle-edit-offline.component.spec.ts index 79e932503..babbc0f80 100644 --- a/src/app/components/toolbar/toggle-edit-offline/toggle-edit-offline.component.spec.ts +++ b/src/app/components/toolbar/toggle-edit-offline/toggle-edit-offline.component.spec.ts @@ -30,11 +30,7 @@ import { TestBed } from '@angular/core/testing'; import { of } from 'rxjs'; import { Store } from '@ngrx/store'; import { NodeEntry } from '@alfresco/js-api'; -import { - DownloadNodesAction, - EditOfflineAction, - SnackbarErrorAction -} from '@alfresco/aca-shared/store'; +import { DownloadNodesAction, EditOfflineAction, SnackbarErrorAction } from '@alfresco/aca-shared/store'; import { TranslateModule } from '@ngx-translate/core'; describe('ToggleEditOfflineComponent', () => { @@ -89,9 +85,7 @@ describe('ToggleEditOfflineComponent', () => { fixture.detectChanges(); - expect(dispatchSpy.calls.argsFor(0)).toEqual([ - new DownloadNodesAction([selection.file as NodeEntry]) - ]); + expect(dispatchSpy.calls.argsFor(0)).toEqual([new DownloadNodesAction([selection.file as NodeEntry])]); }); it('should not download content if node is not locked', () => { @@ -103,9 +97,7 @@ describe('ToggleEditOfflineComponent', () => { fixture.detectChanges(); - expect(dispatchSpy.calls.argsFor(0)).not.toEqual([ - new DownloadNodesAction([selection.file as NodeEntry]) - ]); + expect(dispatchSpy.calls.argsFor(0)).not.toEqual([new DownloadNodesAction([selection.file as NodeEntry])]); }); it('should dispatch EditOfflineAction action', () => { @@ -117,9 +109,7 @@ describe('ToggleEditOfflineComponent', () => { fixture.detectChanges(); - expect(dispatchSpy.calls.argsFor(0)).toEqual([ - new EditOfflineAction(selection.file as NodeEntry) - ]); + expect(dispatchSpy.calls.argsFor(0)).toEqual([new EditOfflineAction(selection.file as NodeEntry)]); }); it('should raise notification on lock error', () => { diff --git a/src/app/components/toolbar/toggle-edit-offline/toggle-edit-offline.component.ts b/src/app/components/toolbar/toggle-edit-offline/toggle-edit-offline.component.ts index 8e3f7c3e0..a4982929e 100644 --- a/src/app/components/toolbar/toggle-edit-offline/toggle-edit-offline.component.ts +++ b/src/app/components/toolbar/toggle-edit-offline/toggle-edit-offline.component.ts @@ -23,13 +23,7 @@ * along with Alfresco. If not, see . */ -import { - AppStore, - DownloadNodesAction, - EditOfflineAction, - SnackbarErrorAction, - getAppSelection -} from '@alfresco/aca-shared/store'; +import { AppStore, DownloadNodesAction, EditOfflineAction, SnackbarErrorAction, getAppSelection } from '@alfresco/aca-shared/store'; import { MinimalNodeEntity } from '@alfresco/js-api'; import { Component, OnInit, ViewEncapsulation } from '@angular/core'; import { Store } from '@ngrx/store'; @@ -44,11 +38,7 @@ import { Store } from '@ngrx/store'; (lockError)="onLockError()" (unlockError)="onUnlockLockError()" [acaLockNode]="selection" - [attr.title]=" - lock.isNodeLocked() - ? ('APP.ACTIONS.EDIT_OFFLINE_CANCEL' | translate) - : ('APP.ACTIONS.EDIT_OFFLINE' | translate) - " + [attr.title]="lock.isNodeLocked() ? ('APP.ACTIONS.EDIT_OFFLINE_CANCEL' | translate) : ('APP.ACTIONS.EDIT_OFFLINE' | translate)" > cancel diff --git a/src/app/components/toolbar/toggle-favorite-library/toggle-favorite-library.component.spec.ts b/src/app/components/toolbar/toggle-favorite-library/toggle-favorite-library.component.spec.ts index cbcbca4e8..0b82dccc8 100644 --- a/src/app/components/toolbar/toggle-favorite-library/toggle-favorite-library.component.spec.ts +++ b/src/app/components/toolbar/toggle-favorite-library/toggle-favorite-library.component.spec.ts @@ -24,11 +24,7 @@ */ import { TestBed, ComponentFixture } from '@angular/core/testing'; -import { - CoreModule, - AlfrescoApiService, - AlfrescoApiServiceMock -} from '@alfresco/adf-core'; +import { CoreModule, AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-core'; import { ToggleFavoriteLibraryComponent } from './toggle-favorite-library.component'; import { LibraryFavoriteDirective } from '../../../directives/library-favorite.directive'; import { NO_ERRORS_SCHEMA } from '@angular/core'; @@ -50,11 +46,7 @@ describe('ToggleFavoriteLibraryComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ - TranslateModule.forRoot(), - CoreModule.forRoot(), - AppTestingModule - ], + imports: [TranslateModule.forRoot(), CoreModule.forRoot(), AppTestingModule], declarations: [ToggleFavoriteLibraryComponent, LibraryFavoriteDirective], providers: [ { @@ -84,9 +76,7 @@ describe('ToggleFavoriteLibraryComponent', () => { contentManagementService = TestBed.inject(ContentManagementService); const api = TestBed.inject(AlfrescoApiService); - spyOn(api.peopleApi, 'getFavoriteSite').and.returnValue( - Promise.resolve(null) - ); + spyOn(api.peopleApi, 'getFavoriteSite').and.returnValue(Promise.resolve(null)); }); it('should get library selection from Store', async () => { @@ -112,8 +102,6 @@ describe('ToggleFavoriteLibraryComponent', () => { component.onToggleEvent(); - expect( - contentManagementService.favoriteLibraryToggle.next - ).toHaveBeenCalled(); + expect(contentManagementService.favoriteLibraryToggle.next).toHaveBeenCalled(); }); }); diff --git a/src/app/components/toolbar/toggle-favorite-library/toggle-favorite-library.component.ts b/src/app/components/toolbar/toggle-favorite-library/toggle-favorite-library.component.ts index 333a91a21..5e81166e6 100644 --- a/src/app/components/toolbar/toggle-favorite-library/toggle-favorite-library.component.ts +++ b/src/app/components/toolbar/toggle-favorite-library/toggle-favorite-library.component.ts @@ -39,20 +39,11 @@ import { Subject } from 'rxjs'; mat-menu-item (toggle)="onToggleEvent()" [acaFavoriteLibrary]="library" - [attr.title]=" - library.isFavorite - ? ('APP.ACTIONS.REMOVE_FAVORITE' | translate) - : ('APP.ACTIONS.FAVORITE' | translate) - " + [attr.title]="library.isFavorite ? ('APP.ACTIONS.REMOVE_FAVORITE' | translate) : ('APP.ACTIONS.FAVORITE' | translate)" > star star_border - {{ - (library.isFavorite - ? 'APP.ACTIONS.REMOVE_FAVORITE' - : 'APP.ACTIONS.FAVORITE' - ) | translate - }} + {{ (library.isFavorite ? 'APP.ACTIONS.REMOVE_FAVORITE' : 'APP.ACTIONS.FAVORITE') | translate }} `, encapsulation: ViewEncapsulation.None, @@ -62,16 +53,10 @@ export class ToggleFavoriteLibraryComponent implements OnInit, OnDestroy { library; private onDestroy$: Subject = new Subject(); - constructor( - private store: Store, - private content: ContentManagementService, - private router: Router - ) {} + constructor(private store: Store, private content: ContentManagementService, private router: Router) {} ngOnInit() { - const isFavoriteLibraries = this.router.url.startsWith( - '/favorite/libraries' - ); + const isFavoriteLibraries = this.router.url.startsWith('/favorite/libraries'); this.store .select(getAppSelection) diff --git a/src/app/components/toolbar/toggle-favorite/toggle-favorite.component.spec.ts b/src/app/components/toolbar/toggle-favorite/toggle-favorite.component.spec.ts index b4350380c..9ea7b945a 100644 --- a/src/app/components/toolbar/toggle-favorite/toggle-favorite.component.spec.ts +++ b/src/app/components/toolbar/toggle-favorite/toggle-favorite.component.spec.ts @@ -51,17 +51,9 @@ describe('ToggleFavoriteComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ - TranslateModule.forRoot(), - CoreModule.forRoot(), - AppTestingModule - ], + imports: [TranslateModule.forRoot(), CoreModule.forRoot(), AppTestingModule], declarations: [ToggleFavoriteComponent], - providers: [ - ExtensionService, - { provide: Store, useValue: mockStore }, - { provide: Router, useValue: mockRouter } - ] + providers: [ExtensionService, { provide: Store, useValue: mockStore }, { provide: Router, useValue: mockRouter }] }); fixture = TestBed.createComponent(ToggleFavoriteComponent); diff --git a/src/app/components/toolbar/toggle-favorite/toggle-favorite.component.ts b/src/app/components/toolbar/toggle-favorite/toggle-favorite.component.ts index 560293629..346bc4483 100644 --- a/src/app/components/toolbar/toggle-favorite/toggle-favorite.component.ts +++ b/src/app/components/toolbar/toggle-favorite/toggle-favorite.component.ts @@ -27,30 +27,16 @@ import { Component, ViewEncapsulation, OnInit, Input } from '@angular/core'; import { Store } from '@ngrx/store'; import { Observable } from 'rxjs'; import { SelectionState } from '@alfresco/adf-extensions'; -import { - AppStore, - ReloadDocumentListAction, - getAppSelection -} from '@alfresco/aca-shared/store'; +import { AppStore, ReloadDocumentListAction, getAppSelection } from '@alfresco/aca-shared/store'; import { Router } from '@angular/router'; @Component({ selector: 'app-toggle-favorite', template: ` - `, encapsulation: ViewEncapsulation.None, diff --git a/src/app/components/toolbar/toggle-info-drawer/toggle-info-drawer.component.ts b/src/app/components/toolbar/toggle-info-drawer/toggle-info-drawer.component.ts index 90170d82d..f4c24b359 100644 --- a/src/app/components/toolbar/toggle-info-drawer/toggle-info-drawer.component.ts +++ b/src/app/components/toolbar/toggle-info-drawer/toggle-info-drawer.component.ts @@ -26,10 +26,7 @@ import { Component, ViewEncapsulation } from '@angular/core'; import { Observable } from 'rxjs'; import { Store } from '@ngrx/store'; -import { - ToggleInfoDrawerAction, - isInfoDrawerOpened -} from '@alfresco/aca-shared/store'; +import { ToggleInfoDrawerAction, isInfoDrawerOpened } from '@alfresco/aca-shared/store'; @Component({ selector: 'app-toggle-info-drawer', diff --git a/src/app/components/toolbar/toggle-join-library/toggle-join-library-button.component.ts b/src/app/components/toolbar/toggle-join-library/toggle-join-library-button.component.ts index 9bd32bd29..256cb66f8 100644 --- a/src/app/components/toolbar/toggle-join-library/toggle-join-library-button.component.ts +++ b/src/app/components/toolbar/toggle-join-library/toggle-join-library-button.component.ts @@ -23,21 +23,12 @@ * along with Alfresco. If not, see . */ -import { - AppStore, - SetSelectedNodesAction, - SnackbarErrorAction, - SnackbarInfoAction, - getAppSelection -} from '@alfresco/aca-shared/store'; +import { AppStore, SetSelectedNodesAction, SnackbarErrorAction, SnackbarInfoAction, getAppSelection } from '@alfresco/aca-shared/store'; import { SelectionState } from '@alfresco/adf-extensions'; import { Component, ViewEncapsulation } from '@angular/core'; import { Store } from '@ngrx/store'; import { Observable } from 'rxjs'; -import { - LibraryMembershipErrorEvent, - LibraryMembershipToggleEvent -} from '../../../directives/library-membership.directive'; +import { LibraryMembershipErrorEvent, LibraryMembershipToggleEvent } from '../../../directives/library-membership.directive'; import { ContentManagementService } from '../../../services/content-management.service'; @Component({ @@ -50,17 +41,10 @@ import { ContentManagementService } from '../../../services/content-management.s (toggle)="onToggleEvent($event)" (error)="onErrorEvent($event)" [acaLibraryMembership]="(selection$ | async).library" - [attr.title]=" - (membership.isJoinRequested | async) - ? ('APP.ACTIONS.CANCEL_JOIN' | translate) - : ('APP.ACTIONS.JOIN' | translate) - " + [attr.title]="(membership.isJoinRequested | async) ? ('APP.ACTIONS.CANCEL_JOIN' | translate) : ('APP.ACTIONS.JOIN' | translate)" > cancel - + `, encapsulation: ViewEncapsulation.None, @@ -69,10 +53,7 @@ import { ContentManagementService } from '../../../services/content-management.s export class ToggleJoinLibraryButtonComponent { selection$: Observable; - constructor( - private store: Store, - private content: ContentManagementService - ) { + constructor(private store: Store, private content: ContentManagementService) { this.selection$ = this.store.select(getAppSelection); } @@ -83,11 +64,7 @@ export class ToggleJoinLibraryButtonComponent { this.content.libraryJoined.next(); } else { if (event.updatedEntry) { - this.store.dispatch( - new SetSelectedNodesAction([ - { entry: event.updatedEntry, isLibrary: true } as any - ]) - ); + this.store.dispatch(new SetSelectedNodesAction([{ entry: event.updatedEntry, isLibrary: true } as any])); } this.content.joinLibraryToggle.next(); } diff --git a/src/app/components/toolbar/toggle-join-library/toggle-join-library-menu.component.ts b/src/app/components/toolbar/toggle-join-library/toggle-join-library-menu.component.ts index 4459fd219..b2edd5f8c 100644 --- a/src/app/components/toolbar/toggle-join-library/toggle-join-library-menu.component.ts +++ b/src/app/components/toolbar/toggle-join-library/toggle-join-library-menu.component.ts @@ -38,22 +38,11 @@ import { ToggleJoinLibraryButtonComponent } from './toggle-join-library-button.c (toggle)="onToggleEvent($event)" (error)="onErrorEvent($event)" [acaLibraryMembership]="(selection$ | async).library" - [attr.title]=" - (membership.isJoinRequested | async) - ? ('APP.ACTIONS.CANCEL_JOIN' | translate) - : ('APP.ACTIONS.JOIN' | translate) - " + [attr.title]="(membership.isJoinRequested | async) ? ('APP.ACTIONS.CANCEL_JOIN' | translate) : ('APP.ACTIONS.JOIN' | translate)" > cancel - - {{ - (membership.isJoinRequested | async) - ? ('APP.ACTIONS.CANCEL_JOIN' | translate) - : ('APP.ACTIONS.JOIN' | translate) - }} + + {{ (membership.isJoinRequested | async) ? ('APP.ACTIONS.CANCEL_JOIN' | translate) : ('APP.ACTIONS.JOIN' | translate) }} `, encapsulation: ViewEncapsulation.None, diff --git a/src/app/components/toolbar/toggle-join-library/toggle-join-library.component.spec.ts b/src/app/components/toolbar/toggle-join-library/toggle-join-library.component.spec.ts index d837f946d..7e904ac2c 100644 --- a/src/app/components/toolbar/toggle-join-library/toggle-join-library.component.spec.ts +++ b/src/app/components/toolbar/toggle-join-library/toggle-join-library.component.spec.ts @@ -29,10 +29,7 @@ import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-core'; import { LibraryMembershipDirective } from '../../../directives/library-membership.directive'; import { Store } from '@ngrx/store'; import { NO_ERRORS_SCHEMA } from '@angular/core'; -import { - SnackbarErrorAction, - SnackbarInfoAction -} from '@alfresco/aca-shared/store'; +import { SnackbarErrorAction, SnackbarInfoAction } from '@alfresco/aca-shared/store'; import { AppTestingModule } from '../../../testing/app-testing.module'; import { ContentManagementService } from '../../../services/content-management.service'; import { ToggleJoinLibraryButtonComponent } from './toggle-join-library-button.component'; @@ -59,10 +56,7 @@ describe('ToggleJoinLibraryComponent', () => { TestBed.configureTestingModule({ imports: [AppTestingModule], - declarations: [ - ToggleJoinLibraryButtonComponent, - LibraryMembershipDirective - ], + declarations: [ToggleJoinLibraryButtonComponent, LibraryMembershipDirective], providers: [ { provide: Store, useValue: storeMock }, { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock } @@ -83,8 +77,8 @@ describe('ToggleJoinLibraryComponent', () => { storeMock.dispatch.calls.reset(); }); - it('should get Store selection entry on initialization', done => { - component.selection$.subscribe(selection => { + it('should get Store selection entry on initialization', (done) => { + component.selection$.subscribe((selection) => { expect(selection.library.entry).toEqual(entry); done(); }); @@ -94,21 +88,17 @@ describe('ToggleJoinLibraryComponent', () => { const event = { error: {}, i18nKey: 'ERROR_i18nKey' }; component.onErrorEvent(event); - expect(storeMock.dispatch).toHaveBeenCalledWith( - new SnackbarErrorAction(event.i18nKey) - ); + expect(storeMock.dispatch).toHaveBeenCalledWith(new SnackbarErrorAction(event.i18nKey)); }); it('should dispatch `SnackbarInfoAction` action on onToggleEvent', () => { const event = { shouldReload: true, i18nKey: 'SOME_i18nKey' }; component.onToggleEvent(event); - expect(storeMock.dispatch).toHaveBeenCalledWith( - new SnackbarInfoAction(event.i18nKey) - ); + expect(storeMock.dispatch).toHaveBeenCalledWith(new SnackbarInfoAction(event.i18nKey)); }); - it('should call libraryJoined.next on contentManagementService onToggleEvent', done => { + it('should call libraryJoined.next on contentManagementService onToggleEvent', (done) => { spyOn(contentManagementService.libraryJoined, 'next').and.callThrough(); contentManagementService.libraryJoined.subscribe(() => { @@ -119,13 +109,11 @@ describe('ToggleJoinLibraryComponent', () => { component.onToggleEvent(event); }); - it('should call joinLibraryToggle.next on contentManagementService onToggleEvent', done => { + it('should call joinLibraryToggle.next on contentManagementService onToggleEvent', (done) => { spyOn(contentManagementService.joinLibraryToggle, 'next').and.callThrough(); contentManagementService.joinLibraryToggle.subscribe(() => { - expect( - contentManagementService.joinLibraryToggle.next - ).toHaveBeenCalled(); + expect(contentManagementService.joinLibraryToggle.next).toHaveBeenCalled(); done(); }); const event = { shouldReload: false, i18nKey: null }; diff --git a/src/app/components/toolbar/toolbar.module.ts b/src/app/components/toolbar/toolbar.module.ts index ffcd26ec7..5b806c471 100644 --- a/src/app/components/toolbar/toolbar.module.ts +++ b/src/app/components/toolbar/toolbar.module.ts @@ -53,14 +53,7 @@ export function components() { } @NgModule({ - imports: [ - CommonModule, - CoreModule.forChild(), - AppCommonModule, - ExtensionsModule, - SharedToolbarModule, - DirectivesModule - ], + imports: [CommonModule, CoreModule.forChild(), AppCommonModule, ExtensionsModule, SharedToolbarModule, DirectivesModule], declarations: components(), exports: [components(), SharedToolbarModule] }) diff --git a/src/app/components/toolbar/view-node/view-node.component.spec.ts b/src/app/components/toolbar/view-node/view-node.component.spec.ts index e5c80b695..61ed4cb4a 100644 --- a/src/app/components/toolbar/view-node/view-node.component.spec.ts +++ b/src/app/components/toolbar/view-node/view-node.component.spec.ts @@ -75,9 +75,7 @@ describe('ViewNodeComponent', () => { fixture.detectChanges(); - expect(fixture.nativeElement.querySelector('.mat-menu-item')).not.toBe( - null - ); + expect(fixture.nativeElement.querySelector('.mat-menu-item')).not.toBe(null); }); it('should render as a icon button', () => { @@ -87,9 +85,7 @@ describe('ViewNodeComponent', () => { fixture.detectChanges(); - expect(fixture.nativeElement.querySelector('.mat-icon-button')).not.toBe( - null - ); + expect(fixture.nativeElement.querySelector('.mat-icon-button')).not.toBe(null); }); it('should call ViewNodeAction onClick event', () => { diff --git a/src/app/components/toolbar/view-node/view-node.component.ts b/src/app/components/toolbar/view-node/view-node.component.ts index 024d7ddd0..7528d9e66 100644 --- a/src/app/components/toolbar/view-node/view-node.component.ts +++ b/src/app/components/toolbar/view-node/view-node.component.ts @@ -25,11 +25,7 @@ import { Component, ViewEncapsulation, Input } from '@angular/core'; import { Store } from '@ngrx/store'; -import { - AppStore, - ViewNodeAction, - getAppSelection -} from '@alfresco/aca-shared/store'; +import { AppStore, ViewNodeAction, getAppSelection } from '@alfresco/aca-shared/store'; import { Router } from '@angular/router'; import { take } from 'rxjs/operators'; import { SharedLinkEntry } from '@alfresco/js-api'; @@ -64,15 +60,10 @@ export class ViewNodeComponent { this.store .select(getAppSelection) .pipe(take(1)) - .subscribe(selection => { - const id = - (selection.file as SharedLinkEntry).entry.nodeId || - (selection.file as any).entry.guid || - selection.file.entry.id; + .subscribe((selection) => { + const id = (selection.file as SharedLinkEntry).entry.nodeId || (selection.file as any).entry.guid || selection.file.entry.id; - this.store.dispatch( - new ViewNodeAction(id, { location: this.router.url }) - ); + this.store.dispatch(new ViewNodeAction(id, { location: this.router.url })); }); } } diff --git a/src/app/components/trashcan/trashcan.component.spec.ts b/src/app/components/trashcan/trashcan.component.spec.ts index 7a9c317b7..8dcb6b410 100644 --- a/src/app/components/trashcan/trashcan.component.spec.ts +++ b/src/app/components/trashcan/trashcan.component.spec.ts @@ -24,12 +24,7 @@ */ import { NO_ERRORS_SCHEMA } from '@angular/core'; import { TestBed, ComponentFixture } from '@angular/core/testing'; -import { - AlfrescoApiService, - NodeFavoriteDirective, - DataTableComponent, - AppConfigPipe -} from '@alfresco/adf-core'; +import { AlfrescoApiService, NodeFavoriteDirective, DataTableComponent, AppConfigPipe } from '@alfresco/adf-core'; import { DocumentListComponent } from '@alfresco/adf-content-services'; import { TrashcanComponent } from './trashcan.component'; import { AppTestingModule } from '../../testing/app-testing.module'; @@ -52,13 +47,7 @@ describe('TrashcanComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [AppTestingModule], - declarations: [ - DataTableComponent, - NodeFavoriteDirective, - DocumentListComponent, - TrashcanComponent, - AppConfigPipe - ], + declarations: [DataTableComponent, NodeFavoriteDirective, DocumentListComponent, TrashcanComponent, AppConfigPipe], schemas: [NO_ERRORS_SCHEMA] }); @@ -75,8 +64,6 @@ describe('TrashcanComponent', () => { }); beforeEach(() => { - spyOn(alfrescoApi.nodesApi, 'getDeletedNodes').and.returnValue( - Promise.resolve(page) - ); + spyOn(alfrescoApi.nodesApi, 'getDeletedNodes').and.returnValue(Promise.resolve(page)); }); }); diff --git a/src/app/components/trashcan/trashcan.component.ts b/src/app/components/trashcan/trashcan.component.ts index fd694e78b..ec09495ad 100644 --- a/src/app/components/trashcan/trashcan.component.ts +++ b/src/app/components/trashcan/trashcan.component.ts @@ -56,11 +56,9 @@ export class TrashcanComponent extends PageComponent implements OnInit { super.ngOnInit(); this.subscriptions.push( - this.breakpointObserver - .observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]) - .subscribe(result => { - this.isSmallScreen = result.matches; - }) + this.breakpointObserver.observe([Breakpoints.HandsetPortrait, Breakpoints.HandsetLandscape]).subscribe((result) => { + this.isSmallScreen = result.matches; + }) ); this.columns = this.extensions.documentListPresets.trashcan || []; diff --git a/src/app/components/viewer/viewer.component.ts b/src/app/components/viewer/viewer.component.ts index 5bc983e7d..eab553658 100644 --- a/src/app/components/viewer/viewer.component.ts +++ b/src/app/components/viewer/viewer.component.ts @@ -36,20 +36,9 @@ import { } from '@alfresco/aca-shared/store'; import { ContentActionRef, SelectionState } from '@alfresco/adf-extensions'; import { MinimalNodeEntryEntity, SearchRequest } from '@alfresco/js-api'; -import { - Component, - HostListener, - OnDestroy, - OnInit, - ViewEncapsulation -} from '@angular/core'; +import { Component, HostListener, OnDestroy, OnInit, ViewEncapsulation } from '@angular/core'; import { ActivatedRoute, Router, PRIMARY_OUTLET } from '@angular/router'; -import { - UserPreferencesService, - ObjectUtils, - UploadService, - AlfrescoApiService -} from '@alfresco/adf-core'; +import { UserPreferencesService, ObjectUtils, UploadService, AlfrescoApiService } from '@alfresco/adf-core'; import { ContentManagementService } from '../../services/content-management.service'; import { Store } from '@ngrx/store'; import { from, Observable, Subject } from 'rxjs'; @@ -82,13 +71,7 @@ export class AppViewerComponent implements OnInit, OnDestroy { nextNodeId: string; navigateMultiple = true; routesSkipNavigation = ['shared', 'recent-files', 'favorites']; - navigationSources = [ - 'favorites', - 'libraries', - 'personal-files', - 'recent-files', - 'shared' - ]; + navigationSources = ['favorites', 'libraries', 'personal-files', 'recent-files', 'shared']; recentFileFilters = [ 'TYPE:"content"', '-PNAME:"0/wiki"', @@ -115,11 +98,7 @@ export class AppViewerComponent implements OnInit, OnDestroy { private navigationPath: string; private previewLocation: string; - private containersSkipNavigation = [ - 'adf-viewer__sidebar', - 'cdk-overlay-container', - 'adf-image-viewer' - ]; + private containersSkipNavigation = ['adf-viewer__sidebar', 'cdk-overlay-container', 'adf-image-viewer']; constructor( private router: Router, @@ -139,21 +118,21 @@ export class AppViewerComponent implements OnInit, OnDestroy { from(this.infoDrawerOpened$) .pipe(takeUntil(this.onDestroy$)) - .subscribe(val => { + .subscribe((val) => { this.showRightSide = val; }); this.store .select(getAppSelection) .pipe(takeUntil(this.onDestroy$)) - .subscribe(selection => { + .subscribe((selection) => { this.selection = selection; this.toolbarActions = this.extensions.getViewerToolbarActions(); this.openWith = this.extensions.openWithActions; }); - this.route.params.subscribe(params => { + this.route.params.subscribe((params) => { this.folderId = params.folderId; const { nodeId } = params; if (nodeId) { @@ -161,7 +140,7 @@ export class AppViewerComponent implements OnInit, OnDestroy { } }); - this.route.queryParams.subscribe(params => { + this.route.queryParams.subscribe((params) => { this.navigationPath = params.path; }); @@ -173,30 +152,19 @@ export class AppViewerComponent implements OnInit, OnDestroy { } this.actions$ - .pipe( - ofType(ViewerActionTypes.ClosePreview), - takeUntil(this.onDestroy$) - ) + .pipe(ofType(ViewerActionTypes.ClosePreview), takeUntil(this.onDestroy$)) .subscribe(() => this.navigateToFileLocation()); - this.content.nodesDeleted - .pipe(takeUntil(this.onDestroy$)) - .subscribe(() => this.navigateToFileLocation()); + this.content.nodesDeleted.pipe(takeUntil(this.onDestroy$)).subscribe(() => this.navigateToFileLocation()); - this.uploadService.fileUploadDeleted - .pipe(takeUntil(this.onDestroy$)) - .subscribe(() => this.navigateToFileLocation()); + this.uploadService.fileUploadDeleted.pipe(takeUntil(this.onDestroy$)).subscribe(() => this.navigateToFileLocation()); - this.uploadService.fileUploadComplete - .pipe(debounceTime(300), takeUntil(this.onDestroy$)) - .subscribe(file => { - this.apiService.nodeUpdated.next(file.data.entry); - this.displayNode(file.data.entry.id); - }); + this.uploadService.fileUploadComplete.pipe(debounceTime(300), takeUntil(this.onDestroy$)).subscribe((file) => { + this.apiService.nodeUpdated.next(file.data.entry); + this.displayNode(file.data.entry.id); + }); - this.previewLocation = this.router.url - .substr(0, this.router.url.indexOf('/', 1)) - .replace(/\//g, ''); + this.previewLocation = this.router.url.substr(0, this.router.url.indexOf('/', 1)).replace(/\//g, ''); } onViewerVisibilityChanged() { @@ -220,10 +188,7 @@ export class AppViewerComponent implements OnInit, OnDestroy { this.store.dispatch(new SetSelectedNodesAction([{ entry: this.node }])); if (this.node && this.node.isFile) { - const nearest = await this.getNearestNodes( - this.node.id, - this.node.parentId - ); + const nearest = await this.getNearestNodes(this.node.id, this.node.parentId); this.previousNodeId = nearest.left; this.nextNodeId = nearest.right; @@ -235,21 +200,16 @@ export class AppViewerComponent implements OnInit, OnDestroy { const statusCode = JSON.parse(error.message).error.statusCode; if (statusCode !== 401) { - this.router - .navigate([this.previewLocation, { outlets: { viewer: null } }]) - .then(() => { - this.router.navigate([this.previewLocation, id]); - }); + this.router.navigate([this.previewLocation, { outlets: { viewer: null } }]).then(() => { + this.router.navigate([this.previewLocation, id]); + }); } } } } onNavigateBefore(event: MouseEvent | KeyboardEvent): void { - if ( - event.type !== 'click' && - this.shouldNavigate(event.target as HTMLElement) - ) { + if (event.type !== 'click' && this.shouldNavigate(event.target as HTMLElement)) { return; } @@ -258,10 +218,7 @@ export class AppViewerComponent implements OnInit, OnDestroy { } onNavigateNext(event: MouseEvent | KeyboardEvent): void { - if ( - event.type !== 'click' && - this.shouldNavigate(event.target as HTMLElement) - ) { + if (event.type !== 'click' && this.shouldNavigate(event.target as HTMLElement)) { return; } @@ -274,10 +231,7 @@ export class AppViewerComponent implements OnInit, OnDestroy { * @param nodeId Unique identifier of the document node * @param folderId Unique identifier of the containing folder node. */ - async getNearestNodes( - nodeId: string, - folderId: string - ): Promise<{ left: string; right: string }> { + async getNearestNodes(nodeId: string, folderId: string): Promise<{ left: string; right: string }> { const empty = { left: null, right: null @@ -311,10 +265,8 @@ export class AppViewerComponent implements OnInit, OnDestroy { */ async getFileIds(source: string, folderId?: string): Promise { if ((source === 'personal-files' || source === 'libraries') && folderId) { - const sortKey = - this.preferences.get('personal-files.sorting.key') || 'modifiedAt'; - const sortDirection = - this.preferences.get('personal-files.sorting.direction') || 'desc'; + const sortKey = this.preferences.get('personal-files.sorting.key') || 'modifiedAt'; + const sortDirection = this.preferences.get('personal-files.sorting.direction') || 'desc'; const nodes = await this.contentApi .getNodeChildren(folderId, { // orderBy: `${sortKey} ${sortDirection}`, @@ -323,10 +275,10 @@ export class AppViewerComponent implements OnInit, OnDestroy { }) .toPromise(); - const entries = nodes.list.entries.map(obj => obj.entry); + const entries = nodes.list.entries.map((obj) => obj.entry); this.sort(entries, sortKey, sortDirection); - return entries.map(obj => obj.id); + return entries.map((obj) => obj.id); } if (source === 'favorites') { @@ -337,21 +289,17 @@ export class AppViewerComponent implements OnInit, OnDestroy { }) .toPromise(); - const sortKey = - this.preferences.get('favorites.sorting.key') || 'modifiedAt'; - const sortDirection = - this.preferences.get('favorites.sorting.direction') || 'desc'; - const files = nodes.list.entries.map(obj => obj.entry.target.file); + const sortKey = this.preferences.get('favorites.sorting.key') || 'modifiedAt'; + const sortDirection = this.preferences.get('favorites.sorting.direction') || 'desc'; + const files = nodes.list.entries.map((obj) => obj.entry.target.file); this.sort(files, sortKey, sortDirection); - return files.map(f => f.id); + return files.map((f) => f.id); } if (source === 'shared') { - const sortingKey = - this.preferences.get('shared.sorting.key') || 'modifiedAt'; - const sortingDirection = - this.preferences.get('shared.sorting.direction') || 'desc'; + const sortingKey = this.preferences.get('shared.sorting.key') || 'modifiedAt'; + const sortingDirection = this.preferences.get('shared.sorting.direction') || 'desc'; const nodes = await this.contentApi .findSharedLinks({ @@ -359,19 +307,17 @@ export class AppViewerComponent implements OnInit, OnDestroy { }) .toPromise(); - const entries = nodes.list.entries.map(obj => obj.entry); + const entries = nodes.list.entries.map((obj) => obj.entry); this.sort(entries, sortingKey, sortingDirection); - return entries.map(obj => obj.nodeId); + return entries.map((obj) => obj.nodeId); } if (source === 'recent-files') { const person = await this.contentApi.getPerson('-me-').toPromise(); const username = person.entry.id; - const sortingKey = - this.preferences.get('recent-files.sorting.key') || 'modifiedAt'; - const sortingDirection = - this.preferences.get('recent-files.sorting.direction') || 'desc'; + const sortingKey = this.preferences.get('recent-files.sorting.key') || 'modifiedAt'; + const sortingDirection = this.preferences.get('recent-files.sorting.direction') || 'desc'; const query: SearchRequest = { query: { @@ -397,10 +343,10 @@ export class AppViewerComponent implements OnInit, OnDestroy { }; const nodes = await this.contentApi.search(query).toPromise(); - const entries = nodes.list.entries.map(obj => obj.entry); + const entries = nodes.list.entries.map((obj) => obj.entry); this.sort(entries, sortingKey, sortingDirection); - return entries.map(obj => obj.id); + return entries.map((obj) => obj.id); } return []; @@ -440,23 +386,19 @@ export class AppViewerComponent implements OnInit, OnDestroy { items.sort((a: any, b: any) => { let left = ObjectUtils.getValue(a, key); if (left) { - left = - left instanceof Date ? left.valueOf().toString() : left.toString(); + left = left instanceof Date ? left.valueOf().toString() : left.toString(); } else { left = ''; } let right = ObjectUtils.getValue(b, key); if (right) { - right = - right instanceof Date ? right.valueOf().toString() : right.toString(); + right = right instanceof Date ? right.valueOf().toString() : right.toString(); } else { right = ''; } - return direction === 'asc' - ? left.localeCompare(right, undefined, options) - : right.localeCompare(left, undefined, options); + return direction === 'asc' ? left.localeCompare(right, undefined, options) : right.localeCompare(left, undefined, options); }); } @@ -466,9 +408,7 @@ export class AppViewerComponent implements OnInit, OnDestroy { } private getFileLocation(): string { - return this.router - .parseUrl(this.navigationPath || this.router.url) - .root.children[PRIMARY_OUTLET].toString(); + return this.router.parseUrl(this.navigationPath || this.router.url).root.children[PRIMARY_OUTLET].toString(); } private shouldNavigate(element: HTMLElement): boolean { @@ -482,8 +422,6 @@ export class AppViewerComponent implements OnInit, OnDestroy { } private isChild(list: DOMTokenList): boolean { - return Array.from(list).some((className: string) => - this.containersSkipNavigation.includes(className) - ); + return Array.from(list).some((className: string) => this.containersSkipNavigation.includes(className)); } } diff --git a/src/app/dialogs/node-template/create-from-template.dialog.spec.ts b/src/app/dialogs/node-template/create-from-template.dialog.spec.ts index 27180141c..8194dffc1 100644 --- a/src/app/dialogs/node-template/create-from-template.dialog.spec.ts +++ b/src/app/dialogs/node-template/create-from-template.dialog.spec.ts @@ -27,24 +27,14 @@ import { CreateFromTemplateDialogComponent } from './create-from-template.dialog import { TestBed, ComponentFixture } from '@angular/core/testing'; import { AppTestingModule } from '../../testing/app-testing.module'; import { CoreModule, TranslationMock } from '@alfresco/adf-core'; -import { - MatDialogModule, - MAT_DIALOG_DATA, - MatDialogRef -} from '@angular/material/dialog'; +import { MatDialogModule, MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { Store } from '@ngrx/store'; import { CreateFromTemplate } from '@alfresco/aca-shared/store'; import { Node } from '@alfresco/js-api'; import { TranslateModule } from '@ngx-translate/core'; function text(length: number) { - return new Array(length) - .fill( - Math.random() - .toString() - .substring(2, 3) - ) - .join(''); + return new Array(length).fill(Math.random().toString().substring(2, 3)).join(''); } describe('CreateFileFromTemplateDialogComponent', () => { @@ -65,12 +55,7 @@ describe('CreateFileFromTemplateDialogComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ - TranslateModule.forRoot(), - CoreModule.forRoot(), - AppTestingModule, - MatDialogModule - ], + imports: [TranslateModule.forRoot(), CoreModule.forRoot(), AppTestingModule, MatDialogModule], declarations: [CreateFromTemplateDialogComponent], providers: [ { @@ -105,12 +90,8 @@ describe('CreateFileFromTemplateDialogComponent', () => { fixture.detectChanges(); expect(component.form.controls.name.value).toBe(data.name); - expect(component.form.controls.title.value).toBe( - data.properties['cm:title'] - ); - expect(component.form.controls.description.value).toBe( - data.properties['cm:description'] - ); + expect(component.form.controls.title.value).toBe(data.properties['cm:title']); + expect(component.form.controls.description.value).toBe(data.properties['cm:description']); }); it('should invalidate form if required `name` field is invalid', () => { @@ -180,8 +161,6 @@ describe('CreateFileFromTemplateDialogComponent', () => { component.onSubmit(); - expect(store.dispatch['calls'].mostRecent().args[0]).toEqual( - new CreateFromTemplate(newNode) - ); + expect(store.dispatch['calls'].mostRecent().args[0]).toEqual(new CreateFromTemplate(newNode)); }); }); diff --git a/src/app/dialogs/node-template/create-from-template.dialog.ts b/src/app/dialogs/node-template/create-from-template.dialog.ts index 6ac877c25..eeb1e735f 100644 --- a/src/app/dialogs/node-template/create-from-template.dialog.ts +++ b/src/app/dialogs/node-template/create-from-template.dialog.ts @@ -26,13 +26,7 @@ import { Component, ViewEncapsulation, Inject, OnInit } from '@angular/core'; import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; import { Node } from '@alfresco/js-api'; -import { - FormBuilder, - FormGroup, - Validators, - FormControl, - ValidationErrors -} from '@angular/forms'; +import { FormBuilder, FormGroup, Validators, FormControl, ValidationErrors } from '@angular/forms'; import { Store } from '@ngrx/store'; import { AppStore, CreateFromTemplate } from '@alfresco/aca-shared/store'; import { TranslationService } from '@alfresco/adf-core'; @@ -55,23 +49,9 @@ export class CreateFromTemplateDialogComponent implements OnInit { ngOnInit() { this.form = this.formBuilder.group({ - name: [ - this.data.name, - [ - Validators.required, - this.forbidEndingDot, - this.forbidOnlySpaces, - this.forbidSpecialCharacters - ] - ], - title: [ - this.data.properties ? this.data.properties['cm:title'] : '', - Validators.maxLength(256) - ], - description: [ - this.data.properties ? this.data.properties['cm:description'] : '', - Validators.maxLength(512) - ] + name: [this.data.name, [Validators.required, this.forbidEndingDot, this.forbidOnlySpaces, this.forbidSpecialCharacters]], + title: [this.data.properties ? this.data.properties['cm:title'] : '', Validators.maxLength(256)], + description: [this.data.properties ? this.data.properties['cm:description'] : '', Validators.maxLength(512)] }); } @@ -89,25 +69,17 @@ export class CreateFromTemplateDialogComponent implements OnInit { title(): string { if (this.data.isFolder) { - return this.translationService.instant( - 'NODE_FROM_TEMPLATE.FOLDER_DIALOG_TITLE', - { template: this.data.name } - ); + return this.translationService.instant('NODE_FROM_TEMPLATE.FOLDER_DIALOG_TITLE', { template: this.data.name }); } - return this.translationService.instant( - 'NODE_FROM_TEMPLATE.FILE_DIALOG_TITLE', - { template: this.data.name } - ); + return this.translationService.instant('NODE_FROM_TEMPLATE.FILE_DIALOG_TITLE', { template: this.data.name }); } close() { this.dialogRef.close(); } - private forbidSpecialCharacters({ - value - }: FormControl): ValidationErrors | null { + private forbidSpecialCharacters({ value }: FormControl): ValidationErrors | null { const specialCharacters: RegExp = /([\*\"\<\>\\\/\?\:\|])/; const isValid: boolean = !specialCharacters.test(value); @@ -119,11 +91,7 @@ export class CreateFromTemplateDialogComponent implements OnInit { } private forbidEndingDot({ value }: FormControl): ValidationErrors | null { - const isValid: boolean = - (value || '') - .trim() - .split('') - .pop() !== '.'; + const isValid: boolean = (value || '').trim().split('').pop() !== '.'; return isValid ? null diff --git a/src/app/dialogs/node-versions/node-versions.dialog.spec.ts b/src/app/dialogs/node-versions/node-versions.dialog.spec.ts index 457bc48b4..96063eafa 100644 --- a/src/app/dialogs/node-versions/node-versions.dialog.spec.ts +++ b/src/app/dialogs/node-versions/node-versions.dialog.spec.ts @@ -25,18 +25,9 @@ import { NodeVersionsDialogComponent } from './node-versions.dialog'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { - AlfrescoApiService, - AlfrescoApiServiceMock, - CoreModule, - TranslationMock -} from '@alfresco/adf-core'; +import { AlfrescoApiService, AlfrescoApiServiceMock, CoreModule, TranslationMock } from '@alfresco/adf-core'; import { AppTestingModule } from '../../testing/app-testing.module'; -import { - MAT_DIALOG_DATA, - MatDialogModule, - MatDialogRef -} from '@angular/material/dialog'; +import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef } from '@angular/material/dialog'; import { Store } from '@ngrx/store'; import { NodeEntityEvent, @@ -45,11 +36,7 @@ import { VersionListComponent, VersionUploadComponent } from '@alfresco/adf-content-services'; -import { - TranslateFakeLoader, - TranslateLoader, - TranslateModule -} from '@ngx-translate/core'; +import { TranslateFakeLoader, TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { AppStore, UnlockWriteAction } from '@alfresco/aca-shared/store'; describe('NodeVersionsDialogComponent', () => { @@ -134,18 +121,14 @@ describe('NodeVersionsDialogComponent', () => { it('should display adf upload version if isTypeList is passed as false from parent component', () => { component.isTypeList = false; fixture.detectChanges(); - const adfVersionComponent = document.querySelector( - '#adf-version-upload-button' - ); + const adfVersionComponent = document.querySelector('#adf-version-upload-button'); expect(adfVersionComponent).not.toEqual(null); }); it('should display adf version comparison if isTypeList is passed as false from parent component', () => { component.isTypeList = false; fixture.detectChanges(); - const adfVersionComparisonComponent = document.querySelector( - '#adf-version-comparison' - ); + const adfVersionComparisonComponent = document.querySelector('#adf-version-comparison'); expect(adfVersionComparisonComponent).not.toEqual(null); }); @@ -168,8 +151,6 @@ describe('NodeVersionsDialogComponent', () => { } }); component.handleUpload(nodeEvent); - expect(store.dispatch).toHaveBeenCalledWith( - new UnlockWriteAction(nodeEvent.value) - ); + expect(store.dispatch).toHaveBeenCalledWith(new UnlockWriteAction(nodeEvent.value)); }); }); diff --git a/src/app/dialogs/node-versions/node-versions.dialog.ts b/src/app/dialogs/node-versions/node-versions.dialog.ts index 1efd491c6..c161cdb48 100644 --- a/src/app/dialogs/node-versions/node-versions.dialog.ts +++ b/src/app/dialogs/node-versions/node-versions.dialog.ts @@ -23,19 +23,9 @@ * along with Alfresco. If not, see . */ -import { - AppStore, - SnackbarErrorAction, - UnlockWriteAction -} from '@alfresco/aca-shared/store'; +import { AppStore, SnackbarErrorAction, UnlockWriteAction } from '@alfresco/aca-shared/store'; import { MinimalNodeEntryEntity, Node } from '@alfresco/js-api'; -import { - Component, - EventEmitter, - Inject, - Output, - ViewEncapsulation -} from '@angular/core'; +import { Component, EventEmitter, Inject, Output, ViewEncapsulation } from '@angular/core'; import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { Store } from '@ngrx/store'; import { NodeEntityEvent } from '@alfresco/adf-content-services'; @@ -54,11 +44,7 @@ export class NodeVersionsDialogComponent { @Output() refreshEvent: EventEmitter = new EventEmitter(); - constructor( - @Inject(MAT_DIALOG_DATA) data: any, - private store: Store, - private dialogRef: MatDialogRef - ) { + constructor(@Inject(MAT_DIALOG_DATA) data: any, private store: Store, private dialogRef: MatDialogRef) { this.node = data.node; this.file = data.file; this.isTypeList = data.isTypeList !== undefined ? data.isTypeList : true; diff --git a/src/app/directives/directives.module.ts b/src/app/directives/directives.module.ts index d0d109f4a..f43e56b2f 100644 --- a/src/app/directives/directives.module.ts +++ b/src/app/directives/directives.module.ts @@ -31,12 +31,7 @@ import { LockNodeDirective } from './lock-node.directive'; import { SharedDirectivesModule } from '@alfresco/aca-shared'; export function directives() { - return [ - DocumentListDirective, - LibraryMembershipDirective, - LibraryFavoriteDirective, - LockNodeDirective - ]; + return [DocumentListDirective, LibraryMembershipDirective, LibraryFavoriteDirective, LockNodeDirective]; } @NgModule({ diff --git a/src/app/directives/document-list.directive.spec.ts b/src/app/directives/document-list.directive.spec.ts index b7fdb58ea..51e9deaa6 100644 --- a/src/app/directives/document-list.directive.spec.ts +++ b/src/app/directives/document-list.directive.spec.ts @@ -108,9 +108,7 @@ describe('DocumentListDirective', () => { documentListDirective.ngOnInit(); documentListMock.ready.next(); - expect(storeMock.dispatch).toHaveBeenCalledWith( - new SetSelectedNodesAction([{ isLibrary: true } as any]) - ); + expect(storeMock.dispatch).toHaveBeenCalledWith(new SetSelectedNodesAction([{ isLibrary: true } as any])); }); it('should update store selection on `node-unselect` event', () => { @@ -141,9 +139,7 @@ describe('DocumentListDirective', () => { documentListDirective.ngOnInit(); contentManagementServiceMock.reload.next(); - expect(storeMock.dispatch).toHaveBeenCalledWith( - new SetSelectedNodesAction([]) - ); + expect(storeMock.dispatch).toHaveBeenCalledWith(new SetSelectedNodesAction([])); }); it('should reset store selection and document list on `reset` event', () => { @@ -151,8 +147,6 @@ describe('DocumentListDirective', () => { contentManagementServiceMock.reload.next(); expect(documentListMock.resetSelection).toHaveBeenCalled(); - expect(storeMock.dispatch).toHaveBeenCalledWith( - new SetSelectedNodesAction([]) - ); + expect(storeMock.dispatch).toHaveBeenCalledWith(new SetSelectedNodesAction([])); }); }); diff --git a/src/app/directives/document-list.directive.ts b/src/app/directives/document-list.directive.ts index d09f4c3fe..c685ce37f 100644 --- a/src/app/directives/document-list.directive.ts +++ b/src/app/directives/document-list.directive.ts @@ -68,14 +68,8 @@ export class DocumentListDirective implements OnInit, OnDestroy { if (this.sortingPreferenceKey) { const current = this.documentList.sorting; - const key = this.preferences.get( - `${this.sortingPreferenceKey}.sorting.key`, - current[0] - ); - const direction = this.preferences.get( - `${this.sortingPreferenceKey}.sorting.direction`, - current[1] - ); + const key = this.preferences.get(`${this.sortingPreferenceKey}.sorting.key`, current[0]); + const direction = this.preferences.get(`${this.sortingPreferenceKey}.sorting.direction`, current[1]); this.documentList.sorting = [key, direction]; // TODO: bug in ADF, the `sorting` binding is not updated when changed from code @@ -106,14 +100,8 @@ export class DocumentListDirective implements OnInit, OnDestroy { @HostListener('sorting-changed', ['$event']) onSortingChanged(event: CustomEvent) { if (this.sortingPreferenceKey) { - this.preferences.set( - `${this.sortingPreferenceKey}.sorting.key`, - event.detail.key - ); - this.preferences.set( - `${this.sortingPreferenceKey}.sorting.direction`, - event.detail.direction - ); + this.preferences.set(`${this.sortingPreferenceKey}.sorting.key`, event.detail.key); + this.preferences.set(`${this.sortingPreferenceKey}.sorting.direction`, event.detail.direction); } } @@ -135,7 +123,7 @@ export class DocumentListDirective implements OnInit, OnDestroy { } private updateSelection() { - const selection = this.documentList.selection.map(node => { + const selection = this.documentList.selection.map((node) => { node['isLibrary'] = this.isLibrary; return node; }); diff --git a/src/app/directives/library-favorite.directive.spec.ts b/src/app/directives/library-favorite.directive.spec.ts index 3e5acd603..bc6f9635e 100644 --- a/src/app/directives/library-favorite.directive.spec.ts +++ b/src/app/directives/library-favorite.directive.spec.ts @@ -25,12 +25,7 @@ import { Component, ViewChild } from '@angular/core'; import { LibraryFavoriteDirective } from './library-favorite.directive'; -import { - AlfrescoApiService, - AlfrescoApiServiceMock, - setupTestBed, - CoreModule -} from '@alfresco/adf-core'; +import { AlfrescoApiService, AlfrescoApiServiceMock, setupTestBed, CoreModule } from '@alfresco/adf-core'; import { TestBed, async } from '@angular/core/testing'; import { TranslateModule } from '@ngx-translate/core'; @@ -111,9 +106,7 @@ describe('LibraryFavoriteDirective', () => { expect(component.directive.isFavorite()).toBeFalsy(); fixture.whenStable().then(() => { - fixture.nativeElement - .querySelector('button') - .dispatchEvent(new MouseEvent('click')); + fixture.nativeElement.querySelector('button').dispatchEvent(new MouseEvent('click')); fixture.detectChanges(); @@ -123,18 +116,14 @@ describe('LibraryFavoriteDirective', () => { it('should call removeFavoriteSite() on click event when selection is not a favorite', async(() => { spyOn(api.peopleApi, 'getFavoriteSite').and.returnValue(Promise.resolve()); - spyOn(api.favoritesApi, 'removeFavoriteSite').and.returnValue( - Promise.resolve() - ); + spyOn(api.favoritesApi, 'removeFavoriteSite').and.returnValue(Promise.resolve()); component.selection = selection; fixture.detectChanges(); expect(component.directive.isFavorite()).toBeFalsy(); fixture.whenStable().then(() => { - fixture.nativeElement - .querySelector('button') - .dispatchEvent(new MouseEvent('click')); + fixture.nativeElement.querySelector('button').dispatchEvent(new MouseEvent('click')); fixture.detectChanges(); diff --git a/src/app/directives/library-favorite.directive.ts b/src/app/directives/library-favorite.directive.ts index 439a5ec65..745f0c3c5 100644 --- a/src/app/directives/library-favorite.directive.ts +++ b/src/app/directives/library-favorite.directive.ts @@ -23,14 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Directive, - HostListener, - Input, - OnChanges, - Output, - EventEmitter -} from '@angular/core'; +import { Directive, HostListener, Input, OnChanges, Output, EventEmitter } from '@angular/core'; import { SiteBody, FavoriteBody, FavoriteEntry, Site } from '@alfresco/js-api'; import { AlfrescoApiService } from '@alfresco/adf-core'; @@ -116,7 +109,7 @@ export class LibraryFavoriteDirective implements OnChanges { this.targetLibrary.isFavorite = true; this.toggle.emit(libraryEntry); }) - .catch(error => this.error.emit(error)); + .catch((error) => this.error.emit(error)); } private removeFavorite(favoriteId: string) { @@ -126,6 +119,6 @@ export class LibraryFavoriteDirective implements OnChanges { this.targetLibrary.isFavorite = false; this.toggle.emit(libraryBody); }) - .catch(error => this.error.emit(error)); + .catch((error) => this.error.emit(error)); } } diff --git a/src/app/directives/library-membership.directive.spec.ts b/src/app/directives/library-membership.directive.spec.ts index 4711ad76e..2b7b386f8 100644 --- a/src/app/directives/library-membership.directive.spec.ts +++ b/src/app/directives/library-membership.directive.spec.ts @@ -24,13 +24,7 @@ */ import { fakeAsync, TestBed, tick } from '@angular/core/testing'; -import { - AlfrescoApiService, - AlfrescoApiServiceMock, - AppConfigService, - CoreModule, - StorageService -} from '@alfresco/adf-core'; +import { AlfrescoApiService, AlfrescoApiServiceMock, AppConfigService, CoreModule, StorageService } from '@alfresco/adf-core'; import { AppTestingModule } from '../testing/app-testing.module'; import { DirectivesModule } from './directives.module'; import { LibraryMembershipDirective } from './library-membership.directive'; @@ -60,30 +54,17 @@ describe('LibraryMembershipDirective', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ - TranslateModule.forRoot(), - AppTestingModule, - DirectivesModule, - CoreModule.forRoot() - ], + imports: [TranslateModule.forRoot(), AppTestingModule, DirectivesModule, CoreModule.forRoot()], schemas: [NO_ERRORS_SCHEMA] }); - alfrescoApiService = new AlfrescoApiServiceMock( - new AppConfigService(null), - new StorageService() - ); + alfrescoApiService = new AlfrescoApiServiceMock(new AppConfigService(null), new StorageService()); peopleApi = alfrescoApiService.getInstance().core.peopleApi; directive = new LibraryMembershipDirective(alfrescoApiService); }); describe('markMembershipRequest', () => { beforeEach(() => { - getMembershipSpy = spyOn( - peopleApi, - 'getSiteMembershipRequest' - ).and.returnValue( - Promise.resolve({ entry: requestedMembershipResponse }) - ); + getMembershipSpy = spyOn(peopleApi, 'getSiteMembershipRequest').and.returnValue(Promise.resolve({ entry: requestedMembershipResponse })); }); it('should not check membership requests if no entry is selected', fakeAsync(() => { @@ -123,22 +104,9 @@ describe('LibraryMembershipDirective', () => { describe('toggleMembershipRequest', () => { beforeEach(() => { - getMembershipSpy = spyOn( - peopleApi, - 'getSiteMembershipRequest' - ).and.returnValue( - Promise.resolve({ entry: requestedMembershipResponse }) - ); - addMembershipSpy = spyOn( - peopleApi, - 'addSiteMembershipRequest' - ).and.returnValue( - Promise.resolve({ entry: requestedMembershipResponse }) - ); - deleteMembershipSpy = spyOn( - peopleApi, - 'removeSiteMembershipRequest' - ).and.returnValue(Promise.resolve({})); + getMembershipSpy = spyOn(peopleApi, 'getSiteMembershipRequest').and.returnValue(Promise.resolve({ entry: requestedMembershipResponse })); + addMembershipSpy = spyOn(peopleApi, 'addSiteMembershipRequest').and.returnValue(Promise.resolve({ entry: requestedMembershipResponse })); + deleteMembershipSpy = spyOn(peopleApi, 'removeSiteMembershipRequest').and.returnValue(Promise.resolve({})); }); it('should do nothing if there is no selected library ', fakeAsync(() => { @@ -204,7 +172,7 @@ describe('LibraryMembershipDirective', () => { } ]; - testData.forEach(data => { + testData.forEach((data) => { addMembershipSpy.and.returnValue(throwError({ message: data.fixture })); emitErrorSpy.calls.reset(); directive.toggleMembershipRequest(); diff --git a/src/app/directives/library-membership.directive.ts b/src/app/directives/library-membership.directive.ts index dcfc989c8..c6a393f02 100644 --- a/src/app/directives/library-membership.directive.ts +++ b/src/app/directives/library-membership.directive.ts @@ -23,15 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Directive, - EventEmitter, - HostListener, - Input, - OnChanges, - Output, - SimpleChanges -} from '@angular/core'; +import { Directive, EventEmitter, HostListener, Input, OnChanges, Output, SimpleChanges } from '@angular/core'; import { SiteEntry, SiteMembershipRequestBody } from '@alfresco/js-api'; import { AlfrescoApiService } from '@alfresco/adf-core'; import { BehaviorSubject, from } from 'rxjs'; @@ -54,9 +46,7 @@ export interface LibraryMembershipErrorEvent { export class LibraryMembershipDirective implements OnChanges { targetSite: any = null; - isJoinRequested: BehaviorSubject = new BehaviorSubject( - false - ); + isJoinRequested: BehaviorSubject = new BehaviorSubject(false); /** Site for which to toggle the membership request. */ @Input('acaLibraryMembership') @@ -77,10 +67,7 @@ export class LibraryMembershipDirective implements OnChanges { constructor(private alfrescoApiService: AlfrescoApiService) {} ngOnChanges(changes: SimpleChanges) { - if ( - !changes.selection.currentValue || - !changes.selection.currentValue.entry - ) { + if (!changes.selection.currentValue || !changes.selection.currentValue.entry) { this.targetSite = null; return; @@ -106,7 +93,7 @@ export class LibraryMembershipDirective implements OnChanges { }; this.toggle.emit(info); }, - error => { + (error) => { const errWithMessage = { error, i18nKey: 'APP.MESSAGES.ERRORS.JOIN_CANCEL_FAILED' @@ -118,15 +105,11 @@ export class LibraryMembershipDirective implements OnChanges { if (!this.targetSite.joinRequested) { this.joinLibraryRequest().subscribe( - createdMembership => { + (createdMembership) => { this.targetSite.joinRequested = true; this.isJoinRequested.next(true); - if ( - createdMembership.entry && - createdMembership.entry.site && - createdMembership.entry.site.role - ) { + if (createdMembership.entry && createdMembership.entry.site && createdMembership.entry.site.role) { const info = { shouldReload: true, i18nKey: 'APP.MESSAGES.INFO.JOINED' @@ -141,23 +124,20 @@ export class LibraryMembershipDirective implements OnChanges { this.toggle.emit(info); } }, - error => { + (error) => { const errWithMessage = { error, i18nKey: 'APP.MESSAGES.ERRORS.JOIN_REQUEST_FAILED' }; const senderEmailCheck = 'Failed to resolve sender mail address'; - const receiverEmailCheck = - 'All recipients for the mail action were invalid'; + const receiverEmailCheck = 'All recipients for the mail action were invalid'; if (error.message) { if (error.message.includes(senderEmailCheck)) { - errWithMessage.i18nKey = - 'APP.MESSAGES.ERRORS.INVALID_SENDER_EMAIL'; + errWithMessage.i18nKey = 'APP.MESSAGES.ERRORS.INVALID_SENDER_EMAIL'; } else if (error.message.includes(receiverEmailCheck)) { - errWithMessage.i18nKey = - 'APP.MESSAGES.ERRORS.INVALID_RECEIVER_EMAIL'; + errWithMessage.i18nKey = 'APP.MESSAGES.ERRORS.INVALID_RECEIVER_EMAIL'; } } @@ -173,7 +153,7 @@ export class LibraryMembershipDirective implements OnChanges { } this.getMembershipRequest().subscribe( - data => { + (data) => { if (data.entry.id === this.targetSite.id) { this.targetSite.joinRequested = true; this.isJoinRequested.next(true); @@ -191,29 +171,14 @@ export class LibraryMembershipDirective implements OnChanges { id: this.targetSite.id } as SiteMembershipRequestBody; - return from( - this.alfrescoApiService.peopleApi.addSiteMembershipRequest( - '-me-', - memberBody - ) - ); + return from(this.alfrescoApiService.peopleApi.addSiteMembershipRequest('-me-', memberBody)); } private cancelJoinRequest() { - return from( - this.alfrescoApiService.peopleApi.removeSiteMembershipRequest( - '-me-', - this.targetSite.id - ) - ); + return from(this.alfrescoApiService.peopleApi.removeSiteMembershipRequest('-me-', this.targetSite.id)); } private getMembershipRequest() { - return from( - this.alfrescoApiService.peopleApi.getSiteMembershipRequest( - '-me-', - this.targetSite.id - ) - ); + return from(this.alfrescoApiService.peopleApi.getSiteMembershipRequest('-me-', this.targetSite.id)); } } diff --git a/src/app/directives/lock-node.directive.spec.ts b/src/app/directives/lock-node.directive.spec.ts index 6c982e9e5..fa96efaaa 100644 --- a/src/app/directives/lock-node.directive.spec.ts +++ b/src/app/directives/lock-node.directive.spec.ts @@ -25,20 +25,13 @@ import { Component, ViewChild } from '@angular/core'; import { LockNodeDirective } from './lock-node.directive'; -import { - AlfrescoApiService, - AlfrescoApiServiceMock, - setupTestBed, - CoreModule -} from '@alfresco/adf-core'; +import { AlfrescoApiService, AlfrescoApiServiceMock, setupTestBed, CoreModule } from '@alfresco/adf-core'; import { TestBed, fakeAsync, tick } from '@angular/core/testing'; import { TranslateModule } from '@ngx-translate/core'; @Component({ selector: 'app-test-component', - template: ` - - ` + template: ` ` }) class TestComponent { @ViewChild('lock') @@ -115,9 +108,7 @@ describe('LockNodeDirective', () => { tick(); fixture.detectChanges(); - expect(component.selection.entry.properties['cm:lockType']).toBe( - 'WRITE_LOCK' - ); + expect(component.selection.entry.properties['cm:lockType']).toBe('WRITE_LOCK'); })); it('should unlock selection', fakeAsync(() => { diff --git a/src/app/directives/lock-node.directive.ts b/src/app/directives/lock-node.directive.ts index 7d6a0ae98..2740801c2 100644 --- a/src/app/directives/lock-node.directive.ts +++ b/src/app/directives/lock-node.directive.ts @@ -23,13 +23,7 @@ * along with Alfresco. If not, see . */ -import { - Directive, - EventEmitter, - HostListener, - Input, - Output -} from '@angular/core'; +import { Directive, EventEmitter, HostListener, Input, Output } from '@angular/core'; import { NodeEntry, SharedLinkEntry } from '@alfresco/js-api'; import { AlfrescoApiService } from '@alfresco/adf-core'; import { isLocked } from '@alfresco/aca-shared'; diff --git a/src/app/extensions/core.extensions.module.ts b/src/app/extensions/core.extensions.module.ts index e42f33b8b..462f77b63 100644 --- a/src/app/extensions/core.extensions.module.ts +++ b/src/app/extensions/core.extensions.module.ts @@ -53,10 +53,7 @@ import { ViewNodeComponent } from '../components/toolbar/view-node/view-node.com import { LanguagePickerComponent } from '../components/common/language-picker/language-picker.component'; import { LogoutComponent } from '../components/common/logout/logout.component'; import { CurrentUserComponent } from '../components/current-user/current-user.component'; -import { - AppExtensionService, - ExtensionsDataLoaderGuard -} from '@alfresco/aca-shared'; +import { AppExtensionService, ExtensionsDataLoaderGuard } from '@alfresco/aca-shared'; export function setupExtensions(service: AppExtensionService): Function { return () => service.load(); diff --git a/src/app/material.module.ts b/src/app/material.module.ts index 2f5d2b07e..3a966e3cc 100644 --- a/src/app/material.module.ts +++ b/src/app/material.module.ts @@ -27,33 +27,14 @@ import { NgModule } from '@angular/core'; import { MatMenuModule } from '@angular/material/menu'; import { MatIconModule } from '@angular/material/icon'; import { MatButtonModule } from '@angular/material/button'; -import { - MatDialogModule, - MAT_DIALOG_DEFAULT_OPTIONS -} from '@angular/material/dialog'; +import { MatDialogModule, MAT_DIALOG_DEFAULT_OPTIONS } from '@angular/material/dialog'; import { MatInputModule } from '@angular/material/input'; import { MatSnackBarModule } from '@angular/material/snack-bar'; import { MatProgressBarModule } from '@angular/material/progress-bar'; @NgModule({ - imports: [ - MatMenuModule, - MatIconModule, - MatButtonModule, - MatDialogModule, - MatInputModule, - MatSnackBarModule, - MatProgressBarModule - ], - exports: [ - MatMenuModule, - MatIconModule, - MatButtonModule, - MatDialogModule, - MatInputModule, - MatSnackBarModule, - MatProgressBarModule - ], + imports: [MatMenuModule, MatIconModule, MatButtonModule, MatDialogModule, MatInputModule, MatSnackBarModule, MatProgressBarModule], + exports: [MatMenuModule, MatIconModule, MatButtonModule, MatDialogModule, MatInputModule, MatSnackBarModule, MatProgressBarModule], providers: [ { provide: MAT_DIALOG_DEFAULT_OPTIONS, diff --git a/src/app/services/content-management.service.spec.ts b/src/app/services/content-management.service.spec.ts index 5aadb4500..3fc6338df 100644 --- a/src/app/services/content-management.service.spec.ts +++ b/src/app/services/content-management.service.spec.ts @@ -51,17 +51,9 @@ import { ContentApiService } from '@alfresco/aca-shared'; import { Store } from '@ngrx/store'; import { ContentManagementService } from './content-management.service'; import { NodeActionsService } from './node-actions.service'; -import { - TranslationService, - AlfrescoApiService, - FileModel -} from '@alfresco/adf-core'; +import { TranslationService, AlfrescoApiService, FileModel } from '@alfresco/adf-core'; import { MatDialog, MatDialogRef } from '@angular/material/dialog'; -import { - MatSnackBar, - MatSnackBarRef, - SimpleSnackBar -} from '@angular/material/snack-bar'; +import { MatSnackBar, MatSnackBarRef, SimpleSnackBar } from '@angular/material/snack-bar'; import { NodeEntry, Node } from '@alfresco/js-api'; describe('ContentManagementService', () => { @@ -105,9 +97,7 @@ describe('ContentManagementService', () => { it('notifies successful copy of a node', () => { spyOn(nodeActions, 'copyNodes').and.returnValue(subject); - const selection: any[] = [ - { entry: { id: 'node-to-copy-id', name: 'name' } } - ]; + const selection: any[] = [{ entry: { id: 'node-to-copy-id', name: 'name' } }]; const createdItems: any[] = [{ entry: { id: 'copy-id', name: 'name' } }]; store.dispatch(new CopyNodesAction(selection)); @@ -115,52 +105,35 @@ describe('ContentManagementService', () => { subject.next('OPERATION.SUCCES.CONTENT.COPY'); expect(nodeActions.copyNodes).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.INFO.NODE_COPY.SINGULAR' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.SINGULAR'); }); it('notifies successful copy of multiple nodes', () => { spyOn(nodeActions, 'copyNodes').and.returnValue(subject); - const selection: any[] = [ - { entry: { id: 'node-to-copy-1', name: 'name1' } }, - { entry: { id: 'node-to-copy-2', name: 'name2' } } - ]; - const createdItems: any[] = [ - { entry: { id: 'copy-of-node-1', name: 'name1' } }, - { entry: { id: 'copy-of-node-2', name: 'name2' } } - ]; + const selection: any[] = [{ entry: { id: 'node-to-copy-1', name: 'name1' } }, { entry: { id: 'node-to-copy-2', name: 'name2' } }]; + const createdItems: any[] = [{ entry: { id: 'copy-of-node-1', name: 'name1' } }, { entry: { id: 'copy-of-node-2', name: 'name2' } }]; store.dispatch(new CopyNodesAction(selection)); nodeActions.contentCopied.next(createdItems); subject.next('OPERATION.SUCCES.CONTENT.COPY'); expect(nodeActions.copyNodes).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.INFO.NODE_COPY.PLURAL' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.PLURAL'); }); it('notifies partially copy of one node out of a multiple selection of nodes', () => { spyOn(nodeActions, 'copyNodes').and.returnValue(subject); - const selection: any[] = [ - { entry: { id: 'node-to-copy-1', name: 'name1' } }, - { entry: { id: 'node-to-copy-2', name: 'name2' } } - ]; - const createdItems: any[] = [ - { entry: { id: 'copy-of-node-1', name: 'name1' } } - ]; + const selection: any[] = [{ entry: { id: 'node-to-copy-1', name: 'name1' } }, { entry: { id: 'node-to-copy-2', name: 'name2' } }]; + const createdItems: any[] = [{ entry: { id: 'copy-of-node-1', name: 'name1' } }]; store.dispatch(new CopyNodesAction(selection)); nodeActions.contentCopied.next(createdItems); subject.next('OPERATION.SUCCES.CONTENT.COPY'); expect(nodeActions.copyNodes).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.INFO.NODE_COPY.PARTIAL_SINGULAR' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.PARTIAL_SINGULAR'); }); it('notifies partially copy of more nodes out of a multiple selection of nodes', () => { @@ -171,19 +144,14 @@ describe('ContentManagementService', () => { { entry: { id: 'node-to-copy-1', name: 'name1' } }, { entry: { id: 'node-to-copy-2', name: 'name2' } } ]; - const createdItems: any[] = [ - { entry: { id: 'copy-of-node-0', name: 'name0' } }, - { entry: { id: 'copy-of-node-1', name: 'name1' } } - ]; + const createdItems: any[] = [{ entry: { id: 'copy-of-node-0', name: 'name0' } }, { entry: { id: 'copy-of-node-1', name: 'name1' } }]; store.dispatch(new CopyNodesAction(selection)); nodeActions.contentCopied.next(createdItems); subject.next('OPERATION.SUCCES.CONTENT.COPY'); expect(nodeActions.copyNodes).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.INFO.NODE_COPY.PARTIAL_PLURAL' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.PARTIAL_PLURAL'); }); it('notifies of failed copy of multiple nodes', () => { @@ -201,17 +169,13 @@ describe('ContentManagementService', () => { subject.next('OPERATION.SUCCES.CONTENT.COPY'); expect(nodeActions.copyNodes).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.INFO.NODE_COPY.FAIL_PLURAL' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.FAIL_PLURAL'); }); it('notifies of failed copy of one node', () => { spyOn(nodeActions, 'copyNodes').and.returnValue(subject); - const selection: any[] = [ - { entry: { id: 'node-to-copy', name: 'name' } } - ]; + const selection: any[] = [{ entry: { id: 'node-to-copy', name: 'name' } }]; const createdItems: any[] = []; store.dispatch(new CopyNodesAction(selection)); @@ -219,26 +183,20 @@ describe('ContentManagementService', () => { subject.next('OPERATION.SUCCES.CONTENT.COPY'); expect(nodeActions.copyNodes).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.INFO.NODE_COPY.FAIL_SINGULAR' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.FAIL_SINGULAR'); }); it('notifies error if success message was not emitted', () => { spyOn(nodeActions, 'copyNodes').and.returnValue(subject); - const selection: any[] = [ - { entry: { id: 'node-to-copy-id', name: 'name' } } - ]; + const selection: any[] = [{ entry: { id: 'node-to-copy-id', name: 'name' } }]; store.dispatch(new CopyNodesAction(selection)); nodeActions.contentCopied.next(); subject.next(''); expect(nodeActions.copyNodes).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.ERRORS.GENERIC' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.GENERIC'); }); it('notifies permission error on copy of node', () => { @@ -249,9 +207,7 @@ describe('ContentManagementService', () => { subject.error(new Error(JSON.stringify({ error: { statusCode: 403 } }))); expect(nodeActions.copyNodes).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.ERRORS.PERMISSION' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.PERMISSION'); }); it('notifies generic error message on all errors, but 403', () => { @@ -263,9 +219,7 @@ describe('ContentManagementService', () => { subject.error(new Error(JSON.stringify({ error: { statusCode: 404 } }))); expect(nodeActions.copyNodes).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.ERRORS.GENERIC' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.GENERIC'); }); }); @@ -284,9 +238,7 @@ describe('ContentManagementService', () => { it('should delete the newly created node on Undo action', () => { spyOn(contentApi, 'deleteNode').and.returnValue(of(null)); - const selection: any[] = [ - { entry: { id: 'node-to-copy-id', name: 'name' } } - ]; + const selection: any[] = [{ entry: { id: 'node-to-copy-id', name: 'name' } }]; const createdItems: any[] = [{ entry: { id: 'copy-id', name: 'name' } }]; store.dispatch(new CopyNodesAction(selection)); @@ -294,20 +246,13 @@ describe('ContentManagementService', () => { nodeActions.contentCopied.next(createdItems); expect(nodeActions.copyNodes).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.INFO.NODE_COPY.SINGULAR' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.SINGULAR'); - expect(contentApi.deleteNode).toHaveBeenCalledWith( - createdItems[0].entry.id, - { permanent: true } - ); + expect(contentApi.deleteNode).toHaveBeenCalledWith(createdItems[0].entry.id, { permanent: true }); }); it('should delete also the node created inside an already existing folder from destination', () => { - const spyOnDeleteNode = spyOn(contentApi, 'deleteNode').and.returnValue( - of(null) - ); + const spyOnDeleteNode = spyOn(contentApi, 'deleteNode').and.returnValue(of(null)); const selection: any[] = [ { entry: { id: 'node-to-copy-1', name: 'name1' } }, @@ -338,9 +283,7 @@ describe('ContentManagementService', () => { nodeActions.contentCopied.next(createdItems); expect(nodeActions.copyNodes).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.INFO.NODE_COPY.PLURAL' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_COPY.PLURAL'); expect(spyOnDeleteNode).toHaveBeenCalled(); expect(spyOnDeleteNode.calls.allArgs()).toEqual([ @@ -352,9 +295,7 @@ describe('ContentManagementService', () => { it('notifies when error occurs on Undo action', () => { spyOn(contentApi, 'deleteNode').and.returnValue(throwError(null)); - const selection: any[] = [ - { entry: { id: 'node-to-copy-id', name: 'name' } } - ]; + const selection: any[] = [{ entry: { id: 'node-to-copy-id', name: 'name' } }]; const createdItems: any[] = [{ entry: { id: 'copy-id', name: 'name' } }]; store.dispatch(new CopyNodesAction(selection)); @@ -363,19 +304,13 @@ describe('ContentManagementService', () => { expect(nodeActions.copyNodes).toHaveBeenCalled(); expect(contentApi.deleteNode).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toEqual( - 'APP.MESSAGES.INFO.NODE_COPY.SINGULAR' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toEqual('APP.MESSAGES.INFO.NODE_COPY.SINGULAR'); }); it('notifies when some error of type Error occurs on Undo action', () => { - spyOn(contentApi, 'deleteNode').and.returnValue( - throwError(new Error('oops!')) - ); + spyOn(contentApi, 'deleteNode').and.returnValue(throwError(new Error('oops!'))); - const selection: any[] = [ - { entry: { id: 'node-to-copy-id', name: 'name' } } - ]; + const selection: any[] = [{ entry: { id: 'node-to-copy-id', name: 'name' } }]; const createdItems: any[] = [{ entry: { id: 'copy-id', name: 'name' } }]; store.dispatch(new CopyNodesAction(selection)); @@ -384,19 +319,13 @@ describe('ContentManagementService', () => { expect(nodeActions.copyNodes).toHaveBeenCalled(); expect(contentApi.deleteNode).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toEqual( - 'APP.MESSAGES.INFO.NODE_COPY.SINGULAR' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toEqual('APP.MESSAGES.INFO.NODE_COPY.SINGULAR'); }); it('notifies permission error when it occurs on Undo action', () => { - spyOn(contentApi, 'deleteNode').and.returnValue( - throwError(new Error(JSON.stringify({ error: { statusCode: 403 } }))) - ); + spyOn(contentApi, 'deleteNode').and.returnValue(throwError(new Error(JSON.stringify({ error: { statusCode: 403 } })))); - const selection: any[] = [ - { entry: { id: 'node-to-copy-id', name: 'name' } } - ]; + const selection: any[] = [{ entry: { id: 'node-to-copy-id', name: 'name' } }]; const createdItems: any[] = [{ entry: { id: 'copy-id', name: 'name' } }]; store.dispatch(new CopyNodesAction(selection)); @@ -405,9 +334,7 @@ describe('ContentManagementService', () => { expect(nodeActions.copyNodes).toHaveBeenCalled(); expect(contentApi.deleteNode).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toEqual( - 'APP.MESSAGES.INFO.NODE_COPY.SINGULAR' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toEqual('APP.MESSAGES.INFO.NODE_COPY.SINGULAR'); }); }); @@ -415,10 +342,10 @@ describe('ContentManagementService', () => { let subject: Subject; beforeEach(() => { - spyOn(translationService, 'instant').and.callFake(keysArray => { + spyOn(translationService, 'instant').and.callFake((keysArray) => { if (Array.isArray(keysArray)) { const processedKeys = {}; - keysArray.forEach(key => { + keysArray.forEach((key) => { processedKeys[key] = key; }); return processedKeys; @@ -452,16 +379,11 @@ describe('ContentManagementService', () => { nodeActions.contentMoved.next(moveResponse); expect(nodeActions.moveNodes).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.INFO.NODE_MOVE.SINGULAR' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR'); }); it('notifies successful move of multiple nodes', () => { - const nodes = [ - { entry: { id: '1', name: 'name1' } }, - { entry: { id: '2', name: 'name2' } } - ]; + const nodes = [{ entry: { id: '1', name: 'name1' } }, { entry: { id: '2', name: 'name2' } }]; const moveResponse = { succeeded: nodes, failed: [], @@ -478,9 +400,7 @@ describe('ContentManagementService', () => { nodeActions.contentMoved.next(moveResponse); expect(nodeActions.moveNodes).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.INFO.NODE_MOVE.PLURAL' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.PLURAL'); }); it('notifies partial move of a node', () => { @@ -501,16 +421,11 @@ describe('ContentManagementService', () => { nodeActions.contentMoved.next(moveResponse); expect(nodeActions.moveNodes).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.SINGULAR' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.SINGULAR'); }); it('notifies partial move of multiple nodes', () => { - const nodes: any[] = [ - { entry: { id: '1', name: 'name' } }, - { entry: { id: '2', name: 'name2' } } - ]; + const nodes: any[] = [{ entry: { id: '1', name: 'name' } }, { entry: { id: '2', name: 'name2' } }]; const moveResponse = { succeeded: [], failed: [], @@ -527,16 +442,11 @@ describe('ContentManagementService', () => { nodeActions.contentMoved.next(moveResponse); expect(nodeActions.moveNodes).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.PLURAL' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.PLURAL'); }); it('notifies successful move and the number of nodes that could not be moved', () => { - const nodes: any[] = [ - { entry: { id: '1', name: 'name' } }, - { entry: { id: '2', name: 'name2' } } - ]; + const nodes: any[] = [{ entry: { id: '1', name: 'name' } }, { entry: { id: '2', name: 'name2' } }]; const moveResponse = { succeeded: [nodes[0]], failed: [nodes[1]], @@ -551,16 +461,11 @@ describe('ContentManagementService', () => { nodeActions.contentMoved.next(moveResponse); expect(nodeActions.moveNodes).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.INFO.NODE_MOVE.SINGULAR APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.FAIL' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.FAIL'); }); it('notifies successful move and the number of partially moved ones', () => { - const nodes: any[] = [ - { entry: { id: '1', name: 'name' } }, - { entry: { id: '2', name: 'name2' } } - ]; + const nodes: any[] = [{ entry: { id: '1', name: 'name' } }, { entry: { id: '2', name: 'name2' } }]; const moveResponse = { succeeded: [nodes[0]], failed: [], @@ -575,9 +480,7 @@ describe('ContentManagementService', () => { nodeActions.contentMoved.next(moveResponse); expect(nodeActions.moveNodes).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.INFO.NODE_MOVE.SINGULAR APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.SINGULAR' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR APP.MESSAGES.INFO.NODE_MOVE.PARTIAL.SINGULAR'); }); it('notifies error if success message was not emitted', () => { @@ -595,9 +498,7 @@ describe('ContentManagementService', () => { nodeActions.contentMoved.next(moveResponse); expect(nodeActions.moveNodes).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.ERRORS.GENERIC' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.GENERIC'); }); it('notifies permission error on move of node', () => { @@ -605,14 +506,10 @@ describe('ContentManagementService', () => { const selection: any[] = [{ entry: { id: '1', name: 'name' } }]; store.dispatch(new MoveNodesAction(selection)); - nodeActions - .moveNodes(null) - .error(new Error(JSON.stringify({ error: { statusCode: 403 } }))); + nodeActions.moveNodes(null).error(new Error(JSON.stringify({ error: { statusCode: 403 } }))); expect(nodeActions.moveNodes).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.ERRORS.PERMISSION' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.PERMISSION'); }); it('notifies generic error message on all errors, but 403', () => { @@ -620,14 +517,10 @@ describe('ContentManagementService', () => { const selection: any[] = [{ entry: { id: '1', name: 'name' } }]; store.dispatch(new MoveNodesAction(selection)); - nodeActions - .moveNodes(null) - .error(new Error(JSON.stringify({ error: { statusCode: 404 } }))); + nodeActions.moveNodes(null).error(new Error(JSON.stringify({ error: { statusCode: 404 } }))); expect(nodeActions.moveNodes).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.ERRORS.GENERIC' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.GENERIC'); }); it('notifies conflict error message on 409', () => { @@ -635,14 +528,10 @@ describe('ContentManagementService', () => { const selection: any[] = [{ entry: { id: '1', name: 'name' } }]; store.dispatch(new MoveNodesAction(selection)); - nodeActions - .moveNodes(null) - .error(new Error(JSON.stringify({ error: { statusCode: 409 } }))); + nodeActions.moveNodes(null).error(new Error(JSON.stringify({ error: { statusCode: 409 } }))); expect(nodeActions.moveNodes).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.ERRORS.NODE_MOVE' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.NODE_MOVE'); }); it('notifies error if move response has only failed items', () => { @@ -661,9 +550,7 @@ describe('ContentManagementService', () => { nodeActions.contentMoved.next(moveResponse); expect(nodeActions.moveNodes).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.ERRORS.GENERIC' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.ERRORS.GENERIC'); }); }); @@ -671,10 +558,10 @@ describe('ContentManagementService', () => { let subject: Subject; beforeEach(() => { - spyOn(translationService, 'instant').and.callFake(keysArray => { + spyOn(translationService, 'instant').and.callFake((keysArray) => { if (Array.isArray(keysArray)) { const processedKeys = {}; - keysArray.forEach(key => { + keysArray.forEach((key) => { processedKeys[key] = key; }); return processedKeys; @@ -713,13 +600,8 @@ describe('ContentManagementService', () => { }; nodeActions.contentMoved.next(movedItems); - expect(nodeActions.moveNodeAction).toHaveBeenCalledWith( - movedItems.succeeded[0].itemMoved.entry, - movedItems.succeeded[0].initialParentId - ); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.INFO.NODE_MOVE.SINGULAR' - ); + expect(nodeActions.moveNodeAction).toHaveBeenCalledWith(movedItems.succeeded[0].itemMoved.entry, movedItems.succeeded[0].initialParentId); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR'); }); it('should move node back to initial parent, after succeeded move of a single file', () => { @@ -746,13 +628,8 @@ describe('ContentManagementService', () => { nodeActions.moveNodes(null).next('OPERATION.SUCCES.CONTENT.MOVE'); nodeActions.contentMoved.next(movedItems); - expect(nodeActions.moveNodeAction).toHaveBeenCalledWith( - node.entry, - initialParent - ); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.INFO.NODE_MOVE.SINGULAR' - ); + expect(nodeActions.moveNodeAction).toHaveBeenCalledWith(node.entry, initialParent); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR'); }); it('should restore deleted folder back to initial parent, after succeeded moving all its files', () => { @@ -784,12 +661,10 @@ describe('ContentManagementService', () => { nodeActions.contentMoved.next(movedItems); expect(contentApi.restoreNode).toHaveBeenCalled(); - expect(snackBar.open['calls'].argsFor(0)[0]).toBe( - 'APP.MESSAGES.INFO.NODE_MOVE.SINGULAR' - ); + expect(snackBar.open['calls'].argsFor(0)[0]).toBe('APP.MESSAGES.INFO.NODE_MOVE.SINGULAR'); }); - it('should notify when error occurs on Undo Move action', fakeAsync(done => { + it('should notify when error occurs on Undo Move action', fakeAsync((done) => { spyOn(contentApi, 'restoreNode').and.returnValue(throwError(null)); actions$.pipe( @@ -830,10 +705,8 @@ describe('ContentManagementService', () => { expect(contentApi.restoreNode).toHaveBeenCalled(); })); - it('should notify when some error of type Error occurs on Undo Move action', fakeAsync(done => { - spyOn(contentApi, 'restoreNode').and.returnValue( - throwError(new Error('oops!')) - ); + it('should notify when some error of type Error occurs on Undo Move action', fakeAsync((done) => { + spyOn(contentApi, 'restoreNode').and.returnValue(throwError(new Error('oops!'))); actions$.pipe( ofType(SnackbarActionTypes.Error), @@ -864,10 +737,8 @@ describe('ContentManagementService', () => { expect(contentApi.restoreNode).toHaveBeenCalled(); })); - it('should notify permission error when it occurs on Undo Move action', fakeAsync(done => { - spyOn(contentApi, 'restoreNode').and.returnValue( - throwError(new Error(JSON.stringify({ error: { statusCode: 403 } }))) - ); + it('should notify permission error when it occurs on Undo Move action', fakeAsync((done) => { + spyOn(contentApi, 'restoreNode').and.returnValue(throwError(new Error(JSON.stringify({ error: { statusCode: 403 } })))); actions$.pipe( ofType(SnackbarActionTypes.Error), @@ -901,7 +772,7 @@ describe('ContentManagementService', () => { }); describe('Delete action', () => { - it('should raise info message on successful single file deletion', fakeAsync(done => { + it('should raise info message on successful single file deletion', fakeAsync((done) => { spyOn(contentApi, 'deleteNode').and.returnValue(of(null)); actions$.pipe( @@ -914,7 +785,7 @@ describe('ContentManagementService', () => { store.dispatch(new DeleteNodesAction(selection)); })); - it('should raise error message on failed single file deletion', fakeAsync(done => { + it('should raise error message on failed single file deletion', fakeAsync((done) => { spyOn(contentApi, 'deleteNode').and.returnValue(throwError(null)); actions$.pipe( @@ -929,7 +800,7 @@ describe('ContentManagementService', () => { store.dispatch(new DeleteNodesAction(selection)); })); - it('should raise info message on successful multiple files deletion', fakeAsync(done => { + it('should raise info message on successful multiple files deletion', fakeAsync((done) => { spyOn(contentApi, 'deleteNode').and.returnValue(of(null)); actions$.pipe( @@ -937,15 +808,12 @@ describe('ContentManagementService', () => { map(() => done()) ); - const selection: any[] = [ - { entry: { id: '1', name: 'name1' } }, - { entry: { id: '2', name: 'name2' } } - ]; + const selection: any[] = [{ entry: { id: '1', name: 'name1' } }, { entry: { id: '2', name: 'name2' } }]; store.dispatch(new DeleteNodesAction(selection)); })); - it('should raise error message failed multiple files deletion', fakeAsync(done => { + it('should raise error message failed multiple files deletion', fakeAsync((done) => { spyOn(contentApi, 'deleteNode').and.returnValue(throwError(null)); actions$.pipe( @@ -953,16 +821,13 @@ describe('ContentManagementService', () => { map(() => done()) ); - const selection: any[] = [ - { entry: { id: '1', name: 'name1' } }, - { entry: { id: '2', name: 'name2' } } - ]; + const selection: any[] = [{ entry: { id: '1', name: 'name1' } }, { entry: { id: '2', name: 'name2' } }]; store.dispatch(new DeleteNodesAction(selection)); })); - it('should raise warning message when only one file is successful', fakeAsync(done => { - spyOn(contentApi, 'deleteNode').and.callFake(id => { + it('should raise warning message when only one file is successful', fakeAsync((done) => { + spyOn(contentApi, 'deleteNode').and.callFake((id) => { if (id === '1') { return throwError(null); } else { @@ -975,16 +840,13 @@ describe('ContentManagementService', () => { map(() => done()) ); - const selection: any[] = [ - { entry: { id: '1', name: 'name1' } }, - { entry: { id: '2', name: 'name2' } } - ]; + const selection: any[] = [{ entry: { id: '1', name: 'name1' } }, { entry: { id: '2', name: 'name2' } }]; store.dispatch(new DeleteNodesAction(selection)); })); - it('should raise warning message when some files are successfully deleted', fakeAsync(done => { - spyOn(contentApi, 'deleteNode').and.callFake(id => { + it('should raise warning message when some files are successfully deleted', fakeAsync((done) => { + spyOn(contentApi, 'deleteNode').and.callFake((id) => { if (id === '1') { return throwError(null); } @@ -1005,11 +867,7 @@ describe('ContentManagementService', () => { map(() => done()) ); - const selection: any[] = [ - { entry: { id: '1', name: 'name1' } }, - { entry: { id: '2', name: 'name2' } }, - { entry: { id: '3', name: 'name3' } } - ]; + const selection: any[] = [{ entry: { id: '1', name: 'name1' } }, { entry: { id: '2', name: 'name2' } }, { entry: { id: '3', name: 'name3' } }]; store.dispatch(new DeleteNodesAction(selection)); })); @@ -1041,13 +899,13 @@ describe('ContentManagementService', () => { })); describe('notification', () => { - it('raises warning on multiple fail and one success', fakeAsync(done => { + it('raises warning on multiple fail and one success', fakeAsync((done) => { actions$.pipe( ofType(SnackbarActionTypes.Warning), map(() => done()) ); - spyOn(contentApi, 'purgeDeletedNode').and.callFake(id => { + spyOn(contentApi, 'purgeDeletedNode').and.callFake((id) => { if (id === '1') { return of({}); } @@ -1072,13 +930,13 @@ describe('ContentManagementService', () => { store.dispatch(new PurgeDeletedNodesAction(selection)); })); - it('raises warning on multiple success and multiple fail', fakeAsync(done => { + it('raises warning on multiple success and multiple fail', fakeAsync((done) => { actions$.pipe( ofType(SnackbarActionTypes.Warning), map(() => done()) ); - spyOn(contentApi, 'purgeDeletedNode').and.callFake(id => { + spyOn(contentApi, 'purgeDeletedNode').and.callFake((id) => { if (id === '1') { return of({}); } @@ -1108,7 +966,7 @@ describe('ContentManagementService', () => { store.dispatch(new PurgeDeletedNodesAction(selection)); })); - it('raises info on one selected node success', fakeAsync(done => { + it('raises info on one selected node success', fakeAsync((done) => { actions$.pipe( ofType(SnackbarActionTypes.Info), map(() => done()) @@ -1121,7 +979,7 @@ describe('ContentManagementService', () => { store.dispatch(new PurgeDeletedNodesAction(selection)); })); - it('raises error on one selected node fail', fakeAsync(done => { + it('raises error on one selected node fail', fakeAsync((done) => { actions$.pipe( ofType(SnackbarActionTypes.Error), map(() => done()) @@ -1134,12 +992,12 @@ describe('ContentManagementService', () => { store.dispatch(new PurgeDeletedNodesAction(selection)); })); - it('raises info on all nodes success', fakeAsync(done => { + it('raises info on all nodes success', fakeAsync((done) => { actions$.pipe( ofType(SnackbarActionTypes.Info), map(() => done()) ); - spyOn(contentApi, 'purgeDeletedNode').and.callFake(id => { + spyOn(contentApi, 'purgeDeletedNode').and.callFake((id) => { if (id === '1') { return of({}); } @@ -1151,20 +1009,17 @@ describe('ContentManagementService', () => { return of(null); }); - const selection: any[] = [ - { entry: { id: '1', name: 'name1' } }, - { entry: { id: '2', name: 'name2' } } - ]; + const selection: any[] = [{ entry: { id: '1', name: 'name1' } }, { entry: { id: '2', name: 'name2' } }]; store.dispatch(new PurgeDeletedNodesAction(selection)); })); - it('raises error on all nodes fail', fakeAsync(done => { + it('raises error on all nodes fail', fakeAsync((done) => { actions$.pipe( ofType(SnackbarActionTypes.Error), map(() => done()) ); - spyOn(contentApi, 'purgeDeletedNode').and.callFake(id => { + spyOn(contentApi, 'purgeDeletedNode').and.callFake((id) => { if (id === '1') { return throwError({}); } @@ -1176,10 +1031,7 @@ describe('ContentManagementService', () => { return of({}); }); - const selection: any[] = [ - { entry: { id: '1', name: 'name1' } }, - { entry: { id: '2', name: 'name2' } } - ]; + const selection: any[] = [{ entry: { id: '1', name: 'name1' } }, { entry: { id: '2', name: 'name2' } }]; store.dispatch(new PurgeDeletedNodesAction(selection)); })); @@ -1270,10 +1122,7 @@ describe('ContentManagementService', () => { store.dispatch(new RestoreDeletedNodesAction(selection)); - expect( - store.dispatch['calls'].argsFor(1)[0].userAction.action instanceof - NavigateToParentFolder - ).toBe(true); + expect(store.dispatch['calls'].argsFor(1)[0].userAction.action instanceof NavigateToParentFolder).toBe(true); })); describe('notification', () => { @@ -1285,7 +1134,7 @@ describe('ContentManagementService', () => { ); }); - it('should raise error message on partial multiple fail ', fakeAsync(done => { + it('should raise error message on partial multiple fail ', fakeAsync((done) => { const error = { message: '{ "error": {} }' }; actions$.pipe( @@ -1293,7 +1142,7 @@ describe('ContentManagementService', () => { map(() => done()) ); - spyOn(contentApi, 'restoreNode').and.callFake(id => { + spyOn(contentApi, 'restoreNode').and.callFake((id) => { if (id === '1') { return of({} as NodeEntry); } @@ -1327,7 +1176,7 @@ describe('ContentManagementService', () => { store.dispatch(new RestoreDeletedNodesAction(selection)); })); - it('should raise error message when restored node exist, error 409', fakeAsync(done => { + it('should raise error message when restored node exist, error 409', fakeAsync((done) => { const error = { message: '{ "error": { "statusCode": 409 } }' }; spyOn(contentApi, 'restoreNode').and.returnValue(throwError(error)); @@ -1350,7 +1199,7 @@ describe('ContentManagementService', () => { store.dispatch(new RestoreDeletedNodesAction(selection)); })); - it('should raise error message when restored node returns different statusCode', fakeAsync(done => { + it('should raise error message when restored node returns different statusCode', fakeAsync((done) => { const error = { message: '{ "error": { "statusCode": 404 } }' }; spyOn(contentApi, 'restoreNode').and.returnValue(throwError(error)); @@ -1374,7 +1223,7 @@ describe('ContentManagementService', () => { store.dispatch(new RestoreDeletedNodesAction(selection)); })); - it('should raise error message when restored node location is missing', fakeAsync(done => { + it('should raise error message when restored node location is missing', fakeAsync((done) => { const error = { message: '{ "error": { } }' }; spyOn(contentApi, 'restoreNode').and.returnValue(throwError(error)); @@ -1398,8 +1247,8 @@ describe('ContentManagementService', () => { store.dispatch(new RestoreDeletedNodesAction(selection)); })); - it('should raise info message when restore multiple nodes', fakeAsync(done => { - spyOn(contentApi, 'restoreNode').and.callFake(id => { + it('should raise info message when restore multiple nodes', fakeAsync((done) => { + spyOn(contentApi, 'restoreNode').and.callFake((id) => { const entry = {} as NodeEntry; if (id === '1') { return of(entry); @@ -1426,15 +1275,12 @@ describe('ContentManagementService', () => { ] }; - const selection: any[] = [ - { entry: { id: '1', name: 'name1', path } }, - { entry: { id: '2', name: 'name2', path } } - ]; + const selection: any[] = [{ entry: { id: '1', name: 'name1', path } }, { entry: { id: '2', name: 'name2', path } }]; store.dispatch(new RestoreDeletedNodesAction(selection)); })); - it('should raise info message when restore selected node', fakeAsync(done => { + it('should raise info message when restore selected node', fakeAsync((done) => { spyOn(contentApi, 'restoreNode').and.returnValue(of({} as NodeEntry)); actions$.pipe( @@ -1456,7 +1302,7 @@ describe('ContentManagementService', () => { store.dispatch(new RestoreDeletedNodesAction(selection)); })); - it('navigate to restore selected node location onAction', fakeAsync(done => { + it('navigate to restore selected node location onAction', fakeAsync((done) => { spyOn(contentApi, 'restoreNode').and.returnValue(of({} as NodeEntry)); actions$.pipe( @@ -1532,9 +1378,7 @@ describe('ContentManagementService', () => { store.dispatch(new ShareNodeAction(node)); - expect(store.dispatch['calls'].argsFor(1)[0]).toEqual( - new SetSelectedNodesAction([node]) - ); + expect(store.dispatch['calls'].argsFor(1)[0]).toEqual(new SetSelectedNodesAction([node])); })); it('should emit event when node is un-shared', fakeAsync(() => { @@ -1548,17 +1392,13 @@ describe('ContentManagementService', () => { tick(); flush(); - expect(contentManagementService.linksUnshared.next).toHaveBeenCalledWith( - jasmine.any(Object) - ); + expect(contentManagementService.linksUnshared.next).toHaveBeenCalledWith(jasmine.any(Object)); })); }); describe('Unlock Node', () => { it('should unlock node', fakeAsync(() => { - spyOn(contentApi, 'unlockNode').and.returnValue( - Promise.resolve({} as NodeEntry) - ); + spyOn(contentApi, 'unlockNode').and.returnValue(Promise.resolve({} as NodeEntry)); store.dispatch(new UnlockWriteAction({ entry: { id: 'node-id' } })); tick(); @@ -1568,13 +1408,9 @@ describe('ContentManagementService', () => { })); it('should raise error when unlock node fails', fakeAsync(() => { - spyOn(contentApi, 'unlockNode').and.callFake( - () => new Promise((_resolve, reject) => reject('error')) - ); + spyOn(contentApi, 'unlockNode').and.callFake(() => new Promise((_resolve, reject) => reject('error'))); spyOn(store, 'dispatch').and.callThrough(); - store.dispatch( - new UnlockWriteAction({ entry: { id: 'node-id', name: 'some-file' } }) - ); + store.dispatch(new UnlockWriteAction({ entry: { id: 'node-id', name: 'some-file' } })); tick(); flush(); @@ -1593,17 +1429,11 @@ describe('ContentManagementService', () => { name: 'lights.jpg', id: 'f5e5cb54-200e-41a8-9c21-b5ee77da3992' }; - const fakeFile = new FileModel( - { name: 'file1.png', size: 10 } as File, - null, - 'file1' - ); + const fakeFile = new FileModel({ name: 'file1.png', size: 10 } as File, null, 'file1'); contentManagementService.versionUpdateDialog(fakeNode, fakeFile); - expect(dialog.open['calls'].argsFor(0)[0].name).toBe( - 'NodeVersionsDialogComponent' - ); + expect(dialog.open['calls'].argsFor(0)[0].name).toBe('NodeVersionsDialogComponent'); }); it('should return dialog instance reference', () => { @@ -1614,18 +1444,11 @@ describe('ContentManagementService', () => { name: 'lights.jpg', id: 'f5e5cb54-200e-41a8-9c21-b5ee77da3992' }; - const fakeFile = new FileModel( - { name: 'file1.png', size: 10 } as File, - null, - 'file1' - ); + const fakeFile = new FileModel({ name: 'file1.png', size: 10 } as File, null, 'file1'); spyOn(dialog, 'open').and.returnValue(mockDialogInstance); - const dialogRef = contentManagementService.versionUpdateDialog( - fakeNode, - fakeFile - ); + const dialogRef = contentManagementService.versionUpdateDialog(fakeNode, fakeFile); expect(dialogRef).toBe(mockDialogInstance); }); @@ -1642,9 +1465,7 @@ describe('ContentManagementService', () => { contentManagementService.editFolder(node); - expect(dialog.open['calls'].argsFor(0)[0].name).toBe( - 'FolderDialogComponent' - ); + expect(dialog.open['calls'].argsFor(0)[0].name).toBe('FolderDialogComponent'); }); it('should raise error when edit operation fails', fakeAsync(() => { @@ -1660,9 +1481,7 @@ describe('ContentManagementService', () => { mockDialogInstance.componentInstance.error.next('edit folder error'); - expect(store.dispatch['calls'].argsFor(0)[0]).toEqual( - new SnackbarErrorAction('edit folder error') - ); + expect(store.dispatch['calls'].argsFor(0)[0]).toEqual(new SnackbarErrorAction('edit folder error')); })); it('should call nodeUpdated event with edited node data', fakeAsync(() => { diff --git a/src/app/services/content-management.service.ts b/src/app/services/content-management.service.ts index 74793a59a..2033c76e9 100644 --- a/src/app/services/content-management.service.ts +++ b/src/app/services/content-management.service.ts @@ -42,12 +42,7 @@ import { SnackbarWarningAction, UndoDeleteNodesAction } from '@alfresco/aca-shared/store'; -import { - ConfirmDialogComponent, - FolderDialogComponent, - LibraryDialogComponent, - ShareDialogComponent -} from '@alfresco/adf-content-services'; +import { ConfirmDialogComponent, FolderDialogComponent, LibraryDialogComponent, ShareDialogComponent } from '@alfresco/adf-content-services'; import { TranslationService, AlfrescoApiService } from '@alfresco/adf-core'; import { DeletedNodesPaging, @@ -106,7 +101,7 @@ export class ContentManagementService { addFavorite(nodes: Array) { if (nodes && nodes.length > 0) { this.contentApi.addFavorite(nodes).subscribe(() => { - const favoriteNodes = nodes.map(node => { + const favoriteNodes = nodes.map((node) => { const newNode = JSON.parse(JSON.stringify(node)); newNode.entry.isFavorite = true; return newNode; @@ -120,7 +115,7 @@ export class ContentManagementService { removeFavorite(nodes: Array) { if (nodes && nodes.length > 0) { this.contentApi.removeFavorite(nodes).subscribe(() => { - const favoriteNodes = nodes.map(node => { + const favoriteNodes = nodes.map((node) => { const newNode = JSON.parse(JSON.stringify(node)); newNode.entry.isFavorite = false; return newNode; @@ -144,9 +139,7 @@ export class ContentManagementService { width: '730px' }); } else { - this.store.dispatch( - new SnackbarErrorAction('APP.MESSAGES.ERRORS.PERMISSION') - ); + this.store.dispatch(new SnackbarErrorAction('APP.MESSAGES.ERRORS.PERMISSION')); } } } @@ -157,7 +150,7 @@ export class ContentManagementService { const id = node.entry.nodeId || (node as any).entry.guid; if (id) { - this.contentApi.getNodeInfo(id).subscribe(entry => { + this.contentApi.getNodeInfo(id).subscribe((entry) => { this.openVersionManagerDialog(entry); }); } else { @@ -178,9 +171,7 @@ export class ContentManagementService { this.store.dispatch(new ReloadDocumentListAction()); }); } else { - this.store.dispatch( - new SnackbarErrorAction('APP.MESSAGES.ERRORS.PERMISSION') - ); + this.store.dispatch(new SnackbarErrorAction('APP.MESSAGES.ERRORS.PERMISSION')); } } @@ -198,7 +189,7 @@ export class ContentManagementService { const id = node.entry.nodeId || (node as any).entry.guid; if (id) { - this.contentApi.getNodeInfo(id).subscribe(entry => { + this.contentApi.getNodeInfo(id).subscribe((entry) => { this.openShareLinkDialog({ entry }); }); } else { @@ -211,7 +202,7 @@ export class ContentManagementService { this.store .select(getSharedUrl) .pipe(take(1)) - .subscribe(baseShareUrl => { + .subscribe((baseShareUrl) => { this.dialogRef .open(ShareDialogComponent, { restoreFocus: true, @@ -223,7 +214,7 @@ export class ContentManagementService { } }) .afterClosed() - .subscribe(deletedSharedLink => { + .subscribe((deletedSharedLink) => { this.store.dispatch(new SetSelectedNodesAction([node])); if (deletedSharedLink) { this.linksUnshared.next(deletedSharedLink); @@ -246,7 +237,7 @@ export class ContentManagementService { this.store.dispatch(new SnackbarErrorAction(message)); }); - dialogInstance.afterClosed().subscribe(node => { + dialogInstance.afterClosed().subscribe((node) => { if (node) { this.store.dispatch(new ReloadDocumentListAction()); } @@ -269,7 +260,7 @@ export class ContentManagementService { this.store.dispatch(new SnackbarErrorAction(message)); }); - dialog.afterClosed().subscribe(node => { + dialog.afterClosed().subscribe((node) => { if (node) { this.alfrescoApiService.nodeUpdated.next(node); } @@ -286,7 +277,7 @@ export class ContentManagementService { }); return dialogInstance.afterClosed().pipe( - tap(node => { + tap((node) => { if (node) { this.libraryCreated.next(node); } @@ -304,14 +295,10 @@ export class ContentManagementService { this.contentApi.deleteSite(id).subscribe( () => { this.libraryDeleted.next(id); - this.store.dispatch( - new SnackbarInfoAction('APP.MESSAGES.INFO.LIBRARY_DELETED') - ); + this.store.dispatch(new SnackbarInfoAction('APP.MESSAGES.INFO.LIBRARY_DELETED')); }, () => { - this.store.dispatch( - new SnackbarErrorAction('APP.MESSAGES.ERRORS.DELETE_LIBRARY_FAILED') - ); + this.store.dispatch(new SnackbarErrorAction('APP.MESSAGES.ERRORS.DELETE_LIBRARY_FAILED')); } ); } @@ -327,21 +314,15 @@ export class ContentManagementService { minWidth: '250px' }); - dialogRef.afterClosed().subscribe(result => { + dialogRef.afterClosed().subscribe((result) => { if (result === true) { this.contentApi.leaveSite(siteId).subscribe( () => { this.libraryLeft.next(siteId); - this.store.dispatch( - new SnackbarInfoAction('APP.MESSAGES.INFO.LEFT_LIBRARY') - ); + this.store.dispatch(new SnackbarInfoAction('APP.MESSAGES.INFO.LEFT_LIBRARY')); }, () => { - this.store.dispatch( - new SnackbarErrorAction( - 'APP.MESSAGES.ERRORS.LEAVE_LIBRARY_FAILED' - ) - ); + this.store.dispatch(new SnackbarErrorAction('APP.MESSAGES.ERRORS.LEAVE_LIBRARY_FAILED')); } ); } @@ -352,22 +333,16 @@ export class ContentManagementService { this.contentApi.updateLibrary(siteId, siteBody).subscribe( (siteEntry: SiteEntry) => { this.libraryUpdated.next(siteEntry); - this.store.dispatch( - new SnackbarInfoAction('LIBRARY.SUCCESS.LIBRARY_UPDATED') - ); + this.store.dispatch(new SnackbarInfoAction('LIBRARY.SUCCESS.LIBRARY_UPDATED')); }, () => { - this.store.dispatch( - new SnackbarErrorAction('LIBRARY.ERRORS.LIBRARY_UPDATE_ERROR') - ); + this.store.dispatch(new SnackbarErrorAction('LIBRARY.ERRORS.LIBRARY_UPDATE_ERROR')); } ); } async unshareNodes(links: Array) { - const promises = links.map(link => - this.contentApi.deleteSharedLink(link.entry.id).toPromise() - ); + const promises = links.map((link) => this.contentApi.deleteSharedLink(link.entry.id).toPromise()); await Promise.all(promises); this.linksUnshared.next(); } @@ -395,9 +370,9 @@ export class ContentManagementService { minWidth: '250px' }); - dialogRef.afterClosed().subscribe(result => { + dialogRef.afterClosed().subscribe((result) => { if (result === true) { - const nodesToDelete: NodeInfo[] = nodes.map(node => { + const nodesToDelete: NodeInfo[] = nodes.map((node) => { const { name } = node.entry; const id = (node as any).entry.nodeId || node.entry.id; @@ -416,7 +391,7 @@ export class ContentManagementService { return; } - const nodesWithPath = selection.filter(node => node.entry.path); + const nodesWithPath = selection.filter((node) => node.entry.path); if (selection.length && !nodesWithPath.length) { const failedStatus = this.processStatus([]); @@ -428,9 +403,9 @@ export class ContentManagementService { let status: DeleteStatus; - forkJoin(nodesWithPath.map(node => this.restoreNode(node))) + forkJoin(nodesWithPath.map((node) => this.restoreNode(node))) .pipe( - tap(restoredNodes => { + tap((restoredNodes) => { status = this.processStatus(restoredNodes); }), mergeMap(() => this.contentApi.getDeletedNodes()) @@ -449,25 +424,18 @@ export class ContentManagementService { } copyNodes(nodes: Array) { - zip( - this.nodeActionsService.copyNodes(nodes), - this.nodeActionsService.contentCopied - ).subscribe( - result => { + zip(this.nodeActionsService.copyNodes(nodes), this.nodeActionsService.contentCopied).subscribe( + (result) => { const [operationResult, newItems] = result; this.showCopyMessage(operationResult, nodes, newItems); }, - error => { + (error) => { this.showCopyMessage(error, nodes); } ); } - private showCopyMessage( - info: any, - nodes: Array, - newItems?: Array - ) { + private showCopyMessage(info: any, nodes: Array, newItems?: Array) { const numberOfCopiedItems = newItems ? newItems.length : 0; const failedItems = nodes.length - numberOfCopiedItems; @@ -479,11 +447,9 @@ export class ContentManagementService { if (failedItems) { if (numberOfCopiedItems) { - i18MessageSuffix = - numberOfCopiedItems === 1 ? 'PARTIAL_SINGULAR' : 'PARTIAL_PLURAL'; + i18MessageSuffix = numberOfCopiedItems === 1 ? 'PARTIAL_SINGULAR' : 'PARTIAL_PLURAL'; } else { - i18MessageSuffix = - failedItems === 1 ? 'FAIL_SINGULAR' : 'FAIL_PLURAL'; + i18MessageSuffix = failedItems === 1 ? 'FAIL_SINGULAR' : 'FAIL_PLURAL'; } } else { i18MessageSuffix = numberOfCopiedItems === 1 ? 'SINGULAR' : 'PLURAL'; @@ -503,10 +469,7 @@ export class ContentManagementService { } catch {} } - const undo = - numberOfCopiedItems > 0 - ? this.translation.instant('APP.ACTIONS.UNDO') - : ''; + const undo = numberOfCopiedItems > 0 ? this.translation.instant('APP.ACTIONS.UNDO') : ''; const message = this.translation.instant(i18nMessageString, { success: numberOfCopiedItems, @@ -525,17 +488,15 @@ export class ContentManagementService { private undoCopyNodes(nodes: MinimalNodeEntity[]) { const batch = this.nodeActionsService .flatten(nodes) - .filter(item => item.entry) - .map(item => - this.contentApi.deleteNode(item.entry.id, { permanent: true }) - ); + .filter((item) => item.entry) + .map((item) => this.contentApi.deleteNode(item.entry.id, { permanent: true })); forkJoin(...batch).subscribe( () => { this.nodesDeleted.next(null); this.store.dispatch(new ReloadDocumentListAction()); }, - error => { + (error) => { let i18nMessageString = 'APP.MESSAGES.ERRORS.GENERIC'; let errorJson = null; @@ -543,11 +504,7 @@ export class ContentManagementService { errorJson = JSON.parse(error.message); } catch {} - if ( - errorJson && - errorJson.error && - errorJson.error.statusCode === 403 - ) { + if (errorJson && errorJson.error && errorJson.error.statusCode === 403) { i18nMessageString = 'APP.MESSAGES.ERRORS.PERMISSION'; } @@ -559,39 +516,26 @@ export class ContentManagementService { moveNodes(nodes: Array) { const permissionForMove = '!'; - zip( - this.nodeActionsService.moveNodes(nodes, permissionForMove), - this.nodeActionsService.contentMoved - ).subscribe( - result => { + zip(this.nodeActionsService.moveNodes(nodes, permissionForMove), this.nodeActionsService.contentMoved).subscribe( + (result) => { const [operationResult, moveResponse] = result; this.showMoveMessage(nodes, operationResult, moveResponse); this.store.dispatch(new ReloadDocumentListAction()); }, - error => { + (error) => { this.showMoveMessage(nodes, error); } ); } private undoMoveNodes(moveResponse, selectionParentId: string) { - const movedNodes = - moveResponse && moveResponse['succeeded'] - ? moveResponse['succeeded'] - : []; - const partiallyMovedNodes = - moveResponse && moveResponse['partiallySucceeded'] - ? moveResponse['partiallySucceeded'] - : []; + const movedNodes = moveResponse && moveResponse['succeeded'] ? moveResponse['succeeded'] : []; + const partiallyMovedNodes = moveResponse && moveResponse['partiallySucceeded'] ? moveResponse['partiallySucceeded'] : []; - const restoreDeletedNodesBatch = this.nodeActionsService.moveDeletedEntries.map( - folderEntry => { - return this.contentApi - .restoreNode(folderEntry.nodeId || folderEntry.id) - .pipe(map(node => node.entry)); - } - ); + const restoreDeletedNodesBatch = this.nodeActionsService.moveDeletedEntries.map((folderEntry) => { + return this.contentApi.restoreNode(folderEntry.nodeId || folderEntry.id).pipe(map((node) => node.entry)); + }); zip(...restoreDeletedNodesBatch, of(null)) .pipe( @@ -600,20 +544,12 @@ export class ContentManagementService { const revertMoveBatch = this.nodeActionsService .flatten(nodesToBeMovedBack) - .filter( - node => node.entry || (node.itemMoved && node.itemMoved.entry) - ) - .map(node => { + .filter((node) => node.entry || (node.itemMoved && node.itemMoved.entry)) + .map((node) => { if (node.itemMoved) { - return this.nodeActionsService.moveNodeAction( - node.itemMoved.entry, - node.initialParentId - ); + return this.nodeActionsService.moveNodeAction(node.itemMoved.entry, node.initialParentId); } else { - return this.nodeActionsService.moveNodeAction( - node.entry, - selectionParentId - ); + return this.nodeActionsService.moveNodeAction(node.entry, selectionParentId); } }); @@ -624,7 +560,7 @@ export class ContentManagementService { () => { this.store.dispatch(new ReloadDocumentListAction()); }, - error => { + (error) => { let message = 'APP.MESSAGES.ERRORS.GENERIC'; let errorJson = null; @@ -632,11 +568,7 @@ export class ContentManagementService { errorJson = JSON.parse(error.message); } catch {} - if ( - errorJson && - errorJson.error && - errorJson.error.statusCode === 403 - ) { + if (errorJson && errorJson.error && errorJson.error.statusCode === 403) { message = 'APP.MESSAGES.ERRORS.PERMISSION'; } @@ -648,7 +580,7 @@ export class ContentManagementService { deleteNodes(items: MinimalNodeEntity[]): void { const batch: Observable[] = []; - items.forEach(node => { + items.forEach((node) => { batch.push(this.deleteNode(node)); }); @@ -658,10 +590,7 @@ export class ContentManagementService { if (message && status.someSucceeded) { message.duration = 10000; - message.userAction = new SnackbarUserAction( - 'APP.ACTIONS.UNDO', - new UndoDeleteNodesAction([...status.success]) - ); + message.userAction = new SnackbarUserAction('APP.ACTIONS.UNDO', new UndoDeleteNodesAction([...status.success])); } this.store.dispatch(message); @@ -676,11 +605,11 @@ export class ContentManagementService { undoDeleteNodes(items: DeletedNodeInfo[]): void { const batch: Observable[] = []; - items.forEach(item => { + items.forEach((item) => { batch.push(this.undoDeleteNode(item)); }); - forkJoin(...batch).subscribe(data => { + forkJoin(...batch).subscribe((data) => { const processedData = this.processStatus(data); if (processedData.fail.length) { @@ -717,10 +646,7 @@ export class ContentManagementService { private getUndoDeleteMessage(status: DeleteStatus): SnackbarAction { if (status.someFailed && !status.oneFailed) { - return new SnackbarErrorAction( - 'APP.MESSAGES.ERRORS.NODE_RESTORE_PLURAL', - { number: status.fail.length } - ); + return new SnackbarErrorAction('APP.MESSAGES.ERRORS.NODE_RESTORE_PLURAL', { number: status.fail.length }); } if (status.oneFailed) { @@ -740,7 +666,7 @@ export class ContentManagementService { status: 1, entry })), - catchError(error => { + catchError((error) => { const { statusCode } = JSON.parse(error.message).error; return of({ @@ -757,9 +683,9 @@ export class ContentManagementService { return; } - const batch = selection.map(node => this.purgeDeletedNode(node)); + const batch = selection.map((node) => this.purgeDeletedNode(node)); - forkJoin(batch).subscribe(purgedNodes => { + forkJoin(batch).subscribe((purgedNodes) => { const status = this.processStatus(purgedNodes); if (status.success.length) { @@ -832,51 +758,33 @@ export class ContentManagementService { private getPurgeMessage(status: DeleteStatus): SnackbarAction { if (status.oneSucceeded && status.someFailed && !status.oneFailed) { - return new SnackbarWarningAction( - 'APP.MESSAGES.INFO.TRASH.NODES_PURGE.PARTIAL_SINGULAR', - { - name: status.success[0].name, - failed: status.fail.length - } - ); + return new SnackbarWarningAction('APP.MESSAGES.INFO.TRASH.NODES_PURGE.PARTIAL_SINGULAR', { + name: status.success[0].name, + failed: status.fail.length + }); } if (status.someSucceeded && !status.oneSucceeded && status.someFailed) { - return new SnackbarWarningAction( - 'APP.MESSAGES.INFO.TRASH.NODES_PURGE.PARTIAL_PLURAL', - { - number: status.success.length, - failed: status.fail.length - } - ); + return new SnackbarWarningAction('APP.MESSAGES.INFO.TRASH.NODES_PURGE.PARTIAL_PLURAL', { + number: status.success.length, + failed: status.fail.length + }); } if (status.oneSucceeded) { - return new SnackbarInfoAction( - 'APP.MESSAGES.INFO.TRASH.NODES_PURGE.SINGULAR', - { name: status.success[0].name } - ); + return new SnackbarInfoAction('APP.MESSAGES.INFO.TRASH.NODES_PURGE.SINGULAR', { name: status.success[0].name }); } if (status.oneFailed) { - return new SnackbarErrorAction( - 'APP.MESSAGES.ERRORS.TRASH.NODES_PURGE.SINGULAR', - { name: status.fail[0].name } - ); + return new SnackbarErrorAction('APP.MESSAGES.ERRORS.TRASH.NODES_PURGE.SINGULAR', { name: status.fail[0].name }); } if (status.allSucceeded) { - return new SnackbarInfoAction( - 'APP.MESSAGES.INFO.TRASH.NODES_PURGE.PLURAL', - { number: status.success.length } - ); + return new SnackbarInfoAction('APP.MESSAGES.INFO.TRASH.NODES_PURGE.PLURAL', { number: status.success.length }); } if (status.allFailed) { - return new SnackbarErrorAction( - 'APP.MESSAGES.ERRORS.TRASH.NODES_PURGE.PLURAL', - { number: status.fail.length } - ); + return new SnackbarErrorAction('APP.MESSAGES.ERRORS.TRASH.NODES_PURGE.PLURAL', { number: status.fail.length }); } return null; @@ -890,9 +798,7 @@ export class ContentManagementService { const isSite = this.isSite(status.success[0].entry); const path: PathInfoEntity = status.success[0].entry.path; const parent = path.elements[path.elements.length - 1]; - const route = isSite - ? ['/libraries', parent.id] - : ['/personal-files', parent.id]; + const route = isSite ? ['/libraries', parent.id] : ['/personal-files', parent.id]; let navigate; @@ -902,10 +808,7 @@ export class ContentManagementService { navigate = new NavigateRouteAction(route); } - message.userAction = new SnackbarUserAction( - 'APP.ACTIONS.VIEW', - navigate - ); + message.userAction = new SnackbarUserAction('APP.ACTIONS.VIEW', navigate); } this.store.dispatch(message); @@ -917,11 +820,7 @@ export class ContentManagementService { } private isLibraryContent(path: PathInfoEntity): boolean { - if ( - path && - path.elements.length >= 2 && - path.elements[1].name === 'Sites' - ) { + if (path && path.elements.length >= 2 && path.elements[1].name === 'Sites') { return true; } @@ -930,53 +829,46 @@ export class ContentManagementService { private getRestoreMessage(status: DeleteStatus): SnackbarAction { if (status.someFailed && !status.oneFailed) { - return new SnackbarErrorAction( - 'APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.PARTIAL_PLURAL', - { number: status.fail.length } - ); + return new SnackbarErrorAction('APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.PARTIAL_PLURAL', { + number: status.fail.length + }); } if (status.oneFailed && status.fail[0].statusCode) { if (status.fail[0].statusCode === 409) { - return new SnackbarErrorAction( - 'APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.NODE_EXISTS', - { name: status.fail[0].entry.name } - ); + return new SnackbarErrorAction('APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.NODE_EXISTS', { + name: status.fail[0].entry.name + }); } else { - return new SnackbarErrorAction( - 'APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.GENERIC', - { name: status.fail[0].entry.name } - ); + return new SnackbarErrorAction('APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.GENERIC', { + name: status.fail[0].entry.name + }); } } if (status.oneFailed && !status.fail[0].statusCode) { - return new SnackbarErrorAction( - 'APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.LOCATION_MISSING', - { name: status.fail[0].entry.name } - ); + return new SnackbarErrorAction('APP.MESSAGES.ERRORS.TRASH.NODES_RESTORE.LOCATION_MISSING', { + name: status.fail[0].entry.name + }); } if (status.allSucceeded && !status.oneSucceeded) { - return new SnackbarInfoAction( - 'APP.MESSAGES.INFO.TRASH.NODES_RESTORE.PLURAL' - ); + return new SnackbarInfoAction('APP.MESSAGES.INFO.TRASH.NODES_RESTORE.PLURAL'); } if (status.allSucceeded && status.oneSucceeded) { - return new SnackbarInfoAction( - 'APP.MESSAGES.INFO.TRASH.NODES_RESTORE.SINGULAR', - { name: status.success[0].entry.name } - ); + return new SnackbarInfoAction('APP.MESSAGES.INFO.TRASH.NODES_RESTORE.SINGULAR', { + name: status.success[0].entry.name + }); } return null; } private diff(selection: any[], list: any[], fromList = true): any { - const ids = selection.map(item => item.entry.id); + const ids = selection.map((item) => item.entry.id); - return list.filter(item => { + return list.filter((item) => { if (fromList) { return ids.includes(item.entry.id) ? item : null; } else { @@ -1009,10 +901,7 @@ export class ContentManagementService { private getDeleteMessage(status: DeleteStatus): SnackbarAction { if (status.allFailed && !status.oneFailed) { - return new SnackbarErrorAction( - 'APP.MESSAGES.ERRORS.NODE_DELETION_PLURAL', - { number: status.fail.length } - ); + return new SnackbarErrorAction('APP.MESSAGES.ERRORS.NODE_DELETION_PLURAL', { number: status.fail.length }); } if (status.allSucceeded && !status.oneSucceeded) { @@ -1022,23 +911,17 @@ export class ContentManagementService { } if (status.someFailed && status.someSucceeded && !status.oneSucceeded) { - return new SnackbarWarningAction( - 'APP.MESSAGES.INFO.NODE_DELETION.PARTIAL_PLURAL', - { - success: status.success.length, - failed: status.fail.length - } - ); + return new SnackbarWarningAction('APP.MESSAGES.INFO.NODE_DELETION.PARTIAL_PLURAL', { + success: status.success.length, + failed: status.fail.length + }); } if (status.someFailed && status.oneSucceeded) { - return new SnackbarWarningAction( - 'APP.MESSAGES.INFO.NODE_DELETION.PARTIAL_SINGULAR', - { - success: status.success.length, - failed: status.fail.length - } - ); + return new SnackbarWarningAction('APP.MESSAGES.INFO.NODE_DELETION.PARTIAL_SINGULAR', { + success: status.success.length, + failed: status.fail.length + }); } if (status.oneFailed && !status.someSucceeded) { @@ -1048,32 +931,16 @@ export class ContentManagementService { } if (status.oneSucceeded && !status.someFailed) { - return new SnackbarInfoAction( - 'APP.MESSAGES.INFO.NODE_DELETION.SINGULAR', - { name: status.success[0].name } - ); + return new SnackbarInfoAction('APP.MESSAGES.INFO.NODE_DELETION.SINGULAR', { name: status.success[0].name }); } return null; } - private showMoveMessage( - nodes: Array, - info: any, - moveResponse?: any - ) { - const succeeded = - moveResponse && moveResponse['succeeded'] - ? moveResponse['succeeded'].length - : 0; - const partiallySucceeded = - moveResponse && moveResponse['partiallySucceeded'] - ? moveResponse['partiallySucceeded'].length - : 0; - const failures = - moveResponse && moveResponse['failed'] - ? moveResponse['failed'].length - : 0; + private showMoveMessage(nodes: Array, info: any, moveResponse?: any) { + const succeeded = moveResponse && moveResponse['succeeded'] ? moveResponse['succeeded'].length : 0; + const partiallySucceeded = moveResponse && moveResponse['partiallySucceeded'] ? moveResponse['partiallySucceeded'].length : 0; + const failures = moveResponse && moveResponse['failed'] ? moveResponse['failed'].length : 0; let successMessage = ''; let partialSuccessMessage = ''; @@ -1092,17 +959,14 @@ export class ContentManagementService { } if (partiallySucceeded) { - i18MessageSuffix = - partiallySucceeded === 1 ? 'PARTIAL.SINGULAR' : 'PARTIAL.PLURAL'; + i18MessageSuffix = partiallySucceeded === 1 ? 'PARTIAL.SINGULAR' : 'PARTIAL.PLURAL'; partialSuccessMessage = `${i18nMessageString}${i18MessageSuffix}`; } if (failures) { // if moving failed for ALL nodes, emit error if (failures === nodes.length) { - const errors = this.nodeActionsService.flatten( - moveResponse['failed'] - ); + const errors = this.nodeActionsService.flatten(moveResponse['failed']); errorMessage = this.getErrorMessage(errors[0]); } else { i18MessageSuffix = 'PARTIAL.FAIL'; @@ -1116,34 +980,24 @@ export class ContentManagementService { errorMessage = this.getErrorMessage(info); } - const undo = - succeeded + partiallySucceeded > 0 - ? this.translation.instant('APP.ACTIONS.UNDO') - : ''; + const undo = succeeded + partiallySucceeded > 0 ? this.translation.instant('APP.ACTIONS.UNDO') : ''; failedMessage = errorMessage ? errorMessage : failedMessage; - const beforePartialSuccessMessage = - successMessage && partialSuccessMessage ? ' ' : ''; - const beforeFailedMessage = - (successMessage || partialSuccessMessage) && failedMessage ? ' ' : ''; + const beforePartialSuccessMessage = successMessage && partialSuccessMessage ? ' ' : ''; + const beforeFailedMessage = (successMessage || partialSuccessMessage) && failedMessage ? ' ' : ''; - const initialParentId = this.nodeActionsService.getEntryParentId( - nodes[0].entry - ); + const initialParentId = this.nodeActionsService.getEntryParentId(nodes[0].entry); - const messages = this.translation.instant( - [successMessage, partialSuccessMessage, failedMessage], - { success: succeeded, failed: failures, partially: partiallySucceeded } - ); + const messages = this.translation.instant([successMessage, partialSuccessMessage, failedMessage], { + success: succeeded, + failed: failures, + partially: partiallySucceeded + }); // TODO: review in terms of i18n this.snackBar .open( - messages[successMessage] + - beforePartialSuccessMessage + - messages[partialSuccessMessage] + - beforeFailedMessage + - messages[failedMessage], + messages[successMessage] + beforePartialSuccessMessage + messages[partialSuccessMessage] + beforeFailedMessage + messages[failedMessage], undo, { panelClass: 'info-snackbar', diff --git a/src/app/services/node-actions.service.spec.ts b/src/app/services/node-actions.service.spec.ts index 225532c7b..d5cbfbc61 100644 --- a/src/app/services/node-actions.service.spec.ts +++ b/src/app/services/node-actions.service.spec.ts @@ -29,25 +29,14 @@ import { of, throwError, Subject } from 'rxjs'; import { AlfrescoApiService, TranslationService } from '@alfresco/adf-core'; import { DocumentListService } from '@alfresco/adf-content-services'; import { NodeActionsService, BatchOperationType } from './node-actions.service'; -import { - MinimalNodeEntryEntity, - NodeChildAssociationEntry, - NodeEntry -} from '@alfresco/js-api'; +import { MinimalNodeEntryEntity, NodeChildAssociationEntry, NodeEntry } from '@alfresco/js-api'; import { AppTestingModule } from '../testing/app-testing.module'; import { ContentApiService } from '@alfresco/aca-shared'; class TestNode { entry?: MinimalNodeEntryEntity; - constructor( - id?: string, - isFile?: boolean, - name?: string, - permission?: string[], - nodeType?: string, - properties?: any - ) { + constructor(id?: string, isFile?: boolean, name?: string, permission?: string[], nodeType?: string, properties?: any) { this.entry = {} as any; this.entry.id = id || 'node-id'; this.entry.isFile = isFile; @@ -68,15 +57,9 @@ describe('NodeActionsService', () => { const isFile = true; const folderDestinationId = 'folder-destination-id'; const fileId = 'file-to-be-copied-id'; - const conflictError = new Error( - JSON.stringify({ error: { statusCode: 409 } }) - ); - const permissionError = new Error( - JSON.stringify({ error: { statusCode: 403 } }) - ); - const badRequestError = new Error( - JSON.stringify({ error: { statusCode: 400 } }) - ); + const conflictError = new Error(JSON.stringify({ error: { statusCode: 409 } })); + const permissionError = new Error(JSON.stringify({ error: { statusCode: 403 } })); + const badRequestError = new Error(JSON.stringify({ error: { statusCode: 400 } })); const emptyChildrenList = { list: { entries: [] } }; let service: NodeActionsService; let apiService: AlfrescoApiService; @@ -87,19 +70,12 @@ describe('NodeActionsService', () => { let dialog: MatDialog; const helper = { - fakeCopyNode: ( - isForbidden: boolean = false, - nameExistingOnDestination?: string - ) => { + fakeCopyNode: (isForbidden: boolean = false, nameExistingOnDestination?: string) => { return (_entryId, options) => { return new Promise((resolve, reject) => { if (isForbidden) { reject(permissionError); - } else if ( - nameExistingOnDestination && - options && - options.name === nameExistingOnDestination - ) { + } else if (nameExistingOnDestination && options && options.name === nameExistingOnDestination) { reject(conflictError); } else { resolve(); @@ -107,21 +83,14 @@ describe('NodeActionsService', () => { }); }; }, - fakeGetNodeChildren: ( - familyNodes: { parentNodeId: string; nodeChildren: any[] }[], - isForbidden: boolean = false - ) => { - return parentId => { + fakeGetNodeChildren: (familyNodes: { parentNodeId: string; nodeChildren: any[] }[], isForbidden: boolean = false) => { + return (parentId) => { return new Promise((resolve, reject) => { if (isForbidden) { reject(permissionError); } else { - const node = familyNodes.filter( - familyNode => familyNode.parentNodeId === parentId - ); - resolve( - { list: { entries: node[0].nodeChildren } } || emptyChildrenList - ); + const node = familyNodes.filter((familyNode) => familyNode.parentNodeId === parentId); + resolve({ list: { entries: node[0].nodeChildren } } || emptyChildrenList); } }); }; @@ -152,15 +121,13 @@ describe('NodeActionsService', () => { service.getContentNodeSelection('', contentEntities as NodeEntry[]); subject.next([new TestNode().entry]); - const isSelectionValid = dialog.open['calls'] - .argsFor(0)[1] - .data.isSelectionValid({ - name: 'some-folder-template', - isFile: false, - isFolder: true, - path: { elements: [{}, {}] }, - allowableOperations: ['create'] - }); + const isSelectionValid = dialog.open['calls'].argsFor(0)[1].data.isSelectionValid({ + name: 'some-folder-template', + isFile: false, + isFolder: true, + path: { elements: [{}, {}] }, + allowableOperations: ['create'] + }); expect(isSelectionValid).toBe(true); })); @@ -173,15 +140,13 @@ describe('NodeActionsService', () => { service.getContentNodeSelection('', contentEntities as NodeEntry[]); subject.next([new TestNode().entry]); - const isSelectionValid = dialog.open['calls'] - .argsFor(0)[1] - .data.isSelectionValid({ - name: 'some-folder-template', - isFile: false, - isFolder: true, - path: { elements: [{}, {}] }, - allowableOperations: ['any'] - }); + const isSelectionValid = dialog.open['calls'].argsFor(0)[1].data.isSelectionValid({ + name: 'some-folder-template', + isFile: false, + isFolder: true, + path: { elements: [{}, {}] }, + allowableOperations: ['any'] + }); expect(isSelectionValid).toBe(false); })); @@ -194,16 +159,14 @@ describe('NodeActionsService', () => { service.getContentNodeSelection('', contentEntities as NodeEntry[]); subject.next([new TestNode().entry]); - const isSelectionValid = dialog.open['calls'] - .argsFor(0)[1] - .data.isSelectionValid({ - name: 'some-folder-template', - isFile: false, - isFolder: true, - path: { elements: [{}, {}] }, - nodeType: 'st:site', - allowableOperations: ['create'] - }); + const isSelectionValid = dialog.open['calls'].argsFor(0)[1].data.isSelectionValid({ + name: 'some-folder-template', + isFile: false, + isFolder: true, + path: { elements: [{}, {}] }, + nodeType: 'st:site', + allowableOperations: ['create'] + }); expect(isSelectionValid).toBe(false); })); @@ -216,16 +179,14 @@ describe('NodeActionsService', () => { service.getContentNodeSelection('', contentEntities as NodeEntry[]); subject.next([new TestNode().entry]); - const isSelectionValid = dialog.open['calls'] - .argsFor(0)[1] - .data.isSelectionValid({ - name: 'some-folder-template', - isFile: false, - isFolder: true, - path: { elements: [{}, {}] }, - nodeType: 'cm:folder', - allowableOperations: ['create'] - }); + const isSelectionValid = dialog.open['calls'].argsFor(0)[1].data.isSelectionValid({ + name: 'some-folder-template', + isFile: false, + isFolder: true, + path: { elements: [{}, {}] }, + nodeType: 'cm:folder', + allowableOperations: ['create'] + }); expect(isSelectionValid).toBe(true); })); @@ -239,9 +200,7 @@ describe('NodeActionsService', () => { it("should throw error if 'contentEntities' required parameter is missing", async(() => { const contentEntities = undefined; - const doCopyBatchOperation = service - .copyNodes(contentEntities) - .asObservable(); + const doCopyBatchOperation = service.copyNodes(contentEntities).asObservable(); doCopyBatchOperation .toPromise() @@ -249,7 +208,7 @@ describe('NodeActionsService', () => { () => { spyOnSuccess(); }, - error => { + (error) => { spyOnError(error); } ) @@ -261,9 +220,7 @@ describe('NodeActionsService', () => { it("should throw error if 'contentEntities' is not an array of entry entities", async(() => { const contentEntities = [new TestNode(), {}]; - const doCopyBatchOperation = service - .copyNodes(contentEntities) - .asObservable(); + const doCopyBatchOperation = service.copyNodes(contentEntities).asObservable(); doCopyBatchOperation .toPromise() @@ -271,7 +228,7 @@ describe('NodeActionsService', () => { () => { spyOnSuccess(); }, - error => { + (error) => { spyOnError(error); } ) @@ -283,9 +240,7 @@ describe('NodeActionsService', () => { it("should throw error if an entry in 'contentEntities' does not have id nor nodeId property", async(() => { const contentEntities = [new TestNode(), { entry: {} }]; - const doCopyBatchOperation = service - .copyNodes(contentEntities) - .asObservable(); + const doCopyBatchOperation = service.copyNodes(contentEntities).asObservable(); doCopyBatchOperation .toPromise() @@ -293,7 +248,7 @@ describe('NodeActionsService', () => { () => { spyOnSuccess(); }, - error => { + (error) => { spyOnError(error); } ) @@ -348,31 +303,21 @@ describe('NodeActionsService', () => { spyOn(service, 'getEntryParentId').and.returnValue('parent-id'); - spyOn(dialog, 'open').and.callFake( - (_contentNodeSelectorComponent: any, data: any) => { - testContentNodeSelectorComponentData = data; - return { componentInstance: {} } as MatDialogRef; - } - ); + spyOn(dialog, 'open').and.callFake((_contentNodeSelectorComponent: any, data: any) => { + testContentNodeSelectorComponentData = data; + return { componentInstance: {} } as MatDialogRef; + }); service.copyNodes([fileToCopy, folderToCopy]); }); it('should filter destination nodes and not show files', () => { const file = new TestNode('a-file', isFile); - expect( - testContentNodeSelectorComponentData.data.rowFilter({ node: file }) - ).toBe(false); + expect(testContentNodeSelectorComponentData.data.rowFilter({ node: file })).toBe(false); }); it('should filter destination nodes and not show the symlinks', () => { - const symlinkDestinationFolder = new TestNode( - 'symlink-id', - !isFile, - 'symlink-name', - [], - 'app:folderlink' - ); + const symlinkDestinationFolder = new TestNode('symlink-id', !isFile, 'symlink-name', [], 'app:folderlink'); expect( testContentNodeSelectorComponentData.data.rowFilter({ node: symlinkDestinationFolder @@ -402,17 +347,14 @@ describe('NodeActionsService', () => { destinationFolder = new TestNode(folderDestinationId); translationService = TestBed.inject(TranslationService); - spyOn(translationService, 'instant').and.callFake(key => { + spyOn(translationService, 'instant').and.callFake((key) => { return key; }); }); it('should be called', () => { const subject = new Subject(); - const spyOnBatchOperation = spyOn( - service, - 'doBatchOperation' - ).and.callThrough(); + const spyOnBatchOperation = spyOn(service, 'doBatchOperation').and.callThrough(); spyOn(service, 'getContentNodeSelection').and.returnValue(subject); spyOn(service, 'copyNodeAction').and.returnValue(of({})); @@ -420,39 +362,23 @@ describe('NodeActionsService', () => { subject.next([destinationFolder.entry]); expect(spyOnBatchOperation.calls.count()).toEqual(1); - expect(spyOnBatchOperation).toHaveBeenCalledWith( - BatchOperationType.copy, - [fileToCopy, folderToCopy], - undefined - ); + expect(spyOnBatchOperation).toHaveBeenCalledWith(BatchOperationType.copy, [fileToCopy, folderToCopy], undefined); }); it('should use the custom data object with custom rowFilter & imageResolver & title with destination picker', () => { - const spyOnBatchOperation = spyOn( - service, - 'doBatchOperation' - ).and.callThrough(); - const spyOnDestinationPicker = spyOn( - service, - 'getContentNodeSelection' - ).and.callThrough(); + const spyOnBatchOperation = spyOn(service, 'doBatchOperation').and.callThrough(); + const spyOnDestinationPicker = spyOn(service, 'getContentNodeSelection').and.callThrough(); spyOn(service, 'getEntryParentId').and.returnValue('parent-id'); let testContentNodeSelectorComponentData; - const spyOnDialog = spyOn(dialog, 'open').and.callFake( - (_contentNodeSelectorComponent: any, data: any) => { - testContentNodeSelectorComponentData = data; - return { componentInstance: {} } as MatDialogRef; - } - ); + const spyOnDialog = spyOn(dialog, 'open').and.callFake((_contentNodeSelectorComponent: any, data: any) => { + testContentNodeSelectorComponentData = data; + return { componentInstance: {} } as MatDialogRef; + }); service.copyNodes([fileToCopy, folderToCopy]); - expect(spyOnBatchOperation).toHaveBeenCalledWith( - BatchOperationType.copy, - [fileToCopy, folderToCopy], - undefined - ); + expect(spyOnBatchOperation).toHaveBeenCalledWith(BatchOperationType.copy, [fileToCopy, folderToCopy], undefined); expect(spyOnDestinationPicker.calls.count()).toEqual(1); expect(spyOnDialog.calls.count()).toEqual(1); @@ -467,16 +393,11 @@ describe('NodeActionsService', () => { node: destinationFolder }) ).toBeDefined(); - expect(testContentNodeSelectorComponentData.data.title).toBe( - 'NODE_SELECTOR.COPY_ITEMS' - ); - expect(translationService.instant).toHaveBeenCalledWith( - 'NODE_SELECTOR.COPY_ITEMS', - { - name: '', - number: 2 - } - ); + expect(testContentNodeSelectorComponentData.data.title).toBe('NODE_SELECTOR.COPY_ITEMS'); + expect(translationService.instant).toHaveBeenCalledWith('NODE_SELECTOR.COPY_ITEMS', { + name: '', + number: 2 + }); destinationFolder.entry['allowableOperations'] = ['update']; expect( @@ -487,67 +408,47 @@ describe('NodeActionsService', () => { }); it('should use the ContentNodeSelectorComponentData object with file name in title', () => { - const spyOnBatchOperation = spyOn( - service, - 'doBatchOperation' - ).and.callThrough(); + const spyOnBatchOperation = spyOn(service, 'doBatchOperation').and.callThrough(); spyOn(service, 'getContentNodeSelection').and.callThrough(); spyOn(service, 'getEntryParentId').and.returnValue('parent-id'); let testContentNodeSelectorComponentData; - spyOn(dialog, 'open').and.callFake( - (_contentNodeSelectorComponent: any, data: any) => { - testContentNodeSelectorComponentData = data; - return { componentInstance: {} } as MatDialogRef; - } - ); + spyOn(dialog, 'open').and.callFake((_contentNodeSelectorComponent: any, data: any) => { + testContentNodeSelectorComponentData = data; + return { componentInstance: {} } as MatDialogRef; + }); service.copyNodes([{ entry: { id: 'entry-id', name: 'entry-name' } }]); expect(spyOnBatchOperation).toHaveBeenCalled(); expect(testContentNodeSelectorComponentData).toBeDefined(); - expect(testContentNodeSelectorComponentData.data.title).toBe( - 'NODE_SELECTOR.COPY_ITEM' - ); - expect(translationService.instant).toHaveBeenCalledWith( - 'NODE_SELECTOR.COPY_ITEM', - { - name: 'entry-name', - number: 1 - } - ); + expect(testContentNodeSelectorComponentData.data.title).toBe('NODE_SELECTOR.COPY_ITEM'); + expect(translationService.instant).toHaveBeenCalledWith('NODE_SELECTOR.COPY_ITEM', { + name: 'entry-name', + number: 1 + }); }); it('should use the ContentNodeSelectorComponentData object without file name in title, if no name exists', () => { - const spyOnBatchOperation = spyOn( - service, - 'doBatchOperation' - ).and.callThrough(); + const spyOnBatchOperation = spyOn(service, 'doBatchOperation').and.callThrough(); spyOn(service, 'getContentNodeSelection').and.callThrough(); spyOn(service, 'getEntryParentId').and.returnValue('parent-id'); let testContentNodeSelectorComponentData; - spyOn(dialog, 'open').and.callFake( - (_contentNodeSelectorComponent: any, data: any) => { - testContentNodeSelectorComponentData = data; - return { componentInstance: {} } as MatDialogRef; - } - ); + spyOn(dialog, 'open').and.callFake((_contentNodeSelectorComponent: any, data: any) => { + testContentNodeSelectorComponentData = data; + return { componentInstance: {} } as MatDialogRef; + }); service.copyNodes([{ entry: { id: 'entry-id' } }]); expect(spyOnBatchOperation).toHaveBeenCalled(); expect(testContentNodeSelectorComponentData).toBeDefined(); - expect(testContentNodeSelectorComponentData.data.title).toBe( - 'NODE_SELECTOR.COPY_ITEMS' - ); - expect(translationService.instant).toHaveBeenCalledWith( - 'NODE_SELECTOR.COPY_ITEMS', - { - name: '', - number: 1 - } - ); + expect(testContentNodeSelectorComponentData.data.title).toBe('NODE_SELECTOR.COPY_ITEMS'); + expect(translationService.instant).toHaveBeenCalledWith('NODE_SELECTOR.COPY_ITEMS', { + name: '', + number: 1 + }); }); }); @@ -579,32 +480,21 @@ describe('NodeActionsService', () => { }); it('should fail to copy folder node if action is forbidden', async(() => { - spyOn(nodesApi, 'copyNode').and.callFake( - helper.fakeCopyNode(actionIsForbidden) - ); + spyOn(nodesApi, 'copyNode').and.callFake(helper.fakeCopyNode(actionIsForbidden)); const folderToCopy = new TestNode(); const folderDestination = new TestNode(folderDestinationId); - const spyContentAction = spyOn( - service, - 'copyContentAction' - ).and.callThrough(); - const spyFolderAction = spyOn( - service, - 'copyFolderAction' - ).and.callThrough(); - const copyObservable = service.copyNodeAction( - folderToCopy.entry, - folderDestination.entry.id - ); + const spyContentAction = spyOn(service, 'copyContentAction').and.callThrough(); + const spyFolderAction = spyOn(service, 'copyFolderAction').and.callThrough(); + const copyObservable = service.copyNodeAction(folderToCopy.entry, folderDestination.entry.id); spyOnSuccess.calls.reset(); spyOnError.calls.reset(); copyObservable .toPromise() .then( - response => { + (response) => { spyOnSuccess(response); }, () => { @@ -612,10 +502,10 @@ describe('NodeActionsService', () => { expect(spyContentAction.calls.count()).toEqual(0); expect(spyFolderAction.calls.count()).toEqual(1); - expect(nodesApi.copyNode).toHaveBeenCalledWith( - folderToCopy.entry.id, - { targetParentId: folderDestination.entry.id, name: undefined } - ); + expect(nodesApi.copyNode).toHaveBeenCalledWith(folderToCopy.entry.id, { + targetParentId: folderDestination.entry.id, + name: undefined + }); } ) .then(() => { @@ -626,32 +516,21 @@ describe('NodeActionsService', () => { })); it('should fail to copy file node if action is forbidden', async(() => { - spyOn(nodesApi, 'copyNode').and.callFake( - helper.fakeCopyNode(actionIsForbidden) - ); + spyOn(nodesApi, 'copyNode').and.callFake(helper.fakeCopyNode(actionIsForbidden)); - const spyContentAction = spyOn( - service, - 'copyContentAction' - ).and.callThrough(); - const spyFolderAction = spyOn( - service, - 'copyFolderAction' - ).and.callThrough(); + const spyContentAction = spyOn(service, 'copyContentAction').and.callThrough(); + const spyFolderAction = spyOn(service, 'copyFolderAction').and.callThrough(); const fileToCopy = new TestNode(fileId, isFile, 'test-name'); const folderDestination = new TestNode(folderDestinationId); - const copyObservable = service.copyNodeAction( - fileToCopy.entry, - folderDestination.entry.id - ); + const copyObservable = service.copyNodeAction(fileToCopy.entry, folderDestination.entry.id); spyOnSuccess.calls.reset(); spyOnError.calls.reset(); copyObservable .toPromise() .then( - response => { + (response) => { spyOnSuccess(response); }, () => { @@ -673,21 +552,13 @@ describe('NodeActionsService', () => { it('should copy one file node to same destination and autoRename it', async(() => { const alreadyExistingName = 'file-name'; - spyOn(nodesApi, 'copyNode').and.callFake( - helper.fakeCopyNode(!actionIsForbidden, alreadyExistingName) - ); + spyOn(nodesApi, 'copyNode').and.callFake(helper.fakeCopyNode(!actionIsForbidden, alreadyExistingName)); - const spyContentAction = spyOn( - service, - 'copyContentAction' - ).and.callThrough(); + const spyContentAction = spyOn(service, 'copyContentAction').and.callThrough(); const fileToCopy = new TestNode(fileId, isFile, 'file-name'); const folderDestination = new TestNode(folderDestinationId); - const copyObservable = service.copyNodeAction( - fileToCopy.entry, - folderDestination.entry.id - ); + const copyObservable = service.copyNodeAction(fileToCopy.entry, folderDestination.entry.id); spyOnSuccess.calls.reset(); spyOnError.calls.reset(); @@ -726,37 +597,18 @@ describe('NodeActionsService', () => { beforeEach(() => { subject = new Subject(); - folderToCopy = new TestNode( - 'folder-to-copy-id', - !isFile, - 'conflicting-name' - ); + folderToCopy = new TestNode('folder-to-copy-id', !isFile, 'conflicting-name'); fileChildOfFolderToCopy = new TestNode(fileId, isFile, 'file-name'); folderParentAndDestination = new TestNode(folderDestinationId); - existingFolder = new TestNode( - 'existing-folder-id', - !isFile, - 'conflicting-name' - ); + existingFolder = new TestNode('existing-folder-id', !isFile, 'conflicting-name'); - spy = spyOn(nodesApi, 'copyNode').and.callFake( - helper.fakeCopyNode(!actionIsForbidden, 'conflicting-name') - ); + spy = spyOn(nodesApi, 'copyNode').and.callFake(helper.fakeCopyNode(!actionIsForbidden, 'conflicting-name')); - spyOnContentAction = spyOn( - service, - 'copyContentAction' - ).and.callThrough(); - spyOnFolderAction = spyOn( - service, - 'copyFolderAction' - ).and.callThrough(); + spyOnContentAction = spyOn(service, 'copyContentAction').and.callThrough(); + spyOnFolderAction = spyOn(service, 'copyFolderAction').and.callThrough(); - copyObservable = service.copyNodeAction( - folderToCopy.entry, - folderParentAndDestination.entry.id - ); + copyObservable = service.copyNodeAction(folderToCopy.entry, folderParentAndDestination.entry.id); spyOnSuccess.calls.reset(); spyOnError.calls.reset(); }); @@ -774,12 +626,8 @@ describe('NodeActionsService', () => { nodeChildren: [existingFolder] } ]; - spyOn(nodesApi, 'getNodeChildren').and.callFake( - helper.fakeGetNodeChildren(testFamilyNodes) - ); - spyOn(service, 'getChildByName').and.returnValue( - of(existingFolder) as any - ); + spyOn(nodesApi, 'getNodeChildren').and.callFake(helper.fakeGetNodeChildren(testFamilyNodes)); + spyOn(service, 'getChildByName').and.returnValue(of(existingFolder) as any); copyObservable .toPromise() @@ -827,9 +675,7 @@ describe('NodeActionsService', () => { nodeChildren: [existingFolder] } ]; - spyOn(nodesApi, 'getNodeChildren').and.callFake( - helper.fakeGetNodeChildren(testFamilyNodes) - ); + spyOn(nodesApi, 'getNodeChildren').and.callFake(helper.fakeGetNodeChildren(testFamilyNodes)); spyOn(service, 'getChildByName').and.returnValue(subject); copyObservable @@ -874,12 +720,8 @@ describe('NodeActionsService', () => { nodeChildren: [existingFolder] } ]; - spyOn(nodesApi, 'getNodeChildren').and.callFake( - helper.fakeGetNodeChildren(testFamilyNodes) - ); - spyOn(service, 'getChildByName').and.returnValue( - of(existingFolder) as any - ); + spyOn(nodesApi, 'getNodeChildren').and.callFake(helper.fakeGetNodeChildren(testFamilyNodes)); + spyOn(service, 'getChildByName').and.returnValue(of(existingFolder) as any); copyObservable .toPromise() @@ -935,19 +777,13 @@ describe('NodeActionsService', () => { destinationFolder = new TestNode(folderDestinationId); documentListService = TestBed.inject(DocumentListService); - spyOnBatchOperation = spyOn( - service, - 'doBatchOperation' - ).and.callThrough(); + spyOnBatchOperation = spyOn(service, 'doBatchOperation').and.callThrough(); }); afterEach(() => subject.complete()); it('should allow to select destination for nodes that have permission to be moved', () => { - const spyOnDestinationPicker = spyOn( - service, - 'getContentNodeSelection' - ).and.returnValue(subject); + const spyOnDestinationPicker = spyOn(service, 'getContentNodeSelection').and.returnValue(subject); spyOn(service, 'moveContentAction').and.returnValue(of({})); spyOn(service, 'moveFolderAction').and.returnValue(of({})); @@ -957,19 +793,12 @@ describe('NodeActionsService', () => { service.moveNodes([fileToMove, folderToMove], permissionToMove); subject.next([destinationFolder.entry]); - expect(spyOnBatchOperation).toHaveBeenCalledWith( - BatchOperationType.move, - [fileToMove, folderToMove], - permissionToMove - ); + expect(spyOnBatchOperation).toHaveBeenCalledWith(BatchOperationType.move, [fileToMove, folderToMove], permissionToMove); expect(spyOnDestinationPicker).toHaveBeenCalled(); }); it('should not allow to select destination for nodes that do not have permission to be moved', () => { - const spyOnDestinationPicker = spyOn( - service, - 'getContentNodeSelection' - ).and.returnValue(subject); + const spyOnDestinationPicker = spyOn(service, 'getContentNodeSelection').and.returnValue(subject); fileToMove.entry['allowableOperations'] = []; folderToMove.entry['allowableOperations'] = []; @@ -977,21 +806,14 @@ describe('NodeActionsService', () => { service.moveNodes([fileToMove, folderToMove], permissionToMove); subject.next([destinationFolder.entry]); - expect(spyOnBatchOperation).toHaveBeenCalledWith( - BatchOperationType.move, - [fileToMove, folderToMove], - permissionToMove - ); + expect(spyOnBatchOperation).toHaveBeenCalledWith(BatchOperationType.move, [fileToMove, folderToMove], permissionToMove); expect(spyOnDestinationPicker).not.toHaveBeenCalled(); }); it('should call the documentListService moveNode directly for moving a file that has permission to be moved', () => { spyOn(service, 'getContentNodeSelection').and.returnValue(subject); fileToMove.entry['allowableOperations'] = [permissionToMove]; - spyOnDocumentListServiceAction = spyOn( - documentListService, - 'moveNode' - ).and.returnValue(of([fileToMove])); + spyOnDocumentListServiceAction = spyOn(documentListService, 'moveNode').and.returnValue(of([fileToMove])); spyOn(service, 'moveNodeAction'); service.moveNodes([fileToMove], permissionToMove); @@ -1008,22 +830,16 @@ describe('NodeActionsService', () => { }); it('should not throw error on conflict, to be able to show message in case of partial move of files', async(() => { - spyOnDocumentListServiceAction = spyOn( - documentListService, - 'moveNode' - ).and.returnValue(throwError(conflictError)); + spyOnDocumentListServiceAction = spyOn(documentListService, 'moveNode').and.returnValue(throwError(conflictError)); - const moveContentActionObservable = service.moveContentAction( - fileToMove.entry, - folderDestinationId - ); + const moveContentActionObservable = service.moveContentAction(fileToMove.entry, folderDestinationId); moveContentActionObservable .toPromise() .then( - value => { + (value) => { spyOnSuccess(value); }, - error => { + (error) => { spyOnError(error); } ) @@ -1036,22 +852,16 @@ describe('NodeActionsService', () => { })); it('should not throw permission error, to be able to show message in case of partial move of files', async(() => { - spyOnDocumentListServiceAction = spyOn( - documentListService, - 'moveNode' - ).and.returnValue(throwError(permissionError)); + spyOnDocumentListServiceAction = spyOn(documentListService, 'moveNode').and.returnValue(throwError(permissionError)); - const moveContentActionObservable = service.moveContentAction( - fileToMove.entry, - folderDestinationId - ); + const moveContentActionObservable = service.moveContentAction(fileToMove.entry, folderDestinationId); moveContentActionObservable .toPromise() .then( - value => { + (value) => { spyOnSuccess(value); }, - error => { + (error) => { spyOnError(error); } ) @@ -1067,22 +877,16 @@ describe('NodeActionsService', () => { const parentID = 'parent-id'; fileToMove.entry['parentId'] = parentID; fileToMove.entry['allowableOperations'] = [permissionToMove]; - spyOnDocumentListServiceAction = spyOn( - documentListService, - 'moveNode' - ).and.returnValue(of(fileToMove)); + spyOnDocumentListServiceAction = spyOn(documentListService, 'moveNode').and.returnValue(of(fileToMove)); - const moveContentActionObservable = service.moveContentAction( - fileToMove.entry, - folderDestinationId - ); + const moveContentActionObservable = service.moveContentAction(fileToMove.entry, folderDestinationId); moveContentActionObservable .toPromise() .then( - value => { + (value) => { spyOnSuccess(value); }, - error => { + (error) => { spyOnError(error); } ) @@ -1109,22 +913,16 @@ describe('NodeActionsService', () => { afterEach(() => subject$.complete()); it('should not throw permission error in case it occurs on folder move', async(() => { - spyOnDocumentListServiceAction = spyOn( - documentListService, - 'moveNode' - ).and.returnValue(throwError(permissionError)); + spyOnDocumentListServiceAction = spyOn(documentListService, 'moveNode').and.returnValue(throwError(permissionError)); - const moveFolderActionObservable = service.moveFolderAction( - folderToMove.entry, - folderDestinationId - ); + const moveFolderActionObservable = service.moveFolderAction(folderToMove.entry, folderDestinationId); moveFolderActionObservable .toPromise() .then( - value => { + (value) => { spyOnSuccess(value); }, - error => { + (error) => { spyOnError(error); } ) @@ -1137,24 +935,13 @@ describe('NodeActionsService', () => { })); it('should not throw error on conflict in case it occurs on folder move', async(() => { - const newDestination = new TestNode( - 'new-destination', - !isFile, - folderToMove.entry.name - ) as NodeChildAssociationEntry; + const newDestination = new TestNode('new-destination', !isFile, folderToMove.entry.name) as NodeChildAssociationEntry; - spyOnDocumentListServiceAction = spyOn( - documentListService, - 'moveNode' - ).and.returnValue(throwError(conflictError)); + spyOnDocumentListServiceAction = spyOn(documentListService, 'moveNode').and.returnValue(throwError(conflictError)); spyOn(service, 'getChildByName').and.returnValue(subject$); - spyOn(service, 'getNodeChildren').and.returnValue( - of(emptyChildrenList) - ); + spyOn(service, 'getNodeChildren').and.returnValue(of(emptyChildrenList)); - service - .moveFolderAction(folderToMove.entry, folderDestinationId) - .subscribe(spyOnSuccess, spyOnError); + service.moveFolderAction(folderToMove.entry, folderDestinationId).subscribe(spyOnSuccess, spyOnError); subject$.next(newDestination); @@ -1163,15 +950,8 @@ describe('NodeActionsService', () => { })); it('should try to move children nodes of a folder to already existing folder with same name', async(() => { - const parentFolderToMove = new TestNode( - 'parent-folder', - !isFile, - 'conflicting-name' - ); - spyOnDocumentListServiceAction = spyOn( - documentListService, - 'moveNode' - ).and.callFake(contentEntryId => { + const parentFolderToMove = new TestNode('parent-folder', !isFile, 'conflicting-name'); + spyOnDocumentListServiceAction = spyOn(documentListService, 'moveNode').and.callFake((contentEntryId) => { if (contentEntryId === parentFolderToMove.entry.id) { return throwError(conflictError); } @@ -1179,20 +959,12 @@ describe('NodeActionsService', () => { }); spyOn(service, 'moveContentAction').and.returnValue(of({})); - const newDestination = new TestNode( - 'new-destination', - !isFile, - 'conflicting-name' - ) as NodeChildAssociationEntry; + const newDestination = new TestNode('new-destination', !isFile, 'conflicting-name') as NodeChildAssociationEntry; spyOn(service, 'getChildByName').and.returnValue(subject$); const childrenNodes = [fileToMove, folderToMove]; - spyOn(service, 'getNodeChildren').and.returnValue( - of({ list: { entries: childrenNodes } }) - ); + spyOn(service, 'getNodeChildren').and.returnValue(of({ list: { entries: childrenNodes } })); - service - .moveFolderAction(parentFolderToMove.entry, folderDestinationId) - .subscribe(spyOnSuccess, spyOnError); + service.moveFolderAction(parentFolderToMove.entry, folderDestinationId).subscribe(spyOnSuccess, spyOnError); subject$.next(newDestination); expect(spyOnDocumentListServiceAction).toHaveBeenCalled(); @@ -1210,14 +982,8 @@ describe('NodeActionsService', () => { beforeEach(() => { subject$ = new Subject(); - parentFolderToMove = new TestNode( - 'parent-folder', - !isFile, - 'conflicting-name' - ); - spyOnDelete = spyOn(contentApi, 'deleteNode').and.returnValue( - of(null) - ); + parentFolderToMove = new TestNode('parent-folder', !isFile, 'conflicting-name'); + spyOnDelete = spyOn(contentApi, 'deleteNode').and.returnValue(of(null)); }); afterEach(() => { @@ -1231,15 +997,13 @@ describe('NodeActionsService', () => { spyOn(service, 'moveFolderAction').and.returnValue(of(null)); parentFolderToMove.entry.parentId = folderDestinationId; - moveNodeActionPromise = service - .moveNodeAction(parentFolderToMove.entry, folderDestinationId) - .toPromise(); + moveNodeActionPromise = service.moveNodeAction(parentFolderToMove.entry, folderDestinationId).toPromise(); moveNodeActionPromise .then( () => { spyOnSuccess(); }, - error => { + (error) => { spyOnError(error); } ) @@ -1253,9 +1017,7 @@ describe('NodeActionsService', () => { it('should take no extra delete action, if its children were partially moved', async(() => { const movedChildrenNodes = [fileToMove, folderToMove]; - spyOn(service, 'moveFolderAction').and.returnValue( - of(movedChildrenNodes) - ); + spyOn(service, 'moveFolderAction').and.returnValue(of(movedChildrenNodes)); spyOn(service, 'processResponse').and.returnValue({ succeeded: [fileToMove], failed: [folderToMove], @@ -1263,15 +1025,13 @@ describe('NodeActionsService', () => { }); parentFolderToMove.entry.parentId = `not-${folderDestinationId}`; - moveNodeActionPromise = service - .moveNodeAction(parentFolderToMove.entry, folderDestinationId) - .toPromise(); + moveNodeActionPromise = service.moveNodeAction(parentFolderToMove.entry, folderDestinationId).toPromise(); moveNodeActionPromise .then( () => { spyOnSuccess(); }, - error => { + (error) => { spyOnError(error); } ) @@ -1285,9 +1045,7 @@ describe('NodeActionsService', () => { it('should take extra delete action, if children successfully moved and folder is still on location', async(() => { const movedChildrenNodes = [fileToMove, folderToMove]; - spyOn(service, 'moveFolderAction').and.returnValue( - of(movedChildrenNodes) - ); + spyOn(service, 'moveFolderAction').and.returnValue(of(movedChildrenNodes)); spyOn(service, 'processResponse').and.returnValue({ succeeded: [movedChildrenNodes], failed: [], @@ -1297,9 +1055,7 @@ describe('NodeActionsService', () => { spyOn(service, 'getChildByName').and.returnValue(subject$); parentFolderToMove.entry.parentId = `not-${folderDestinationId}`; - moveNodeActionPromise = service - .moveNodeAction(parentFolderToMove.entry, folderDestinationId) - .subscribe(spyOnSuccess, spyOnError); + moveNodeActionPromise = service.moveNodeAction(parentFolderToMove.entry, folderDestinationId).subscribe(spyOnSuccess, spyOnError); subject$.next(folderOnLocation); expect(spyOnDelete).toHaveBeenCalled(); @@ -1310,9 +1066,7 @@ describe('NodeActionsService', () => { it('should take no extra delete action, if folder is no longer on location', async(() => { const movedChildrenNodes = [fileToMove, folderToMove]; - spyOn(service, 'moveFolderAction').and.returnValue( - of(movedChildrenNodes) - ); + spyOn(service, 'moveFolderAction').and.returnValue(of(movedChildrenNodes)); spyOn(service, 'processResponse').and.returnValue({ succeeded: [movedChildrenNodes], failed: [], @@ -1321,9 +1075,7 @@ describe('NodeActionsService', () => { spyOn(service, 'getChildByName').and.returnValue(subject$); parentFolderToMove.entry.parentId = `not-${folderDestinationId}`; - moveNodeActionPromise = service - .moveNodeAction(parentFolderToMove.entry, folderDestinationId) - .subscribe(spyOnSuccess, spyOnError); + moveNodeActionPromise = service.moveNodeAction(parentFolderToMove.entry, folderDestinationId).subscribe(spyOnSuccess, spyOnError); subject$.next(null); expect(spyOnDelete).not.toHaveBeenCalled(); @@ -1357,45 +1109,27 @@ describe('NodeActionsService', () => { }); it('emits child node with specified name, when it exists in folder', () => { - spyOn(nodesApi, 'getNodeChildren').and.callFake( - helper.fakeGetNodeChildren(testFamilyNodes) - ); + spyOn(nodesApi, 'getNodeChildren').and.callFake(helper.fakeGetNodeChildren(testFamilyNodes)); - service - .getChildByName(testFamilyNodes[0].parentNodeId, childNode.entry.name) - .subscribe(value => { - expect(value).toEqual(childNode); - }); + service.getChildByName(testFamilyNodes[0].parentNodeId, childNode.entry.name).subscribe((value) => { + expect(value).toEqual(childNode); + }); }); it('emits null value when child with specified name is not found in folder', async(() => { - spyOn(nodesApi, 'getNodeChildren').and.callFake( - helper.fakeGetNodeChildren(testFamilyNodes) - ); + spyOn(nodesApi, 'getNodeChildren').and.callFake(helper.fakeGetNodeChildren(testFamilyNodes)); - service - .getChildByName( - testFamilyNodes[0].parentNodeId, - notChildNode.entry.name - ) - .subscribe(value => { - expect(value).toEqual(null); - }); + service.getChildByName(testFamilyNodes[0].parentNodeId, notChildNode.entry.name).subscribe((value) => { + expect(value).toEqual(null); + }); })); it('emits error when permission error occurs', async(() => { - spyOn(nodesApi, 'getNodeChildren').and.callFake( - helper.fakeGetNodeChildren(testFamilyNodes, actionIsForbidden) - ); + spyOn(nodesApi, 'getNodeChildren').and.callFake(helper.fakeGetNodeChildren(testFamilyNodes, actionIsForbidden)); - service - .getChildByName( - testFamilyNodes[0].parentNodeId, - notChildNode.entry.name - ) - .subscribe(value => { - expect(value).toEqual(null); - }); + service.getChildByName(testFamilyNodes[0].parentNodeId, notChildNode.entry.name).subscribe((value) => { + expect(value).toEqual(null); + }); })); }); @@ -1447,7 +1181,7 @@ describe('NodeActionsService', () => { expected: 'noExtension-007-1' } ]; - testData.forEach(data => { + testData.forEach((data) => { it(`new name should be \'${data.expected}\' for given name: \'${data.name}\', and baseName: \'${data.baseName}\'`, () => { const result = service.getNewNameFrom(data.name, data.baseName); expect(result).toBe(data.expected); @@ -1474,7 +1208,7 @@ describe('NodeActionsService', () => { } ]; - testData.forEach(data => { + testData.forEach((data) => { it(`flattened array should be \'${data.expected}\' for given data: \'${data.nDimArray}\'`, () => { const result = service.flatten(data.nDimArray); @@ -1566,13 +1300,11 @@ describe('NodeActionsService', () => { } ]; - testData.forEach(response => { + testData.forEach((response) => { it(`processed response should be \'${response.expected}\' for given input: \'${response.data}\'`, () => { const result = service.processResponse(response.data); - expect(JSON.stringify(result)).toEqual( - JSON.stringify(response.expected) - ); + expect(JSON.stringify(result)).toEqual(JSON.stringify(response.expected)); }); }); }); diff --git a/src/app/services/node-actions.service.ts b/src/app/services/node-actions.service.ts index f41994e56..d3fbb2b78 100644 --- a/src/app/services/node-actions.service.ts +++ b/src/app/services/node-actions.service.ts @@ -26,14 +26,7 @@ import { Injectable } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { Observable, Subject, of, zip, from } from 'rxjs'; - -import { - AlfrescoApiService, - ContentService, - DataColumn, - TranslationService, - ThumbnailService -} from '@alfresco/adf-core'; +import { AlfrescoApiService, ContentService, DataColumn, TranslationService, ThumbnailService } from '@alfresco/adf-core'; import { DocumentListService, ContentNodeSelectorComponent, @@ -41,13 +34,7 @@ import { ContentNodeDialogService, ShareDataRow } from '@alfresco/adf-content-services'; -import { - MinimalNodeEntity, - MinimalNodeEntryEntity, - SitePaging, - NodeChildAssociationPaging, - NodeChildAssociationEntry -} from '@alfresco/js-api'; +import { MinimalNodeEntity, MinimalNodeEntryEntity, SitePaging, NodeChildAssociationPaging, NodeChildAssociationEntry } from '@alfresco/js-api'; import { ContentApiService } from '@alfresco/aca-shared'; import { catchError, map, mergeMap } from 'rxjs/operators'; @@ -60,9 +47,7 @@ export enum BatchOperationType { providedIn: 'root' }) export class NodeActionsService { - contentCopied: Subject = new Subject< - MinimalNodeEntity[] - >(); + contentCopied: Subject = new Subject(); contentMoved: Subject = new Subject(); moveDeletedEntries: any[] = []; isSitesDestinationAvailable = false; @@ -84,11 +69,7 @@ export class NodeActionsService { * @param permission permission which is needed to apply the action */ copyNodes(contentEntities: any[], permission?: string): Subject { - return this.doBatchOperation( - BatchOperationType.copy, - contentEntities, - permission - ); + return this.doBatchOperation(BatchOperationType.copy, contentEntities, permission); } /** @@ -98,11 +79,7 @@ export class NodeActionsService { * @param permission permission which is needed to apply the action */ moveNodes(contentEntities: any[], permission?: string): Subject { - return this.doBatchOperation( - BatchOperationType.move, - contentEntities, - permission - ); + return this.doBatchOperation(BatchOperationType.move, contentEntities, permission); } /** @@ -112,22 +89,13 @@ export class NodeActionsService { * @param contentEntities the contentEntities which have to have the action performed on * @param permission permission which is needed to apply the action */ - doBatchOperation( - action: BatchOperationType, - contentEntities: any[], - permission?: string - ): Subject { + doBatchOperation(action: BatchOperationType, contentEntities: any[], permission?: string): Subject { const observable: Subject = new Subject(); if (!this.isEntryEntitiesArray(contentEntities)) { - observable.error( - new Error(JSON.stringify({ error: { statusCode: 400 } })) - ); + observable.error(new Error(JSON.stringify({ error: { statusCode: 400 } }))); } else if (this.checkPermission(action, contentEntities, permission)) { - const destinationSelection = this.getContentNodeSelection( - action, - contentEntities - ); + const destinationSelection = this.getContentNodeSelection(action, contentEntities); destinationSelection.subscribe((selections: MinimalNodeEntryEntity[]) => { const contentEntry = contentEntities[0].entry; // Check if there's nodeId for Shared Files @@ -139,27 +107,18 @@ export class NodeActionsService { const selection = selections[0]; let action$: Observable; - if ( - action === BatchOperationType.move && - contentEntities.length === 1 && - type === 'content' - ) { - action$ = this.documentListService.moveNode( - contentEntryId, - selection.id - ); + if (action === BatchOperationType.move && contentEntities.length === 1 && type === 'content') { + action$ = this.documentListService.moveNode(contentEntryId, selection.id); } else { - contentEntities.forEach(node => { + contentEntities.forEach((node) => { // batch.push(this.copyNodeAction(node.entry, selection.id)); batch.push(this[`${action}NodeAction`](node.entry, selection.id)); }); action$ = zip(...batch); } - action$.subscribe(newContent => { - observable.next( - `OPERATION.SUCCES.${type.toUpperCase()}.${action.toUpperCase()}` - ); + action$.subscribe((newContent) => { + observable.next(`OPERATION.SUCCES.${type.toUpperCase()}.${action.toUpperCase()}`); const processedData = this.processResponse(newContent); if (action === BatchOperationType.copy) { @@ -170,9 +129,7 @@ export class NodeActionsService { }, observable.error.bind(observable)); }); } else { - observable.error( - new Error(JSON.stringify({ error: { statusCode: 403 } })) - ); + observable.error(new Error(JSON.stringify({ error: { statusCode: 403 } }))); } return observable; @@ -180,22 +137,14 @@ export class NodeActionsService { isEntryEntitiesArray(contentEntities: any[]): boolean { if (contentEntities && contentEntities.length) { - const nonEntryNode = contentEntities.find( - node => !node || !node.entry || !(node.entry.nodeId || node.entry.id) - ); + const nonEntryNode = contentEntities.find((node) => !node || !node.entry || !(node.entry.nodeId || node.entry.id)); return !nonEntryNode; } return false; } - checkPermission( - action: BatchOperationType, - contentEntities: any[], - permission?: string - ) { - const notAllowedNode = contentEntities.find( - node => !this.isActionAllowed(action, node.entry, permission) - ); + checkPermission(action: BatchOperationType, contentEntities: any[], permission?: string) { + const notAllowedNode = contentEntities.find((node) => !this.isActionAllowed(action, node.entry, permission)); return !notAllowedNode; } @@ -204,25 +153,15 @@ export class NodeActionsService { if (nodeEntry.parentId) { entryParentId = nodeEntry.parentId; - } else if ( - nodeEntry.path && - nodeEntry.path.elements && - nodeEntry.path.elements.length - ) { - entryParentId = - nodeEntry.path.elements[nodeEntry.path.elements.length - 1].id; + } else if (nodeEntry.path && nodeEntry.path.elements && nodeEntry.path.elements.length) { + entryParentId = nodeEntry.path.elements[nodeEntry.path.elements.length - 1].id; } return entryParentId; } - getContentNodeSelection( - action: string, - contentEntities: MinimalNodeEntity[] - ): Subject { - const currentParentFolderId = this.getEntryParentId( - contentEntities[0].entry - ); + getContentNodeSelection(action: string, contentEntities: MinimalNodeEntity[]): Subject { + const currentParentFolderId = this.getEntryParentId(contentEntities[0].entry); const customDropdown = new SitePaging({ list: { @@ -230,17 +169,13 @@ export class NodeActionsService { { entry: { guid: '-my-', - title: this.translation.instant( - 'APP.BROWSE.PERSONAL.SIDENAV_LINK.LABEL' - ) + title: this.translation.instant('APP.BROWSE.PERSONAL.SIDENAV_LINK.LABEL') } }, { entry: { guid: '-mysites-', - title: this.translation.instant( - 'APP.BROWSE.LIBRARIES.MENU.MY_LIBRARIES.SIDENAV_LINK.LABEL' - ) + title: this.translation.instant('APP.BROWSE.LIBRARIES.MENU.MY_LIBRARIES.SIDENAV_LINK.LABEL') } } ] @@ -287,10 +222,7 @@ export class NodeActionsService { } const number = nodes.length; - return this.translation.instant( - `NODE_SELECTOR.${action.toUpperCase()}_${keyPrefix}`, - { name, number } - ); + return this.translation.instant(`NODE_SELECTOR.${action.toUpperCase()}_${keyPrefix}`, { name, number }); } private canCopyMoveInsideIt(entry: MinimalNodeEntryEntity): boolean { @@ -302,11 +234,7 @@ export class NodeActionsService { } private isSite(entry) { - return ( - !!entry.guid || - entry.nodeType === 'st:site' || - entry.nodeType === 'st:sites' - ); + return !!entry.guid || entry.nodeType === 'st:site' || entry.nodeType === 'st:sites'; } close() { @@ -324,9 +252,7 @@ export class NodeActionsService { // make sure first item is 'Personal Files' if (elements[0]) { - elements[0].name = this.translation.instant( - 'APP.BROWSE.PERSONAL.TITLE' - ); + elements[0].name = this.translation.instant('APP.BROWSE.PERSONAL.TITLE'); elements[0].id = '-my-'; } else { node.name = this.translation.instant('APP.BROWSE.PERSONAL.TITLE'); @@ -336,17 +262,13 @@ export class NodeActionsService { } } else if (elements.length === 1) { if (node.name === 'Sites') { - node.name = this.translation.instant( - 'APP.BROWSE.LIBRARIES.MENU.MY_LIBRARIES.TITLE' - ); + node.name = this.translation.instant('APP.BROWSE.LIBRARIES.MENU.MY_LIBRARIES.TITLE'); elements.splice(0, 1); } } } else if (node === null && this.isSitesDestinationAvailable) { node = { - name: this.translation.instant( - 'APP.BROWSE.LIBRARIES.MENU.MY_LIBRARIES.TITLE' - ), + name: this.translation.instant('APP.BROWSE.LIBRARIES.MENU.MY_LIBRARIES.TITLE'), path: { elements: [] } } as any; } @@ -362,9 +284,7 @@ export class NodeActionsService { elements.splice(0, 1); // replace first item with 'File Libraries' - elements[0].name = this.translation.instant( - 'APP.BROWSE.LIBRARIES.MENU.MY_LIBRARIES.TITLE' - ); + elements[0].name = this.translation.instant('APP.BROWSE.LIBRARIES.MENU.MY_LIBRARIES.TITLE'); elements[0].id = '-mysites-'; if (this.isSiteContainer(node)) { @@ -376,7 +296,7 @@ export class NodeActionsService { elements.splice(1, 1); } else { // remove 'documentLibrary' in the middle of the path - const docLib = elements.findIndex(el => el.name === 'documentLibrary'); + const docLib = elements.findIndex((el) => el.name === 'documentLibrary'); if (docLib > -1) { elements.splice(docLib, 1); } @@ -399,18 +319,14 @@ export class NodeActionsService { } } - copyContentAction( - contentEntry: any, - selectionId: string, - oldName?: string - ): Observable { + copyContentAction(contentEntry: any, selectionId: string, oldName?: string): Observable { const _oldName = oldName || contentEntry.name; // Check if there's nodeId for Shared Files const contentEntryId = contentEntry.nodeId || contentEntry.id; // use local method until new name parameter is added on ADF copyNode return this.copyNode(contentEntryId, selectionId, _oldName).pipe( - catchError(err => { + catchError((err) => { let errStatusCode; try { const { @@ -422,11 +338,7 @@ export class NodeActionsService { } if (errStatusCode && errStatusCode === 409) { - return this.copyContentAction( - contentEntry, - selectionId, - this.getNewNameFrom(_oldName, contentEntry.name) - ); + return this.copyContentAction(contentEntry, selectionId, this.getNewNameFrom(_oldName, contentEntry.name)); } else { // do not throw error, to be able to show message in case of partial copy of files return of(err || 'Server error'); @@ -443,7 +355,7 @@ export class NodeActionsService { let newDestinationFolder; return this.copyNode(contentEntryId, selectionId, contentEntry.name).pipe( - catchError(err => { + catchError((err) => { let errStatusCode; try { const { @@ -453,34 +365,21 @@ export class NodeActionsService { } catch {} if (errStatusCode && errStatusCode === 409) { - $destinationFolder = this.getChildByName( - selectionId, - contentEntry.name - ); + $destinationFolder = this.getChildByName(selectionId, contentEntry.name); $childrenToCopy = this.getNodeChildren(contentEntryId); return $destinationFolder.pipe( - mergeMap(destination => { + mergeMap((destination) => { newDestinationFolder = destination; return $childrenToCopy; }), - mergeMap(nodesToCopy => { + mergeMap((nodesToCopy) => { const batch = []; - nodesToCopy.list.entries.forEach(node => { + nodesToCopy.list.entries.forEach((node) => { if (node.entry.isFolder) { - batch.push( - this.copyFolderAction( - node.entry, - newDestinationFolder.entry.id - ) - ); + batch.push(this.copyFolderAction(node.entry, newDestinationFolder.entry.id)); } else { - batch.push( - this.copyContentAction( - node.entry, - newDestinationFolder.entry.id - ) - ); + batch.push(this.copyContentAction(node.entry, newDestinationFolder.entry.id)); } }); @@ -505,7 +404,7 @@ export class NodeActionsService { const initialParentId = nodeEntry.parentId; return this.moveFolderAction(nodeEntry, selectionId).pipe( - mergeMap(newContent => { + mergeMap((newContent) => { // take no extra action, if folder is moved to the same location if (initialParentId === selectionId) { return of(newContent); @@ -518,7 +417,7 @@ export class NodeActionsService { if (processedData.failed.length === 0) { // check if folder still exists on location return this.getChildByName(initialParentId, nodeEntry.name).pipe( - mergeMap(folderOnInitialLocation => { + mergeMap((folderOnInitialLocation) => { if (folderOnInitialLocation) { // Check if there's nodeId for Shared Files const nodeEntryId = nodeEntry.nodeId || nodeEntry.id; @@ -552,10 +451,10 @@ export class NodeActionsService { let newDestinationFolder; return this.documentListService.moveNode(contentEntryId, selectionId).pipe( - map(itemMoved => { + map((itemMoved) => { return { itemMoved, initialParentId }; }), - catchError(err => { + catchError((err) => { let errStatusCode; try { const { @@ -567,34 +466,21 @@ export class NodeActionsService { } if (errStatusCode && errStatusCode === 409) { - $destinationFolder = this.getChildByName( - selectionId, - contentEntry.name - ); + $destinationFolder = this.getChildByName(selectionId, contentEntry.name); $childrenToMove = this.getNodeChildren(contentEntryId); return $destinationFolder.pipe( - mergeMap(destination => { + mergeMap((destination) => { newDestinationFolder = destination; return $childrenToMove; }), - mergeMap(childrenToMove => { + mergeMap((childrenToMove) => { const batch: any[] = []; - childrenToMove.list.entries.forEach(node => { + childrenToMove.list.entries.forEach((node) => { if (node.entry.isFolder) { - batch.push( - this.moveFolderAction( - node.entry, - newDestinationFolder.entry.id - ) - ); + batch.push(this.moveFolderAction(node.entry, newDestinationFolder.entry.id)); } else { - batch.push( - this.moveContentAction( - node.entry, - newDestinationFolder.entry.id - ) - ); + batch.push(this.moveContentAction(node.entry, newDestinationFolder.entry.id)); } }); @@ -618,27 +504,22 @@ export class NodeActionsService { const initialParentId = this.getEntryParentId(contentEntry); return this.documentListService.moveNode(contentEntryId, selectionId).pipe( - map(itemMoved => { + map((itemMoved) => { return { itemMoved, initialParentId }; }), - catchError(err => { + catchError((err) => { // do not throw error, to be able to show message in case of partial move of files return of(err); }) ); } - getChildByName( - parentId: string, - name: string - ): Subject { + getChildByName(parentId: string, name: string): Subject { const matchedNodes = new Subject(); this.getNodeChildren(parentId).subscribe( (childrenNodes: NodeChildAssociationPaging) => { - const result = childrenNodes.list.entries.find( - node => node.entry.name === name - ); + const result = childrenNodes.list.entries.find((node) => node.entry.name === name); if (result) { matchedNodes.next(result); @@ -646,18 +527,14 @@ export class NodeActionsService { matchedNodes.next(null); } }, - err => { + (err) => { return of(err || 'Server error'); } ); return matchedNodes; } - private isActionAllowed( - action: BatchOperationType, - node: MinimalNodeEntryEntity, - permission?: string - ): boolean { + private isActionAllowed(action: BatchOperationType, node: MinimalNodeEntryEntity, permission?: string): boolean { if (action === BatchOperationType.copy) { return true; } @@ -685,9 +562,7 @@ export class NodeActionsService { // remove extension in case there is one const fileExtension = extensionMatch ? extensionMatch[0] : ''; - let extensionFree = extensionMatch - ? name.slice(0, extensionMatch.index) - : name; + let extensionFree = extensionMatch ? name.slice(0, extensionMatch.index) : name; let prefixNumber = 1; let baseExtensionFree; @@ -696,9 +571,7 @@ export class NodeActionsService { const baseExtensionMatch = baseName.match(/\.[^/.]+$/); // remove extension in case there is one - baseExtensionFree = baseExtensionMatch - ? baseName.slice(0, baseExtensionMatch.index) - : baseName; + baseExtensionFree = baseExtensionMatch ? baseName.slice(0, baseExtensionMatch.index) : baseName; } if (!baseExtensionFree || baseExtensionFree !== extensionFree) { @@ -722,13 +595,8 @@ export class NodeActionsService { * @param nodeId The id of the parent node * @param params optional parameters */ - getNodeChildren( - nodeId: string, - params?: any - ): Observable { - return from( - this.apiService.getInstance().nodes.getNodeChildren(nodeId, params) - ); + getNodeChildren(nodeId: string, params?: any): Observable { + return from(this.apiService.getInstance().nodes.getNodeChildren(nodeId, params)); } // Copied from ADF document-list.service, and added the name parameter @@ -740,11 +608,7 @@ export class NodeActionsService { * @param name The new name for the copy that would be added on the destination folder */ copyNode(nodeId: string, targetParentId: string, name?: string) { - return from( - this.apiService - .getInstance() - .nodes.copyNode(nodeId, { targetParentId, name }) - ); + return from(this.apiService.getInstance().nodes.copyNode(nodeId, { targetParentId, name })); } public flatten(nDimArray: any[]) { @@ -756,7 +620,7 @@ export class NodeActionsService { const resultingArray: any[] = []; do { - nodeQueue.forEach(node => { + nodeQueue.forEach((node) => { if (Array.isArray(node)) { nodeQueue.push(...node); } else { @@ -786,14 +650,9 @@ export class NodeActionsService { // if content of a folder was moved const folderMoveResponseData = this.flatten(next); - const foundError = folderMoveResponseData.find( - node => node instanceof Error - ); + const foundError = folderMoveResponseData.find((node) => node instanceof Error); // data might contain also items of form: { itemMoved, initialParentId } - const foundEntry = folderMoveResponseData.find( - node => - (node.itemMoved && node.itemMoved.entry) || (node && node.entry) - ); + const foundEntry = folderMoveResponseData.find((node) => (node.itemMoved && node.itemMoved.entry) || (node && node.entry)); if (!foundError) { // consider success if NONE of the items from the folder move response is an error diff --git a/src/app/services/node-template.service.spec.ts b/src/app/services/node-template.service.spec.ts index 6ff7a1eb2..593ddb4ab 100644 --- a/src/app/services/node-template.service.spec.ts +++ b/src/app/services/node-template.service.spec.ts @@ -51,10 +51,7 @@ describe('NodeTemplateService', () => { beforeEach(() => { TestBed.configureTestingModule({ imports: [AppTestingModule, EffectsModule.forRoot([TemplateEffects])], - providers: [ - NodeTemplateService, - { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock } - ] + providers: [NodeTemplateService, { provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock }] }); store = TestBed.inject(Store); @@ -74,9 +71,7 @@ describe('NodeTemplateService', () => { nodeTemplateService.selectTemplateDialog(fileTemplateConfig); tick(); - expect(dialog.open['calls'].argsFor(0)[1].data).toEqual( - jasmine.objectContaining({ currentFolderId: 'parent-node-id' }) - ); + expect(dialog.open['calls'].argsFor(0)[1].data).toEqual(jasmine.objectContaining({ currentFolderId: 'parent-node-id' })); })); it('should remove parents path for templates breadcrumb', fakeAsync(() => { @@ -105,18 +100,16 @@ describe('NodeTemplateService', () => { nodeTemplateService.selectTemplateDialog(fileTemplateConfig); tick(); - const breadcrumb = dialog.open['calls'] - .argsFor(0)[1] - .data.breadcrumbTransform({ - name: 'Node Templates', - path: { - elements: [ - { id: 'id1', name: 'Company Home' }, - { id: 'id2', name: 'Data Dictionary' } - ], - name: '/Company Home/Data Dictionary' - } - }); + const breadcrumb = dialog.open['calls'].argsFor(0)[1].data.breadcrumbTransform({ + name: 'Node Templates', + path: { + elements: [ + { id: 'id1', name: 'Company Home' }, + { id: 'id2', name: 'Data Dictionary' } + ], + name: '/Company Home/Data Dictionary' + } + }); expect(breadcrumb.path.elements).toEqual([]); })); @@ -147,23 +140,19 @@ describe('NodeTemplateService', () => { nodeTemplateService.selectTemplateDialog(fileTemplateConfig); tick(); - const breadcrumb = dialog.open['calls'] - .argsFor(0)[1] - .data.breadcrumbTransform({ - name: 'Node Templates', - path: { - elements: [ - { id: 'id1', name: 'Company Home' }, - { id: 'id2', name: 'Data Dictionary' }, - { id: 'id3', name: 'Templates' } - ], - name: '/Company Home/Data Dictionary/Templates' - } - }); + const breadcrumb = dialog.open['calls'].argsFor(0)[1].data.breadcrumbTransform({ + name: 'Node Templates', + path: { + elements: [ + { id: 'id1', name: 'Company Home' }, + { id: 'id2', name: 'Data Dictionary' }, + { id: 'id3', name: 'Templates' } + ], + name: '/Company Home/Data Dictionary/Templates' + } + }); - expect(breadcrumb.path.elements).toEqual([ - { id: 'id3', name: 'Templates' } - ]); + expect(breadcrumb.path.elements).toEqual([{ id: 'id3', name: 'Templates' }]); })); it('should raise an error when getNodeInfo fails', fakeAsync(() => { @@ -177,9 +166,7 @@ describe('NodeTemplateService', () => { nodeTemplateService.selectTemplateDialog(fileTemplateConfig); tick(); - expect(store.dispatch).toHaveBeenCalledWith( - new SnackbarErrorAction('APP.MESSAGES.ERRORS.GENERIC') - ); + expect(store.dispatch).toHaveBeenCalledWith(new SnackbarErrorAction('APP.MESSAGES.ERRORS.GENERIC')); })); it('should return true if row is not a `link` nodeType', fakeAsync(() => { @@ -284,14 +271,12 @@ describe('NodeTemplateService', () => { nodeTemplateService.selectTemplateDialog(fileTemplateConfig); tick(); - const isSelectionValid = dialog.open['calls'] - .argsFor(0)[1] - .data.isSelectionValid({ - name: 'some-folder-template', - isFile: false, - isFolder: true, - path: { elements: [{}, {}] } - }); + const isSelectionValid = dialog.open['calls'].argsFor(0)[1].data.isSelectionValid({ + name: 'some-folder-template', + isFile: false, + isFolder: true, + path: { elements: [{}, {}] } + }); expect(isSelectionValid).toBe(false); })); @@ -307,14 +292,12 @@ describe('NodeTemplateService', () => { nodeTemplateService.selectTemplateDialog(fileTemplateConfig); tick(); - const isSelectionValid = dialog.open['calls'] - .argsFor(0)[1] - .data.isSelectionValid({ - name: 'some-file-template', - isFile: true, - isFolder: false, - path: { elements: [{}, {}] } - }); + const isSelectionValid = dialog.open['calls'].argsFor(0)[1].data.isSelectionValid({ + name: 'some-file-template', + isFile: true, + isFolder: false, + path: { elements: [{}, {}] } + }); expect(isSelectionValid).toBe(true); })); @@ -348,14 +331,12 @@ describe('NodeTemplateService', () => { nodeTemplateService.selectTemplateDialog(folderTemplateConfig); tick(); - const isSelectionValid = dialog.open['calls'] - .argsFor(0)[1] - .data.isSelectionValid({ - name: 'some-file-template', - isFile: true, - isFolder: false, - path: { elements: [{}, {}] } - }); + const isSelectionValid = dialog.open['calls'].argsFor(0)[1].data.isSelectionValid({ + name: 'some-file-template', + isFile: true, + isFolder: false, + path: { elements: [{}, {}] } + }); expect(isSelectionValid).toBe(false); })); @@ -371,14 +352,12 @@ describe('NodeTemplateService', () => { nodeTemplateService.selectTemplateDialog(folderTemplateConfig); tick(); - const isSelectionValid = dialog.open['calls'] - .argsFor(0)[1] - .data.isSelectionValid({ - name: 'parent-folder-templates', - isFile: false, - isFolder: true, - path: { elements: [] } - }); + const isSelectionValid = dialog.open['calls'].argsFor(0)[1].data.isSelectionValid({ + name: 'parent-folder-templates', + isFile: false, + isFolder: true, + path: { elements: [] } + }); expect(isSelectionValid).toBe(false); })); @@ -387,9 +366,7 @@ describe('NodeTemplateService', () => { spyOn(alfrescoApiService.searchApi, 'search').and.returnValue( Promise.resolve({ list: { - entries: [ - { entry: { id: 'templates-folder-id', path: { elements: [] } } } - ] + entries: [{ entry: { id: 'templates-folder-id', path: { elements: [] } } }] } } as ResultSetPaging) ); @@ -398,14 +375,12 @@ describe('NodeTemplateService', () => { nodeTemplateService.selectTemplateDialog(folderTemplateConfig); tick(); - const isSelectionValid = dialog.open['calls'] - .argsFor(0)[1] - .data.isSelectionValid({ - name: 'some-folder-template', - isFile: false, - isFolder: true, - path: { elements: [{}, {}] } - }); + const isSelectionValid = dialog.open['calls'].argsFor(0)[1].data.isSelectionValid({ + name: 'some-folder-template', + isFile: false, + isFolder: true, + path: { elements: [{}, {}] } + }); expect(isSelectionValid).toBe(true); })); diff --git a/src/app/services/node-template.service.ts b/src/app/services/node-template.service.ts index 7c5e0b8a7..36f3cea99 100644 --- a/src/app/services/node-template.service.ts +++ b/src/app/services/node-template.service.ts @@ -27,22 +27,12 @@ import { Injectable } from '@angular/core'; import { MatDialog, MatDialogRef } from '@angular/material/dialog'; import { CreateFromTemplateDialogComponent } from '../dialogs/node-template/create-from-template.dialog'; import { Subject, from, of } from 'rxjs'; -import { - Node, - MinimalNode, - MinimalNodeEntryEntity, - ResultNode, - PathElement -} from '@alfresco/js-api'; +import { Node, MinimalNode, MinimalNodeEntryEntity, ResultNode, PathElement } from '@alfresco/js-api'; import { AlfrescoApiService, TranslationService } from '@alfresco/adf-core'; import { switchMap, catchError } from 'rxjs/operators'; import { Store } from '@ngrx/store'; import { AppStore, SnackbarErrorAction } from '@alfresco/aca-shared/store'; -import { - ContentNodeSelectorComponent, - ContentNodeSelectorComponentData, - ShareDataRow -} from '@alfresco/adf-content-services'; +import { ContentNodeSelectorComponent, ContentNodeSelectorComponentData, ShareDataRow } from '@alfresco/adf-content-services'; export interface TemplateDialogConfig { primaryPathName: string; @@ -95,7 +85,7 @@ export class NodeTemplateService { from(this.alfrescoApiService.searchApi.search(query)) .pipe( - switchMap(response => { + switchMap((response) => { const entry = response.list.entries[0].entry; this.rootNode = entry; data.currentFolderId = entry.id; @@ -103,18 +93,13 @@ export class NodeTemplateService { return this.dialog .open(ContentNodeSelectorComponent, { data, - panelClass: [ - 'adf-content-node-selector-dialog', - 'aca-template-node-selector-dialog' - ], + panelClass: ['adf-content-node-selector-dialog', 'aca-template-node-selector-dialog'], width: '630px' }) .afterClosed(); }), - catchError(error => { - this.store.dispatch( - new SnackbarErrorAction('APP.MESSAGES.ERRORS.GENERIC') - ); + catchError((error) => { + this.store.dispatch(new SnackbarErrorAction('APP.MESSAGES.ERRORS.GENERIC')); return of(error); }) ) @@ -123,9 +108,7 @@ export class NodeTemplateService { return select; } - createTemplateDialog( - node: Node - ): MatDialogRef { + createTemplateDialog(node: Node): MatDialogRef { return this.dialog.open(CreateFromTemplateDialogComponent, { data: node, panelClass: 'aca-create-from-template-dialog', @@ -158,29 +141,18 @@ export class NodeTemplateService { private title(selectionType: string) { if (selectionType === 'file') { - return this.translation.instant( - 'NODE_SELECTOR.SELECT_FILE_TEMPLATE_TITLE' - ); + return this.translation.instant('NODE_SELECTOR.SELECT_FILE_TEMPLATE_TITLE'); } - return this.translation.instant( - 'NODE_SELECTOR.SELECT_FOLDER_TEMPLATE_TITLE' - ); + return this.translation.instant('NODE_SELECTOR.SELECT_FOLDER_TEMPLATE_TITLE'); } private rowFilter(row: ShareDataRow): boolean { const node: MinimalNodeEntryEntity = row.node.entry; - return ( - node.nodeType !== 'app:filelink' && node.nodeType !== 'app:folderlink' - ); + return node.nodeType !== 'app:filelink' && node.nodeType !== 'app:folderlink'; } private getPathElements(node: Node): PathElement[] { - return node.path.elements.filter( - pathElement => - !this.rootNode.path.elements.some( - rootPathElement => pathElement.id === rootPathElement.id - ) - ); + return node.path.elements.filter((pathElement) => !this.rootNode.path.elements.some((rootPathElement) => pathElement.id === rootPathElement.id)); } } diff --git a/src/app/store/app-store.module.ts b/src/app/store/app-store.module.ts index 9a4acb1de..904aa096e 100644 --- a/src/app/store/app-store.module.ts +++ b/src/app/store/app-store.module.ts @@ -26,10 +26,7 @@ import { NgModule } from '@angular/core'; import { StoreModule } from '@ngrx/store'; import { appReducer } from './reducers/app.reducer'; -import { - StoreRouterConnectingModule, - DefaultRouterStateSerializer -} from '@ngrx/router-store'; +import { StoreRouterConnectingModule, DefaultRouterStateSerializer } from '@ngrx/router-store'; import { EffectsModule } from '@ngrx/effects'; import { environment } from '../../environments/environment'; import { StoreDevtoolsModule } from '@ngrx/store-devtools'; @@ -77,9 +74,7 @@ import { INITIAL_STATE } from './initial-state'; TemplateEffects, ContextMenuEffects ]), - !environment.production - ? StoreDevtoolsModule.instrument({ maxAge: 25 }) - : [] + !environment.production ? StoreDevtoolsModule.instrument({ maxAge: 25 }) : [] ] }) export class AppStoreModule {} diff --git a/src/app/store/effects/app.effects.ts b/src/app/store/effects/app.effects.ts index bd2c8b637..f697ed04c 100644 --- a/src/app/store/effects/app.effects.ts +++ b/src/app/store/effects/app.effects.ts @@ -26,29 +26,19 @@ import { Effect, Actions, ofType } from '@ngrx/effects'; import { Injectable } from '@angular/core'; import { map } from 'rxjs/operators'; -import { - AppActionTypes, - LogoutAction, - ReloadDocumentListAction, - ResetSelectionAction -} from '@alfresco/aca-shared/store'; +import { AppActionTypes, LogoutAction, ReloadDocumentListAction, ResetSelectionAction } from '@alfresco/aca-shared/store'; import { AuthenticationService } from '@alfresco/adf-core'; import { Router } from '@angular/router'; import { ContentManagementService } from '../../services/content-management.service'; @Injectable() export class AppEffects { - constructor( - private actions$: Actions, - private auth: AuthenticationService, - private router: Router, - private content: ContentManagementService - ) {} + constructor(private actions$: Actions, private auth: AuthenticationService, private router: Router, private content: ContentManagementService) {} @Effect({ dispatch: false }) reload = this.actions$.pipe( ofType(AppActionTypes.ReloadDocumentList), - map(action => { + map((action) => { this.content.reload.next(action); }) ); @@ -56,7 +46,7 @@ export class AppEffects { @Effect({ dispatch: false }) resetSelection = this.actions$.pipe( ofType(AppActionTypes.ResetSelection), - map(action => { + map((action) => { this.content.reset.next(action); }) ); diff --git a/src/app/store/effects/contextmenu.effects.ts b/src/app/store/effects/contextmenu.effects.ts index 0934262ba..07e1d30b5 100644 --- a/src/app/store/effects/contextmenu.effects.ts +++ b/src/app/store/effects/contextmenu.effects.ts @@ -23,10 +23,7 @@ * along with Alfresco. If not, see . */ -import { - ContextMenuActionTypes, - ContextMenu -} from '@alfresco/aca-shared/store'; +import { ContextMenuActionTypes, ContextMenu } from '@alfresco/aca-shared/store'; import { Injectable } from '@angular/core'; import { Actions, Effect, ofType } from '@ngrx/effects'; import { map } from 'rxjs/operators'; @@ -37,15 +34,12 @@ import { ContextMenuService } from '../../components/context-menu/context-menu.s export class ContextMenuEffects { private overlayRef: ContextMenuOverlayRef = null; - constructor( - private contextMenuService: ContextMenuService, - private actions$: Actions - ) {} + constructor(private contextMenuService: ContextMenuService, private actions$: Actions) {} @Effect({ dispatch: false }) contextMenu$ = this.actions$.pipe( ofType(ContextMenuActionTypes.ContextMenu), - map(action => { + map((action) => { if (this.overlayRef) { this.overlayRef.close(); } diff --git a/src/app/store/effects/download.effects.ts b/src/app/store/effects/download.effects.ts index 187cdf3dd..7e9025289 100644 --- a/src/app/store/effects/download.effects.ts +++ b/src/app/store/effects/download.effects.ts @@ -23,13 +23,7 @@ * along with Alfresco. If not, see . */ -import { - AppStore, - DownloadNodesAction, - NodeActionTypes, - NodeInfo, - getAppSelection -} from '@alfresco/aca-shared/store'; +import { AppStore, DownloadNodesAction, NodeActionTypes, NodeInfo, getAppSelection } from '@alfresco/aca-shared/store'; import { DownloadZipDialogComponent } from '@alfresco/adf-core'; import { MinimalNodeEntity } from '@alfresco/js-api'; import { Injectable } from '@angular/core'; @@ -41,24 +35,19 @@ import { ContentApiService } from '@alfresco/aca-shared'; @Injectable() export class DownloadEffects { - constructor( - private store: Store, - private actions$: Actions, - private contentApi: ContentApiService, - private dialog: MatDialog - ) {} + constructor(private store: Store, private actions$: Actions, private contentApi: ContentApiService, private dialog: MatDialog) {} @Effect({ dispatch: false }) downloadNode$ = this.actions$.pipe( ofType(NodeActionTypes.Download), - map(action => { + map((action) => { if (action.payload && action.payload.length > 0) { this.downloadNodes(action.payload); } else { this.store .select(getAppSelection) .pipe(take(1)) - .subscribe(selection => { + .subscribe((selection) => { if (selection && !selection.isEmpty) { this.downloadNodes(selection.nodes); } @@ -68,7 +57,7 @@ export class DownloadEffects { ); private downloadNodes(toDownload: Array) { - const nodes = toDownload.map(node => { + const nodes = toDownload.map((node) => { const { id, nodeId, name, isFile, isFolder } = node.entry as any; return { @@ -106,16 +95,13 @@ export class DownloadEffects { } if (node && this.isSharedLinkPreview) { - this.download( - this.contentApi.getSharedLinkContent(node.id, false), - node.name - ); + this.download(this.contentApi.getSharedLinkContent(node.id, false), node.name); } } private downloadZip(nodes: Array) { if (nodes && nodes.length > 0) { - const nodeIds = nodes.map(node => node.id); + const nodeIds = nodes.map((node) => node.id); this.dialog.open(DownloadZipDialogComponent, { width: '600px', diff --git a/src/app/store/effects/favorite.effects.ts b/src/app/store/effects/favorite.effects.ts index 5533fbdeb..776dd5e9d 100644 --- a/src/app/store/effects/favorite.effects.ts +++ b/src/app/store/effects/favorite.effects.ts @@ -26,35 +26,25 @@ import { Effect, Actions, ofType } from '@ngrx/effects'; import { Injectable } from '@angular/core'; import { map, take } from 'rxjs/operators'; -import { - AppStore, - NodeActionTypes, - AddFavoriteAction, - RemoveFavoriteAction, - getAppSelection -} from '@alfresco/aca-shared/store'; +import { AppStore, NodeActionTypes, AddFavoriteAction, RemoveFavoriteAction, getAppSelection } from '@alfresco/aca-shared/store'; import { Store } from '@ngrx/store'; import { ContentManagementService } from '../../services/content-management.service'; @Injectable() export class FavoriteEffects { - constructor( - private store: Store, - private actions$: Actions, - private content: ContentManagementService - ) {} + constructor(private store: Store, private actions$: Actions, private content: ContentManagementService) {} @Effect({ dispatch: false }) addFavorite$ = this.actions$.pipe( ofType(NodeActionTypes.AddFavorite), - map(action => { + map((action) => { if (action.payload && action.payload.length > 0) { this.content.addFavorite(action.payload); } else { this.store .select(getAppSelection) .pipe(take(1)) - .subscribe(selection => { + .subscribe((selection) => { if (selection && !selection.isEmpty) { this.content.addFavorite(selection.nodes); } @@ -66,14 +56,14 @@ export class FavoriteEffects { @Effect({ dispatch: false }) removeFavorite$ = this.actions$.pipe( ofType(NodeActionTypes.RemoveFavorite), - map(action => { + map((action) => { if (action.payload && action.payload.length > 0) { this.content.removeFavorite(action.payload); } else { this.store .select(getAppSelection) .pipe(take(1)) - .subscribe(selection => { + .subscribe((selection) => { if (selection && !selection.isEmpty) { this.content.removeFavorite(selection.nodes); } diff --git a/src/app/store/effects/library.effects.ts b/src/app/store/effects/library.effects.ts index 0a0217b71..abb833f0b 100644 --- a/src/app/store/effects/library.effects.ts +++ b/src/app/store/effects/library.effects.ts @@ -54,14 +54,14 @@ export class LibraryEffects { @Effect({ dispatch: false }) deleteLibrary$ = this.actions$.pipe( ofType(LibraryActionTypes.Delete), - map(action => { + map((action) => { if (action.payload) { this.content.deleteLibrary(action.payload); } else { this.store .select(getAppSelection) .pipe(take(1)) - .subscribe(selection => { + .subscribe((selection) => { if (selection && selection.library) { this.content.deleteLibrary(selection.library.entry.id); } @@ -73,14 +73,14 @@ export class LibraryEffects { @Effect({ dispatch: false }) leaveLibrary$ = this.actions$.pipe( ofType(LibraryActionTypes.Leave), - map(action => { + map((action) => { if (action.payload) { this.content.leaveLibrary(action.payload); } else { this.store .select(getAppSelection) .pipe(take(1)) - .subscribe(selection => { + .subscribe((selection) => { if (selection && selection.library) { this.content.leaveLibrary(selection.library.entry.id); } @@ -93,27 +93,25 @@ export class LibraryEffects { createLibrary$ = this.actions$.pipe( ofType(LibraryActionTypes.Create), mergeMap(() => this.content.createLibrary()), - map(libraryId => new NavigateLibraryAction(libraryId)) + map((libraryId) => new NavigateLibraryAction(libraryId)) ); @Effect({ dispatch: false }) navigateLibrary$ = this.actions$.pipe( ofType(LibraryActionTypes.Navigate), - map(action => { + map((action) => { const libraryId = action.payload; if (libraryId) { this.contentApi .getNode(libraryId, { relativePath: '/documentLibrary' }) - .pipe(map(node => node.entry.id)) + .pipe(map((node) => node.entry.id)) .subscribe( - id => { + (id) => { const route = action.route ? action.route : 'libraries'; this.store.dispatch(new NavigateRouteAction([route, id])); }, () => { - this.store.dispatch( - new SnackbarErrorAction('APP.MESSAGES.ERRORS.MISSING_CONTENT') - ); + this.store.dispatch(new SnackbarErrorAction('APP.MESSAGES.ERRORS.MISSING_CONTENT')); } ); } @@ -123,11 +121,11 @@ export class LibraryEffects { @Effect({ dispatch: false }) updateLibrary$ = this.actions$.pipe( ofType(LibraryActionTypes.Update), - map(action => { + map((action) => { this.store .select(getAppSelection) .pipe(take(1)) - .subscribe(selection => { + .subscribe((selection) => { if (selection && selection.library) { const { id } = selection.library.entry; const { title, description, visibility } = action.payload; diff --git a/src/app/store/effects/node.effects.spec.ts b/src/app/store/effects/node.effects.spec.ts index 713ad49f2..b00f0b00f 100644 --- a/src/app/store/effects/node.effects.spec.ts +++ b/src/app/store/effects/node.effects.spec.ts @@ -59,11 +59,7 @@ describe('NodeEffects', () => { beforeEach(() => { TestBed.configureTestingModule({ - imports: [ - AppTestingModule, - SharedStoreModule, - EffectsModule.forRoot([NodeEffects, ViewerEffects]) - ], + imports: [AppTestingModule, SharedStoreModule, EffectsModule.forRoot([NodeEffects, ViewerEffects])], providers: [ViewUtilService] }); @@ -266,9 +262,7 @@ describe('NodeEffects', () => { tick(100); store.dispatch(new CreateFolderAction(null)); - expect(contentService.createFolder).toHaveBeenCalledWith( - currentFolder.id - ); + expect(contentService.createFolder).toHaveBeenCalledWith(currentFolder.id); })); }); @@ -410,10 +404,7 @@ describe('NodeEffects', () => { store.dispatch(new PrintFileAction(node)); - expect(viewUtilService.printFileGeneric).toHaveBeenCalledWith( - 'node-id', - 'text/json' - ); + expect(viewUtilService.printFileGeneric).toHaveBeenCalledWith('node-id', 'text/json'); }); it('it should print node content from store', fakeAsync(() => { @@ -432,10 +423,7 @@ describe('NodeEffects', () => { store.dispatch(new PrintFileAction(null)); - expect(viewUtilService.printFileGeneric).toHaveBeenCalledWith( - 'node-id', - 'text/json' - ); + expect(viewUtilService.printFileGeneric).toHaveBeenCalledWith('node-id', 'text/json'); })); }); diff --git a/src/app/store/effects/node.effects.ts b/src/app/store/effects/node.effects.ts index e96b5e7b8..a0d5ff73d 100644 --- a/src/app/store/effects/node.effects.ts +++ b/src/app/store/effects/node.effects.ts @@ -62,14 +62,14 @@ export class NodeEffects { @Effect({ dispatch: false }) shareNode$ = this.actions$.pipe( ofType(NodeActionTypes.Share), - map(action => { + map((action) => { if (action.payload) { this.contentService.shareNode(action.payload); } else { this.store .select(getAppSelection) .pipe(take(1)) - .subscribe(selection => { + .subscribe((selection) => { if (selection && selection.file) { this.contentService.shareNode(selection.file); } @@ -81,14 +81,14 @@ export class NodeEffects { @Effect({ dispatch: false }) unshareNodes$ = this.actions$.pipe( ofType(NodeActionTypes.Unshare), - map(action => { + map((action) => { if (action && action.payload && action.payload.length > 0) { this.contentService.unshareNodes(action.payload); } else { this.store .select(getAppSelection) .pipe(take(1)) - .subscribe(selection => { + .subscribe((selection) => { if (selection && !selection.isEmpty) { this.contentService.unshareNodes(selection.nodes); } @@ -100,14 +100,14 @@ export class NodeEffects { @Effect({ dispatch: false }) purgeDeletedNodes$ = this.actions$.pipe( ofType(NodeActionTypes.PurgeDeleted), - map(action => { + map((action) => { if (action && action.payload && action.payload.length > 0) { this.contentService.purgeDeletedNodes(action.payload); } else { this.store .select(getAppSelection) .pipe(take(1)) - .subscribe(selection => { + .subscribe((selection) => { if (selection && selection.count > 0) { this.contentService.purgeDeletedNodes(selection.nodes); } @@ -119,14 +119,14 @@ export class NodeEffects { @Effect({ dispatch: false }) restoreDeletedNodes$ = this.actions$.pipe( ofType(NodeActionTypes.RestoreDeleted), - map(action => { + map((action) => { if (action && action.payload && action.payload.length > 0) { this.contentService.restoreDeletedNodes(action.payload); } else { this.store .select(getAppSelection) .pipe(take(1)) - .subscribe(selection => { + .subscribe((selection) => { if (selection && selection.count > 0) { this.contentService.restoreDeletedNodes(selection.nodes); } @@ -138,14 +138,14 @@ export class NodeEffects { @Effect({ dispatch: false }) deleteNodes$ = this.actions$.pipe( ofType(NodeActionTypes.Delete), - map(action => { + map((action) => { if (action && action.payload && action.payload.length > 0) { this.contentService.deleteNodes(action.payload); } else { this.store .select(getAppSelection) .pipe(take(1)) - .subscribe(selection => { + .subscribe((selection) => { if (selection && selection.count > 0) { this.contentService.deleteNodes(selection.nodes); } @@ -157,7 +157,7 @@ export class NodeEffects { @Effect({ dispatch: false }) undoDeleteNodes$ = this.actions$.pipe( ofType(NodeActionTypes.UndoDelete), - map(action => { + map((action) => { if (action.payload.length > 0) { this.contentService.undoDeleteNodes(action.payload); } @@ -167,14 +167,14 @@ export class NodeEffects { @Effect({ dispatch: false }) createFolder$ = this.actions$.pipe( ofType(NodeActionTypes.CreateFolder), - map(action => { + map((action) => { if (action.payload) { this.contentService.createFolder(action.payload); } else { this.store .select(getCurrentFolder) .pipe(take(1)) - .subscribe(node => { + .subscribe((node) => { if (node && node.id) { this.contentService.createFolder(node.id); } @@ -186,14 +186,14 @@ export class NodeEffects { @Effect({ dispatch: false }) editFolder$ = this.actions$.pipe( ofType(NodeActionTypes.EditFolder), - map(action => { + map((action) => { if (action.payload) { this.contentService.editFolder(action.payload); } else { this.store .select(getAppSelection) .pipe(take(1)) - .subscribe(selection => { + .subscribe((selection) => { if (selection && selection.folder) { this.contentService.editFolder(selection.folder); } @@ -205,14 +205,14 @@ export class NodeEffects { @Effect({ dispatch: false }) copyNodes$ = this.actions$.pipe( ofType(NodeActionTypes.Copy), - map(action => { + map((action) => { if (action.payload && action.payload.length > 0) { this.contentService.copyNodes(action.payload); } else { this.store .select(getAppSelection) .pipe(take(1)) - .subscribe(selection => { + .subscribe((selection) => { if (selection && !selection.isEmpty) { this.contentService.copyNodes(selection.nodes); } @@ -224,14 +224,14 @@ export class NodeEffects { @Effect({ dispatch: false }) moveNodes$ = this.actions$.pipe( ofType(NodeActionTypes.Move), - map(action => { + map((action) => { if (action.payload && action.payload.length > 0) { this.contentService.moveNodes(action.payload); } else { this.store .select(getAppSelection) .pipe(take(1)) - .subscribe(selection => { + .subscribe((selection) => { if (selection && !selection.isEmpty) { this.contentService.moveNodes(selection.nodes); } @@ -243,14 +243,14 @@ export class NodeEffects { @Effect({ dispatch: false }) managePermissions$ = this.actions$.pipe( ofType(NodeActionTypes.ManagePermissions), - map(action => { + map((action) => { if (action && action.payload) { this.contentService.managePermissions(action.payload); } else { this.store .select(getAppSelection) .pipe(take(1)) - .subscribe(selection => { + .subscribe((selection) => { if (selection && !selection.isEmpty) { this.contentService.managePermissions(selection.first); } @@ -262,14 +262,14 @@ export class NodeEffects { @Effect({ dispatch: false }) manageVersions$ = this.actions$.pipe( ofType(NodeActionTypes.ManageVersions), - map(action => { + map((action) => { if (action && action.payload) { this.contentService.manageVersions(action.payload); } else { this.store .select(getAppSelection) .pipe(take(1)) - .subscribe(selection => { + .subscribe((selection) => { if (selection && selection.file) { this.contentService.manageVersions(selection.file); } @@ -281,14 +281,14 @@ export class NodeEffects { @Effect({ dispatch: false }) printFile$ = this.actions$.pipe( ofType(NodeActionTypes.PrintFile), - map(action => { + map((action) => { if (action && action.payload) { this.printFile(action.payload); } else { this.store .select(getAppSelection) .pipe(take(1)) - .subscribe(selection => { + .subscribe((selection) => { if (selection && selection.file) { this.printFile(selection.file); } @@ -300,14 +300,14 @@ export class NodeEffects { @Effect({ dispatch: false }) unlockWrite$ = this.actions$.pipe( ofType(NodeActionTypes.UnlockForWriting), - map(action => { + map((action) => { if (action && action.payload) { this.contentService.unlockNode(action.payload); } else { this.store .select(getAppSelection) .pipe(take(1)) - .subscribe(selection => { + .subscribe((selection) => { if (selection && selection.file) { this.contentService.unlockNode(selection.file); } diff --git a/src/app/store/effects/search.effects.spec.ts b/src/app/store/effects/search.effects.spec.ts index a867b3ebf..b2033401d 100644 --- a/src/app/store/effects/search.effects.spec.ts +++ b/src/app/store/effects/search.effects.spec.ts @@ -29,10 +29,7 @@ import { SearchEffects } from './search.effects'; import { EffectsModule } from '@ngrx/effects'; import { Store } from '@ngrx/store'; import { Router } from '@angular/router'; -import { - SearchOptionIds, - SearchByTermAction -} from '@alfresco/aca-shared/store'; +import { SearchOptionIds, SearchByTermAction } from '@alfresco/aca-shared/store'; describe('SearchEffects', () => { let store: Store; @@ -70,9 +67,7 @@ describe('SearchEffects', () => { tick(); - expect(router.navigateByUrl).toHaveBeenCalledWith( - '/search-libraries;q=test' - ); + expect(router.navigateByUrl).toHaveBeenCalledWith('/search-libraries;q=test'); })); it('should encode search string for parentheses', fakeAsync(() => { @@ -80,9 +75,7 @@ describe('SearchEffects', () => { tick(); - expect(router.navigateByUrl).toHaveBeenCalledWith( - '/search;q=%2528test%2529' - ); + expect(router.navigateByUrl).toHaveBeenCalledWith('/search;q=%2528test%2529'); })); }); }); diff --git a/src/app/store/effects/search.effects.ts b/src/app/store/effects/search.effects.ts index 206b77de4..39bb9ba79 100644 --- a/src/app/store/effects/search.effects.ts +++ b/src/app/store/effects/search.effects.ts @@ -26,11 +26,7 @@ import { Effect, Actions, ofType } from '@ngrx/effects'; import { Injectable } from '@angular/core'; import { map } from 'rxjs/operators'; -import { - SearchActionTypes, - SearchByTermAction, - SearchOptionIds -} from '@alfresco/aca-shared/store'; +import { SearchActionTypes, SearchByTermAction, SearchOptionIds } from '@alfresco/aca-shared/store'; import { Router } from '@angular/router'; @Injectable() @@ -40,19 +36,13 @@ export class SearchEffects { @Effect({ dispatch: false }) searchByTerm$ = this.actions$.pipe( ofType(SearchActionTypes.SearchByTerm), - map(action => { - const query = action.payload - .replace(/[(]/g, '%28') - .replace(/[)]/g, '%29'); + map((action) => { + const query = action.payload.replace(/[(]/g, '%28').replace(/[)]/g, '%29'); - const libItem = action.searchOptions.find( - item => item.id === SearchOptionIds.Libraries - ); + const libItem = action.searchOptions.find((item) => item.id === SearchOptionIds.Libraries); const librarySelected = !!libItem && libItem.value; if (librarySelected) { - this.router.navigateByUrl( - '/search-libraries;q=' + encodeURIComponent(query) - ); + this.router.navigateByUrl('/search-libraries;q=' + encodeURIComponent(query)); } else { this.router.navigateByUrl('/search;q=' + encodeURIComponent(query)); } diff --git a/src/app/store/effects/template.effects.spec.ts b/src/app/store/effects/template.effects.spec.ts index 53bdd2702..70c1d68fe 100644 --- a/src/app/store/effects/template.effects.spec.ts +++ b/src/app/store/effects/template.effects.spec.ts @@ -28,13 +28,7 @@ import { AppTestingModule } from '../../testing/app-testing.module'; import { TemplateEffects } from './template.effects'; import { EffectsModule } from '@ngrx/effects'; import { Store } from '@ngrx/store'; -import { - CreateFromTemplate, - CreateFromTemplateSuccess, - FileFromTemplate, - FolderFromTemplate, - SnackbarErrorAction -} from '@alfresco/aca-shared/store'; +import { CreateFromTemplate, CreateFromTemplateSuccess, FileFromTemplate, FolderFromTemplate, SnackbarErrorAction } from '@alfresco/aca-shared/store'; import { NodeTemplateService } from '../../services/node-template.service'; import { of, Subject } from 'rxjs'; import { AlfrescoApiServiceMock, AlfrescoApiService } from '@alfresco/adf-core'; @@ -140,9 +134,7 @@ describe('TemplateEffects', () => { store.dispatch(new FileFromTemplate()); tick(); - expect(nodeTemplateService.selectTemplateDialog).toHaveBeenCalledWith( - fileTemplateConfig - ); + expect(nodeTemplateService.selectTemplateDialog).toHaveBeenCalledWith(fileTemplateConfig); })); it('should open dialog to select template folders', fakeAsync(() => { @@ -153,23 +145,17 @@ describe('TemplateEffects', () => { store.dispatch(new FolderFromTemplate()); tick(); - expect(nodeTemplateService.selectTemplateDialog).toHaveBeenCalledWith( - folderTemplateConfig - ); + expect(nodeTemplateService.selectTemplateDialog).toHaveBeenCalledWith(folderTemplateConfig); })); it('should create node from template successful', fakeAsync(() => { - copyNodeSpy.and.returnValue( - of({ entry: { id: 'node-id', properties: {} } }) - ); + copyNodeSpy.and.returnValue(of({ entry: { id: 'node-id', properties: {} } })); updateNodeSpy.and.returnValue(of({ entry: node })); store.dispatch(new CreateFromTemplate(node)); tick(); - expect(store.dispatch['calls'].mostRecent().args[0]).toEqual( - new CreateFromTemplateSuccess(node) - ); + expect(store.dispatch['calls'].mostRecent().args[0]).toEqual(new CreateFromTemplateSuccess(node)); })); it('should raise generic error when copyNode api fails', fakeAsync(() => { @@ -182,12 +168,8 @@ describe('TemplateEffects', () => { store.dispatch(new CreateFromTemplate(node)); tick(); - expect(store.dispatch['calls'].mostRecent().args[0]).not.toEqual( - new CreateFromTemplateSuccess(node) - ); - expect(store.dispatch['calls'].argsFor(1)[0]).toEqual( - new SnackbarErrorAction('APP.MESSAGES.ERRORS.GENERIC') - ); + expect(store.dispatch['calls'].mostRecent().args[0]).not.toEqual(new CreateFromTemplateSuccess(node)); + expect(store.dispatch['calls'].argsFor(1)[0]).toEqual(new SnackbarErrorAction('APP.MESSAGES.ERRORS.GENERIC')); })); it('should raise name conflict error when copyNode api returns 409', fakeAsync(() => { @@ -200,12 +182,8 @@ describe('TemplateEffects', () => { store.dispatch(new CreateFromTemplate(node)); tick(); - expect(store.dispatch['calls'].mostRecent().args[0]).not.toEqual( - new CreateFromTemplateSuccess(node) - ); - expect(store.dispatch['calls'].argsFor(1)[0]).toEqual( - new SnackbarErrorAction('APP.MESSAGES.ERRORS.CONFLICT') - ); + expect(store.dispatch['calls'].mostRecent().args[0]).not.toEqual(new CreateFromTemplateSuccess(node)); + expect(store.dispatch['calls'].argsFor(1)[0]).toEqual(new SnackbarErrorAction('APP.MESSAGES.ERRORS.CONFLICT')); })); it('should resolve error with current node value when updateNode api fails', fakeAsync(() => { @@ -229,9 +207,7 @@ describe('TemplateEffects', () => { store.dispatch(new CreateFromTemplate(test_node.entry)); tick(); - expect(store.dispatch['calls'].mostRecent().args[0]).toEqual( - new CreateFromTemplateSuccess(test_node.entry) - ); + expect(store.dispatch['calls'].mostRecent().args[0]).toEqual(new CreateFromTemplateSuccess(test_node.entry)); })); it('should close dialog on create template success', fakeAsync(() => { @@ -244,8 +220,6 @@ describe('TemplateEffects', () => { const test_node = { id: 'test-node-id' } as Node; store.dispatch(new CreateFromTemplateSuccess(test_node)); tick(); - expect(contentManagementService.reload.next).toHaveBeenCalledWith( - test_node - ); + expect(contentManagementService.reload.next).toHaveBeenCalledWith(test_node); })); }); diff --git a/src/app/store/effects/template.effects.ts b/src/app/store/effects/template.effects.ts index 917162d9a..f768de45f 100644 --- a/src/app/store/effects/template.effects.ts +++ b/src/app/store/effects/template.effects.ts @@ -37,10 +37,7 @@ import { AppStore, SnackbarErrorAction } from '@alfresco/aca-shared/store'; -import { - NodeTemplateService, - TemplateDialogConfig -} from '../../services/node-template.service'; +import { NodeTemplateService, TemplateDialogConfig } from '../../services/node-template.service'; import { AlfrescoApiService } from '@alfresco/adf-core'; import { ContentManagementService } from '../../services/content-management.service'; import { from, Observable, of } from 'rxjs'; @@ -83,11 +80,11 @@ export class TemplateEffects { @Effect({ dispatch: false }) createFromTemplate$ = this.actions$.pipe( ofType(TemplateActionTypes.CreateFromTemplate), - map(action => { + map((action) => { this.store .select(getCurrentFolder) .pipe( - switchMap(folder => { + switchMap((folder) => { return this.copyNode(action.payload, folder.id); }), take(1) @@ -102,10 +99,8 @@ export class TemplateEffects { @Effect({ dispatch: false }) createFromTemplateSuccess$ = this.actions$.pipe( - ofType( - TemplateActionTypes.CreateFromTemplateSuccess - ), - map(payload => { + ofType(TemplateActionTypes.CreateFromTemplateSuccess), + map((payload) => { this.matDialog.closeAll(); this.content.reload.next(payload.node); }) @@ -115,9 +110,7 @@ export class TemplateEffects { this.nodeTemplateService .selectTemplateDialog(config) .pipe(debounceTime(300)) - .subscribe(([node]) => - this.nodeTemplateService.createTemplateDialog(node) - ); + .subscribe(([node]) => this.nodeTemplateService.createTemplateDialog(node)); } private copyNode(source: Node, parentId: string): Observable { @@ -127,7 +120,7 @@ export class TemplateEffects { name: source.name }) ).pipe( - switchMap(node => + switchMap((node) => this.updateNode(node, { properties: { 'cm:title': source.properties['cm:title'], @@ -135,19 +128,14 @@ export class TemplateEffects { } }) ), - catchError(error => { + catchError((error) => { return this.handleError(error); }) ); } - private updateNode( - node: NodeEntry, - update: NodeBodyUpdate - ): Observable { - return from( - this.apiService.getInstance().nodes.updateNode(node.entry.id, update) - ).pipe(catchError(() => of(node))); + private updateNode(node: NodeEntry, update: NodeBodyUpdate): Observable { + return from(this.apiService.getInstance().nodes.updateNode(node.entry.id, update)).pipe(catchError(() => of(node))); } private handleError(error: Error): Observable { @@ -160,13 +148,9 @@ export class TemplateEffects { } if (statusCode !== 409) { - this.store.dispatch( - new SnackbarErrorAction('APP.MESSAGES.ERRORS.GENERIC') - ); + this.store.dispatch(new SnackbarErrorAction('APP.MESSAGES.ERRORS.GENERIC')); } else { - this.store.dispatch( - new SnackbarErrorAction('APP.MESSAGES.ERRORS.CONFLICT') - ); + this.store.dispatch(new SnackbarErrorAction('APP.MESSAGES.ERRORS.CONFLICT')); } return of(null); diff --git a/src/app/store/effects/upload.effects.spec.ts b/src/app/store/effects/upload.effects.spec.ts index f8cd18b05..794eef627 100644 --- a/src/app/store/effects/upload.effects.spec.ts +++ b/src/app/store/effects/upload.effects.spec.ts @@ -29,15 +29,8 @@ import { EffectsModule } from '@ngrx/effects'; import { UploadEffects } from './upload.effects'; import { AppTestingModule } from '../../testing/app-testing.module'; import { NgZone } from '@angular/core'; -import { - UploadService, - FileUploadCompleteEvent, - FileModel -} from '@alfresco/adf-core'; -import { - UnlockWriteAction, - UploadFileVersionAction -} from '@alfresco/aca-shared/store'; +import { UploadService, FileUploadCompleteEvent, FileModel } from '@alfresco/adf-core'; +import { UnlockWriteAction, UploadFileVersionAction } from '@alfresco/aca-shared/store'; import { ContentManagementService } from '../../services/content-management.service'; describe('UploadEffects', () => { @@ -87,11 +80,7 @@ describe('UploadEffects', () => { }); it('should dispatch the unlock write action for a locked file', () => { - const file: FileModel = new FileModel( - { name: 'file1.png', size: 10 } as File, - null, - 'file1' - ); + const file: FileModel = new FileModel({ name: 'file1.png', size: 10 } as File, null, 'file1'); file.data = { entry: { @@ -107,21 +96,13 @@ describe('UploadEffects', () => { spyOn(store, 'dispatch').and.stub(); effects.uploadAndUnlock(file); - uploadService.fileUploadComplete.next( - new FileUploadCompleteEvent(file, 100, file.data) - ); + uploadService.fileUploadComplete.next(new FileUploadCompleteEvent(file, 100, file.data)); - expect(store.dispatch).toHaveBeenCalledWith( - new UnlockWriteAction(file.data) - ); + expect(store.dispatch).toHaveBeenCalledWith(new UnlockWriteAction(file.data)); }); it('should dispatch only one unlock action for a locked file', () => { - const file: FileModel = new FileModel( - { name: 'file1.png', size: 10 } as File, - null, - 'file1' - ); + const file: FileModel = new FileModel({ name: 'file1.png', size: 10 } as File, null, 'file1'); file.data = { entry: { @@ -143,19 +124,13 @@ describe('UploadEffects', () => { uploadService.fileUploadComplete.next(completeEvent); uploadService.fileUploadComplete.next(completeEvent); - expect(store.dispatch).toHaveBeenCalledWith( - new UnlockWriteAction(file.data) - ); + expect(store.dispatch).toHaveBeenCalledWith(new UnlockWriteAction(file.data)); expect(store.dispatch).toHaveBeenCalledTimes(1); }); it('should dispatch no actions if file is not locked', () => { - const file: FileModel = new FileModel( - { name: 'file1.png', size: 10 } as File, - null, - 'file1' - ); + const file: FileModel = new FileModel({ name: 'file1.png', size: 10 } as File, null, 'file1'); file.data = { entry: { @@ -169,9 +144,7 @@ describe('UploadEffects', () => { spyOn(store, 'dispatch').and.stub(); effects.uploadAndUnlock(file); - uploadService.fileUploadComplete.next( - new FileUploadCompleteEvent(file, 100, file.data) - ); + uploadService.fileUploadComplete.next(new FileUploadCompleteEvent(file, 100, file.data)); expect(store.dispatch).not.toHaveBeenCalled(); }); @@ -234,10 +207,7 @@ describe('UploadEffects', () => { } }); store.dispatch(new UploadFileVersionAction(fakeEvent)); - expect(contentManagementService.versionUpdateDialog).toHaveBeenCalledWith( - fakeEvent.detail.data.node.entry, - fakeEvent.detail.files[0].file - ); + expect(contentManagementService.versionUpdateDialog).toHaveBeenCalledWith(fakeEvent.detail.data.node.entry, fakeEvent.detail.files[0].file); }); }); }); diff --git a/src/app/store/effects/upload.effects.ts b/src/app/store/effects/upload.effects.ts index 83a896f5d..ec4adfe26 100644 --- a/src/app/store/effects/upload.effects.ts +++ b/src/app/store/effects/upload.effects.ts @@ -63,7 +63,7 @@ export class UploadEffects { this.fileInput.type = 'file'; this.fileInput.style.display = 'none'; this.fileInput.setAttribute('multiple', ''); - this.fileInput.addEventListener('change', event => this.upload(event)); + this.fileInput.addEventListener('change', (event) => this.upload(event)); renderer.appendChild(document.body, this.fileInput); this.fileVersionInput = renderer.createElement('input') as HTMLInputElement; @@ -81,7 +81,7 @@ export class UploadEffects { this.folderInput.style.display = 'none'; this.folderInput.setAttribute('directory', ''); this.folderInput.setAttribute('webkitdirectory', ''); - this.folderInput.addEventListener('change', event => this.upload(event)); + this.folderInput.addEventListener('change', (event) => this.upload(event)); renderer.appendChild(document.body, this.folderInput); } @@ -104,7 +104,7 @@ export class UploadEffects { @Effect({ dispatch: false }) uploadVersion$ = this.actions$.pipe( ofType(UploadActionTypes.UploadFileVersion), - map(action => { + map((action) => { if (action && action.payload) { const node = action.payload.detail.data.node.entry; const file: any = action.payload.detail.files[0].file; @@ -119,17 +119,14 @@ export class UploadEffects { this.contentService .getNodeInfo() .pipe( - catchError(_ => { + catchError((_) => { this.store.dispatch(new SnackbarErrorAction('VERSION.ERROR.GENERIC')); return of(null); }) ) .subscribe((node: MinimalNodeEntryEntity) => { if (node) { - this.contentService.versionUpdateDialog( - node, - this.fileVersionInput.files[0] - ); + this.contentService.versionUpdateDialog(node, this.fileVersionInput.files[0]); this.fileVersionInput.value = ''; } }); @@ -139,7 +136,7 @@ export class UploadEffects { this.store .select(getCurrentFolder) .pipe(take(1)) - .subscribe(node => { + .subscribe((node) => { if (node && node.id) { const input = event.currentTarget as HTMLInputElement; const files = FileUtils.toFileArray(input.files).map((file: any) => { @@ -174,21 +171,19 @@ export class UploadEffects { this.uploadService.addToQueue(file); this.uploadService.uploadFilesInTheQueue(); - const subscription = this.uploadService.fileUploadComplete.subscribe( - completed => { - if ( - file.data && - file.data.entry && - file.data.entry.properties && - file.data.entry.properties['cm:lockType'] === 'WRITE_LOCK' && - file.data.entry.id === completed.data.entry.id - ) { - this.store.dispatch(new UnlockWriteAction(completed.data)); - } - - subscription.unsubscribe(); + const subscription = this.uploadService.fileUploadComplete.subscribe((completed) => { + if ( + file.data && + file.data.entry && + file.data.entry.properties && + file.data.entry.properties['cm:lockType'] === 'WRITE_LOCK' && + file.data.entry.id === completed.data.entry.id + ) { + this.store.dispatch(new UnlockWriteAction(completed.data)); } - ); + + subscription.unsubscribe(); + }); }); } } diff --git a/src/app/store/effects/viewer.effects.spec.ts b/src/app/store/effects/viewer.effects.spec.ts index 2392dca94..8884a3a45 100644 --- a/src/app/store/effects/viewer.effects.spec.ts +++ b/src/app/store/effects/viewer.effects.spec.ts @@ -29,12 +29,7 @@ import { ViewerEffects } from './viewer.effects'; import { EffectsModule } from '@ngrx/effects'; import { Store } from '@ngrx/store'; import { Router } from '@angular/router'; -import { - ViewFileAction, - ViewNodeAction, - SetSelectedNodesAction, - SetCurrentFolderAction -} from '@alfresco/aca-shared/store'; +import { ViewFileAction, ViewNodeAction, SetSelectedNodesAction, SetCurrentFolderAction } from '@alfresco/aca-shared/store'; describe('ViewerEffects', () => { let store: Store; @@ -61,9 +56,7 @@ describe('ViewerEffects', () => { store.dispatch(new ViewFileAction()); tick(100); - expect(router.navigateByUrl).toHaveBeenCalledWith( - '/folder1/preview/someId' - ); + expect(router.navigateByUrl).toHaveBeenCalledWith('/folder1/preview/someId'); })); it('should preview file from payload', fakeAsync(() => { const node: any = { entry: { isFile: true, id: 'someId' } }; @@ -75,32 +68,24 @@ describe('ViewerEffects', () => { describe('ViewNode', () => { it('should open viewer from file location if', fakeAsync(() => { - store.dispatch( - new ViewNodeAction('nodeId', { location: 'some-location' }) - ); + store.dispatch(new ViewNodeAction('nodeId', { location: 'some-location' })); tick(100); - expect(router.navigateByUrl['calls'].argsFor(0)[0].toString()).toEqual( - '/some-location/(viewer:view/nodeId)?location=some-location' - ); + expect(router.navigateByUrl['calls'].argsFor(0)[0].toString()).toEqual('/some-location/(viewer:view/nodeId)?location=some-location'); })); it('should navigate to viewer route if no location is passed', fakeAsync(() => { store.dispatch(new ViewNodeAction('nodeId')); tick(100); - expect(router.navigateByUrl['calls'].argsFor(0)[0].toString()).toEqual( - '/view/(viewer:nodeId)' - ); + expect(router.navigateByUrl['calls'].argsFor(0)[0].toString()).toEqual('/view/(viewer:nodeId)'); })); it('should navigate to viewer route with query param if path is passed', fakeAsync(() => { store.dispatch(new ViewNodeAction('nodeId', { path: 'absolute-path' })); tick(100); - expect(router.navigateByUrl['calls'].argsFor(0)[0].toString()).toEqual( - '/view/(viewer:nodeId)?path=absolute-path' - ); + expect(router.navigateByUrl['calls'].argsFor(0)[0].toString()).toEqual('/view/(viewer:nodeId)?path=absolute-path'); })); }); }); diff --git a/src/app/store/effects/viewer.effects.ts b/src/app/store/effects/viewer.effects.ts index f30c04005..354581fcc 100644 --- a/src/app/store/effects/viewer.effects.ts +++ b/src/app/store/effects/viewer.effects.ts @@ -35,35 +35,20 @@ import { getAppSelection, FullscreenViewerAction } from '@alfresco/aca-shared/store'; -import { - Router, - UrlTree, - UrlSegmentGroup, - PRIMARY_OUTLET, - UrlSegment -} from '@angular/router'; +import { Router, UrlTree, UrlSegmentGroup, PRIMARY_OUTLET, UrlSegment } from '@angular/router'; import { Store, createSelector } from '@ngrx/store'; import { AppExtensionService } from '@alfresco/aca-shared'; -export const fileToPreview = createSelector( - getAppSelection, - getCurrentFolder, - (selection, folder) => { - return { - selection, - folder - }; - } -); +export const fileToPreview = createSelector(getAppSelection, getCurrentFolder, (selection, folder) => { + return { + selection, + folder + }; +}); @Injectable() export class ViewerEffects { - constructor( - private store: Store, - private actions$: Actions, - private router: Router, - private extensions: AppExtensionService - ) {} + constructor(private store: Store, private actions$: Actions, private router: Router, private extensions: AppExtensionService) {} @Effect({ dispatch: false }) fullscreenViewer$ = this.actions$.pipe( @@ -76,34 +61,25 @@ export class ViewerEffects { @Effect({ dispatch: false }) viewNode$ = this.actions$.pipe( ofType(ViewerActionTypes.ViewNode), - map(action => { + map((action) => { if (action.viewNodeExtras) { const { location, path } = action.viewNodeExtras; if (location) { const navigation = this.getNavigationCommands(location); - this.router.navigate( - [...navigation, { outlets: { viewer: ['view', action.nodeId] } }], - { - queryParams: { location } - } - ); + this.router.navigate([...navigation, { outlets: { viewer: ['view', action.nodeId] } }], { + queryParams: { location } + }); } if (path) { - this.router.navigate( - ['view', { outlets: { viewer: [action.nodeId] } }], - { - queryParams: { path } - } - ); + this.router.navigate(['view', { outlets: { viewer: [action.nodeId] } }], { + queryParams: { path } + }); } } else { - this.router.navigate([ - 'view', - { outlets: { viewer: [action.nodeId] } } - ]); + this.router.navigate(['view', { outlets: { viewer: [action.nodeId] } }]); } }) ); @@ -111,28 +87,22 @@ export class ViewerEffects { @Effect({ dispatch: false }) viewFile$ = this.actions$.pipe( ofType(ViewerActionTypes.ViewFile), - map(action => { + map((action) => { if (action.payload && action.payload.entry) { const { id, nodeId, isFile } = action.payload.entry as any; - if ( - this.extensions.canPreviewNode(action.payload) && - (isFile || nodeId) - ) { + if (this.extensions.canPreviewNode(action.payload) && (isFile || nodeId)) { this.displayPreview(nodeId || id, action.parentId); } } else { this.store .select(fileToPreview) .pipe(take(1)) - .subscribe(result => { + .subscribe((result) => { if (result.selection && result.selection.file) { const { id, nodeId, isFile } = result.selection.file.entry as any; - if ( - this.extensions.canPreviewNode(action.payload) && - (isFile || nodeId) - ) { + if (this.extensions.canPreviewNode(action.payload) && (isFile || nodeId)) { const parentId = result.folder ? result.folder.id : null; this.displayPreview(nodeId || id, parentId); } @@ -149,10 +119,7 @@ export class ViewerEffects { let previewLocation = this.router.url; if (previewLocation.lastIndexOf('/') > 0) { - previewLocation = previewLocation.substr( - 0, - this.router.url.indexOf('/', 1) - ); + previewLocation = previewLocation.substr(0, this.router.url.indexOf('/', 1)); } previewLocation = previewLocation.replace(/\//g, ''); @@ -165,9 +132,7 @@ export class ViewerEffects { } enterFullScreen() { - const container: any = document.documentElement.querySelector( - '.adf-viewer__fullscreen-container' - ); + const container: any = document.documentElement.querySelector('.adf-viewer__fullscreen-container'); if (container) { if (container.requestFullscreen) { container.requestFullscreen(); @@ -183,8 +148,7 @@ export class ViewerEffects { private getNavigationCommands(url: string): any[] { const urlTree: UrlTree = this.router.parseUrl(url); - const urlSegmentGroup: UrlSegmentGroup = - urlTree.root.children[PRIMARY_OUTLET]; + const urlSegmentGroup: UrlSegmentGroup = urlTree.root.children[PRIMARY_OUTLET]; if (!urlSegmentGroup) { return [url]; @@ -192,7 +156,7 @@ export class ViewerEffects { const urlSegments: UrlSegment[] = urlSegmentGroup.segments; - return urlSegments.reduce(function(acc, item) { + return urlSegments.reduce(function (acc, item) { acc.push(item.path, item.parameters); return acc; }, []); diff --git a/src/app/store/reducers/app.reducer.ts b/src/app/store/reducers/app.reducer.ts index 2f6a98a08..8508cf898 100644 --- a/src/app/store/reducers/app.reducer.ts +++ b/src/app/store/reducers/app.reducer.ts @@ -42,10 +42,7 @@ import { } from '@alfresco/aca-shared/store'; import { INITIAL_APP_STATE } from '../initial-state'; -export function appReducer( - state: AppState = INITIAL_APP_STATE, - action: Action -): AppState { +export function appReducer(state: AppState = INITIAL_APP_STATE, action: Action): AppState { let newState: AppState; switch (action.type) { @@ -53,10 +50,7 @@ export function appReducer( newState = Object.assign({}, (action as SetInitialStateAction).payload); break; case AppActionTypes.SetSettingsParameter: - newState = handleSettingsUpdate( - state, - action as SetSettingsParameterAction - ); + newState = handleSettingsUpdate(state, action as SetSettingsParameterAction); break; case AppActionTypes.SetHeaderColor: newState = { @@ -83,19 +77,13 @@ export function appReducer( newState = setInfoDrawer(state, action as SetInfoDrawerStateAction); break; case AppActionTypes.SetInfoDrawerMetadataAspect: - newState = setInfoDrawerAspect( - state, - action as SetInfoDrawerMetadataAspectAction - ); + newState = setInfoDrawerAspect(state, action as SetInfoDrawerMetadataAspectAction); break; case AppActionTypes.ToggleDocumentDisplayMode: newState = toggleDocumentDisplayMode(state); break; case AppActionTypes.SetRepositoryInfo: - newState = updateRepositoryStatus( - state, - action as SetRepositoryInfoAction - ); + newState = updateRepositoryStatus(state, action as SetRepositoryInfoAction); break; case SearchActionTypes.ToggleFilter: newState = toggleSearchFilter(state); @@ -191,15 +179,11 @@ function toggleInfoDrawer(state: AppState) { function toggleDocumentDisplayMode(state: AppState) { return { ...state, - documentDisplayMode: - state.documentDisplayMode === 'list' ? 'gallery' : 'list' + documentDisplayMode: state.documentDisplayMode === 'list' ? 'gallery' : 'list' }; } -function updateSelectedNodes( - state: AppState, - action: SetSelectedNodesAction -): AppState { +function updateSelectedNodes(state: AppState, action: SetSelectedNodesAction): AppState { const newState = { ...state }; const nodes = [...action.payload]; const count = nodes.length; @@ -218,19 +202,13 @@ function updateSelectedNodes( if (nodes.length === 1) { file = nodes.find((entity: any) => { // workaround Shared - return entity.entry.isFile || - entity.entry.nodeId || - entity.entry.sharedByUser - ? true - : false; + return entity.entry.isFile || entity.entry.nodeId || entity.entry.sharedByUser ? true : false; }); folder = nodes.find((entity: any) => entity.entry.isFolder); } } - const libraries: any[] = [...action.payload].filter( - (node: any) => node.isLibrary - ); + const libraries: any[] = [...action.payload].filter((node: any) => node.isLibrary); if (libraries.length === 1) { library = libraries[0] as any; } @@ -260,29 +238,20 @@ function setInfoDrawer(state: AppState, action: SetInfoDrawerStateAction) { }; } -function setInfoDrawerAspect( - state: AppState, - action: SetInfoDrawerMetadataAspectAction -) { +function setInfoDrawerAspect(state: AppState, action: SetInfoDrawerMetadataAspectAction) { return { ...state, infoDrawerMetadataAspect: action.payload }; } -function updateRepositoryStatus( - state: AppState, - action: SetRepositoryInfoAction -) { +function updateRepositoryStatus(state: AppState, action: SetRepositoryInfoAction) { const newState = { ...state }; newState.repository = action.payload; return newState; } -function handleSettingsUpdate( - state: AppState, - action: SetSettingsParameterAction -): AppState { +function handleSettingsUpdate(state: AppState, action: SetSettingsParameterAction): AppState { const newState = { ...state }; const { payload } = action; diff --git a/src/app/testing/app-testing.module.ts b/src/app/testing/app-testing.module.ts index 99d3b1309..80ad23e2c 100644 --- a/src/app/testing/app-testing.module.ts +++ b/src/app/testing/app-testing.module.ts @@ -48,10 +48,7 @@ import { StoreModule } from '@ngrx/store'; import { appReducer } from '../store/reducers/app.reducer'; import { RouterTestingModule } from '@angular/router/testing'; import { EffectsModule } from '@ngrx/effects'; -import { - CustomResourcesService, - DocumentListService -} from '@alfresco/adf-content-services'; +import { CustomResourcesService, DocumentListService } from '@alfresco/adf-content-services'; import { MaterialModule } from '../material.module'; import { INITIAL_STATE } from '../store/initial-state'; import { TranslatePipeMock } from './translate-pipe.directive'; diff --git a/src/app/testing/translation.service.ts b/src/app/testing/translation.service.ts index 9a4fc35d7..932bb95ea 100644 --- a/src/app/testing/translation.service.ts +++ b/src/app/testing/translation.service.ts @@ -33,17 +33,13 @@ export class TranslateServiceMock extends TranslateService { super(null, null, null, null, null, null, null, null, null); } - get( - key: string | Array /*, - interpolateParams?: Object*/ - ): Observable { + get(key: string | Array /*, + interpolateParams?: Object*/): Observable { return of(key); } - instant( - key: string | Array /*, - interpolateParams?: Object*/ - ): string | any { + instant(key: string | Array /*, + interpolateParams?: Object*/): string | any { return key; } } diff --git a/src/test.ts b/src/test.ts index 29f91c2a2..149ae467e 100644 --- a/src/test.ts +++ b/src/test.ts @@ -32,23 +32,17 @@ import 'zone.js/dist/jasmine-patch'; import 'zone.js/dist/async-test'; import 'zone.js/dist/fake-async-test'; import { getTestBed } from '@angular/core/testing'; -import { - BrowserDynamicTestingModule, - platformBrowserDynamicTesting -} from '@angular/platform-browser-dynamic/testing'; +import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; // Unfortunately there's no typing for the `__karma__` variable. Just declare it as any. declare const __karma__: any; declare const require: any; // Prevent Karma from running prematurely. -__karma__.loaded = function() {}; +__karma__.loaded = function () {}; // First, initialize the Angular testing environment. -getTestBed().initTestEnvironment( - BrowserDynamicTestingModule, - platformBrowserDynamicTesting() -); +getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting()); // Then we find all the tests. const context = require.context('./', true, /\.spec\.ts$/); // And load the modules. diff --git a/tsconfig.json b/tsconfig.json index c29e2629c..8b03693fa 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,32 +16,18 @@ "noImplicitReturns": true, "target": "es2015", "resolveJsonModule": true, - "typeRoots": [ - "node_modules/@types" - ], - "lib": [ - "es2018", - "dom" - ], + "allowSyntheticDefaultImports": true, + "typeRoots": ["node_modules/@types"], + "lib": ["es2018", "dom"], "paths": { - "@alfresco/aca-shared": [ - "projects/aca-shared/src/public-api.ts" - ], - "@alfresco/aca-shared/store": [ - "projects/aca-shared/store/src/public-api.ts" - ], - "@alfresco/aca-shared/rules": [ - "projects/aca-shared/rules/src/public-api.ts" - ], - "@alfresco/adf-office-services-ext": [ - "projects/adf-office-services-ext/src/public-api.ts" - ], + "@alfresco/aca-shared": ["projects/aca-shared/src/public-api.ts"], + "@alfresco/aca-shared/store": ["projects/aca-shared/store/src/public-api.ts"], + "@alfresco/aca-shared/rules": ["projects/aca-shared/rules/src/public-api.ts"], + "@alfresco/adf-office-services-ext": ["projects/adf-office-services-ext/src/public-api.ts"], "@alfresco/aca-testing-shared": ["projects/aca-testing-shared"] } }, - "exclude": [ - "node_modules" - ], + "exclude": ["node_modules"], "angularCompilerOptions": { "preserveWhitespaces": false, "fullTemplateTypeCheck": true,