From e9b837462ad8854b7551fa6f91c237a0eef658d7 Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Wed, 7 Oct 2020 19:06:21 +0100 Subject: [PATCH] e2e improvements part2 (#1728) * deprecate comments api wrapper, delete sites perf improve * introduce user actions * admin actions inherit user actions * unlock nodes helper * api improvements * api improvements * update code * api improvements * deprecate trashcan api wrapper * shared api improvements --- .travis.yml | 12 +- .../files-folders-actions.test.ts | 20 +-- .../libraries/library.test.ts | 47 +++-- e2e/suites/actions/copy-move/copy.test.ts | 16 +- e2e/suites/actions/copy-move/move.test.ts | 16 +- e2e/suites/actions/delete-undo-delete.test.ts | 35 ++-- e2e/suites/actions/download.test.ts | 12 +- e2e/suites/actions/library-actions.test.ts | 26 ++- e2e/suites/actions/permanently-delete.test.ts | 13 +- e2e/suites/actions/restore.test.ts | 42 ++--- e2e/suites/actions/share-file.test.ts | 41 +++-- .../unshare-file-search-results.test.ts | 16 +- e2e/suites/actions/unshare-file.test.ts | 44 ++--- e2e/suites/info-drawer/comments.test.ts | 14 +- e2e/suites/list-views/favorites.test.ts | 17 +- e2e/suites/list-views/generic-errors.test.ts | 11 +- e2e/suites/list-views/permissions.test.ts | 13 +- e2e/suites/list-views/recent-files.test.ts | 15 +- e2e/suites/list-views/shared-files.test.ts | 2 +- e2e/suites/list-views/tooltips.test.ts | 14 +- e2e/suites/list-views/trash.test.ts | 19 +- e2e/suites/navigation/single-click.test.ts | 20 ++- .../pagination/multiple-pages-trash.test.ts | 12 +- e2e/suites/pagination/single-page.test.ts | 23 +-- e2e/suites/viewer/viewer-actions.test.ts | 30 ++-- e2e/suites/viewer/viewer-general.test.ts | 9 +- .../src/utilities/admin-actions.ts | 75 ++++---- .../aca-testing-shared/src/utilities/index.ts | 1 + .../repo-client/apis/comments/comments-api.ts | 45 ----- .../src/utilities/repo-client/apis/index.ts | 2 - .../repo-client/apis/nodes/nodes-api.ts | 1 + .../repo-client/apis/sites/sites-api.ts | 13 +- .../repo-client/apis/trashcan/trashcan-api.ts | 113 ------------ .../src/utilities/repo-client/repo-client.ts | 13 +- .../src/utilities/user-actions.ts | 165 ++++++++++++++++++ 35 files changed, 509 insertions(+), 458 deletions(-) delete mode 100755 projects/aca-testing-shared/src/utilities/repo-client/apis/comments/comments-api.ts delete mode 100644 projects/aca-testing-shared/src/utilities/repo-client/apis/trashcan/trashcan-api.ts create mode 100644 projects/aca-testing-shared/src/utilities/user-actions.ts diff --git a/.travis.yml b/.travis.yml index e2225b80c..ca737ad81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -85,42 +85,42 @@ jobs: cache: false - stage: e2e - name: 'Test Suite appNavigation & search' + name: 'Test Suites: authentication,listViews,navigation,application,pagination,search' before_script: - ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" "-a" script: ./scripts/ci/jobs/affected-project-with.sh -target e2e -options "--suite=authentication,listViews,navigation,application,pagination,search" after_script: - ./scripts/ci/job_hooks/after_e2e.sh - - name: 'Test Suite actionsAvailable' + - name: 'Test Suites: actionsAvailable' before_script: - ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" "-a" script: ./scripts/ci/jobs/affected-project-with.sh -target e2e -options "--suite=actionsAvailable" after_script: - ./scripts/ci/job_hooks/after_e2e.sh - - name: 'Test Suite addRemoveContent' + - name: 'Test Suites: addRemoveContent' before_script: - ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" "-a" script: ./scripts/ci/jobs/affected-project-with.sh -target e2e -options "--suite=addRemoveContent" after_script: - ./scripts/ci/job_hooks/after_e2e.sh - - name: 'Test Suite manageContent' + - name: 'Test Suites: manageContent' before_script: - ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" "-a" script: ./scripts/ci/jobs/affected-project-with.sh -target e2e -options "--suite=manageContent" after_script: - ./scripts/ci/job_hooks/after_e2e.sh - - name: 'Test Suite sharingContent & markFavorite' + - name: 'Test Suite: sharingContent' before_script: - ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" "-a" script: ./scripts/ci/jobs/affected-project-with.sh -target e2e -options "--suite=sharingContent" after_script: - ./scripts/ci/job_hooks/after_e2e.sh - - name: 'Test Suite viewContent & metadata & extensions' + - name: 'Test Suites: viewer,infoDrawer,extensions' before_script: - ./scripts/ci/job_hooks/before_e2e.sh "$S3_DBP_FOLDER/alfresco-content-app.tar.bz2" "./dist/app" "-a" script: ./scripts/ci/jobs/affected-project-with.sh -target e2e -options "--suite=viewer,infoDrawer,extensions" 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 e998f343c..914bcd0dd 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 @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { RepoClient, Utils, AdminActions, LoginPage, FILES } from '@alfresco/aca-testing-shared'; +import { RepoClient, Utils, AdminActions, UserActions, LoginPage, FILES } from '@alfresco/aca-testing-shared'; import * as testData from './test-data'; import { personalFilesTests } from './personal-files'; import { recentFilesTests } from './recent-files'; @@ -35,9 +35,7 @@ import { trashTests } from './trash'; describe('Files / folders actions : ', () => { const random = Utils.random(); - const username = `user-${random}`; - const parent = `parent-${random}`; let parentId: string; @@ -60,11 +58,14 @@ describe('Files / folders actions : ', () => { const userApi = new RepoClient(username, username); const adminApiActions = new AdminActions(); + const userActions = new UserActions(); const loginPage = new LoginPage(); beforeAll(async () => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); + await userActions.login(username, username); parentId = (await userApi.nodes.createFolder(parent)).entry.id; @@ -121,8 +122,8 @@ describe('Files / folders actions : ', () => { }); afterAll(async () => { - await userApi.nodes.deleteNodeById(parentId); - await userApi.trashcan.emptyTrash(); + await userActions.deleteNodes([parentId]); + await userActions.emptyTrashcan(); }); beforeEach(async () => { @@ -160,12 +161,9 @@ describe('Files / folders actions : ', () => { folderInTrashId = (await userApi.nodes.createFolder(testData.folderInTrash.name)).entry.id; folder2InTrashId = (await userApi.nodes.createFolder(testData.folder2InTrash.name)).entry.id; - const initialDeletedTotalItems = await userApi.trashcan.getDeletedNodesTotalItems(); - await userApi.nodes.deleteNodeById(fileInTrashId, false); - await userApi.nodes.deleteNodeById(file2InTrashId, false); - await userApi.nodes.deleteNodeById(folderInTrashId, false); - await userApi.nodes.deleteNodeById(folder2InTrashId, false); - await userApi.trashcan.waitForApi({ expect: initialDeletedTotalItems + 4 }); + const initialDeletedTotalItems = await userActions.getTrashcanSize(); + await userActions.deleteNodes([fileInTrashId, file2InTrashId, folderInTrashId, folder2InTrashId], false); + await userActions.waitForTrashcanSize(initialDeletedTotalItems + 4); }); trashTests(); }); diff --git a/e2e/suites/actions-available/libraries/library.test.ts b/e2e/suites/actions-available/libraries/library.test.ts index becad1ebf..3f368867c 100755 --- a/e2e/suites/actions-available/libraries/library.test.ts +++ b/e2e/suites/actions-available/libraries/library.test.ts @@ -23,7 +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, UserActions } from '@alfresco/aca-testing-shared'; import * as testData from './test-data-libraries'; import * as testUtil from '../test-util'; @@ -31,8 +31,8 @@ describe('Library actions : ', () => { const username = `user-${Utils.random()}`; const userApi = new RepoClient(username, username); - const adminApiActions = new AdminActions(); + const userActions = new UserActions(); const loginPage = new LoginPage(); const page = new BrowsingPage(); @@ -40,11 +40,13 @@ describe('Library actions : ', () => { const { searchInput } = searchResultsPage.header; beforeAll(async () => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); + await userActions.login(username, username); const initialAdminSitesTotalItems = await adminApiActions.sites.getSitesTotalItems(); const initialUserSitesTotalItems = await userApi.sites.getSitesTotalItems(); - const initialDeletedTotalItems = await userApi.trashcan.getDeletedNodesTotalItems(); + const initialDeletedTotalItems = await userActions.getTrashcanSize(); const initialQuerySitesTotalItems = await userApi.queries.findSitesTotalItems('actionsSite-'); await userApi.sites.createSite(testData.publicUserMemberFav.name); @@ -78,33 +80,30 @@ describe('Library actions : ', () => { await userApi.sites.createSite(testData.siteInTrash.name); await userApi.sites.createSite(testData.site2InTrash.name); - await userApi.sites.deleteSite(testData.siteInTrash.name, false); - await userApi.sites.deleteSite(testData.site2InTrash.name, false); - await userApi.trashcan.waitForApi({ expect: initialDeletedTotalItems + 2 }); + await userActions.deleteSites([testData.siteInTrash.name, testData.site2InTrash.name], false); + await userActions.waitForTrashcanSize(initialDeletedTotalItems + 2); await loginPage.loginWith(username); }); afterAll(async () => { - await Promise.all([ - userApi.sites.deleteSites([ - testData.publicUserMemberFav.name, - testData.privateUserMemberFav.name, - testData.moderatedUserMemberFav.name, - testData.publicUserMemberNotFav.name, - testData.privateUserMemberNotFav.name, - testData.moderatedUserMemberNotFav.name - ]), - adminApiActions.sites.deleteSites([ - testData.publicNotMemberFav.name, - testData.moderatedNotMemberFav.name, - testData.publicNotMemberNotFav.name, - testData.moderatedNotMemberNotFav.name, - testData.moderatedRequestedJoinFav.name, - testData.moderatedRequestedJoinNotFav.name - ]), - userApi.trashcan.emptyTrash() + await userActions.deleteSites([ + testData.publicUserMemberFav.name, + testData.privateUserMemberFav.name, + testData.moderatedUserMemberFav.name, + testData.publicUserMemberNotFav.name, + testData.privateUserMemberNotFav.name, + testData.moderatedUserMemberNotFav.name ]); + await adminApiActions.deleteSites([ + testData.publicNotMemberFav.name, + testData.moderatedNotMemberFav.name, + testData.publicNotMemberNotFav.name, + testData.moderatedNotMemberNotFav.name, + testData.moderatedRequestedJoinFav.name, + testData.moderatedRequestedJoinNotFav.name + ]); + await userActions.emptyTrashcan(); }); describe('on My Libraries', () => { diff --git a/e2e/suites/actions/copy-move/copy.test.ts b/e2e/suites/actions/copy-move/copy.test.ts index 786d15bf6..2d9fd7f11 100755 --- a/e2e/suites/actions/copy-move/copy.test.ts +++ b/e2e/suites/actions/copy-move/copy.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { AdminActions, LoginPage, BrowsingPage, ContentNodeSelectorDialog, RepoClient, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, UserActions, LoginPage, BrowsingPage, ContentNodeSelectorDialog, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Copy content', () => { const username = `user-${Utils.random()}`; @@ -108,10 +108,14 @@ describe('Copy content', () => { const { dataTable, toolbar } = page; const copyDialog = new ContentNodeSelectorDialog(); const { searchInput } = page.header; + const adminApiActions = new AdminActions(); + const userActions = new UserActions(); beforeAll(async (done) => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); + await userActions.login(username, username); const initialSharedTotalItems = await apis.user.shared.getSharedLinksTotalItems(); const initialFavoritesTotalItems = await apis.user.favorites.getFavoritesTotalItems(); @@ -124,7 +128,7 @@ describe('Copy content', () => { destinationIdSearch = (await apis.user.nodes.createFolder(destinationSearch)).entry.id; existingFileToCopyId = (await apis.user.nodes.createFile(existingFile, sourceId)).entry.id; - await apis.user.shared.shareFileById(existingFileToCopyId); + await userActions.shareNodes([existingFileToCopyId]); await apis.user.favorites.addFavoriteById('file', existingFileToCopyId); await apis.user.nodes.createFile(existingFile, destinationIdPF); @@ -152,7 +156,7 @@ describe('Copy content', () => { fileInFolderId = (await apis.user.nodes.createFile(fileInFolder, folder1Id)).entry.id; await apis.user.favorites.addFavoriteById('folder', folder1Id); await apis.user.favorites.addFavoriteById('file', fileInFolderId); - await apis.user.shared.shareFileById(fileInFolderId); + await userActions.shareNodes([fileInFolderId]); folderExistingId = (await apis.user.nodes.createFolder(folderExisting, sourceId)).entry.id; await apis.user.favorites.addFavoriteById('folder', folderExistingId); @@ -184,11 +188,7 @@ describe('Copy content', () => { file3Id = (await apis.user.nodes.createFile(file3, sourceId)).entry.id; file4Id = (await apis.user.nodes.createFile(file4, sourceId)).entry.id; - await apis.user.shared.shareFileById(file1Id); - await apis.user.shared.shareFileById(file2Id); - await apis.user.shared.shareFileById(file3Id); - await apis.user.shared.shareFileById(file4Id); - await apis.user.shared.shareFileById(fileLocked1Id); + await userActions.shareNodes([file1Id, file2Id, file3Id, file4Id, fileLocked1Id]); await apis.user.favorites.addFavoriteById('file', file1Id); await apis.user.favorites.addFavoriteById('file', file2Id); diff --git a/e2e/suites/actions/copy-move/move.test.ts b/e2e/suites/actions/copy-move/move.test.ts index 28719eac4..0f49cb0f3 100755 --- a/e2e/suites/actions/copy-move/move.test.ts +++ b/e2e/suites/actions/copy-move/move.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { AdminActions, LoginPage, BrowsingPage, ContentNodeSelectorDialog, RepoClient, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, UserActions, LoginPage, BrowsingPage, ContentNodeSelectorDialog, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Move content', () => { const username = `user-${Utils.random()}`; @@ -62,10 +62,14 @@ describe('Move content', () => { const page = new BrowsingPage(); const { dataTable, toolbar } = page; const moveDialog = new ContentNodeSelectorDialog(); + const adminApiActions = new AdminActions(); + const userActions = new UserActions(); beforeAll(async (done) => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); + await userActions.login(username, username); await apis.user.sites.createSite(siteName); const docLibId = await apis.user.sites.getDocLibId(siteName); @@ -420,20 +424,18 @@ describe('Move content', () => { file1Id = (await apis.user.nodes.createFile(file1, sourceIdSF)).entry.id; const initialSharedTotalItems = await apis.user.shared.getSharedLinksTotalItems(); - await apis.user.shared.shareFileById(file1Id); + await userActions.shareNodes([file1Id]); file2Id = (await apis.user.nodes.createFile(file2, sourceIdSF)).entry.id; file3Id = (await apis.user.nodes.createFile(file3, sourceIdSF)).entry.id; - await apis.user.shared.shareFileById(file2Id); - await apis.user.shared.shareFileById(file3Id); + await userActions.shareNodes([file2Id, file3Id]); existingFileId = (await apis.user.nodes.createFile(`${existingFile}.txt`, sourceIdSF)).entry.id; - await apis.user.shared.shareFileById(existingFileId); + await userActions.shareNodes([existingFileId]); await apis.user.nodes.createFile(`${existingFile}.txt`, destinationIdSF); file4Id = (await apis.user.nodes.createFile(file4, sourceIdSF)).entry.id; - await apis.user.shared.shareFileById(file4Id); - + await userActions.shareNodes([file4Id]); await apis.user.shared.waitForApi({ expect: initialSharedTotalItems + 5 }); done(); diff --git a/e2e/suites/actions/delete-undo-delete.test.ts b/e2e/suites/actions/delete-undo-delete.test.ts index 0ff1ad2e4..41fc15202 100755 --- a/e2e/suites/actions/delete-undo-delete.test.ts +++ b/e2e/suites/actions/delete-undo-delete.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { AdminActions, LoginPage, BrowsingPage, RepoClient, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, UserActions, LoginPage, BrowsingPage, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Delete and undo delete', () => { const username = `user-${Utils.random()}`; @@ -35,14 +35,19 @@ describe('Delete and undo delete', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable, toolbar } = page; + const adminApiActions = new AdminActions(); + const userActions = new UserActions(); beforeAll(async () => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); + + await userActions.login(username, username); }); afterAll(async () => { - await apis.user.trashcan.emptyTrash(); + await userActions.emptyTrashcan(); }); describe('on Recent Files', () => { @@ -78,8 +83,8 @@ describe('Delete and undo delete', () => { }); afterAll(async () => { - await apis.user.nodes.deleteNodeById(parentId); - await apis.user.trashcan.emptyTrash(); + await userActions.deleteNodes([parentId]); + await userActions.emptyTrashcan(); }); it('[C280528] delete a file and check notification', async () => { @@ -209,12 +214,9 @@ describe('Delete and undo delete', () => { }); afterAll(async () => { - await apis.user.nodes.unlockFile(fileLocked1Id); - await apis.user.nodes.unlockFile(fileLocked2Id); - await apis.user.nodes.unlockFile(fileLocked3Id); - await apis.user.nodes.unlockFile(fileLocked4Id); - await apis.user.nodes.deleteNodeById(parentId); - await apis.user.trashcan.emptyTrash(); + await userActions.unlockNodes([fileLocked1Id, fileLocked2Id, fileLocked3Id, fileLocked4Id]); + await userActions.deleteNodes([parentId]); + await userActions.emptyTrashcan(); }); it('[C217125] delete a file and check notification', async () => { @@ -362,8 +364,8 @@ describe('Delete and undo delete', () => { }); afterAll(async (done) => { - await apis.user.nodes.deleteNodeById(parentId); - await apis.user.trashcan.emptyTrash(); + await userActions.deleteNodes([parentId]); + await userActions.emptyTrashcan(); done(); }); @@ -498,12 +500,9 @@ describe('Delete and undo delete', () => { }); afterAll(async (done) => { - await apis.user.nodes.unlockFile(fileLocked1Id); - await apis.user.nodes.unlockFile(fileLocked2Id); - await apis.user.nodes.unlockFile(fileLocked3Id); - await apis.user.nodes.unlockFile(fileLocked4Id); - await apis.user.nodes.deleteNodeById(parentId); - await apis.user.trashcan.emptyTrash(); + await userActions.unlockNodes([fileLocked1Id, fileLocked2Id, fileLocked3Id, fileLocked4Id]); + await userActions.deleteNodes([parentId]); + await userActions.emptyTrashcan(); done(); }); diff --git a/e2e/suites/actions/download.test.ts b/e2e/suites/actions/download.test.ts index 6808fc4be..e26808102 100755 --- a/e2e/suites/actions/download.test.ts +++ b/e2e/suites/actions/download.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { AdminActions, LoginPage, BrowsingPage, SearchResultsPage, RepoClient, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, UserActions, LoginPage, BrowsingPage, SearchResultsPage, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Download', () => { const username = `user-${Utils.random()}`; @@ -77,9 +77,12 @@ describe('Download', () => { let initialRecentTotalItems: number; const adminApiActions = new AdminActions(); + const userActions = new UserActions(); beforeAll(async (done) => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); + await userActions.login(username, username); initialRecentTotalItems = await apis.user.search.getTotalItems(username); @@ -105,8 +108,7 @@ describe('Download', () => { await apis.user.search.waitForApi(username, { expect: initialRecentTotalItems + 10 }); initialSharedTotalItems = await apis.user.shared.getSharedLinksTotalItems(); - await apis.user.shared.shareFileById(fileShared1Id); - await apis.user.shared.shareFileById(fileShared2Id); + await userActions.shareNodes([fileShared1Id, fileShared2Id]); await apis.user.shared.waitForApi({ expect: initialSharedTotalItems + 2 }); initialFavoritesTotalItems = await apis.user.favorites.getFavoritesTotalItems(); @@ -119,8 +121,8 @@ describe('Download', () => { }); afterAll(async (done) => { - await apis.user.nodes.deleteNodeById(parentId); - await apis.user.trashcan.emptyTrash(); + await userActions.deleteNodes([parentId]); + await userActions.emptyTrashcan(); done(); }); diff --git a/e2e/suites/actions/library-actions.test.ts b/e2e/suites/actions/library-actions.test.ts index 56a067abd..0146b422b 100755 --- a/e2e/suites/actions/library-actions.test.ts +++ b/e2e/suites/actions/library-actions.test.ts @@ -23,7 +23,17 @@ * along with Alfresco. If not, see . */ -import { AdminActions, SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, ConfirmDialog, RepoClient } from '@alfresco/aca-testing-shared'; +import { + AdminActions, + UserActions, + SITE_VISIBILITY, + SITE_ROLES, + LoginPage, + BrowsingPage, + Utils, + ConfirmDialog, + RepoClient +} from '@alfresco/aca-testing-shared'; describe('Library actions', () => { const username = `user-${Utils.random()}`; @@ -64,9 +74,12 @@ describe('Library actions', () => { const confirmDialog = new ConfirmDialog(); const adminApiActions = new AdminActions(); + const userActions = new UserActions(); beforeAll(async (done) => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); + await userActions.login(username, username); await adminApiActions.sites.createSite(siteSearchPublic1Admin); await adminApiActions.sites.createSite(siteSearchPublic2Admin); @@ -95,7 +108,7 @@ describe('Library actions', () => { }); afterAll(async () => { - await adminApiActions.sites.deleteSites([ + await adminApiActions.deleteSites([ sitePublic1Admin, siteSearchPublic1Admin, sitePublic2Admin, @@ -104,9 +117,7 @@ describe('Library actions', () => { sitePublic5Admin, sitePublic6Admin, sitePublic7Admin, - sitePublic8Admin - ]); - await adminApiActions.sites.deleteSites([ + sitePublic8Admin, siteSearchPublic2Admin, siteSearchPublic3Admin, siteSearchPublic4Admin, @@ -115,8 +126,9 @@ describe('Library actions', () => { siteSearchModerated1Admin, siteSearchModerated2Admin ]); - await apis.user.sites.deleteSite(sitePublicUser); - await apis.user.trashcan.emptyTrash(); + + await userActions.deleteSites([sitePublicUser]); + await userActions.emptyTrashcan(); }); describe('Join a public library', () => { diff --git a/e2e/suites/actions/permanently-delete.test.ts b/e2e/suites/actions/permanently-delete.test.ts index d7282b49e..46b5ca63e 100755 --- a/e2e/suites/actions/permanently-delete.test.ts +++ b/e2e/suites/actions/permanently-delete.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { AdminActions, LoginPage, BrowsingPage, ConfirmDialog, RepoClient, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, UserActions, LoginPage, BrowsingPage, ConfirmDialog, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Permanently delete from Trash', () => { const username = `user-${Utils.random()}`; @@ -49,16 +49,19 @@ describe('Permanently delete from Trash', () => { const confirmDialog = new ConfirmDialog(); const adminApiActions = new AdminActions(); + const userActions = new UserActions(); beforeAll(async (done) => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); + await userActions.login(username, 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 userActions.deleteNodes([...filesIds, ...foldersIds], false); + await userActions.deleteSites([site], false); await loginPage.loginWith(username); done(); @@ -70,7 +73,7 @@ describe('Permanently delete from Trash', () => { }); afterAll(async (done) => { - await apis.user.trashcan.emptyTrash(); + await userActions.emptyTrashcan(); done(); }); diff --git a/e2e/suites/actions/restore.test.ts b/e2e/suites/actions/restore.test.ts index 52e94ce8f..8c08ec45b 100755 --- a/e2e/suites/actions/restore.test.ts +++ b/e2e/suites/actions/restore.test.ts @@ -24,7 +24,7 @@ */ import { browser } from 'protractor'; -import { AdminActions, LoginPage, BrowsingPage, APP_ROUTES, RepoClient, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, UserActions, LoginPage, BrowsingPage, APP_ROUTES, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Restore from Trash', () => { const username = `user-${Utils.random()}`; @@ -37,15 +37,19 @@ describe('Restore from Trash', () => { const page = new BrowsingPage(); const { dataTable, toolbar } = page; const adminApiActions = new AdminActions(); + const userActions = new UserActions(); beforeAll(async (done) => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); + await userActions.login(username, username); + await loginPage.loginWith(username); done(); }); afterAll(async (done) => { - await apis.user.trashcan.emptyTrash(); + await userActions.emptyTrashcan(); done(); }); @@ -61,8 +65,8 @@ describe('Restore from Trash', () => { folderId = (await apis.user.nodes.createFolder(folder)).entry.id; await apis.user.sites.createSite(site); - await apis.user.nodes.deleteNodesById([fileId, folderId], false); - await apis.user.sites.deleteSite(site, false); + await userActions.deleteNodes([fileId, folderId], false); + await userActions.deleteSites([site], false); done(); }); @@ -72,7 +76,7 @@ describe('Restore from Trash', () => { }); afterAll(async (done) => { - await apis.user.trashcan.emptyTrash(); + await userActions.emptyTrashcan(); done(); }); @@ -86,7 +90,7 @@ describe('Restore from Trash', () => { await page.clickPersonalFilesAndWait(); expect(await page.dataTable.isItemPresent(file)).toBe(true, 'Item not displayed in list'); - await apis.user.nodes.deleteNodeById(fileId, false); + await userActions.deleteNodes([fileId], false); }); it('[C280438] restore folder', async () => { @@ -99,7 +103,7 @@ describe('Restore from Trash', () => { await page.clickPersonalFilesAndWait(); expect(await page.dataTable.isItemPresent(folder)).toBe(true, 'Item not displayed in list'); - await apis.user.nodes.deleteNodeById(folderId, false); + await userActions.deleteNodes([folderId], false); }); it('[C290104] restore library', async () => { @@ -125,7 +129,7 @@ describe('Restore from Trash', () => { expect(await page.dataTable.isItemPresent(file)).toBe(true, 'Item not displayed in list'); expect(await page.dataTable.isItemPresent(folder)).toBe(true, 'Item not displayed in list'); - await apis.user.nodes.deleteNodesById([fileId, folderId], false); + await userActions.deleteNodes([fileId, folderId], false); }); it('[C217181] View from notification', async () => { @@ -136,7 +140,7 @@ describe('Restore from Trash', () => { expect(await page.sidenav.isActive('Personal Files')).toBe(true, 'Personal Files sidebar link not active'); expect(await browser.getCurrentUrl()).toContain(APP_ROUTES.PERSONAL_FILES); - await apis.user.nodes.deleteNodeById(fileId, false); + await userActions.deleteNodes([fileId], false); }); }); @@ -155,14 +159,13 @@ describe('Restore from Trash', () => { beforeAll(async (done) => { folder1Id = (await apis.user.nodes.createFolder(folder1)).entry.id; file1Id1 = (await apis.user.nodes.createFile(file1, folder1Id)).entry.id; - await apis.user.nodes.deleteNodeById(file1Id1, false); + await userActions.deleteNodes([file1Id1], false); file1Id2 = (await apis.user.nodes.createFile(file1, folder1Id)).entry.id; folder2Id = (await apis.user.nodes.createFolder(folder2)).entry.id; file2Id = (await apis.user.nodes.createFile(file2, folder2Id)).entry.id; - await apis.user.nodes.deleteNodeById(file2Id, false); - await apis.user.nodes.deleteNodeById(folder2Id, false); + await userActions.deleteNodes([file2Id, folder2Id], false); done(); }); @@ -172,7 +175,8 @@ describe('Restore from Trash', () => { }); afterAll(async (done) => { - await Promise.all([apis.user.nodes.deleteNodeById(file1Id2), apis.user.trashcan.emptyTrash()]); + await userActions.deleteNodes([file1Id2]); + await userActions.emptyTrashcan(); done(); }); @@ -217,20 +221,16 @@ describe('Restore from Trash', () => { file1Id = (await apis.user.nodes.createFile(file1, folder1Id)).entry.id; folder2Id = (await apis.user.nodes.createFolder(folder2)).entry.id; file2Id = (await apis.user.nodes.createFile(file2, folder2Id)).entry.id; - await apis.user.nodes.deleteNodeById(file1Id, false); - await apis.user.nodes.deleteNodeById(folder1Id, false); - await apis.user.nodes.deleteNodeById(file2Id, false); + + await userActions.deleteNodes([file1Id, folder1Id, file2Id], false); folder3Id = (await apis.user.nodes.createFolder(folder3)).entry.id; file3Id = (await apis.user.nodes.createFile(file3, folder3Id)).entry.id; file4Id = (await apis.user.nodes.createFile(file4, folder3Id)).entry.id; folder4Id = (await apis.user.nodes.createFolder(folder4)).entry.id; file5Id = (await apis.user.nodes.createFile(file5, folder4Id)).entry.id; - await apis.user.nodes.deleteNodeById(file3Id, false); - await apis.user.nodes.deleteNodeById(file4Id, false); - await apis.user.nodes.deleteNodeById(folder3Id, false); - await apis.user.nodes.deleteNodeById(file5Id, false); + await userActions.deleteNodes([file3Id, file4Id, folder3Id, file5Id], false); await loginPage.loginWith(username); done(); }); @@ -241,7 +241,7 @@ describe('Restore from Trash', () => { }); afterAll(async (done) => { - await apis.user.trashcan.emptyTrash(); + await userActions.emptyTrashcan(); done(); }); diff --git a/e2e/suites/actions/share-file.test.ts b/e2e/suites/actions/share-file.test.ts index 384ffc05c..e52d6d0e5 100755 --- a/e2e/suites/actions/share-file.test.ts +++ b/e2e/suites/actions/share-file.test.ts @@ -24,7 +24,17 @@ */ import { browser } from 'protractor'; -import { AdminActions, LoginPage, BrowsingPage, SITE_VISIBILITY, RepoClient, ShareDialog, Viewer, Utils } from '@alfresco/aca-testing-shared'; +import { + AdminActions, + UserActions, + LoginPage, + BrowsingPage, + SITE_VISIBILITY, + RepoClient, + ShareDialog, + Viewer, + Utils +} from '@alfresco/aca-testing-shared'; describe('Share a file', () => { const username = `user-${Utils.random()}`; @@ -60,9 +70,13 @@ describe('Share a file', () => { }; const adminApiActions = new AdminActions(); + const userActions = new UserActions(); beforeAll(async (done) => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); + await userActions.login(username, username); + parentId = (await apis.user.nodes.createFolder(parent)).entry.id; done(); }); @@ -127,8 +141,7 @@ describe('Share a file', () => { file9Id = (await apis.user.nodes.createFile(file9, parentId)).entry.id; initialTotalItems = await apis.user.shared.getSharedLinksTotalItems(); - await apis.user.shared.shareFileById(file6Id, expiryDate); - await apis.user.shared.shareFileById(file7Id, expiryDate); + await userActions.shareNodes([file6Id, file7Id], expiryDate); await apis.user.shared.waitForApi({ expect: initialTotalItems + 2 }); }); @@ -312,8 +325,7 @@ describe('Share a file', () => { file9Id = (await apis.user.nodes.createFile(file9, parentInSiteId)).entry.id; initialTotalItems = await apis.user.shared.getSharedLinksTotalItems(); - await apis.user.shared.shareFileById(file6Id, expiryDate); - await apis.user.shared.shareFileById(file7Id, expiryDate); + await userActions.shareNodes([file6Id, file7Id], expiryDate); await apis.user.shared.waitForApi({ expect: initialTotalItems + 2 }); }); @@ -485,8 +497,7 @@ describe('Share a file', () => { file9Id = (await apis.user.nodes.createFile(file9, parentId)).entry.id; initialTotalItems = await apis.user.shared.getSharedLinksTotalItems(); - await apis.user.shared.shareFileById(file6Id, expiryDate); - await apis.user.shared.shareFileById(file7Id, expiryDate); + await userActions.shareNodes([file6Id, file7Id], expiryDate); await apis.user.shared.waitForApi({ expect: initialTotalItems + 2 }); }); @@ -660,13 +671,9 @@ describe('Share a file', () => { file7Id = (await apis.user.nodes.createFile(file7, parentId)).entry.id; initialTotalItems = await apis.user.shared.getSharedLinksTotalItems(); - await apis.user.shared.shareFileById(file1Id); - await apis.user.shared.shareFileById(file2Id); - await apis.user.shared.shareFileById(file3Id); - await apis.user.shared.shareFileById(file4Id, expiryDate); - await apis.user.shared.shareFileById(file5Id, expiryDate); - await apis.user.shared.shareFileById(file6Id); - await apis.user.shared.shareFileById(file7Id); + await userActions.shareNodes([file1Id, file2Id, file3Id]); + await userActions.shareNodes([file4Id, file5Id], expiryDate); + await userActions.shareNodes([file6Id, file7Id]); await apis.user.shared.waitForApi({ expect: initialTotalItems + 7 }); }); @@ -820,8 +827,7 @@ describe('Share a file', () => { await apis.user.favorites.addFavoriteById('file', file8Id); await apis.user.favorites.addFavoriteById('file', file9Id); - await apis.user.shared.shareFileById(file6Id, expiryDate); - await apis.user.shared.shareFileById(file7Id, expiryDate); + await userActions.shareNodes([file6Id, file7Id], expiryDate); await apis.user.favorites.waitForApi({ expect: 9 }); await apis.user.shared.waitForApi({ expect: initialTotalItems + 2 }); }); @@ -1002,8 +1008,7 @@ describe('Share a file', () => { await apis.user.search.waitForNodes('search-f', { expect: initialSearchByTermTotalItems + 5 }); initialTotalItems = await apis.user.shared.getSharedLinksTotalItems(); - await apis.user.shared.shareFileById(file6Id, expiryDate); - await apis.user.shared.shareFileById(file7Id, expiryDate); + await userActions.shareNodes([file6Id, file7Id], expiryDate); await apis.user.shared.waitForApi({ expect: initialTotalItems + 2 }); }); diff --git a/e2e/suites/actions/unshare-file-search-results.test.ts b/e2e/suites/actions/unshare-file-search-results.test.ts index eb1a44bb3..33d790ae9 100755 --- a/e2e/suites/actions/unshare-file-search-results.test.ts +++ b/e2e/suites/actions/unshare-file-search-results.test.ts @@ -26,6 +26,7 @@ import { browser } from 'protractor'; import { AdminActions, + UserActions, LoginPage, BrowsingPage, SITE_VISIBILITY, @@ -71,10 +72,15 @@ describe('Unshare a file from Search Results', () => { const contextMenu = dataTable.menu; const viewer = new Viewer(); const { searchInput } = page.header; + const adminApiActions = new AdminActions(); + const userActions = new UserActions(); beforeAll(async (done) => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); + await userActions.login(username, username); + parentId = (await apis.user.nodes.createFolder(parent)).entry.id; const initialSearchByTermTotalItems = await apis.user.search.getSearchByTermTotalItems('search-file'); @@ -84,11 +90,7 @@ describe('Unshare a file from Search Results', () => { file4Id = (await apis.user.nodes.createFile(file4, parentId)).entry.id; const initialSharedTotalItems = await apis.user.shared.getSharedLinksTotalItems(); - await apis.user.shared.shareFileById(file1Id); - await apis.user.shared.shareFileById(file2Id); - await apis.user.shared.shareFileById(file3Id); - await apis.user.shared.shareFileById(file4Id); - + await userActions.shareNodes([file1Id, file2Id, file3Id, file4Id]); await adminApiActions.sites.createSite(sitePrivate, SITE_VISIBILITY.PRIVATE); const docLibId = await adminApiActions.sites.getDocLibId(sitePrivate); @@ -97,8 +99,8 @@ describe('Unshare a file from Search Results', () => { await adminApiActions.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_CONSUMER.ROLE); - await adminApiActions.shared.shareFileById(fileSite1Id); - await apis.user.shared.shareFileById(fileSite2Id); + await adminApiActions.shareNodes([fileSite1Id]); + await userActions.shareNodes([fileSite2Id]); await apis.user.shared.waitForApi({ expect: initialSharedTotalItems + 6 }); await apis.user.search.waitForNodes('search-file', { expect: initialSearchByTermTotalItems + 6 }); diff --git a/e2e/suites/actions/unshare-file.test.ts b/e2e/suites/actions/unshare-file.test.ts index 4c7021768..917f8d903 100755 --- a/e2e/suites/actions/unshare-file.test.ts +++ b/e2e/suites/actions/unshare-file.test.ts @@ -26,6 +26,7 @@ import { browser } from 'protractor'; import { AdminActions, + UserActions, LoginPage, BrowsingPage, SITE_VISIBILITY, @@ -54,10 +55,15 @@ describe('Unshare a file', () => { const confirmDialog = new ConfirmDialog(); const contextMenu = dataTable.menu; const viewer = new Viewer(); + const adminApiActions = new AdminActions(); + const userActions = new UserActions(); beforeAll(async (done) => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); + await userActions.login(username, username); + parentId = (await apis.user.nodes.createFolder(parent)).entry.id; await loginPage.loginWith(username); done(); @@ -85,10 +91,8 @@ describe('Unshare a file', () => { file3Id = (await apis.user.nodes.createFile(file3, parentId)).entry.id; file4Id = (await apis.user.nodes.createFile(file4, parentId)).entry.id; initialSharedTotalItems = await apis.user.shared.getSharedLinksTotalItems(); - await apis.user.shared.shareFileById(file1Id); - await apis.user.shared.shareFileById(file2Id); - await apis.user.shared.shareFileById(file3Id); - await apis.user.shared.shareFileById(file4Id); + + await userActions.shareNodes([file1Id, file2Id, file3Id, file4Id]); await apis.user.shared.waitForApi({ expect: initialSharedTotalItems + 4 }); done(); }); @@ -213,10 +217,8 @@ describe('Unshare a file', () => { file3Id = (await apis.user.nodes.createFile(file3, parentInSiteId)).entry.id; file4Id = (await apis.user.nodes.createFile(file4, parentInSiteId)).entry.id; initialSharedTotalItems = await apis.user.shared.getSharedLinksTotalItems(); - await apis.user.shared.shareFileById(file1Id); - await apis.user.shared.shareFileById(file2Id); - await apis.user.shared.shareFileById(file3Id); - await apis.user.shared.shareFileById(file4Id); + + await userActions.shareNodes([file1Id, file2Id, file3Id, file4Id]); await apis.user.shared.waitForApi({ expect: initialSharedTotalItems + 4 }); done(); }); @@ -333,10 +335,8 @@ describe('Unshare a file', () => { file4Id = (await apis.user.nodes.createFile(file4, parentId)).entry.id; initialSharedTotalItems = await apis.user.shared.getSharedLinksTotalItems(); - await apis.user.shared.shareFileById(file1Id); - await apis.user.shared.shareFileById(file2Id); - await apis.user.shared.shareFileById(file3Id); - await apis.user.shared.shareFileById(file4Id); + + await userActions.shareNodes([file1Id, file2Id, file3Id, file4Id]); await apis.user.shared.waitForApi({ expect: initialSharedTotalItems + 4 }); done(); }); @@ -452,10 +452,8 @@ describe('Unshare a file', () => { file4Id = (await apis.user.nodes.createFile(file4, parentId)).entry.id; initialSharedTotalItems = await apis.user.shared.getSharedLinksTotalItems(); - await apis.user.shared.shareFileById(file1Id); - await apis.user.shared.shareFileById(file2Id); - await apis.user.shared.shareFileById(file3Id); - await apis.user.shared.shareFileById(file4Id); + + await userActions.shareNodes([file1Id, file2Id, file3Id, file4Id]); await apis.user.shared.waitForApi({ expect: initialSharedTotalItems + 4 }); done(); }); @@ -571,10 +569,8 @@ describe('Unshare a file', () => { file4Id = (await apis.user.nodes.createFile(file4, parentId)).entry.id; initialSharedTotalItems = await apis.user.shared.getSharedLinksTotalItems(); - await apis.user.shared.shareFileById(file1Id); - await apis.user.shared.shareFileById(file2Id); - await apis.user.shared.shareFileById(file3Id); - await apis.user.shared.shareFileById(file4Id); + + await userActions.shareNodes([file1Id, file2Id, file3Id, file4Id]); await apis.user.favorites.addFavoriteById('file', file1Id); await apis.user.favorites.addFavoriteById('file', file2Id); @@ -709,12 +705,8 @@ describe('Unshare a file', () => { await adminApiActions.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_CONSUMER.ROLE); const initialSharedTotalItems = await apis.user.shared.getSharedLinksTotalItems(); - await adminApiActions.shared.shareFileById(file1FileLibId); - await apis.user.shared.shareFileById(file2FileLibId); - await adminApiActions.shared.shareFileById(file1SharedId); - await apis.user.shared.shareFileById(file2SharedId); - await adminApiActions.shared.shareFileById(file1FavId); - await apis.user.shared.shareFileById(file2FavId); + await adminApiActions.shareNodes([file1FileLibId, file1SharedId, file1FavId]); + await userActions.shareNodes([file2FileLibId, file2SharedId, file2FavId]); await apis.user.favorites.addFavoriteById('file', file1FavId); await apis.user.favorites.addFavoriteById('file', file2FavId); diff --git a/e2e/suites/info-drawer/comments.test.ts b/e2e/suites/info-drawer/comments.test.ts index 644332cb3..1a03ff53f 100755 --- a/e2e/suites/info-drawer/comments.test.ts +++ b/e2e/suites/info-drawer/comments.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { AdminActions, LoginPage, BrowsingPage, RepoClient, InfoDrawer, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, UserActions, LoginPage, BrowsingPage, RepoClient, InfoDrawer, Utils } from '@alfresco/aca-testing-shared'; const moment = require('moment'); describe('Comments', () => { @@ -63,10 +63,14 @@ describe('Comments', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable } = page; + const adminApiActions = new AdminActions(); + const userActions = new UserActions(); beforeAll(async (done) => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); + await userActions.login(username, username); parentId = (await apis.user.nodes.createFolder(parent)).entry.id; @@ -79,8 +83,8 @@ describe('Comments', () => { fileWith1CommentId = (await apis.user.nodes.createFile(fileWith1Comment, parentId)).entry.id; fileWith2CommentsId = (await apis.user.nodes.createFile(fileWith2Comments, parentId)).entry.id; - comment1File2Entry = (await apis.user.comments.addComment(fileWith2CommentsId, 'first comment')).entry; - comment2File2Entry = (await apis.user.comments.addComment(fileWith2CommentsId, 'second comment')).entry; + comment1File2Entry = await userActions.createComment(fileWith2CommentsId, 'first comment'); + comment2File2Entry = await userActions.createComment(fileWith2CommentsId, 'second comment'); const initialSharedTotalItems = await apis.user.shared.getSharedLinksTotalItems(); await apis.user.shared.shareFilesByIds([file2SharedId, fileWith1CommentId, fileWith2CommentsId]); @@ -97,7 +101,7 @@ describe('Comments', () => { }); afterAll(async (done) => { - await apis.user.nodes.deleteNodeById(parentId); + await userActions.deleteNodes([parentId]); done(); }); @@ -351,7 +355,7 @@ describe('Comments', () => { describe('Comment info display', () => { beforeAll(async (done) => { - commentFile1Entry = (await apis.user.comments.addComment(fileWith1CommentId, 'this is my comment')).entry; + commentFile1Entry = await userActions.createComment(fileWith1CommentId, 'this is my comment'); await apis.user.favorites.waitForApi({ expect: 4 }); await apis.user.search.waitForApi(username, { expect: 7 }); diff --git a/e2e/suites/list-views/favorites.test.ts b/e2e/suites/list-views/favorites.test.ts index 99837963a..ae5df3936 100755 --- a/e2e/suites/list-views/favorites.test.ts +++ b/e2e/suites/list-views/favorites.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { AdminActions, SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; +import { AdminActions, UserActions, SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('Favorites', () => { const username = `user-${Utils.random()}`; @@ -43,10 +43,14 @@ describe('Favorites', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable, breadcrumb } = page; + const adminApiActions = new AdminActions(); + const userActions = new UserActions(); beforeAll(async (done) => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); + await userActions.login(username, username); await adminApiActions.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC); const docLibId = await adminApiActions.sites.getDocLibId(siteName); @@ -64,10 +68,9 @@ describe('Favorites', () => { await apis.user.favorites.addFavoriteById('file', file2Id); await apis.user.favorites.addFavoriteById('file', file3Id); await apis.user.favorites.addFavoriteById('file', file4Id); - await apis.user.nodes.deleteNodeById(file3Id, false); - await apis.user.nodes.deleteNodeById(file4Id, false); - await apis.user.trashcan.restore(file4Id); + await userActions.deleteNodes([file3Id, file4Id], false); + await userActions.trashcanApi.restoreDeletedNode(file4Id); await loginPage.loginWith(username); done(); }); @@ -78,9 +81,9 @@ describe('Favorites', () => { }); afterAll(async (done) => { - await adminApiActions.sites.deleteSite(siteName); - await apis.user.nodes.deleteNodes([favFolderName, parentFolder]); - await apis.user.trashcan.emptyTrash(); + await adminApiActions.deleteSites([siteName]); + await userActions.deleteNodes([favFolderName, parentFolder]); + await userActions.emptyTrashcan(); done(); }); diff --git a/e2e/suites/list-views/generic-errors.test.ts b/e2e/suites/list-views/generic-errors.test.ts index 3f6861d8d..5e22641c0 100755 --- a/e2e/suites/list-views/generic-errors.test.ts +++ b/e2e/suites/list-views/generic-errors.test.ts @@ -24,7 +24,7 @@ */ import { browser } from 'protractor'; -import { AdminActions, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; +import { AdminActions, UserActions, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('Generic errors', () => { const username = `user-${Utils.random()}`; @@ -43,11 +43,16 @@ describe('Generic errors', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable } = page; + const adminApiActions = new AdminActions(); + const userActions = new UserActions(); beforeAll(async (done) => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); await adminApiActions.createUser({ username: username2 }); + await userActions.login(username, username); + parentId = (await apis.user.nodes.createFolder(parent)).entry.id; file1Id = (await apis.user.nodes.createFile(file1, parentId)).entry.id; await apis.user.nodes.createFile(file2, parentId); @@ -57,8 +62,8 @@ describe('Generic errors', () => { }); afterAll(async (done) => { - await apis.user.nodes.deleteNodeById(parentId); - await apis.user.trashcan.emptyTrash(); + await userActions.deleteNodes([parentId]); + await userActions.emptyTrashcan(); done(); }); diff --git a/e2e/suites/list-views/permissions.test.ts b/e2e/suites/list-views/permissions.test.ts index 4b83cce03..8867ea272 100755 --- a/e2e/suites/list-views/permissions.test.ts +++ b/e2e/suites/list-views/permissions.test.ts @@ -23,26 +23,29 @@ * along with Alfresco. If not, see . */ -import { AdminActions, SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; +import { AdminActions, UserActions, SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('Special permissions', () => { const username = `user-${Utils.random()}`; - const password = username; const apis = { - user: new RepoClient(username, password) + user: new RepoClient(username, username) }; const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable } = page; const { searchInput } = page.header; + const adminApiActions = new AdminActions(); + const userActions = new UserActions(); let initialSharedTotalItems: number; beforeAll(async (done) => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); + await userActions.login(username, username); done(); }); @@ -60,7 +63,7 @@ describe('Special permissions', () => { initialSharedTotalItems = await apis.user.shared.getSharedLinksTotalItems(); - await adminApiActions.shared.shareFileById(fileId); + await adminApiActions.shareNodes([fileId]); await apis.user.nodes.editNodeContent(fileId, 'edited by user'); await apis.user.search.waitForApi(username, { expect: 1 }); @@ -134,7 +137,7 @@ describe('Special permissions', () => { await apis.user.favorites.addFavoriteById('file', fileId); initialSharedTotalItems = await apis.user.shared.getSharedLinksTotalItems(); - await apis.user.shared.shareFileById(fileId); + await userActions.shareNodes([fileId]); await apis.user.shared.waitForApi({ expect: initialSharedTotalItems + 1 }); await apis.user.search.waitForApi(username, { expect: 1 }); diff --git a/e2e/suites/list-views/recent-files.test.ts b/e2e/suites/list-views/recent-files.test.ts index b67336505..690062536 100755 --- a/e2e/suites/list-views/recent-files.test.ts +++ b/e2e/suites/list-views/recent-files.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { AdminActions, SITE_VISIBILITY, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; +import { AdminActions, UserActions, SITE_VISIBILITY, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('Recent Files', () => { const username = `user-${Utils.random()}`; @@ -47,15 +47,20 @@ describe('Recent Files', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable, breadcrumb } = page; + const adminApiActions = new AdminActions(); + const userActions = new UserActions(); beforeAll(async (done) => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); + await userActions.login(username, 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; - await apis.user.nodes.deleteNodeById(id, false); + await userActions.deleteNodes([id], false); await apis.user.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC); const docLibId = await apis.user.sites.getDocLibId(siteName); @@ -74,9 +79,9 @@ describe('Recent Files', () => { }); afterAll(async (done) => { - await apis.user.nodes.deleteNodesById([folderId, file2Id]); - await apis.user.sites.deleteSite(siteName); - await apis.user.trashcan.emptyTrash(); + await userActions.deleteNodes([folderId, file2Id]); + await userActions.deleteSites([siteName]); + await userActions.emptyTrashcan(); done(); }); diff --git a/e2e/suites/list-views/shared-files.test.ts b/e2e/suites/list-views/shared-files.test.ts index 1acce20a9..0c92a180d 100755 --- a/e2e/suites/list-views/shared-files.test.ts +++ b/e2e/suites/list-views/shared-files.test.ts @@ -70,7 +70,7 @@ describe('Shared Files', () => { initialSharedTotalItems = await apis.user.shared.getSharedLinksTotalItems(); await apis.user.shared.shareFilesByIds([file1Id, file2Id, file3Id, file4Id]); - await adminApiActions.shared.shareFileById(nodeId); + await adminApiActions.shareNodes([nodeId]); await apis.user.shared.waitForApi({ expect: initialSharedTotalItems + 5 }); await apis.user.nodes.deleteNodeById(file2Id); diff --git a/e2e/suites/list-views/tooltips.test.ts b/e2e/suites/list-views/tooltips.test.ts index 0e7a1e369..52807b056 100755 --- a/e2e/suites/list-views/tooltips.test.ts +++ b/e2e/suites/list-views/tooltips.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { AdminActions, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; +import { AdminActions, UserActions, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('File / folder tooltips', () => { const username = `user-${Utils.random()}`; @@ -50,10 +50,15 @@ describe('File / folder tooltips', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable } = page; + const adminApiActions = new AdminActions(); + const userActions = new UserActions(); beforeAll(async (done) => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); + await userActions.login(username, username); + parentId = (await apis.user.nodes.createFolder(parent)).entry.id; file1Id = (await apis.user.nodes.createFile(file, parentId)).entry.id; @@ -77,7 +82,8 @@ describe('File / folder tooltips', () => { }); afterAll(async (done) => { - await Promise.all([apis.user.nodes.deleteNodes([parent]), apis.user.trashcan.emptyTrash()]); + await userActions.deleteNodes([parent]); + await userActions.emptyTrashcan(); done(); }); @@ -267,8 +273,8 @@ describe('File / folder tooltips', () => { }); afterAll(async (done) => { - await apis.user.nodes.deleteNodes([parentForTrash]); - await apis.user.trashcan.emptyTrash(); + await userActions.deleteNodes([parentForTrash]); + await userActions.emptyTrashcan(); done(); }); diff --git a/e2e/suites/list-views/trash.test.ts b/e2e/suites/list-views/trash.test.ts index e61efd3f0..80bdec1fa 100755 --- a/e2e/suites/list-views/trash.test.ts +++ b/e2e/suites/list-views/trash.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { AdminActions, SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; +import { AdminActions, UserActions, SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('Trash', () => { const username = `user-${Utils.random()}`; @@ -59,10 +59,15 @@ describe('Trash', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable, breadcrumb } = page; + const adminApiActions = new AdminActions(); + const userActions = new UserActions(); beforeAll(async () => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); + await userActions.login(username, username); + fileAdminId = (await adminApiActions.nodes.createFiles([fileAdmin])).entry.id; folderAdminId = (await adminApiActions.nodes.createFolders([folderAdmin])).entry.id; await adminApiActions.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC); @@ -83,13 +88,11 @@ describe('Trash', () => { }); afterAll(async (done) => { - await Promise.all([ - adminApiActions.sites.deleteSite(siteName), - adminApiActions.trashcan.permanentlyDelete(fileAdminId), - adminApiActions.trashcan.permanentlyDelete(folderAdminId), - apis.user.nodes.deleteNodeById(folderNotDeletedId), - apis.user.trashcan.emptyTrash() - ]); + await adminApiActions.sites.deleteSite(siteName); + await adminApiActions.trashcanApi.deleteDeletedNode(fileAdminId); + await adminApiActions.trashcanApi.deleteDeletedNode(folderAdminId); + await apis.user.nodes.deleteNodeById(folderNotDeletedId); + await userActions.emptyTrashcan(); done(); }); diff --git a/e2e/suites/navigation/single-click.test.ts b/e2e/suites/navigation/single-click.test.ts index 15281c5c6..269ddae7d 100755 --- a/e2e/suites/navigation/single-click.test.ts +++ b/e2e/suites/navigation/single-click.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { AdminActions, LoginPage, BrowsingPage, Viewer, RepoClient, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, UserActions, LoginPage, BrowsingPage, Viewer, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Single click on item name', () => { const username = `user-${Utils.random()}`; @@ -50,17 +50,22 @@ describe('Single click on item name', () => { const { dataTable, breadcrumb } = page; const viewer = new Viewer(); const { searchInput } = page.header; + const adminApiActions = new AdminActions(); + const userActions = new UserActions(); beforeAll(async (done) => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); + await userActions.login(username, username); + file1Id = (await apis.user.nodes.createFile(file1)).entry.id; folder1Id = (await apis.user.nodes.createFolder(folder1)).entry.id; deletedFile1Id = (await apis.user.nodes.createFile(deletedFile1)).entry.id; deletedFolder1Id = (await apis.user.nodes.createFolder(deletedFolder1)).entry.id; - await apis.user.nodes.deleteNodeById(deletedFile1Id, false); - await apis.user.nodes.deleteNodeById(deletedFolder1Id, false); + + await userActions.deleteNodes([deletedFile1Id, deletedFolder1Id], false); await apis.user.sites.createSite(siteName); const docLibId = await apis.user.sites.getDocLibId(siteName); @@ -71,10 +76,9 @@ describe('Single click on item name', () => { }); afterAll(async () => { - await apis.user.sites.deleteSite(siteName); - await apis.user.nodes.deleteNodeById(folder1Id); - await apis.user.nodes.deleteNodeById(file1Id); - await apis.user.trashcan.emptyTrash(); + await userActions.deleteSites([siteName]); + await userActions.deleteNodes([folder1Id, file1Id]); + await userActions.emptyTrashcan(); }); it('[C284899] Hyperlink does not appear for items in the Trash', async () => { @@ -128,7 +132,7 @@ describe('Single click on item name', () => { describe('on Shared Files', () => { beforeAll(async () => { const initialSharedTotalItems = await apis.user.shared.getSharedLinksTotalItems(); - await apis.user.shared.shareFileById(file1Id); + await userActions.shareNodes([file1Id]); await apis.user.shared.waitForApi({ expect: initialSharedTotalItems + 1 }); }); diff --git a/e2e/suites/pagination/multiple-pages-trash.test.ts b/e2e/suites/pagination/multiple-pages-trash.test.ts index 3f3093d02..959a5c9f0 100755 --- a/e2e/suites/pagination/multiple-pages-trash.test.ts +++ b/e2e/suites/pagination/multiple-pages-trash.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { LoginPage, BrowsingPage, Utils, AdminActions, RepoClient } from '@alfresco/aca-testing-shared'; +import { LoginPage, BrowsingPage, Utils, AdminActions, UserActions, RepoClient } from '@alfresco/aca-testing-shared'; describe('Pagination on multiple pages on Trash', () => { const random = Utils.random(); @@ -36,17 +36,21 @@ describe('Pagination on multiple pages on Trash', () => { const userApi = new RepoClient(username, username); const adminApiActions = new AdminActions(); + const userActions = new UserActions(); const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable, pagination } = page; beforeAll(async () => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); + await userActions.login(username, username); + 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 userActions.deleteNodes(filesDeletedIds, false); + await userActions.waitForTrashcanSize(101); await loginPage.loginWith(username); await page.clickTrashAndWait(); @@ -57,7 +61,7 @@ describe('Pagination on multiple pages on Trash', () => { }); afterAll(async () => { - await userApi.trashcan.emptyTrash(); + await userActions.emptyTrashcan(); }); it('[C280122] Pagination control default values', async () => { diff --git a/e2e/suites/pagination/single-page.test.ts b/e2e/suites/pagination/single-page.test.ts index cd3ab7623..b7066e2b1 100755 --- a/e2e/suites/pagination/single-page.test.ts +++ b/e2e/suites/pagination/single-page.test.ts @@ -23,7 +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, UserActions, RepoClient } from '@alfresco/aca-testing-shared'; describe('Pagination on single page', () => { const random = Utils.random(); @@ -40,6 +40,7 @@ describe('Pagination on single page', () => { const userApi = new RepoClient(username, username); const adminApiActions = new AdminActions(); + const userActions = new UserActions(); const loginPage = new LoginPage(); const page = new BrowsingPage(); @@ -48,12 +49,14 @@ describe('Pagination on single page', () => { const searchResultsPage = new SearchResultsPage(); beforeAll(async () => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); + await userActions.login(username, username); const initialFavoriteTotalItems = await userApi.favorites.getFavoritesTotalItems(); const initialRecentFilesTotalItems = await userApi.search.getTotalItems(username); const initialSharedTotalItems = await userApi.shared.getSharedLinksTotalItems(); - const initialTrashTotalItems = await userApi.trashcan.getDeletedNodesTotalItems(); + const initialTrashTotalItems = await userActions.getTrashcanSize(); fileId = (await userApi.nodes.createFile(file)).entry.id; fileInTrashId = (await userApi.nodes.createFile(fileInTrash)).entry.id; @@ -61,20 +64,20 @@ describe('Pagination on single page', () => { await userApi.nodes.deleteNodeById(fileInTrashId, false); await userApi.favorites.addFavoriteById('file', fileId); - await userApi.shared.shareFileById(fileId); + await userActions.shareNodes([fileId]); - await Promise.all([ - userApi.favorites.waitForApi({ expect: initialFavoriteTotalItems + 2 }), - userApi.search.waitForApi(username, { expect: initialRecentFilesTotalItems + 1 }), - userApi.shared.waitForApi({ expect: initialSharedTotalItems + 1 }), - userApi.trashcan.waitForApi({ expect: initialTrashTotalItems + 1 }) - ]); + await userApi.favorites.waitForApi({ expect: initialFavoriteTotalItems + 2 }); + await userApi.search.waitForApi(username, { expect: initialRecentFilesTotalItems + 1 }); + await userApi.shared.waitForApi({ expect: initialSharedTotalItems + 1 }); + await userActions.waitForTrashcanSize(initialTrashTotalItems + 1); await loginPage.loginWith(username); }); afterAll(async () => { - await Promise.all([userApi.nodes.deleteNodeById(fileId), userApi.sites.deleteSite(siteId), userApi.trashcan.emptyTrash()]); + await userActions.deleteNodes([fileId]); + await userActions.deleteSites([siteId]); + await userActions.emptyTrashcan(); }); it('[C280112] page selector not displayed on Favorites', async () => { diff --git a/e2e/suites/viewer/viewer-actions.test.ts b/e2e/suites/viewer/viewer-actions.test.ts index f708c6926..60b8feb7c 100755 --- a/e2e/suites/viewer/viewer-actions.test.ts +++ b/e2e/suites/viewer/viewer-actions.test.ts @@ -25,6 +25,7 @@ import { AdminActions, + UserActions, LoginPage, BrowsingPage, FILES, @@ -59,9 +60,12 @@ describe('Viewer actions', () => { const manageVersionsDialog = new ManageVersionsDialog(); const uploadNewVersionDialog = new UploadNewVersionDialog(); const adminApiActions = new AdminActions(); + const userActions = new UserActions(); beforeAll(async (done) => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); + await userActions.login(username, username); done(); }); @@ -125,9 +129,8 @@ describe('Viewer actions', () => { }); afterAll(async (done) => { - await apis.user.nodes.deleteNodeById(parentId); - await apis.user.nodes.deleteNodeById(destinationId); - await apis.user.trashcan.emptyTrash(); + await userActions.deleteNodes([parentId, destinationId]); + await userActions.emptyTrashcan(); done(); }); @@ -354,9 +357,9 @@ describe('Viewer actions', () => { }); afterAll(async (done) => { - await apis.user.sites.deleteSite(siteName); - await apis.user.nodes.deleteNodeById(destinationId); - await apis.user.trashcan.emptyTrash(); + await userActions.deleteSites([siteName]); + await userActions.deleteNodes([destinationId]); + await userActions.emptyTrashcan(); done(); }); @@ -542,9 +545,8 @@ describe('Viewer actions', () => { }); afterAll(async (done) => { - await apis.user.nodes.deleteNodeById(parentId); - await apis.user.nodes.deleteNodeById(destinationId); - await apis.user.trashcan.emptyTrash(); + await userActions.deleteNodes([parentId, destinationId]); + await userActions.emptyTrashcan(); done(); }); @@ -741,9 +743,8 @@ describe('Viewer actions', () => { }); afterAll(async (done) => { - await apis.user.nodes.deleteNodeById(parentId); - await apis.user.nodes.deleteNodeById(destinationId); - await apis.user.trashcan.emptyTrash(); + await userActions.deleteNodes([parentId, destinationId]); + await userActions.emptyTrashcan(); done(); }); @@ -937,9 +938,8 @@ describe('Viewer actions', () => { }); afterAll(async (done) => { - await apis.user.nodes.deleteNodeById(parentId); - await apis.user.nodes.deleteNodeById(destinationId); - await apis.user.trashcan.emptyTrash(); + await userActions.deleteNodes([parentId, destinationId]); + await userActions.emptyTrashcan(); done(); }); diff --git a/e2e/suites/viewer/viewer-general.test.ts b/e2e/suites/viewer/viewer-general.test.ts index a2aa468d4..271dea565 100755 --- a/e2e/suites/viewer/viewer-general.test.ts +++ b/e2e/suites/viewer/viewer-general.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { AdminActions, LoginPage, BrowsingPage, FILES, SITE_VISIBILITY, RepoClient, Utils, Viewer } from '@alfresco/aca-testing-shared'; +import { AdminActions, UserActions, LoginPage, BrowsingPage, FILES, SITE_VISIBILITY, RepoClient, Utils, Viewer } from '@alfresco/aca-testing-shared'; describe('Viewer general', () => { const username = `user-${Utils.random()}`; @@ -52,10 +52,15 @@ describe('Viewer general', () => { const { dataTable } = page; const viewer = new Viewer(); const { searchInput } = page.header; + const adminApiActions = new AdminActions(); + const userActions = new UserActions(); beforeAll(async (done) => { + await adminApiActions.login(); await adminApiActions.createUser({ username }); + await userActions.login(username, username); + parentId = (await apis.user.nodes.createFolder(parent)).entry.id; xlsxFileId = (await apis.user.upload.uploadFile(xlsxFile, parentId)).entry.id; @@ -68,7 +73,7 @@ describe('Viewer general', () => { await apis.user.upload.uploadFile(fileInSite, docLibSiteUserId); const initialSharedTotalItems = await apis.user.shared.getSharedLinksTotalItems(); - await apis.user.shared.shareFileById(xlsxFileId); + await userActions.shareNodes([xlsxFileId]); await apis.user.favorites.addFavoriteById('file', xlsxFileId); await apis.user.favorites.waitForApi({ expect: 2 }); diff --git a/projects/aca-testing-shared/src/utilities/admin-actions.ts b/projects/aca-testing-shared/src/utilities/admin-actions.ts index 2343fe0aa..055b7240c 100755 --- a/projects/aca-testing-shared/src/utilities/admin-actions.ts +++ b/projects/aca-testing-shared/src/utilities/admin-actions.ts @@ -23,26 +23,14 @@ * along with Alfresco. If not, see . */ -import { RepoClient } from './repo-client/repo-client'; import { PersonEntry, NodeEntry, PeopleApi } from '@alfresco/js-api'; -import { - PersonModel, - SitesApi, - UploadApi, - NodesApi, - FavoritesApi, - SearchApi, - NodeContentTree, - Person, - SharedLinksApi, - TrashcanApi -} from './repo-client/apis'; - -export class AdminActions { - private adminApi: RepoClient; +import { PersonModel, SitesApi, UploadApi, NodesApi, FavoritesApi, SearchApi, NodeContentTree, Person, SharedLinksApi } from './repo-client/apis'; +import { UserActions } from './user-actions'; +import { browser } from 'protractor'; +export class AdminActions extends UserActions { constructor() { - this.adminApi = new RepoClient(); + super(); } sites: SitesApi = new SitesApi(); @@ -51,78 +39,81 @@ export class AdminActions { favorites: FavoritesApi = new FavoritesApi(); search: SearchApi = new SearchApi(); shared: SharedLinksApi = new SharedLinksApi(); - trashcan: TrashcanApi = new TrashcanApi(); + + async login(username?: string, password?: string) { + return super.login(username || browser.params.ADMIN_USERNAME, password || browser.params.ADMIN_PASSWORD); + } async getDataDictionaryId(): Promise { - return this.adminApi.nodes.getNodeIdFromParent('Data Dictionary', '-root-'); + return this.nodes.getNodeIdFromParent('Data Dictionary', '-root-'); } async getNodeTemplatesFolderId(): Promise { - return this.adminApi.nodes.getNodeIdFromParent('Node Templates', await this.getDataDictionaryId()); + return this.nodes.getNodeIdFromParent('Node Templates', await this.getDataDictionaryId()); } async getSpaceTemplatesFolderId(): Promise { - return this.adminApi.nodes.getNodeIdFromParent('Space Templates', await this.getDataDictionaryId()); + return this.nodes.getNodeIdFromParent('Space Templates', await this.getDataDictionaryId()); } async createUser(user: PersonModel): Promise { const person = new Person(user); - const peopleApi = new PeopleApi(this.adminApi.alfrescoApi); + const peopleApi = new PeopleApi(this.alfrescoApi); - await this.adminApi.apiAuth(); + await this.login(); return peopleApi.createPerson(person); } async disableUser(username: string): Promise { - const peopleApi = new PeopleApi(this.adminApi.alfrescoApi); + const peopleApi = new PeopleApi(this.alfrescoApi); - await this.adminApi.apiAuth(); + await this.login(); return peopleApi.updatePerson(username, { enabled: false }); } async changePassword(username: string, newPassword: string): Promise { - const peopleApi = new PeopleApi(this.adminApi.alfrescoApi); + const peopleApi = new PeopleApi(this.alfrescoApi); - await this.adminApi.apiAuth(); + await this.login(); return peopleApi.updatePerson(username, { password: newPassword }); } 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.nodes.createFile(name, templatesRootFolderId, title, description, author); } async createNodeTemplatesHierarchy(hierarchy: NodeContentTree): Promise { - return this.adminApi.nodes.createContent(hierarchy, `Data Dictionary/Node Templates`); + return this.nodes.createContent(hierarchy, `Data Dictionary/Node Templates`); } 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.nodes.createFolder(name, templatesRootFolderId, title, description); } async createSpaceTemplatesHierarchy(hierarchy: NodeContentTree): Promise { - return this.adminApi.nodes.createContent(hierarchy, `Data Dictionary/Space Templates`); + return this.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.nodes.getNodeIdFromParent(nodeName, templatesRootFolderId); - return this.adminApi.nodes.setInheritPermissions(nodeId, false); + return this.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.nodes.getNodeIdFromParent(nodeName, templatesRootFolderId); - return this.adminApi.nodes.setInheritPermissions(nodeId, false); + return this.nodes.setInheritPermissions(nodeId, false); } async cleanupNodeTemplatesFolder(): Promise { - return this.adminApi.nodes.deleteNodeChildren(await this.getNodeTemplatesFolderId()); + return this.nodes.deleteNodeChildren(await this.getNodeTemplatesFolderId()); } async cleanupSpaceTemplatesFolder(): Promise { @@ -130,14 +121,14 @@ 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 + const nodesToDelete = (await this.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); + return this.nodes.deleteNodesById(nodesToDelete); } async createLinkToFileId(originalFileId: string, destinationParentId: string): Promise { - return this.adminApi.nodes.createFileLink(originalFileId, destinationParentId); + return this.nodes.createFileLink(originalFileId, destinationParentId); } async createLinkToFileName(originalFileName: string, originalFileParentId: string, destinationParentId?: string): Promise { @@ -145,13 +136,13 @@ export class AdminActions { destinationParentId = originalFileParentId; } - const nodeId = await this.adminApi.nodes.getNodeIdFromParent(originalFileName, originalFileParentId); + const nodeId = await this.nodes.getNodeIdFromParent(originalFileName, originalFileParentId); return this.createLinkToFileId(nodeId, destinationParentId); } async createLinkToFolderId(originalFolderId: string, destinationParentId: string): Promise { - return this.adminApi.nodes.createFolderLink(originalFolderId, destinationParentId); + return this.nodes.createFolderLink(originalFolderId, destinationParentId); } async createLinkToFolderName(originalFolderName: string, originalFolderParentId: string, destinationParentId?: string): Promise { @@ -159,7 +150,7 @@ export class AdminActions { destinationParentId = originalFolderParentId; } - const nodeId = await this.adminApi.nodes.getNodeIdFromParent(originalFolderName, originalFolderParentId); + const nodeId = await this.nodes.getNodeIdFromParent(originalFolderName, originalFolderParentId); return this.createLinkToFolderId(nodeId, destinationParentId); } diff --git a/projects/aca-testing-shared/src/utilities/index.ts b/projects/aca-testing-shared/src/utilities/index.ts index 7d68b2f7f..31ffe1455 100644 --- a/projects/aca-testing-shared/src/utilities/index.ts +++ b/projects/aca-testing-shared/src/utilities/index.ts @@ -26,5 +26,6 @@ export * from './repo-client/apis'; export * from './repo-client/repo-client'; export * from './admin-actions'; +export * from './user-actions'; export * from './browser-utils'; export * from './utils'; 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 deleted file mode 100755 index d2f44b863..000000000 --- a/projects/aca-testing-shared/src/utilities/repo-client/apis/comments/comments-api.ts +++ /dev/null @@ -1,45 +0,0 @@ -/*! - * @license - * Alfresco Example Content Application - * - * Copyright (C) 2005 - 2020 Alfresco Software Limited - * - * This file is part of the Alfresco Example Content Application. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * The Alfresco Example Content Application is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * The Alfresco Example Content Application is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -import { RepoApi } from '../repo-api'; -import { CommentsApi as AdfCommentsApi } from '@alfresco/js-api'; - -export class CommentsApi extends RepoApi { - commentsApi = new AdfCommentsApi(this.alfrescoJsApi); - - constructor(username?: string, password?: string) { - super(username, password); - } - - async addComment(nodeId: string, comment: string) { - try { - await this.apiAuth(); - return await this.commentsApi.createComment(nodeId, { content: comment }); - } catch (error) { - this.handleError(`${this.constructor.name} ${this.addComment.name}`, error); - return null; - } - } -} diff --git a/projects/aca-testing-shared/src/utilities/repo-client/apis/index.ts b/projects/aca-testing-shared/src/utilities/repo-client/apis/index.ts index ed4e64b1b..865f7a53a 100644 --- a/projects/aca-testing-shared/src/utilities/repo-client/apis/index.ts +++ b/projects/aca-testing-shared/src/utilities/repo-client/apis/index.ts @@ -23,7 +23,6 @@ * along with Alfresco. If not, see . */ -export * from './comments/comments-api'; export * from './favorites/favorites-api'; export * from './nodes/node-body-create'; export * from './nodes/node-content-tree'; @@ -33,6 +32,5 @@ export * from './queries/queries-api'; export * from './search/search-api'; export * from './shared-links/shared-links-api'; export * from './sites/sites-api'; -export * from './trashcan/trashcan-api'; export * from './upload/upload-api'; export * from './repo-api'; 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 342176b91..9066372d8 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 @@ -480,6 +480,7 @@ export class NodesApi extends RepoApi { } } + /* @deprecated check {UserActions.unlockNodes} instead. */ async unlockFile(nodeId: string): Promise { try { await this.apiAuth(); 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 057654be5..30b785a2b 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 @@ -164,13 +164,12 @@ export class SitesApi extends RepoApi { } async deleteSites(siteIds: string[], permanent: boolean = true) { - try { - return siteIds.reduce(async (previous, current) => { - await previous; - return this.deleteSite(current, permanent); - }, Promise.resolve()); - } catch (error) { - this.handleError(`SitesApi deleteSites : catch : `, error); + if (siteIds && siteIds.length > 0) { + await this.apiAuth(); + + for (const siteId of siteIds) { + await this.sitesApi.deleteSite(siteId, { permanent }); + } } } 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 deleted file mode 100644 index 8f5c59caf..000000000 --- a/projects/aca-testing-shared/src/utilities/repo-client/apis/trashcan/trashcan-api.ts +++ /dev/null @@ -1,113 +0,0 @@ -/*! - * @license - * Alfresco Example Content Application - * - * Copyright (C) 2005 - 2020 Alfresco Software Limited - * - * This file is part of the Alfresco Example Content Application. - * If the software was purchased under a paid Alfresco license, the terms of - * the paid license agreement will prevail. Otherwise, the software is - * provided under the following open source license terms: - * - * The Alfresco Example Content Application is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * The Alfresco Example Content Application is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Alfresco. If not, see . - */ - -import { RepoApi } from '../repo-api'; -import { Logger } from '@alfresco/adf-testing'; -import { Utils } from '../../../../utilities/utils'; -import { TrashcanApi as AdfTrashcanApi } from '@alfresco/js-api'; - -export class TrashcanApi extends RepoApi { - trashcanApi = new AdfTrashcanApi(this.alfrescoJsApi); - - constructor(username?: string, password?: string) { - super(username, password); - } - - async permanentlyDelete(id: string) { - try { - await this.apiAuth(); - return await this.trashcanApi.deleteDeletedNode(id); - } catch (error) { - this.handleError(`TrashcanApi permanentlyDelete : catch : `, error); - } - } - - async restore(id: string) { - try { - await this.apiAuth(); - return await this.trashcanApi.restoreDeletedNode(id); - } catch (error) { - this.handleError(`TrashcanApi restore : catch : `, error); - return null; - } - } - - async getDeletedNodes() { - const opts = { - maxItems: 1000 - }; - try { - await this.apiAuth(); - return await this.trashcanApi.listDeletedNodes(opts); - } catch (error) { - this.handleError(`TrashcanApi getDeletedNodes : catch : `, error); - return null; - } - } - - async getDeletedNodesTotalItems(): Promise { - const opts = { - maxItems: 1000 - }; - try { - await this.apiAuth(); - return (await this.trashcanApi.listDeletedNodes(opts)).list.pagination.totalItems; - } catch (error) { - this.handleError(`TrashcanApi getDeletedNodesTotalItems : catch : `, error); - return -1; - } - } - - async emptyTrash() { - try { - 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(`TrashcanApi emptyTrash : catch : `, error); - } - } - - async waitForApi(data: { expect: number }) { - try { - const deletedFiles = async () => { - const totalItems = await this.getDeletedNodesTotalItems(); - if (totalItems !== data.expect) { - return Promise.reject(totalItems); - } else { - return Promise.resolve(totalItems); - } - }; - - return await Utils.retryCall(deletedFiles); - } catch (error) { - Logger.error(`TrashcanApi waitForApi : catch : `); - Logger.error(`\tExpected: ${data.expect} items, but found ${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 53398bd1d..e9a3c83a8 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 @@ -24,9 +24,12 @@ */ import { browser } from 'protractor'; -import { NodesApi, CommentsApi, SitesApi, FavoritesApi, QueriesApi, SharedLinksApi, TrashcanApi, SearchApi, UploadApi } from './apis'; +import { NodesApi, SitesApi, FavoritesApi, QueriesApi, SharedLinksApi, SearchApi, UploadApi } from './apis'; import { AlfrescoApi } from '@alfresco/js-api'; +/** + * @deprecated Use {AdminActions} or {UserActions} instead. + */ export class RepoClient { alfrescoApi: AlfrescoApi; @@ -43,10 +46,6 @@ export class RepoClient { return new NodesApi(this.username, this.password); } - get comments(): CommentsApi { - return new CommentsApi(this.username, this.password); - } - get sites(): SitesApi { return new SitesApi(this.username, this.password); } @@ -59,10 +58,6 @@ export class RepoClient { return new SharedLinksApi(this.username, this.password); } - get trashcan(): TrashcanApi { - return new TrashcanApi(this.username, this.password); - } - get search(): SearchApi { return new SearchApi(this.username, this.password); } diff --git a/projects/aca-testing-shared/src/utilities/user-actions.ts b/projects/aca-testing-shared/src/utilities/user-actions.ts new file mode 100644 index 000000000..fe106ee99 --- /dev/null +++ b/projects/aca-testing-shared/src/utilities/user-actions.ts @@ -0,0 +1,165 @@ +/*! + * @license + * Alfresco Example Content Application + * + * Copyright (C) 2005 - 2020 Alfresco Software Limited + * + * This file is part of the Alfresco Example Content Application. + * If the software was purchased under a paid Alfresco license, the terms of + * the paid license agreement will prevail. Otherwise, the software is + * provided under the following open source license terms: + * + * The Alfresco Example Content Application is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Alfresco Example Content Application is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Alfresco. If not, see . + */ + +import { AlfrescoApi, Comment, CommentsApi, NodesApi, TrashcanApi, SitesApi, SharedlinksApi } from '@alfresco/js-api'; +import { browser } from 'protractor'; +import { Utils } from './utils'; + +export class UserActions { + protected readonly alfrescoApi: AlfrescoApi; + + readonly commentsApi: CommentsApi; + readonly nodesApi: NodesApi; + readonly trashcanApi: TrashcanApi; + readonly sitesApi: SitesApi; + readonly sharedLinksApi: SharedlinksApi; + + protected username: string; + protected password: string; + + constructor() { + this.alfrescoApi = new AlfrescoApi(); + this.alfrescoApi.setConfig(browser.params.config); + + this.commentsApi = new CommentsApi(this.alfrescoApi); + this.nodesApi = new NodesApi(this.alfrescoApi); + this.trashcanApi = new TrashcanApi(this.alfrescoApi); + this.sitesApi = new SitesApi(this.alfrescoApi); + this.sharedLinksApi = new SharedlinksApi(this.alfrescoApi); + } + + async login(username: string, password: string) { + this.username = username || this.username; + this.password = password || this.password; + + return this.alfrescoApi.login(this.username, this.password); + } + + async logout(): Promise { + await this.alfrescoApi.login(this.username, this.password); + return this.alfrescoApi.logout(); + } + + async createComment(nodeId: string, content: string): Promise { + const comment = await this.commentsApi.createComment(nodeId, { content }); + return comment?.entry; + } + + /** + * Delete multiple nodes. + * @param nodeIds The list of node IDs to delete. + * @param permanent Delete permanently, without moving to the trashcan? (default: true) + */ + async deleteNodes(nodeIds: string[], permanent: boolean = true): Promise { + for (const nodeId of nodeIds) { + await this.nodesApi.deleteNode(nodeId, { permanent }); + } + } + + /** + * Empties the trashcan. Uses multiple batches 1000 nodes each. + */ + async emptyTrashcan(): Promise { + const nodes = await this.trashcanApi.listDeletedNodes({ + maxItems: 1000 + }); + + if (nodes?.list?.entries && nodes?.list?.entries?.length > 0) { + const ids = nodes.list.entries.map((entries) => entries.entry.id); + + for (const nodeId of ids) { + await this.trashcanApi.deleteDeletedNode(nodeId); + } + + await this.emptyTrashcan(); + } + } + + /** + * Returns the amount of deleted nodes in the trashcan. + * TODO: limited to 1000 items only, needs improvements. + */ + async getTrashcanSize(): Promise { + const response = await this.trashcanApi.listDeletedNodes({ + maxItems: 1000 + }); + + return response?.list?.pagination?.totalItems || 0; + } + + /** + * Performs multiple calls to retrieve the size of the trashcan until the expectedSize is reached. + * Used with eventual consistency calls. + * @param expectedSize Size of the trashcan to wait for. + */ + async waitForTrashcanSize(expectedSize: number): Promise { + return Utils.retryCall(async () => { + const totalItems = await this.getTrashcanSize(); + + if (totalItems !== expectedSize) { + return Promise.reject(totalItems); + } else { + return Promise.resolve(totalItems); + } + }); + } + + /** + * Unlock multiple nodes. + * @param nodeIds The list of node IDs to unlock. + */ + async unlockNodes(nodeIds: string[]): Promise { + for (const nodeId of nodeIds) { + await this.nodesApi.unlockNode(nodeId); + } + } + + /** + * Delete multiple sites/libraries. + * @param siteIds The list of the site/library IDs to delete. + * @param permanent Delete permanently, without moving to the trashcan? (default: true) + */ + async deleteSites(siteIds: string[], permanent: boolean = true) { + if (siteIds && siteIds.length > 0) { + for (const siteId of siteIds) { + await this.sitesApi.deleteSite(siteId, { permanent }); + } + } + } + + /** + * Creates shared links for the given nodes. + * @param nodeIds The list of node IDs to share. + * @param expiresAt (optional) Expiration date. + */ + async shareNodes(nodeIds: string[], expiresAt?: Date): Promise { + for (const nodeId of nodeIds) { + await this.sharedLinksApi.createSharedLink({ + nodeId, + expiresAt + }); + } + } +}