diff --git a/e2e/suites/actions/copy-move/copy.test.ts b/e2e/suites/actions/copy-move/copy.test.ts index 0c28ac217..786d15bf6 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 { LoginPage, BrowsingPage, ContentNodeSelectorDialog, RepoClient, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, ContentNodeSelectorDialog, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Copy content', () => { const username = `user-${Utils.random()}`; @@ -100,7 +100,6 @@ describe('Copy content', () => { let destinationId: string; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -109,9 +108,10 @@ describe('Copy content', () => { const { dataTable, toolbar } = page; const copyDialog = new ContentNodeSelectorDialog(); const { searchInput } = page.header; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); const initialSharedTotalItems = await apis.user.shared.getSharedLinksTotalItems(); const initialFavoritesTotalItems = await apis.user.favorites.getFavoritesTotalItems(); diff --git a/e2e/suites/actions/copy-move/move.test.ts b/e2e/suites/actions/copy-move/move.test.ts index 91e5c2c05..28719eac4 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 { LoginPage, BrowsingPage, ContentNodeSelectorDialog, RepoClient, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, ContentNodeSelectorDialog, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Move content', () => { const username = `user-${Utils.random()}`; @@ -55,7 +55,6 @@ describe('Move content', () => { const folderSiteFav = `folderSiteFavorites-${Utils.random()}`; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -63,9 +62,10 @@ describe('Move content', () => { const page = new BrowsingPage(); const { dataTable, toolbar } = page; const moveDialog = new ContentNodeSelectorDialog(); + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); await apis.user.sites.createSite(siteName); const docLibId = await apis.user.sites.getDocLibId(siteName); diff --git a/e2e/suites/actions/create-folder.test.ts b/e2e/suites/actions/create-folder.test.ts index 024593144..55cf7ce2b 100755 --- a/e2e/suites/actions/create-folder.test.ts +++ b/e2e/suites/actions/create-folder.test.ts @@ -23,7 +23,15 @@ * along with Alfresco. If not, see . */ -import { LoginPage, BrowsingPage, CreateOrEditFolderDialog, Utils, clearTextWithBackspace, RepoClient } from '@alfresco/aca-testing-shared'; +import { + AdminActions, + LoginPage, + BrowsingPage, + CreateOrEditFolderDialog, + Utils, + clearTextWithBackspace, + RepoClient +} from '@alfresco/aca-testing-shared'; describe('Create folder', () => { const username = `user-${Utils.random()}`; @@ -43,7 +51,6 @@ describe('Create folder', () => { let docLibUserSite: string; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -51,9 +58,10 @@ describe('Create folder', () => { const page = new BrowsingPage(); const createDialog = new CreateOrEditFolderDialog(); const { dataTable } = page; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); parentId = (await apis.user.nodes.createFolder(parent)).entry.id; await apis.user.nodes.createFolder(duplicateFolderName, parentId); diff --git a/e2e/suites/actions/create-library.test.ts b/e2e/suites/actions/create-library.test.ts index d55909ec3..adf8a474a 100755 --- a/e2e/suites/actions/create-library.test.ts +++ b/e2e/suites/actions/create-library.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { SITE_VISIBILITY, LoginPage, BrowsingPage, CreateLibraryDialog, Utils, RepoClient } from '@alfresco/aca-testing-shared'; +import { AdminActions, SITE_VISIBILITY, LoginPage, BrowsingPage, CreateLibraryDialog, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('Create library', () => { const username = `user-${Utils.random()}`; @@ -49,7 +49,6 @@ describe('Create library', () => { }; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -57,9 +56,10 @@ describe('Create library', () => { const page = new BrowsingPage(); const createDialog = new CreateLibraryDialog(); const { dataTable } = page; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); await apis.user.sites.createSite(duplicateSite.name, SITE_VISIBILITY.PRIVATE, '', duplicateSite.id); await apis.user.sites.createSite(siteInTrash.name, SITE_VISIBILITY.PUBLIC, '', siteInTrash.id); await apis.user.sites.deleteSite(siteInTrash.id, false); diff --git a/e2e/suites/actions/delete-undo-delete.test.ts b/e2e/suites/actions/delete-undo-delete.test.ts index 4856fe457..0ff1ad2e4 100755 --- a/e2e/suites/actions/delete-undo-delete.test.ts +++ b/e2e/suites/actions/delete-undo-delete.test.ts @@ -23,22 +23,22 @@ * along with Alfresco. If not, see . */ -import { LoginPage, BrowsingPage, RepoClient, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Delete and undo delete', () => { const username = `user-${Utils.random()}`; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable, toolbar } = page; + const adminApiActions = new AdminActions(); beforeAll(async () => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); }); afterAll(async () => { diff --git a/e2e/suites/actions/download.test.ts b/e2e/suites/actions/download.test.ts index a655db22f..6808fc4be 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 { LoginPage, BrowsingPage, SearchResultsPage, RepoClient, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, SearchResultsPage, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Download', () => { const username = `user-${Utils.random()}`; @@ -63,7 +63,6 @@ describe('Download', () => { const archiveZip = 'archive.zip'; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -77,8 +76,10 @@ describe('Download', () => { let initialFavoritesTotalItems: number; let initialRecentTotalItems: number; + const adminApiActions = new AdminActions(); + beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); initialRecentTotalItems = await apis.user.search.getTotalItems(username); diff --git a/e2e/suites/actions/edit-folder.test.ts b/e2e/suites/actions/edit-folder.test.ts index 8ed14584d..bd18f5201 100755 --- a/e2e/suites/actions/edit-folder.test.ts +++ b/e2e/suites/actions/edit-folder.test.ts @@ -24,6 +24,7 @@ */ import { + AdminActions, LoginPage, BrowsingPage, SITE_VISIBILITY, @@ -71,7 +72,6 @@ describe('Edit folder', () => { const folderSearchDuplicate = `folder-search-${Utils.random()}`; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -81,13 +81,15 @@ describe('Edit folder', () => { const { dataTable, toolbar } = page; const { searchInput } = page.header; - beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + const adminApiActions = new AdminActions(); - await apis.admin.sites.createSite(sitePrivate, SITE_VISIBILITY.PRIVATE); - const docLibId = await apis.admin.sites.getDocLibId(sitePrivate); - await apis.admin.nodes.createFolder(folderName, docLibId); - await apis.admin.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_CONSUMER.ROLE); + beforeAll(async (done) => { + await adminApiActions.createUser({ username }); + + await adminApiActions.sites.createSite(sitePrivate, SITE_VISIBILITY.PRIVATE); + const docLibId = await adminApiActions.sites.getDocLibId(sitePrivate); + await adminApiActions.nodes.createFolder(folderName, docLibId); + await adminApiActions.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_CONSUMER.ROLE); parentId = (await apis.user.nodes.createFolder(parent)).entry.id; await apis.user.nodes.createFolder(folderName, parentId, '', folderDescription); @@ -121,7 +123,7 @@ describe('Edit folder', () => { afterAll(async (done) => { await Promise.all([ - apis.admin.sites.deleteSite(sitePrivate), + adminApiActions.sites.deleteSite(sitePrivate), apis.user.sites.deleteSite(siteName), apis.user.nodes.deleteNodesById([parentId, folderFavoriteToEditId, folderFavoriteDuplicateId, folderSearchToEditId]) ]); diff --git a/e2e/suites/actions/edit-offline.test.ts b/e2e/suites/actions/edit-offline.test.ts index 4007fe3cf..b82f25d1f 100755 --- a/e2e/suites/actions/edit-offline.test.ts +++ b/e2e/suites/actions/edit-offline.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { LoginPage, BrowsingPage, FILES, RepoClient, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, FILES, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Edit offline', () => { const username = `user-${Utils.random()}`; @@ -54,7 +54,6 @@ describe('Edit offline', () => { let parentSearchId: string; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -63,8 +62,10 @@ describe('Edit offline', () => { const { dataTable, toolbar } = page; const { searchInput } = page.header; + const adminApiActions = new AdminActions(); + beforeAll(async () => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); }); describe('on Personal Files', () => { diff --git a/e2e/suites/actions/library-actions.test.ts b/e2e/suites/actions/library-actions.test.ts index 8b14f47b7..56a067abd 100755 --- a/e2e/suites/actions/library-actions.test.ts +++ b/e2e/suites/actions/library-actions.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, ConfirmDialog, RepoClient } from '@alfresco/aca-testing-shared'; +import { AdminActions, SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, ConfirmDialog, RepoClient } from '@alfresco/aca-testing-shared'; describe('Library actions', () => { const username = `user-${Utils.random()}`; @@ -54,7 +54,6 @@ describe('Library actions', () => { const siteSearchForDelete = `site-public-search-5-${Utils.random()}`; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -64,16 +63,17 @@ describe('Library actions', () => { const { searchInput } = page.header; const confirmDialog = new ConfirmDialog(); + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); - await apis.admin.sites.createSite(siteSearchPublic1Admin); - await apis.admin.sites.createSite(siteSearchPublic2Admin); - await apis.admin.sites.createSite(siteSearchPublic3Admin); - await apis.admin.sites.createSite(siteSearchPublic4Admin); - await apis.admin.sites.createSite(siteSearchModerated1Admin, SITE_VISIBILITY.MODERATED); - await apis.admin.sites.createSite(siteSearchModerated2Admin, SITE_VISIBILITY.MODERATED); + await adminApiActions.sites.createSite(siteSearchPublic1Admin); + await adminApiActions.sites.createSite(siteSearchPublic2Admin); + await adminApiActions.sites.createSite(siteSearchPublic3Admin); + await adminApiActions.sites.createSite(siteSearchPublic4Admin); + await adminApiActions.sites.createSite(siteSearchModerated1Admin, SITE_VISIBILITY.MODERATED); + await adminApiActions.sites.createSite(siteSearchModerated2Admin, SITE_VISIBILITY.MODERATED); await apis.user.sites.createSite(siteSearchForDelete); await apis.user.queries.waitForSites('site-public-search', { expect: 5 }); @@ -95,7 +95,7 @@ describe('Library actions', () => { }); afterAll(async () => { - await apis.admin.sites.deleteSites([ + await adminApiActions.sites.deleteSites([ sitePublic1Admin, siteSearchPublic1Admin, sitePublic2Admin, @@ -106,7 +106,7 @@ describe('Library actions', () => { sitePublic7Admin, sitePublic8Admin ]); - await apis.admin.sites.deleteSites([ + await adminApiActions.sites.deleteSites([ siteSearchPublic2Admin, siteSearchPublic3Admin, siteSearchPublic4Admin, @@ -121,7 +121,7 @@ describe('Library actions', () => { describe('Join a public library', () => { beforeAll(async (done) => { - await apis.admin.sites.createSite(sitePublic1Admin); + await adminApiActions.sites.createSite(sitePublic1Admin); await apis.user.favorites.addFavoriteById('site', sitePublic1Admin); done(); }); @@ -149,7 +149,7 @@ describe('Library actions', () => { describe('Join a moderated library', () => { beforeAll(async (done) => { - await apis.admin.sites.createSite(siteModerated1Admin, SITE_VISIBILITY.MODERATED); + await adminApiActions.sites.createSite(siteModerated1Admin, SITE_VISIBILITY.MODERATED); await apis.user.favorites.addFavoriteById('site', siteModerated1Admin); await apis.user.queries.waitForSites(siteSearchModerated1Admin, { expect: 1 }); done(); @@ -182,17 +182,17 @@ describe('Library actions', () => { describe('Leave a library', () => { beforeAll(async (done) => { - await apis.admin.sites.createSite(sitePublic2Admin); - await apis.admin.sites.createSite(sitePublic3Admin); - await apis.admin.sites.createSite(sitePublic4Admin); - await apis.admin.sites.createSite(sitePublic5Admin); + await adminApiActions.sites.createSite(sitePublic2Admin); + await adminApiActions.sites.createSite(sitePublic3Admin); + await adminApiActions.sites.createSite(sitePublic4Admin); + await adminApiActions.sites.createSite(sitePublic5Admin); await apis.user.sites.createSite(sitePublicUser); await apis.user.favorites.addFavoriteById('site', sitePublic3Admin); - await apis.admin.sites.addSiteMember(sitePublic2Admin, username, SITE_ROLES.SITE_COLLABORATOR.ROLE); - await apis.admin.sites.addSiteMember(sitePublic3Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); - await apis.admin.sites.addSiteMember(siteSearchPublic2Admin, username, SITE_ROLES.SITE_CONTRIBUTOR.ROLE); - await apis.admin.sites.addSiteMember(sitePublic4Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); - await apis.admin.sites.addSiteMember(sitePublic5Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); + await adminApiActions.sites.addSiteMember(sitePublic2Admin, username, SITE_ROLES.SITE_COLLABORATOR.ROLE); + await adminApiActions.sites.addSiteMember(sitePublic3Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); + await adminApiActions.sites.addSiteMember(siteSearchPublic2Admin, username, SITE_ROLES.SITE_CONTRIBUTOR.ROLE); + await adminApiActions.sites.addSiteMember(sitePublic4Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); + await adminApiActions.sites.addSiteMember(sitePublic5Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); await apis.user.queries.waitForSites(siteSearchPublic2Admin, { expect: 1 }); done(); }); @@ -271,7 +271,7 @@ describe('Library actions', () => { describe('Cancel join', () => { beforeAll(async (done) => { - await apis.admin.sites.createSite(siteModerated2Admin, SITE_VISIBILITY.MODERATED); + await adminApiActions.sites.createSite(siteModerated2Admin, SITE_VISIBILITY.MODERATED); await apis.user.favorites.addFavoriteById('site', siteModerated2Admin); await apis.user.sites.requestToJoin(siteModerated2Admin); await apis.user.sites.requestToJoin(siteSearchModerated2Admin); @@ -308,8 +308,8 @@ describe('Library actions', () => { describe('Mark library as favorite', () => { beforeAll(async (done) => { - await apis.admin.sites.createSite(sitePublic6Admin); - await apis.admin.sites.addSiteMember(sitePublic6Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); + await adminApiActions.sites.createSite(sitePublic6Admin); + await adminApiActions.sites.addSiteMember(sitePublic6Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); await apis.user.queries.waitForSites(siteSearchPublic3Admin, { expect: 1 }); done(); }); @@ -340,14 +340,14 @@ describe('Library actions', () => { describe('Remove library from favorites', () => { beforeAll(async (done) => { - await apis.admin.sites.createSite(sitePublic7Admin); - await apis.admin.sites.createSite(sitePublic8Admin); + await adminApiActions.sites.createSite(sitePublic7Admin); + await adminApiActions.sites.createSite(sitePublic8Admin); await apis.user.favorites.addFavoriteById('site', sitePublic7Admin); await apis.user.favorites.addFavoriteById('site', sitePublic8Admin); await apis.user.favorites.addFavoriteById('site', siteSearchPublic4Admin); - await apis.admin.sites.addSiteMember(sitePublic7Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); - await apis.admin.sites.addSiteMember(sitePublic8Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); - await apis.admin.sites.addSiteMember(siteSearchPublic4Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); + await adminApiActions.sites.addSiteMember(sitePublic7Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); + await adminApiActions.sites.addSiteMember(sitePublic8Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); + await adminApiActions.sites.addSiteMember(siteSearchPublic4Admin, username, SITE_ROLES.SITE_MANAGER.ROLE); await apis.user.queries.waitForSites(siteSearchPublic4Admin, { expect: 1 }); done(); }); diff --git a/e2e/suites/actions/mark-favorite.test.ts b/e2e/suites/actions/mark-favorite.test.ts index 5aeff1470..bdfd627c9 100644 --- a/e2e/suites/actions/mark-favorite.test.ts +++ b/e2e/suites/actions/mark-favorite.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { LoginPage, BrowsingPage, SITE_VISIBILITY, RepoClient, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, SITE_VISIBILITY, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Mark items as favorites', () => { const username = `user-${Utils.random()}`; @@ -74,7 +74,6 @@ describe('Mark items as favorites', () => { let folderSearchId: string; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -83,8 +82,10 @@ describe('Mark items as favorites', () => { const { dataTable, toolbar } = page; const { searchInput } = page.header; + const adminApiActions = new AdminActions(); + beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); parentId = (await apis.user.nodes.createFolder(parent)).entry.id; diff --git a/e2e/suites/actions/new-menu.test.ts b/e2e/suites/actions/new-menu.test.ts index 05b66b27b..ff4ad3117 100755 --- a/e2e/suites/actions/new-menu.test.ts +++ b/e2e/suites/actions/new-menu.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { LoginPage, BrowsingPage, SITE_ROLES, RepoClient, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, SITE_ROLES, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('New menu', () => { const username = `user-${Utils.random()}`; @@ -32,7 +32,6 @@ describe('New menu', () => { const siteAdmin = `site-admin-${Utils.random()}`; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -41,10 +40,12 @@ describe('New menu', () => { const { dataTable, sidenav } = page; const { menu } = sidenav; + const adminApiActions = new AdminActions(); + beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); - await apis.admin.sites.createSite(siteAdmin); - await apis.admin.sites.addSiteMember(siteAdmin, username, SITE_ROLES.SITE_CONSUMER.ROLE); + await adminApiActions.createUser({ username }); + await adminApiActions.sites.createSite(siteAdmin); + await adminApiActions.sites.addSiteMember(siteAdmin, username, SITE_ROLES.SITE_CONSUMER.ROLE); await apis.user.sites.createSite(siteUser); @@ -54,7 +55,7 @@ describe('New menu', () => { afterAll(async (done) => { await apis.user.sites.deleteSite(siteUser); - await apis.admin.sites.deleteSite(siteAdmin); + await adminApiActions.sites.deleteSite(siteAdmin); done(); }); diff --git a/e2e/suites/actions/permanently-delete.test.ts b/e2e/suites/actions/permanently-delete.test.ts index d4cff410f..d7282b49e 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 { LoginPage, BrowsingPage, ConfirmDialog, RepoClient, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, ConfirmDialog, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Permanently delete from Trash', () => { const username = `user-${Utils.random()}`; @@ -40,7 +40,6 @@ describe('Permanently delete from Trash', () => { const site = `site-${Utils.random()}`; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -49,9 +48,10 @@ describe('Permanently delete from Trash', () => { const { dataTable, toolbar } = page; const confirmDialog = new ConfirmDialog(); + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.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); diff --git a/e2e/suites/actions/restore.test.ts b/e2e/suites/actions/restore.test.ts index 93d5148dd..52e94ce8f 100755 --- a/e2e/suites/actions/restore.test.ts +++ b/e2e/suites/actions/restore.test.ts @@ -24,22 +24,22 @@ */ import { browser } from 'protractor'; -import { LoginPage, BrowsingPage, APP_ROUTES, RepoClient, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, APP_ROUTES, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Restore from Trash', () => { const username = `user-${Utils.random()}`; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable, toolbar } = page; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); await loginPage.loginWith(username); done(); }); diff --git a/e2e/suites/actions/share-file.test.ts b/e2e/suites/actions/share-file.test.ts index be83ee889..384ffc05c 100755 --- a/e2e/suites/actions/share-file.test.ts +++ b/e2e/suites/actions/share-file.test.ts @@ -24,7 +24,7 @@ */ import { browser } from 'protractor'; -import { LoginPage, BrowsingPage, SITE_VISIBILITY, RepoClient, ShareDialog, Viewer, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, SITE_VISIBILITY, RepoClient, ShareDialog, Viewer, Utils } from '@alfresco/aca-testing-shared'; describe('Share a file', () => { const username = `user-${Utils.random()}`; @@ -56,12 +56,13 @@ describe('Share a file', () => { const shareLinkPreUrl = `/#/preview/s/`; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; + const adminApiActions = new AdminActions(); + beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); parentId = (await apis.user.nodes.createFolder(parent)).entry.id; done(); }); @@ -330,7 +331,7 @@ describe('Share a file', () => { }); afterAll(async () => { - await apis.admin.sites.deleteSite(siteName); + await adminApiActions.sites.deleteSite(siteName); await apis.user.shared.waitForApi({ expect: initialTotalItems }); }); diff --git a/e2e/suites/actions/unshare-file-search-results.test.ts b/e2e/suites/actions/unshare-file-search-results.test.ts index 26d0e6184..eb1a44bb3 100755 --- a/e2e/suites/actions/unshare-file-search-results.test.ts +++ b/e2e/suites/actions/unshare-file-search-results.test.ts @@ -25,6 +25,7 @@ import { browser } from 'protractor'; import { + AdminActions, LoginPage, BrowsingPage, SITE_VISIBILITY, @@ -59,7 +60,6 @@ describe('Unshare a file from Search Results', () => { let fileSite2Id: string; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -71,9 +71,10 @@ describe('Unshare a file from Search Results', () => { const contextMenu = dataTable.menu; const viewer = new Viewer(); const { searchInput } = page.header; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); parentId = (await apis.user.nodes.createFolder(parent)).entry.id; const initialSearchByTermTotalItems = await apis.user.search.getSearchByTermTotalItems('search-file'); @@ -88,15 +89,15 @@ describe('Unshare a file from Search Results', () => { await apis.user.shared.shareFileById(file3Id); await apis.user.shared.shareFileById(file4Id); - await apis.admin.sites.createSite(sitePrivate, SITE_VISIBILITY.PRIVATE); - const docLibId = await apis.admin.sites.getDocLibId(sitePrivate); + await adminApiActions.sites.createSite(sitePrivate, SITE_VISIBILITY.PRIVATE); + const docLibId = await adminApiActions.sites.getDocLibId(sitePrivate); - fileSite1Id = (await apis.admin.nodes.createFile(fileSite1, docLibId)).entry.id; - fileSite2Id = (await apis.admin.nodes.createFile(fileSite2, docLibId)).entry.id; + fileSite1Id = (await adminApiActions.nodes.createFile(fileSite1, docLibId)).entry.id; + fileSite2Id = (await adminApiActions.nodes.createFile(fileSite2, docLibId)).entry.id; - await apis.admin.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_CONSUMER.ROLE); + await adminApiActions.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_CONSUMER.ROLE); - await apis.admin.shared.shareFileById(fileSite1Id); + await adminApiActions.shared.shareFileById(fileSite1Id); await apis.user.shared.shareFileById(fileSite2Id); await apis.user.shared.waitForApi({ expect: initialSharedTotalItems + 6 }); @@ -108,7 +109,7 @@ describe('Unshare a file from Search Results', () => { afterAll(async (done) => { await apis.user.nodes.deleteNodeById(parentId); - await apis.admin.sites.deleteSite(sitePrivate); + await adminApiActions.sites.deleteSite(sitePrivate); done(); }); diff --git a/e2e/suites/actions/unshare-file.test.ts b/e2e/suites/actions/unshare-file.test.ts index d007db0f5..4c7021768 100755 --- a/e2e/suites/actions/unshare-file.test.ts +++ b/e2e/suites/actions/unshare-file.test.ts @@ -25,6 +25,7 @@ import { browser } from 'protractor'; import { + AdminActions, LoginPage, BrowsingPage, SITE_VISIBILITY, @@ -43,7 +44,6 @@ describe('Unshare a file', () => { let parentId: string; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -54,9 +54,10 @@ describe('Unshare a file', () => { const confirmDialog = new ConfirmDialog(); const contextMenu = dataTable.menu; const viewer = new Viewer(); + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); parentId = (await apis.user.nodes.createFolder(parent)).entry.id; await loginPage.loginWith(username); done(); @@ -236,7 +237,7 @@ describe('Unshare a file', () => { }); afterAll(async (done) => { - await apis.admin.sites.deleteSite(siteName); + await adminApiActions.sites.deleteSite(siteName); await apis.user.shared.waitForApi({ expect: initialSharedTotalItems }); done(); }); @@ -695,24 +696,24 @@ describe('Unshare a file', () => { let file2FavId: string; beforeAll(async (done) => { - await apis.admin.sites.createSite(sitePrivate, SITE_VISIBILITY.PRIVATE); - const docLibId = await apis.admin.sites.getDocLibId(sitePrivate); + await adminApiActions.sites.createSite(sitePrivate, SITE_VISIBILITY.PRIVATE); + const docLibId = await adminApiActions.sites.getDocLibId(sitePrivate); - file1FileLibId = (await apis.admin.nodes.createFile(file1FileLib, docLibId)).entry.id; - file2FileLibId = (await apis.admin.nodes.createFile(file2FileLib, docLibId)).entry.id; - file1SharedId = (await apis.admin.nodes.createFile(file1Shared, docLibId)).entry.id; - file2SharedId = (await apis.admin.nodes.createFile(file2Shared, docLibId)).entry.id; - file1FavId = (await apis.admin.nodes.createFile(file1Fav, docLibId)).entry.id; - file2FavId = (await apis.admin.nodes.createFile(file2Fav, docLibId)).entry.id; + file1FileLibId = (await adminApiActions.nodes.createFile(file1FileLib, docLibId)).entry.id; + file2FileLibId = (await adminApiActions.nodes.createFile(file2FileLib, docLibId)).entry.id; + file1SharedId = (await adminApiActions.nodes.createFile(file1Shared, docLibId)).entry.id; + file2SharedId = (await adminApiActions.nodes.createFile(file2Shared, docLibId)).entry.id; + file1FavId = (await adminApiActions.nodes.createFile(file1Fav, docLibId)).entry.id; + file2FavId = (await adminApiActions.nodes.createFile(file2Fav, docLibId)).entry.id; - await apis.admin.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_CONSUMER.ROLE); + await adminApiActions.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_CONSUMER.ROLE); const initialSharedTotalItems = await apis.user.shared.getSharedLinksTotalItems(); - await apis.admin.shared.shareFileById(file1FileLibId); + await adminApiActions.shared.shareFileById(file1FileLibId); await apis.user.shared.shareFileById(file2FileLibId); - await apis.admin.shared.shareFileById(file1SharedId); + await adminApiActions.shared.shareFileById(file1SharedId); await apis.user.shared.shareFileById(file2SharedId); - await apis.admin.shared.shareFileById(file1FavId); + await adminApiActions.shared.shareFileById(file1FavId); await apis.user.shared.shareFileById(file2FavId); await apis.user.favorites.addFavoriteById('file', file1FavId); @@ -725,7 +726,7 @@ describe('Unshare a file', () => { }); afterAll(async (done) => { - await apis.admin.sites.deleteSite(sitePrivate); + await adminApiActions.sites.deleteSite(sitePrivate); done(); }); diff --git a/e2e/suites/actions/upload-file.test.ts b/e2e/suites/actions/upload-file.test.ts index 579001226..ec3365c92 100755 --- a/e2e/suites/actions/upload-file.test.ts +++ b/e2e/suites/actions/upload-file.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { LoginPage, BrowsingPage, RepoClient, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Upload files', () => { const username = `user-${Utils.random()}`; @@ -32,16 +32,16 @@ describe('Upload files', () => { let folder1Id: string; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable } = page; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); folder1Id = (await apis.user.nodes.createFolder(folder1)).entry.id; await loginPage.loginWith(username); diff --git a/e2e/suites/actions/upload-new-version.test.ts b/e2e/suites/actions/upload-new-version.test.ts index 3d4e425eb..40a160c84 100755 --- a/e2e/suites/actions/upload-new-version.test.ts +++ b/e2e/suites/actions/upload-new-version.test.ts @@ -23,7 +23,16 @@ * along with Alfresco. If not, see . */ -import { LoginPage, BrowsingPage, SearchResultsPage, FILES, RepoClient, Utils, UploadNewVersionDialog } from '@alfresco/aca-testing-shared'; +import { + AdminActions, + LoginPage, + BrowsingPage, + SearchResultsPage, + FILES, + RepoClient, + Utils, + UploadNewVersionDialog +} from '@alfresco/aca-testing-shared'; describe('Upload new version', () => { const username = `user-${Utils.random()}`; @@ -76,7 +85,6 @@ describe('Upload new version', () => { const fileToUpload5 = FILES.xlsxFile2; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -86,9 +94,10 @@ describe('Upload new version', () => { const { dataTable, toolbar } = page; const uploadNewVersionDialog = new UploadNewVersionDialog(); const { searchInput } = page.header; + const adminApiActions = new AdminActions(); beforeAll(async () => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); parentPFId = (await apis.user.nodes.createFolder(parentPF)).entry.id; parentSFId = (await apis.user.nodes.createFolder(parentSF)).entry.id; diff --git a/e2e/suites/actions/version-actions.test.ts b/e2e/suites/actions/version-actions.test.ts index 4ea3b6372..4a2a57449 100644 --- a/e2e/suites/actions/version-actions.test.ts +++ b/e2e/suites/actions/version-actions.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { LoginPage, BrowsingPage, FILES, RepoClient, Utils, UploadNewVersionDialog } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, FILES, RepoClient, Utils, UploadNewVersionDialog } from '@alfresco/aca-testing-shared'; import { VersionManagePage } from '../../../projects/aca-testing-shared/src/components/version-manage/version-manager'; import { Viewer } from '../../../projects/aca-testing-shared/src/components'; import { browser } from 'protractor'; @@ -39,7 +39,6 @@ describe('Version component actions', () => { const filesToUpload = [FILES.pdfFile, FILES.docxFile, FILES.xlsxFile, FILES.jpgFile, FILES.docxFile2]; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -48,9 +47,10 @@ describe('Version component actions', () => { const { dataTable, toolbar } = page; const uploadNewVersionDialog = new UploadNewVersionDialog(); const { searchInput } = page.header; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); fileId = (await apis.user.upload.uploadFile(filesToUpload[0])).entry.id; await apis.user.shared.shareFilesByIds([fileId]); await loginPage.loginWith(username); diff --git a/e2e/suites/application/general.test.ts b/e2e/suites/application/general.test.ts index 5d45b9959..dc1c430c1 100644 --- a/e2e/suites/application/general.test.ts +++ b/e2e/suites/application/general.test.ts @@ -32,18 +32,17 @@ describe('General', () => { const page = new BrowsingPage(); const createDialog = new CreateOrEditFolderDialog(); const adminApi = new RepoClient(); - const { nodes: nodesApi, authentication: authApi } = adminApi; const folder = `folder-${Utils.random()}`; let folderId: string; describe('on session expire', () => { beforeAll(async (done) => { - folderId = (await nodesApi.createFolder(folder)).entry.id; + folderId = (await adminApi.nodes.createFolder(folder)).entry.id; done(); }); afterAll(async (done) => { - await nodesApi.deleteNodeById(folderId); + await adminApi.nodes.deleteNodeById(folderId); done(); }); @@ -54,7 +53,7 @@ describe('General', () => { await createDialog.waitForDialogToOpen(); await createDialog.enterName(folder); - await authApi.logout(); + await adminApi.logout(); await createDialog.createButton.click(); diff --git a/e2e/suites/application/page-titles.test.ts b/e2e/suites/application/page-titles.test.ts index d28d9735d..a878c10c7 100755 --- a/e2e/suites/application/page-titles.test.ts +++ b/e2e/suites/application/page-titles.test.ts @@ -30,7 +30,6 @@ 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: string; const { searchInput } = page.header; @@ -57,7 +56,7 @@ describe('Page titles', () => { describe('on app pages', () => { beforeAll(async (done) => { - fileId = (await nodesApi.createFile(file)).entry.id; + fileId = (await adminApi.nodes.createFile(file)).entry.id; await loginPage.loginWithAdmin(); done(); }); diff --git a/e2e/suites/authentication/login.test.ts b/e2e/suites/authentication/login.test.ts index b58a4760e..7aafe277d 100755 --- a/e2e/suites/authentication/login.test.ts +++ b/e2e/suites/authentication/login.test.ts @@ -24,12 +24,12 @@ */ import { browser } from 'protractor'; -import { APP_ROUTES, LoginPage, BrowsingPage, Utils, RepoClient, navigate } from '@alfresco/aca-testing-shared'; +import { AdminActions, APP_ROUTES, LoginPage, BrowsingPage, Utils, navigate } from '@alfresco/aca-testing-shared'; describe('Login', () => { - const peopleApi = new RepoClient().people; const loginPage = new LoginPage(); const { login } = loginPage; + const adminApiActions = new AdminActions(); /* cspell:disable-next-line */ const testUser = `user-${Utils.random()}@alfness`; @@ -57,12 +57,12 @@ describe('Login', () => { const newPassword = 'new password'; beforeAll(async (done) => { - await peopleApi.createUser({ username: testUser }); - await peopleApi.createUser(russianUser); - await peopleApi.createUser(johnDoe); - await peopleApi.createUser({ username: disabledUser }); - await peopleApi.createUser(testUser2); - await peopleApi.disableUser(disabledUser); + await adminApiActions.createUser({ username: testUser }); + await adminApiActions.createUser(russianUser); + await adminApiActions.createUser(johnDoe); + await adminApiActions.createUser({ username: disabledUser }); + await adminApiActions.createUser(testUser2); + await adminApiActions.disableUser(disabledUser); done(); }); @@ -141,7 +141,7 @@ describe('Login', () => { it('[C213104] user is able to login after changing his password', async () => { await loginPage.loginWith(testUser2.username, testUser2.password); - await peopleApi.changePassword(testUser2.username, newPassword); + await adminApiActions.changePassword(testUser2.username, newPassword); await loginPage.loginWith(testUser2.username, newPassword); expect(await browser.getCurrentUrl()).toContain(APP_ROUTES.PERSONAL_FILES); }); diff --git a/e2e/suites/authentication/logout.test.ts b/e2e/suites/authentication/logout.test.ts index 0fae22fef..3daab5f02 100755 --- a/e2e/suites/authentication/logout.test.ts +++ b/e2e/suites/authentication/logout.test.ts @@ -24,18 +24,16 @@ */ import { browser } from 'protractor'; -import { LoginPage, BrowsingPage, Utils, RepoClient, APP_ROUTES } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, Utils, APP_ROUTES } from '@alfresco/aca-testing-shared'; describe('Logout', () => { const page = new BrowsingPage(); const loginPage = new LoginPage(); - - const peopleApi = new RepoClient().people; - const johnDoe = `user-${Utils.random()}`; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await peopleApi.createUser({ username: johnDoe }); + await adminApiActions.createUser({ username: johnDoe }); done(); }); diff --git a/e2e/suites/extensions/ext-context-submenus.test.ts b/e2e/suites/extensions/ext-context-submenus.test.ts index bd752a455..0f0a53417 100644 --- a/e2e/suites/extensions/ext-context-submenus.test.ts +++ b/e2e/suites/extensions/ext-context-submenus.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { LoginPage, BrowsingPage, EXTENSIBILITY_CONFIGS, RepoClient, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, EXTENSIBILITY_CONFIGS, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Extensions - Context submenu', () => { const username = `user-${Utils.random()}`; @@ -44,7 +44,6 @@ describe('Extensions - Context submenu', () => { }; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -52,9 +51,10 @@ describe('Extensions - Context submenu', () => { const page = new BrowsingPage(); const { dataTable } = page; const contextMenu = dataTable.menu; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); fileId = (await apis.user.nodes.createFile(file)).entry.id; folderId = (await apis.user.nodes.createFolder(folder)).entry.id; diff --git a/e2e/suites/extensions/ext-document-list.test.ts b/e2e/suites/extensions/ext-document-list.test.ts index a6740e5ad..2ffcbb316 100644 --- a/e2e/suites/extensions/ext-document-list.test.ts +++ b/e2e/suites/extensions/ext-document-list.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { BrowsingPage, LoginPage, RepoClient, EXTENSIBILITY_CONFIGS, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, BrowsingPage, LoginPage, RepoClient, EXTENSIBILITY_CONFIGS, Utils } from '@alfresco/aca-testing-shared'; describe('Extensions - DocumentList presets', () => { const username = `user-${Utils.random()}`; @@ -51,16 +51,16 @@ describe('Extensions - DocumentList presets', () => { ]; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable } = page; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); fileId = (await apis.user.nodes.createFile(file)).entry.id; await loginPage.load(); diff --git a/e2e/suites/extensions/ext-header.test.ts b/e2e/suites/extensions/ext-header.test.ts index df9c0a6a3..743e6e2b8 100755 --- a/e2e/suites/extensions/ext-header.test.ts +++ b/e2e/suites/extensions/ext-header.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { LoginPage, RepoClient, EXTENSIBILITY_CONFIGS, Utils, Header, Menu } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, EXTENSIBILITY_CONFIGS, Utils, Header, Menu } from '@alfresco/aca-testing-shared'; describe('Extensions - Info Drawer', () => { const username = `user-${Utils.random()}`; @@ -42,18 +42,14 @@ describe('Extensions - Info Drawer', () => { icon: 'alarm_on' }; - const apis = { - admin: new RepoClient(), - user: new RepoClient(username, username) - }; - const header = new Header(); const toolbarMenu = new Menu(); const loginPage = new LoginPage(); + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); await loginPage.load(); await Utils.setSessionStorageFromConfig(EXTENSIBILITY_CONFIGS.HEADER); await loginPage.loginWith(username); diff --git a/e2e/suites/extensions/ext-info-drawer.test.ts b/e2e/suites/extensions/ext-info-drawer.test.ts index e4aa92270..2947bdfff 100755 --- a/e2e/suites/extensions/ext-info-drawer.test.ts +++ b/e2e/suites/extensions/ext-info-drawer.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { LoginPage, BrowsingPage, InfoDrawer, RepoClient, EXTENSIBILITY_CONFIGS, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, InfoDrawer, RepoClient, EXTENSIBILITY_CONFIGS, Utils } from '@alfresco/aca-testing-shared'; describe('Extensions - Info Drawer', () => { const username = `user-${Utils.random()}`; @@ -54,7 +54,6 @@ describe('Extensions - Info Drawer', () => { }; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -62,9 +61,10 @@ describe('Extensions - Info Drawer', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); fileId = (await apis.user.nodes.createFile(file)).entry.id; done(); }); diff --git a/e2e/suites/extensions/ext-metadata.test.ts b/e2e/suites/extensions/ext-metadata.test.ts index bf7c7f151..6400f792c 100644 --- a/e2e/suites/extensions/ext-metadata.test.ts +++ b/e2e/suites/extensions/ext-metadata.test.ts @@ -23,7 +23,16 @@ * along with Alfresco. If not, see . */ -import { BrowsingPage, LoginPage, RepoClient, EXTENSIBILITY_CONFIGS, Utils, InfoDrawer, MetadataCard } from '@alfresco/aca-testing-shared'; +import { + AdminActions, + BrowsingPage, + LoginPage, + RepoClient, + EXTENSIBILITY_CONFIGS, + Utils, + InfoDrawer, + MetadataCard +} from '@alfresco/aca-testing-shared'; describe('Extensions - Metadata presets', () => { const username = `user-${Utils.random()}`; @@ -53,7 +62,6 @@ describe('Extensions - Metadata presets', () => { }; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -62,9 +70,10 @@ describe('Extensions - Metadata presets', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); fileId = (await apis.user.nodes.createImage(file)).entry.id; await loginPage.load(); diff --git a/e2e/suites/extensions/ext-viewer.test.ts b/e2e/suites/extensions/ext-viewer.test.ts index c667f6ca0..ca8ff4351 100755 --- a/e2e/suites/extensions/ext-viewer.test.ts +++ b/e2e/suites/extensions/ext-viewer.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { LoginPage, BrowsingPage, Viewer, RepoClient, EXTENSIBILITY_CONFIGS, FILES, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, Viewer, RepoClient, EXTENSIBILITY_CONFIGS, FILES, Utils } from '@alfresco/aca-testing-shared'; describe('Extensions - Viewer', () => { const username = `user-${Utils.random()}`; @@ -63,7 +63,6 @@ describe('Extensions - Viewer', () => { }; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -72,9 +71,10 @@ describe('Extensions - Viewer', () => { const viewer = new Viewer(); const { toolbar } = viewer; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); pdfFileId = (await apis.user.upload.uploadFile(pdfFile.file_name)).entry.id; docxFileId = (await apis.user.upload.uploadFile(docxFile.file_name)).entry.id; diff --git a/e2e/suites/info-drawer/comments.test.ts b/e2e/suites/info-drawer/comments.test.ts index 4cc70f975..644332cb3 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 { LoginPage, BrowsingPage, RepoClient, InfoDrawer, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, RepoClient, InfoDrawer, Utils } from '@alfresco/aca-testing-shared'; const moment = require('moment'); describe('Comments', () => { @@ -54,7 +54,6 @@ describe('Comments', () => { let comment2File2Entry: any; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -64,9 +63,10 @@ describe('Comments', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable } = page; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); parentId = (await apis.user.nodes.createFolder(parent)).entry.id; diff --git a/e2e/suites/info-drawer/file-folder-properties.test.ts b/e2e/suites/info-drawer/file-folder-properties.test.ts index 64e6bdac4..aba4c5622 100755 --- a/e2e/suites/info-drawer/file-folder-properties.test.ts +++ b/e2e/suites/info-drawer/file-folder-properties.test.ts @@ -23,7 +23,17 @@ * along with Alfresco. If not, see . */ -import { LoginPage, BrowsingPage, RepoClient, InfoDrawer, Utils, FILES, DATE_TIME_FORMAT, DATE_FORMAT } from '@alfresco/aca-testing-shared'; +import { + AdminActions, + LoginPage, + BrowsingPage, + RepoClient, + InfoDrawer, + Utils, + FILES, + DATE_TIME_FORMAT, + DATE_FORMAT +} from '@alfresco/aca-testing-shared'; const moment = require('moment'); @@ -58,7 +68,6 @@ describe('File / Folder properties', () => { let folder1Id: string; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -68,9 +77,10 @@ describe('File / Folder properties', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable } = page; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); parentId = (await apis.user.nodes.createFolder(parent)).entry.id; file1Id = (await apis.user.nodes.createFile(file1.name, parentId, file1.title, file1.description, file1.author)).entry.id; folder1Id = (await apis.user.nodes.createFolder(folder1.name, parentId, folder1.title, folder1.description, folder1.author)).entry.id; diff --git a/e2e/suites/info-drawer/general.test.ts b/e2e/suites/info-drawer/general.test.ts index dd50e4892..b0429ca20 100755 --- a/e2e/suites/info-drawer/general.test.ts +++ b/e2e/suites/info-drawer/general.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { LoginPage, BrowsingPage, RepoClient, InfoDrawer, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, RepoClient, InfoDrawer, Utils } from '@alfresco/aca-testing-shared'; describe('General', () => { const username = `user1-${Utils.random()}`; @@ -35,7 +35,6 @@ describe('General', () => { const folder1 = `folder1-${Utils.random()}`; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -44,9 +43,10 @@ describe('General', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable } = page; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); parentId = (await apis.user.nodes.createFolder(parent)).entry.id; await apis.user.nodes.createFile(file1, parentId); diff --git a/e2e/suites/info-drawer/library-properties.test.ts b/e2e/suites/info-drawer/library-properties.test.ts index 05a732fb3..235488dce 100755 --- a/e2e/suites/info-drawer/library-properties.test.ts +++ b/e2e/suites/info-drawer/library-properties.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { LoginPage, BrowsingPage, SITE_VISIBILITY, SITE_ROLES, RepoClient, InfoDrawer, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, SITE_VISIBILITY, SITE_ROLES, RepoClient, InfoDrawer, Utils } from '@alfresco/aca-testing-shared'; describe('Library properties', () => { const username = `user1-${Utils.random()}`; @@ -53,7 +53,6 @@ describe('Library properties', () => { const siteDup = `site3-${Utils.random()}`; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -63,11 +62,12 @@ describe('Library properties', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable } = page; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); - await apis.admin.people.createUser({ username: user2 }); - await apis.admin.people.createUser({ username: user3 }); + await adminApiActions.createUser({ username }); + await adminApiActions.createUser({ username: user2 }); + await adminApiActions.createUser({ username: user3 }); await apis.user.sites.createSite(site.name, site.visibility, site.description, site.id); await apis.user.sites.createSite(siteForUpdate.name, siteForUpdate.visibility, siteForUpdate.description, siteForUpdate.id); await apis.user.sites.createSite(siteDup); diff --git a/e2e/suites/list-views/empty-list.test.ts b/e2e/suites/list-views/empty-list.test.ts index 3270982be..2fe9582d7 100755 --- a/e2e/suites/list-views/empty-list.test.ts +++ b/e2e/suites/list-views/empty-list.test.ts @@ -23,25 +23,19 @@ * along with Alfresco. If not, see . */ -import { LoginPage, BrowsingPage, SearchResultsPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, SearchResultsPage, Utils } from '@alfresco/aca-testing-shared'; describe('Empty list views', () => { const username = `user-${Utils.random()}`; - const password = username; - - const apis = { - admin: new RepoClient(), - user: new RepoClient(username, password) - }; - const loginPage = new LoginPage(); const page = new BrowsingPage(); const searchResultsPage = new SearchResultsPage(); const { dataTable, pagination } = page; const { searchInput } = page.header; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); await loginPage.loginWith(username); done(); }); diff --git a/e2e/suites/list-views/favorites.test.ts b/e2e/suites/list-views/favorites.test.ts index eea5712e4..99837963a 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 { SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; +import { AdminActions, SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('Favorites', () => { const username = `user-${Utils.random()}`; @@ -37,22 +37,22 @@ describe('Favorites', () => { const fileName4 = `file4-${Utils.random()}.txt`; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable, breadcrumb } = page; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); - await apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC); - const docLibId = await apis.admin.sites.getDocLibId(siteName); - await apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_MANAGER.ROLE); + await adminApiActions.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC); + const docLibId = await adminApiActions.sites.getDocLibId(siteName); + await adminApiActions.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_MANAGER.ROLE); - const file1Id = (await apis.admin.nodes.createFile(fileName1, docLibId)).entry.id; + const file1Id = (await adminApiActions.nodes.createFile(fileName1, docLibId)).entry.id; const folderId = (await apis.user.nodes.createFolder(favFolderName)).entry.id; const parentId = (await apis.user.nodes.createFolder(parentFolder)).entry.id; const file2Id = (await apis.user.nodes.createFile(fileName2, parentId)).entry.id; @@ -78,7 +78,7 @@ describe('Favorites', () => { }); afterAll(async (done) => { - await apis.admin.sites.deleteSite(siteName); + await adminApiActions.sites.deleteSite(siteName); await apis.user.nodes.deleteNodes([favFolderName, parentFolder]); await apis.user.trashcan.emptyTrash(); done(); diff --git a/e2e/suites/list-views/file-libraries.test.ts b/e2e/suites/list-views/file-libraries.test.ts index 41bb25d17..8a9a7aa27 100755 --- a/e2e/suites/list-views/file-libraries.test.ts +++ b/e2e/suites/list-views/file-libraries.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; +import { AdminActions, SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('File Libraries', () => { const username = `user-${Utils.random()}`; @@ -48,32 +48,32 @@ describe('File Libraries', () => { const siteDescription = 'my site description'; const apis = { - admin: new RepoClient(), user: new RepoClient(username, password) }; const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable } = page; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); await apis.user.sites.createSite(userSitePublic, SITE_VISIBILITY.PUBLIC); await apis.user.sites.createSite(userSiteModerated, SITE_VISIBILITY.MODERATED, siteDescription); await apis.user.sites.createSite(userSitePrivate, SITE_VISIBILITY.PRIVATE, null); - await apis.admin.sites.createSite(adminSite1, SITE_VISIBILITY.PUBLIC); - await apis.admin.sites.createSite(adminSite2, SITE_VISIBILITY.PUBLIC); - await apis.admin.sites.createSite(adminSite3, SITE_VISIBILITY.PUBLIC); - await apis.admin.sites.createSite(adminSite4, SITE_VISIBILITY.PUBLIC); - await apis.admin.sites.createSite(adminSite5, SITE_VISIBILITY.PUBLIC); - await apis.admin.sites.createSite(adminSite6, SITE_VISIBILITY.PUBLIC); - await apis.admin.sites.addSiteMember(adminSite1, username, SITE_ROLES.SITE_CONSUMER.ROLE); - await apis.admin.sites.addSiteMember(adminSite2, username, SITE_ROLES.SITE_CONTRIBUTOR.ROLE); - await apis.admin.sites.addSiteMember(adminSite3, username, SITE_ROLES.SITE_COLLABORATOR.ROLE); - await apis.admin.sites.addSiteMember(adminSite4, username, SITE_ROLES.SITE_MANAGER.ROLE); - await apis.admin.sites.addSiteMember(adminSite6, username, SITE_ROLES.SITE_CONSUMER.ROLE); + await adminApiActions.sites.createSite(adminSite1, SITE_VISIBILITY.PUBLIC); + await adminApiActions.sites.createSite(adminSite2, SITE_VISIBILITY.PUBLIC); + await adminApiActions.sites.createSite(adminSite3, SITE_VISIBILITY.PUBLIC); + await adminApiActions.sites.createSite(adminSite4, SITE_VISIBILITY.PUBLIC); + await adminApiActions.sites.createSite(adminSite5, SITE_VISIBILITY.PUBLIC); + await adminApiActions.sites.createSite(adminSite6, SITE_VISIBILITY.PUBLIC); + await adminApiActions.sites.addSiteMember(adminSite1, username, SITE_ROLES.SITE_CONSUMER.ROLE); + await adminApiActions.sites.addSiteMember(adminSite2, username, SITE_ROLES.SITE_CONTRIBUTOR.ROLE); + await adminApiActions.sites.addSiteMember(adminSite3, username, SITE_ROLES.SITE_COLLABORATOR.ROLE); + await adminApiActions.sites.addSiteMember(adminSite4, username, SITE_ROLES.SITE_MANAGER.ROLE); + await adminApiActions.sites.addSiteMember(adminSite6, username, SITE_ROLES.SITE_CONSUMER.ROLE); await apis.user.favorites.addFavoriteById('site', adminSite1); await apis.user.favorites.addFavoriteById('site', adminSite2); @@ -89,7 +89,7 @@ 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 adminApiActions.sites.deleteSites([adminSite1, adminSite2, adminSite3, adminSite4, adminSite5, adminSite6]); done(); }); diff --git a/e2e/suites/list-views/generic-errors.test.ts b/e2e/suites/list-views/generic-errors.test.ts index 7cd39bcf6..3f6861d8d 100755 --- a/e2e/suites/list-views/generic-errors.test.ts +++ b/e2e/suites/list-views/generic-errors.test.ts @@ -24,11 +24,10 @@ */ import { browser } from 'protractor'; -import { LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; +import { AdminActions, 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()}`; @@ -38,17 +37,17 @@ describe('Generic errors', () => { const file2 = `file2-${Utils.random()}.txt`; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable } = page; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); - await apis.admin.people.createUser({ username: username2 }); + await adminApiActions.createUser({ username }); + await adminApiActions.createUser({ username: username2 }); 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); diff --git a/e2e/suites/list-views/permissions.test.ts b/e2e/suites/list-views/permissions.test.ts index 7eef46c95..4b83cce03 100755 --- a/e2e/suites/list-views/permissions.test.ts +++ b/e2e/suites/list-views/permissions.test.ts @@ -23,14 +23,13 @@ * along with Alfresco. If not, see . */ -import { SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; +import { AdminActions, 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 = { - admin: new RepoClient(), user: new RepoClient(username, password) }; @@ -38,11 +37,12 @@ describe('Special permissions', () => { const page = new BrowsingPage(); const { dataTable } = page; const { searchInput } = page.header; + const adminApiActions = new AdminActions(); let initialSharedTotalItems: number; beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); done(); }); @@ -52,15 +52,15 @@ describe('Special permissions', () => { let fileId; beforeAll(async (done) => { - await apis.admin.sites.createSite(sitePrivate, SITE_VISIBILITY.PRIVATE); - await apis.admin.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_COLLABORATOR.ROLE); - const docLibId = await apis.admin.sites.getDocLibId(sitePrivate); - fileId = (await apis.admin.nodes.createFile(fileName, docLibId)).entry.id; + await adminApiActions.sites.createSite(sitePrivate, SITE_VISIBILITY.PRIVATE); + await adminApiActions.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_COLLABORATOR.ROLE); + const docLibId = await adminApiActions.sites.getDocLibId(sitePrivate); + fileId = (await adminApiActions.nodes.createFile(fileName, docLibId)).entry.id; await apis.user.favorites.addFavoriteById('file', fileId); initialSharedTotalItems = await apis.user.shared.getSharedLinksTotalItems(); - await apis.admin.shared.shareFileById(fileId); + await adminApiActions.shared.shareFileById(fileId); await apis.user.nodes.editNodeContent(fileId, 'edited by user'); await apis.user.search.waitForApi(username, { expect: 1 }); @@ -71,17 +71,17 @@ describe('Special permissions', () => { }); afterEach(async () => { - await apis.admin.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_COLLABORATOR.ROLE); + await adminApiActions.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_COLLABORATOR.ROLE); }); afterAll(async () => { - await apis.admin.sites.deleteSite(sitePrivate); + await adminApiActions.sites.deleteSite(sitePrivate); }); it('[C213173] on Recent Files', async () => { await page.clickRecentFilesAndWait(); expect(await dataTable.getRowsCount()).toBe(1, 'Incorrect number of items'); - await apis.admin.sites.deleteSiteMember(sitePrivate, username); + await adminApiActions.sites.deleteSiteMember(sitePrivate, username); await page.refresh(); expect(await dataTable.isEmpty()).toBe(true, 'Items are still displayed'); }); @@ -89,7 +89,7 @@ describe('Special permissions', () => { it('[C213227] on Favorites', async () => { await page.clickFavoritesAndWait(); expect(await dataTable.getRowsCount()).toBe(1, 'Incorrect number of items'); - await apis.admin.sites.deleteSiteMember(sitePrivate, username); + await adminApiActions.sites.deleteSiteMember(sitePrivate, username); await page.refresh(); expect(await dataTable.isEmpty()).toBe(true, 'Items are still displayed'); }); @@ -97,7 +97,7 @@ describe('Special permissions', () => { it('[C213116] on Shared Files', async () => { await page.clickSharedFilesAndWait(); expect(await dataTable.getRowsCount()).toBe(initialSharedTotalItems + 1, 'Incorrect number of items'); - await apis.admin.sites.deleteSiteMember(sitePrivate, username); + await adminApiActions.sites.deleteSiteMember(sitePrivate, username); await page.refresh(); expect(await dataTable.getRowsCount()).toBe(initialSharedTotalItems, 'Incorrect number of items'); }); @@ -110,7 +110,7 @@ describe('Special permissions', () => { expect(await dataTable.isItemPresent(fileName)).toBe(true, `${fileName} is not displayed`); - await apis.admin.sites.deleteSiteMember(sitePrivate, username); + await adminApiActions.sites.deleteSiteMember(sitePrivate, username); await searchInput.clickSearchButton(); await searchInput.checkFilesAndFolders(); @@ -127,9 +127,9 @@ describe('Special permissions', () => { let fileId; beforeAll(async (done) => { - await apis.admin.sites.createSite(sitePrivate, SITE_VISIBILITY.PRIVATE); - await apis.admin.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_COLLABORATOR.ROLE); - const docLibId = await apis.admin.sites.getDocLibId(sitePrivate); + await adminApiActions.sites.createSite(sitePrivate, SITE_VISIBILITY.PRIVATE); + await adminApiActions.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_COLLABORATOR.ROLE); + const docLibId = await adminApiActions.sites.getDocLibId(sitePrivate); fileId = (await apis.user.nodes.createFile(fileName, docLibId)).entry.id; await apis.user.favorites.addFavoriteById('file', fileId); @@ -138,13 +138,13 @@ describe('Special permissions', () => { await apis.user.shared.waitForApi({ expect: initialSharedTotalItems + 1 }); await apis.user.search.waitForApi(username, { expect: 1 }); - await apis.admin.sites.deleteSiteMember(sitePrivate, username); + await adminApiActions.sites.deleteSiteMember(sitePrivate, username); await loginPage.loginWith(username); done(); }); afterAll(async (done) => { - await apis.admin.sites.deleteSite(sitePrivate); + await adminApiActions.sites.deleteSite(sitePrivate); done(); }); diff --git a/e2e/suites/list-views/personal-files.test.ts b/e2e/suites/list-views/personal-files.test.ts index fde44ef7d..7fdf276d2 100755 --- a/e2e/suites/list-views/personal-files.test.ts +++ b/e2e/suites/list-views/personal-files.test.ts @@ -25,13 +25,12 @@ import { browser } from 'protractor'; -import { APP_ROUTES, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; +import { AdminActions, APP_ROUTES, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('Personal Files', () => { const username = `user-${Utils.random()}`; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -43,16 +42,17 @@ describe('Personal Files', () => { const userFolder = `user-folder-${Utils.random()}`; const userFile = `file-${Utils.random()}.txt`; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await Promise.all([apis.admin.people.createUser({ username }), apis.admin.nodes.createFolders([adminFolder])]); + await Promise.all([adminApiActions.createUser({ username }), adminApiActions.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([adminApiActions.nodes.deleteNodes([adminFolder]), apis.user.nodes.deleteNodes([userFolder])]); done(); }); diff --git a/e2e/suites/list-views/recent-files.test.ts b/e2e/suites/list-views/recent-files.test.ts index 47340fa0c..b67336505 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 { SITE_VISIBILITY, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; +import { AdminActions, SITE_VISIBILITY, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('Recent Files', () => { const username = `user-${Utils.random()}`; @@ -41,16 +41,16 @@ describe('Recent Files', () => { const fileSite = `file-${Utils.random()}.txt`; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable, breadcrumb } = page; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.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; diff --git a/e2e/suites/list-views/shared-files.test.ts b/e2e/suites/list-views/shared-files.test.ts index b55544b3c..1acce20a9 100755 --- a/e2e/suites/list-views/shared-files.test.ts +++ b/e2e/suites/list-views/shared-files.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; +import { AdminActions, SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('Shared Files', () => { const username = `user-${Utils.random()}`; @@ -46,20 +46,20 @@ describe('Shared Files', () => { let initialSharedTotalItems: number; const apis = { - admin: new RepoClient(), user: new RepoClient(username, password) }; const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable, breadcrumb } = page; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); - await apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC); - await apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_CONSUMER.ROLE); - const docLibId = await apis.admin.sites.getDocLibId(siteName); - const nodeId = (await apis.admin.nodes.createFile(fileAdmin, docLibId)).entry.id; + await adminApiActions.createUser({ username }); + await adminApiActions.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC); + await adminApiActions.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_CONSUMER.ROLE); + const docLibId = await adminApiActions.sites.getDocLibId(siteName); + const nodeId = (await adminApiActions.nodes.createFile(fileAdmin, docLibId)).entry.id; folderId = (await apis.user.nodes.createFolder(folderUser)).entry.id; file1Id = (await apis.user.nodes.createFile(file1User, folderId)).entry.id; @@ -70,7 +70,7 @@ describe('Shared Files', () => { initialSharedTotalItems = await apis.user.shared.getSharedLinksTotalItems(); await apis.user.shared.shareFilesByIds([file1Id, file2Id, file3Id, file4Id]); - await apis.admin.shared.shareFileById(nodeId); + await adminApiActions.shared.shareFileById(nodeId); await apis.user.shared.waitForApi({ expect: initialSharedTotalItems + 5 }); await apis.user.nodes.deleteNodeById(file2Id); @@ -88,7 +88,7 @@ describe('Shared Files', () => { }); afterAll(async () => { - await apis.admin.sites.deleteSite(siteName); + await adminApiActions.sites.deleteSite(siteName); await apis.user.nodes.deleteNodeById(folderId); await apis.user.nodes.deleteNodeById(file4Id); }); diff --git a/e2e/suites/list-views/tooltips.test.ts b/e2e/suites/list-views/tooltips.test.ts index ddf1b964e..0e7a1e369 100755 --- a/e2e/suites/list-views/tooltips.test.ts +++ b/e2e/suites/list-views/tooltips.test.ts @@ -23,13 +23,12 @@ * along with Alfresco. If not, see . */ -import { LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('File / folder tooltips', () => { const username = `user-${Utils.random()}`; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -51,9 +50,10 @@ describe('File / folder tooltips', () => { const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable } = page; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); parentId = (await apis.user.nodes.createFolder(parent)).entry.id; file1Id = (await apis.user.nodes.createFile(file, parentId)).entry.id; diff --git a/e2e/suites/list-views/trash.test.ts b/e2e/suites/list-views/trash.test.ts index 4101a0a4c..e61efd3f0 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 { SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; +import { AdminActions, SITE_VISIBILITY, SITE_ROLES, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('Trash', () => { const username = `user-${Utils.random()}`; @@ -53,22 +53,22 @@ describe('Trash', () => { let fileInFolderId: string; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; const loginPage = new LoginPage(); const page = new BrowsingPage(); const { dataTable, breadcrumb } = page; + const adminApiActions = new AdminActions(); beforeAll(async () => { - await apis.admin.people.createUser({ username }); - 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; + await adminApiActions.createUser({ 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); + await adminApiActions.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_MANAGER.ROLE); + const docLibId = await adminApiActions.sites.getDocLibId(siteName); + fileSiteId = (await adminApiActions.nodes.createFile(fileSite, docLibId)).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; @@ -76,7 +76,7 @@ describe('Trash', () => { folderNotDeletedId = (await apis.user.nodes.createFolder(folderNotDeleted)).entry.id; fileInFolderId = (await apis.user.nodes.createFiles([fileInFolder], folderNotDeleted)).entry.id; - await apis.admin.nodes.deleteNodesById([fileAdminId, folderAdminId], false); + await adminApiActions.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); @@ -84,9 +84,9 @@ describe('Trash', () => { afterAll(async (done) => { await Promise.all([ - apis.admin.sites.deleteSite(siteName), - apis.admin.trashcan.permanentlyDelete(fileAdminId), - apis.admin.trashcan.permanentlyDelete(folderAdminId), + adminApiActions.sites.deleteSite(siteName), + adminApiActions.trashcan.permanentlyDelete(fileAdminId), + adminApiActions.trashcan.permanentlyDelete(folderAdminId), apis.user.nodes.deleteNodeById(folderNotDeletedId), apis.user.trashcan.emptyTrash() ]); diff --git a/e2e/suites/navigation/breadcrumb.test.ts b/e2e/suites/navigation/breadcrumb.test.ts index 6162a1b5f..a4431f9ea 100755 --- a/e2e/suites/navigation/breadcrumb.test.ts +++ b/e2e/suites/navigation/breadcrumb.test.ts @@ -25,7 +25,7 @@ import { browser } from 'protractor'; -import { SITE_VISIBILITY, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; +import { AdminActions, SITE_VISIBILITY, LoginPage, BrowsingPage, Utils, RepoClient } from '@alfresco/aca-testing-shared'; describe('Breadcrumb', () => { const username = `user-${Utils.random()}`; @@ -51,12 +51,12 @@ describe('Breadcrumb', () => { const { breadcrumb } = page; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); parentId = (await apis.user.nodes.createFolder(parent)).entry.id; subFolder1Id = (await apis.user.nodes.createFolder(subFolder1, parentId)).entry.id; subFolder2Id = (await apis.user.nodes.createFolder(subFolder2, subFolder1Id)).entry.id; @@ -194,7 +194,7 @@ describe('Breadcrumb', () => { const user2Api = new RepoClient(user2, user2); beforeAll(async (done) => { - await apis.admin.people.createUser({ username: user2 }); + await adminApiActions.createUser({ username: user2 }); userFolderId = (await user2Api.nodes.createFolder(userFolder)).entry.id; await loginPage.loginWithAdmin(); await page.dataTable.waitForBody(); diff --git a/e2e/suites/navigation/single-click.test.ts b/e2e/suites/navigation/single-click.test.ts index 5882d0818..15281c5c6 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 { LoginPage, BrowsingPage, Viewer, RepoClient, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, Viewer, RepoClient, Utils } from '@alfresco/aca-testing-shared'; describe('Single click on item name', () => { const username = `user-${Utils.random()}`; @@ -42,7 +42,6 @@ describe('Single click on item name', () => { const fileSite = `fileSite-${Utils.random()}.txt`; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -51,9 +50,10 @@ describe('Single click on item name', () => { const { dataTable, breadcrumb } = page; const viewer = new Viewer(); const { searchInput } = page.header; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); file1Id = (await apis.user.nodes.createFile(file1)).entry.id; folder1Id = (await apis.user.nodes.createFolder(folder1)).entry.id; diff --git a/e2e/suites/search/search-filters.test.ts b/e2e/suites/search/search-filters.test.ts index c8d867db7..276c4ae15 100644 --- a/e2e/suites/search/search-filters.test.ts +++ b/e2e/suites/search/search-filters.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { LoginPage, SearchResultsPage, RepoClient, Utils, FILES, SITE_VISIBILITY, SITE_ROLES } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, SearchResultsPage, RepoClient, Utils, FILES, SITE_VISIBILITY, SITE_ROLES } from '@alfresco/aca-testing-shared'; const moment = require('moment'); @@ -57,7 +57,6 @@ describe('Search filters', () => { const expectedLocations = ['_REPOSITORY_ (1)', `${site} (1)`]; const apis = { - admin: new RepoClient(), user1: new RepoClient(user1, user1), user2: new RepoClient(user2, user2) }; @@ -74,14 +73,15 @@ describe('Search filters', () => { const locationFilter = filters.location; const modifierFilter = filters.modifier; const modifiedDateFilter = filters.modifiedDate; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username: user1 }); - await apis.admin.people.createUser({ username: user2 }); + await adminApiActions.createUser({ username: user1 }); + await adminApiActions.createUser({ username: user2 }); parentId = (await apis.user1.nodes.createFolder(parent)).entry.id; await apis.user1.sites.createSite(site, SITE_VISIBILITY.PUBLIC); await apis.user1.sites.addSiteMember(site, user2, SITE_ROLES.SITE_MANAGER.ROLE); - docLibId = await apis.admin.sites.getDocLibId(site); + docLibId = await adminApiActions.sites.getDocLibId(site); await apis.user1.nodes.setGranularPermission(parentId, true, user2, 'Collaborator'); diff --git a/e2e/suites/search/search-results-files-folders.test.ts b/e2e/suites/search/search-results-files-folders.test.ts index b96d84cd3..f5cd6ae05 100644 --- a/e2e/suites/search/search-results-files-folders.test.ts +++ b/e2e/suites/search/search-results-files-folders.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { LoginPage, SearchResultsPage, RepoClient, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, SearchResultsPage, RepoClient, Utils } from '@alfresco/aca-testing-shared'; const moment = require('moment'); describe('Search results - files and folders', () => { @@ -46,7 +46,6 @@ describe('Search results - files and folders', () => { const site = `test-site-${Utils.random()}`; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -54,9 +53,10 @@ describe('Search results - files and folders', () => { const page = new SearchResultsPage(); const { searchInput } = page.header; const { dataTable, breadcrumb } = page; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); fileId = (await apis.user.nodes.createFile(file, '-my-', fileTitle, fileDescription)).entry.id; await apis.user.nodes.editNodeContent(fileId, 'edited by user'); diff --git a/e2e/suites/search/search-results-general.test.ts b/e2e/suites/search/search-results-general.test.ts index 2e78fff3a..508c7816e 100644 --- a/e2e/suites/search/search-results-general.test.ts +++ b/e2e/suites/search/search-results-general.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { LoginPage, SearchResultsPage, RepoClient, Utils } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, SearchResultsPage, RepoClient, Utils } from '@alfresco/aca-testing-shared'; import { browser } from 'protractor'; describe('Search results general', () => { @@ -36,7 +36,6 @@ describe('Search results general', () => { const site = `test-site-${Utils.random()}`; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -44,9 +43,10 @@ describe('Search results general', () => { const page = new SearchResultsPage(); const { searchInput } = page.header; const dataTable = page.dataTable; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); fileId = (await apis.user.nodes.createFile(file)).entry.id; folderId = (await apis.user.nodes.createFolder(folder)).entry.id; diff --git a/e2e/suites/search/search-results-libraries.test.ts b/e2e/suites/search/search-results-libraries.test.ts index 2398b536b..2ead68df4 100644 --- a/e2e/suites/search/search-results-libraries.test.ts +++ b/e2e/suites/search/search-results-libraries.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { LoginPage, SearchResultsPage, RepoClient, Utils, SITE_VISIBILITY, SITE_ROLES } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, SearchResultsPage, RepoClient, Utils, SITE_VISIBILITY, SITE_ROLES } from '@alfresco/aca-testing-shared'; describe('Search results - libraries', () => { const username = `user-${Utils.random()}`; @@ -63,7 +63,6 @@ describe('Search results - libraries', () => { const adminPrivate = `admin-site-${Utils.random()}`; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -71,9 +70,10 @@ describe('Search results - libraries', () => { const page = new SearchResultsPage(); const { searchInput } = page.header; const dataTable = page.dataTable; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); await apis.user.sites.createSite(site1.name, SITE_VISIBILITY.PUBLIC, '', site1.id); await apis.user.sites.createSite(site2.name, SITE_VISIBILITY.PUBLIC, '', site2.id); @@ -86,16 +86,16 @@ describe('Search results - libraries', () => { await apis.user.sites.createSite(siteRussian.name, SITE_VISIBILITY.PUBLIC, '', siteRussian.id); - await apis.admin.sites.createSite(adminSite1, SITE_VISIBILITY.PUBLIC); - await apis.admin.sites.createSite(adminSite2, SITE_VISIBILITY.PUBLIC); - await apis.admin.sites.createSite(adminSite3, SITE_VISIBILITY.PUBLIC); - await apis.admin.sites.createSite(adminSite4, SITE_VISIBILITY.PUBLIC); - await apis.admin.sites.addSiteMember(adminSite1, username, SITE_ROLES.SITE_CONSUMER.ROLE); - await apis.admin.sites.addSiteMember(adminSite2, username, SITE_ROLES.SITE_CONTRIBUTOR.ROLE); - await apis.admin.sites.addSiteMember(adminSite3, username, SITE_ROLES.SITE_COLLABORATOR.ROLE); - await apis.admin.sites.addSiteMember(adminSite4, username, SITE_ROLES.SITE_MANAGER.ROLE); + await adminApiActions.sites.createSite(adminSite1, SITE_VISIBILITY.PUBLIC); + await adminApiActions.sites.createSite(adminSite2, SITE_VISIBILITY.PUBLIC); + await adminApiActions.sites.createSite(adminSite3, SITE_VISIBILITY.PUBLIC); + await adminApiActions.sites.createSite(adminSite4, SITE_VISIBILITY.PUBLIC); + await adminApiActions.sites.addSiteMember(adminSite1, username, SITE_ROLES.SITE_CONSUMER.ROLE); + await adminApiActions.sites.addSiteMember(adminSite2, username, SITE_ROLES.SITE_CONTRIBUTOR.ROLE); + await adminApiActions.sites.addSiteMember(adminSite3, username, SITE_ROLES.SITE_COLLABORATOR.ROLE); + await adminApiActions.sites.addSiteMember(adminSite4, username, SITE_ROLES.SITE_MANAGER.ROLE); - await apis.admin.sites.createSite(adminPrivate, SITE_VISIBILITY.PRIVATE); + await adminApiActions.sites.createSite(adminPrivate, SITE_VISIBILITY.PRIVATE); await apis.user.sites.waitForApi({ expect: 12 }); await apis.user.queries.waitForSites('lib', { expect: 2 }); @@ -107,7 +107,7 @@ describe('Search results - libraries', () => { afterAll(async (done) => { await Promise.all([ - apis.admin.sites.deleteSites([adminSite1, adminSite2, adminSite3, adminSite4, adminPrivate]), + adminApiActions.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(); diff --git a/e2e/suites/search/search-sorting.test.ts b/e2e/suites/search/search-sorting.test.ts index 36d44cd72..af5d1083e 100644 --- a/e2e/suites/search/search-sorting.test.ts +++ b/e2e/suites/search/search-sorting.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { LoginPage, SearchResultsPage, RepoClient, Utils, FILES } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, SearchResultsPage, RepoClient, Utils, FILES } from '@alfresco/aca-testing-shared'; describe('Search sorting', () => { const random = Utils.random(); @@ -47,7 +47,6 @@ describe('Search sorting', () => { }; const apis = { - admin: new RepoClient(), user1: new RepoClient(user1, user1), user2: new RepoClient(user2, user2) }; @@ -56,10 +55,11 @@ describe('Search sorting', () => { const page = new SearchResultsPage(); const { searchInput } = page.header; const { dataTable } = page; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username: user1 }); - await apis.admin.people.createUser({ username: user2 }); + await adminApiActions.createUser({ username: user1 }); + await adminApiActions.createUser({ username: user2 }); parentId = (await apis.user1.nodes.createFolder(parent)).entry.id; await apis.user1.nodes.setGranularPermission(parentId, true, user2, 'Collaborator'); diff --git a/e2e/suites/viewer/viewer-actions.test.ts b/e2e/suites/viewer/viewer-actions.test.ts index fa965c913..f708c6926 100755 --- a/e2e/suites/viewer/viewer-actions.test.ts +++ b/e2e/suites/viewer/viewer-actions.test.ts @@ -24,6 +24,7 @@ */ import { + AdminActions, LoginPage, BrowsingPage, FILES, @@ -45,7 +46,6 @@ describe('Viewer actions', () => { const pdfFileForDelete = FILES.pdfFile; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -58,9 +58,10 @@ describe('Viewer actions', () => { const shareDialog = new ShareDialog(); const manageVersionsDialog = new ManageVersionsDialog(); const uploadNewVersionDialog = new UploadNewVersionDialog(); + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); done(); }); diff --git a/e2e/suites/viewer/viewer-general.test.ts b/e2e/suites/viewer/viewer-general.test.ts index 0d913d15a..a2aa468d4 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 { LoginPage, BrowsingPage, FILES, SITE_VISIBILITY, RepoClient, Utils, Viewer } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, FILES, SITE_VISIBILITY, RepoClient, Utils, Viewer } from '@alfresco/aca-testing-shared'; describe('Viewer general', () => { const username = `user-${Utils.random()}`; @@ -44,7 +44,6 @@ describe('Viewer general', () => { const fileInSite = FILES.docxFile; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -53,15 +52,16 @@ describe('Viewer general', () => { const { dataTable } = page; const viewer = new Viewer(); const { searchInput } = page.header; + const adminApiActions = new AdminActions(); beforeAll(async (done) => { - await apis.admin.people.createUser({ username }); + await adminApiActions.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 adminApiActions.sites.createSite(siteAdmin, SITE_VISIBILITY.PRIVATE); + docLibId = await adminApiActions.sites.getDocLibId(siteAdmin); + fileAdminId = (await adminApiActions.upload.uploadFile(fileAdmin, docLibId)).entry.id; await apis.user.sites.createSite(siteUser, SITE_VISIBILITY.PUBLIC); docLibSiteUserId = await apis.user.sites.getDocLibId(siteUser); @@ -94,7 +94,7 @@ describe('Viewer general', () => { afterAll(async (done) => { await apis.user.nodes.deleteNodeById(parentId); - await apis.admin.sites.deleteSite(siteAdmin); + await adminApiActions.sites.deleteSite(siteAdmin); await apis.user.sites.deleteSite(siteUser); done(); }); diff --git a/e2e/suites/viewer/viewer-protected-file.test.ts b/e2e/suites/viewer/viewer-protected-file.test.ts index 1dab326c9..950e28196 100755 --- a/e2e/suites/viewer/viewer-protected-file.test.ts +++ b/e2e/suites/viewer/viewer-protected-file.test.ts @@ -23,7 +23,7 @@ * along with Alfresco. If not, see . */ -import { LoginPage, BrowsingPage, FILES, RepoClient, Utils, Viewer, PasswordDialog } from '@alfresco/aca-testing-shared'; +import { AdminActions, LoginPage, BrowsingPage, FILES, RepoClient, Utils, Viewer, PasswordDialog } from '@alfresco/aca-testing-shared'; describe('Viewer - password protected file', () => { const username = `user-${Utils.random()}`; @@ -34,7 +34,6 @@ describe('Viewer - password protected file', () => { const protectedFile = FILES.protectedFile; const apis = { - admin: new RepoClient(), user: new RepoClient(username, username) }; @@ -43,9 +42,10 @@ describe('Viewer - password protected file', () => { const { dataTable } = page; const viewer = new Viewer(); const passwordDialog = new PasswordDialog(); + const adminApiActions = new AdminActions(); beforeAll(async () => { - await apis.admin.people.createUser({ username }); + await adminApiActions.createUser({ username }); parentId = (await apis.user.nodes.createFolder(parent)).entry.id; await apis.user.upload.uploadFile(protectedFile.name, parentId); diff --git a/projects/aca-testing-shared/src/utilities/admin-actions.ts b/projects/aca-testing-shared/src/utilities/admin-actions.ts index 3e050b145..2343fe0aa 100755 --- a/projects/aca-testing-shared/src/utilities/admin-actions.ts +++ b/projects/aca-testing-shared/src/utilities/admin-actions.ts @@ -23,15 +23,20 @@ * along with Alfresco. If not, see . */ -import { RepoClient, NodeContentTree } from './repo-client/repo-client'; -import { PersonEntry, NodeEntry } from '@alfresco/js-api'; -import { PersonModel } from './repo-client/apis/people/people-api-models'; - -import { SitesApi } from './repo-client/apis/sites/sites-api'; -import { UploadApi } from './repo-client/apis/upload/upload-api'; -import { NodesApi } from './repo-client/apis/nodes/nodes-api'; -import { FavoritesApi } from './repo-client/apis/favorites/favorites-api'; -import { SearchApi } from './repo-client/apis/search/search-api'; +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; @@ -45,6 +50,8 @@ export class AdminActions { nodes: NodesApi = new NodesApi(); favorites: FavoritesApi = new FavoritesApi(); search: SearchApi = new SearchApi(); + shared: SharedLinksApi = new SharedLinksApi(); + trashcan: TrashcanApi = new TrashcanApi(); async getDataDictionaryId(): Promise { return this.adminApi.nodes.getNodeIdFromParent('Data Dictionary', '-root-'); @@ -59,7 +66,25 @@ export class AdminActions { } async createUser(user: PersonModel): Promise { - return this.adminApi.people.createUser(user); + const person = new Person(user); + const peopleApi = new PeopleApi(this.adminApi.alfrescoApi); + + await this.adminApi.apiAuth(); + return peopleApi.createPerson(person); + } + + async disableUser(username: string): Promise { + const peopleApi = new PeopleApi(this.adminApi.alfrescoApi); + + await this.adminApi.apiAuth(); + return peopleApi.updatePerson(username, { enabled: false }); + } + + async changePassword(username: string, newPassword: string): Promise { + const peopleApi = new PeopleApi(this.adminApi.alfrescoApi); + + await this.adminApi.apiAuth(); + return peopleApi.updatePerson(username, { password: newPassword }); } async createNodeTemplate(name: string, title: string = '', description: string = '', author: string = ''): Promise { 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 deleted file mode 100755 index b92252a4a..000000000 --- a/projects/aca-testing-shared/src/utilities/repo-client/apis/authentication/authentication-api.ts +++ /dev/null @@ -1,41 +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'; - -export class AuthenticationApi extends RepoApi { - constructor(username?: string, password?: string) { - super(username, password); - } - - async logout() { - try { - await this.apiAuth(); - await this.alfrescoJsApi.logout(); - } catch (error) { - this.handleError(`${this.constructor.name} ${this.logout.name}`, error); - } - } -} 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 df7dccff7..d2f44b863 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 @@ -33,16 +33,6 @@ export class CommentsApi extends RepoApi { super(username, password); } - async getNodeComments(nodeId: string) { - try { - await this.apiAuth(); - return await this.commentsApi.listComments(nodeId); - } catch (error) { - this.handleError(`${this.constructor.name} ${this.getNodeComments.name}`, error); - return null; - } - } - async addComment(nodeId: string, comment: string) { try { await this.apiAuth(); @@ -52,14 +42,4 @@ export class CommentsApi extends RepoApi { return null; } } - - async addComments(nodeId: string, comment: any) { - try { - await this.apiAuth(); - return await this.commentsApi.createComment(nodeId, comment); - } catch (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 8af248c13..d6b07b7cb 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 @@ -91,7 +91,7 @@ export class FavoritesApi extends RepoApi { async getFavorites() { try { await this.apiAuth(); - return await this.favoritesApi.listFavorites(this.getUsername()); + return await this.favoritesApi.listFavorites(this.username); } catch (error) { this.handleError(`FavoritesApi getFavorites : catch : `, error); return null; @@ -101,7 +101,7 @@ export class FavoritesApi extends RepoApi { async getFavoritesTotalItems(): Promise { try { await this.apiAuth(); - return (await this.favoritesApi.listFavorites(this.getUsername())).list.pagination.totalItems; + return (await this.favoritesApi.listFavorites(this.username)).list.pagination.totalItems; } catch (error) { this.handleError(`FavoritesApi getFavoritesTotalItems : catch : `, error); return -1; 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 5b3de0ca2..ed4e64b1b 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,14 +23,12 @@ * along with Alfresco. If not, see . */ -export * from './authentication/authentication-api'; export * from './comments/comments-api'; export * from './favorites/favorites-api'; export * from './nodes/node-body-create'; export * from './nodes/node-content-tree'; export * from './nodes/nodes-api'; export * from './people/people-api-models'; -export * from './people/people-api'; export * from './queries/queries-api'; export * from './search/search-api'; export * from './shared-links/shared-links-api'; 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 deleted file mode 100755 index db310e3b3..000000000 --- a/projects/aca-testing-shared/src/utilities/repo-client/apis/people/people-api.ts +++ /dev/null @@ -1,85 +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 { PersonModel, Person } from './people-api-models'; -import { RepoApi } from '../repo-api'; -import { PeopleApi as AdfPeopleApi } from '@alfresco/js-api'; - -export class PeopleApi extends RepoApi { - peopleApi = new AdfPeopleApi(this.alfrescoJsApi); - - constructor(username?: string, password?: string) { - super(username, password); - } - - async createUser(user: PersonModel) { - try { - const person = new Person(user); - await this.apiAuth(); - return await this.peopleApi.createPerson(person); - } catch (error) { - this.handleError(`${this.constructor.name} ${this.createUser.name}`, error); - return null; - } - } - - async getUser(username: string) { - try { - await this.apiAuth(); - return await this.peopleApi.getPerson(username); - } catch (error) { - this.handleError(`${this.constructor.name} ${this.getUser.name}`, error); - return null; - } - } - - async updateUser(username: string, userDetails?: PersonModel) { - try { - await this.apiAuth(); - return this.peopleApi.updatePerson(username, userDetails); - } catch (error) { - this.handleError(`${this.constructor.name} ${this.updateUser.name}`, error); - return null; - } - } - - async disableUser(username: string) { - try { - return await this.updateUser(username, { enabled: false }); - } catch (error) { - this.handleError(`${this.constructor.name} ${this.disableUser.name}`, error); - return null; - } - } - - async changePassword(username: string, newPassword: string) { - try { - return await this.updateUser(username, { password: newPassword }); - } catch (error) { - this.handleError(`${this.constructor.name} ${this.changePassword.name}`, error); - return null; - } - } -} 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 701dd3f73..bfcee12fb 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,7 +30,7 @@ import { Logger } from '@alfresco/adf-testing'; export abstract class RepoApi { alfrescoJsApi = new AlfrescoApi(); - protected constructor(private username: string = browser.params.ADMIN_USERNAME, private password: string = browser.params.ADMIN_PASSWORD) { + protected constructor(public username: string = browser.params.ADMIN_USERNAME, private password: string = browser.params.ADMIN_PASSWORD) { this.alfrescoJsApi.setConfig(browser.params.config); } @@ -38,10 +38,6 @@ export abstract class RepoApi { return this.alfrescoJsApi.login(this.username, this.password); } - getUsername(): string { - return this.username; - } - protected handleError(message: string, response: any) { Logger.error(`\n--- ${message} error :`); Logger.error('\t>>> username: ', this.username); 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 776cb40f1..057654be5 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 @@ -57,7 +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.username); } catch (error) { this.handleError(`SitesApi getSites : catch : `, error); return null; @@ -67,7 +67,7 @@ export class SitesApi extends RepoApi { async getSitesTotalItems(): Promise { try { await this.apiAuth(); - return (await this.sitesApi.listSiteMembershipsForPerson(this.getUsername())).list.pagination.totalItems; + return (await this.sitesApi.listSiteMembershipsForPerson(this.username)).list.pagination.totalItems; } catch (error) { this.handleError(`SitesApi getSitesTotalItems : catch : `, error); return -1; 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 6e02fa3d4..53398bd1d 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,71 +24,59 @@ */ import { browser } from 'protractor'; -import { PeopleApi } from './apis/people/people-api'; -import { NodesApi } from './apis/nodes/nodes-api'; -import { CommentsApi } from './apis/comments/comments-api'; -import { SitesApi } from './apis/sites/sites-api'; -import { FavoritesApi } from './apis/favorites/favorites-api'; -import { QueriesApi } from './apis/queries/queries-api'; -import { SharedLinksApi } from './apis/shared-links/shared-links-api'; -import { TrashcanApi } from './apis/trashcan/trashcan-api'; -import { SearchApi } from './apis/search/search-api'; -import { UploadApi } from './apis/upload/upload-api'; -import { AuthenticationApi } from './apis/authentication/authentication-api'; +import { NodesApi, CommentsApi, SitesApi, FavoritesApi, QueriesApi, SharedLinksApi, TrashcanApi, SearchApi, UploadApi } from './apis'; +import { AlfrescoApi } from '@alfresco/js-api'; export class RepoClient { - constructor(private username: string = browser.params.ADMIN_USERNAME, private password: string = browser.params.ADMIN_PASSWORD) {} + alfrescoApi: AlfrescoApi; - private get auth() { - const { username, password } = this; - return { username, password }; + constructor(private username: string = browser.params.ADMIN_USERNAME, private password: string = browser.params.ADMIN_PASSWORD) { + this.alfrescoApi = new AlfrescoApi(); + this.alfrescoApi.setConfig(browser.params.config); } - get people() { - return new PeopleApi(this.auth.username, this.auth.password); + apiAuth(): Promise { + return this.alfrescoApi.login(this.username, this.password); } - get nodes() { - return new NodesApi(this.auth.username, this.auth.password); + get nodes(): NodesApi { + return new NodesApi(this.username, this.password); } - get comments() { - return new CommentsApi(this.auth.username, this.auth.password); + get comments(): CommentsApi { + return new CommentsApi(this.username, this.password); } - get sites() { - return new SitesApi(this.auth.username, this.auth.password); + get sites(): SitesApi { + return new SitesApi(this.username, this.password); } - get favorites() { - return new FavoritesApi(this.auth.username, this.auth.password); + get favorites(): FavoritesApi { + return new FavoritesApi(this.username, this.password); } - get shared() { - return new SharedLinksApi(this.auth.username, this.auth.password); + get shared(): SharedLinksApi { + return new SharedLinksApi(this.username, this.password); } - get trashcan() { - return new TrashcanApi(this.auth.username, this.auth.password); + get trashcan(): TrashcanApi { + return new TrashcanApi(this.username, this.password); } - get search() { - return new SearchApi(this.auth.username, this.auth.password); + get search(): SearchApi { + return new SearchApi(this.username, this.password); } - get queries() { - return new QueriesApi(this.auth.username, this.auth.password); + get queries(): QueriesApi { + return new QueriesApi(this.username, this.password); } - get upload() { - return new UploadApi(this.auth.username, this.auth.password); + get upload(): UploadApi { + return new UploadApi(this.username, this.password); } - get authentication() { - return new AuthenticationApi(this.auth.username, this.auth.password); + async logout(): Promise { + await this.apiAuth(); + return this.alfrescoApi.logout(); } } - -export * from './apis/nodes/node-body-create'; -export * from './apis/nodes/node-content-tree'; -export * from './apis/nodes/nodes-api';