[ACA-1635][ACA-1636] update favoritesApi and nodesApi to use alfresco-js-api-node (#564)

* refactor favoritesApi and nodesApi to use alfresco-js-api-node

* remove node-rest-client
This commit is contained in:
Adina Parpalita 2018-08-14 08:57:03 +03:00 committed by Cilibiu Bogdan
parent 213c2deedc
commit 86a90d33e2
36 changed files with 3292 additions and 3565 deletions

View File

@ -62,15 +62,15 @@ describe('Delete and undo delete', () => {
const fileLocked1 = `fileLocked-${Utils.random()}.txt`; let fileLocked1Id; const fileLocked1 = `fileLocked-${Utils.random()}.txt`; let fileLocked1Id;
beforeAll(done => { beforeAll(done => {
apis.user.nodes.createFile(file1).then(resp => file1Id = resp.data.entry.id) apis.user.nodes.createFile(file1).then(resp => file1Id = resp.entry.id)
.then(() => apis.user.nodes.createFile(file2).then(resp => file2Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile(file2).then(resp => file2Id = resp.entry.id))
.then(() => apis.user.nodes.createFolder(folder1).then(resp => folder1Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFolder(folder1).then(resp => folder1Id = resp.entry.id))
.then(() => apis.user.nodes.createFolder(folder2).then(resp => folder2Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFolder(folder2).then(resp => folder2Id = resp.entry.id))
.then(() => apis.user.nodes.createFile(file3, folder1Id)) .then(() => apis.user.nodes.createFile(file3, folder1Id))
.then(() => apis.user.nodes.createFile(file4, folder2Id).then(resp => file4Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile(file4, folder2Id).then(resp => file4Id = resp.entry.id))
.then(() => apis.user.nodes.lockFile(file4Id)) .then(() => apis.user.nodes.lockFile(file4Id))
.then(() => apis.user.nodes.createFile(fileLocked1).then(resp => fileLocked1Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile(fileLocked1).then(resp => fileLocked1Id = resp.entry.id))
.then(() => apis.user.nodes.lockFile(fileLocked1Id)) .then(() => apis.user.nodes.lockFile(fileLocked1Id))
.then(() => loginPage.loginWith(username)) .then(() => loginPage.loginWith(username))
@ -275,10 +275,10 @@ describe('Delete and undo delete', () => {
const sharedFile4 = `sharedFile4-${Utils.random()}.txt`; let sharedFile4Id; const sharedFile4 = `sharedFile4-${Utils.random()}.txt`; let sharedFile4Id;
beforeAll(done => { beforeAll(done => {
apis.user.nodes.createFile(sharedFile1).then(resp => sharedFile1Id = resp.data.entry.id) apis.user.nodes.createFile(sharedFile1).then(resp => sharedFile1Id = resp.entry.id)
.then(() => apis.user.nodes.createFile(sharedFile2).then(resp => sharedFile2Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile(sharedFile2).then(resp => sharedFile2Id = resp.entry.id))
.then(() => apis.user.nodes.createFile(sharedFile3).then(resp => sharedFile3Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile(sharedFile3).then(resp => sharedFile3Id = resp.entry.id))
.then(() => apis.user.nodes.createFile(sharedFile4).then(resp => sharedFile4Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile(sharedFile4).then(resp => sharedFile4Id = resp.entry.id))
.then(() => apis.user.shared.shareFilesByIds([sharedFile1Id, sharedFile2Id, sharedFile3Id, sharedFile4Id])) .then(() => apis.user.shared.shareFilesByIds([sharedFile1Id, sharedFile2Id, sharedFile3Id, sharedFile4Id]))
.then(() => apis.user.shared.waitForApi({ expect: 4 })) .then(() => apis.user.shared.waitForApi({ expect: 4 }))
@ -386,15 +386,15 @@ describe('Delete and undo delete', () => {
const favoriteFileLocked1 = `favFileLocked-${Utils.random()}.txt`; let favoriteFileLocked1Id; const favoriteFileLocked1 = `favFileLocked-${Utils.random()}.txt`; let favoriteFileLocked1Id;
beforeAll(done => { beforeAll(done => {
apis.user.nodes.createFile(favoriteFile1).then(resp => favoriteFile1Id = resp.data.entry.id) apis.user.nodes.createFile(favoriteFile1).then(resp => favoriteFile1Id = resp.entry.id)
.then(() => apis.user.nodes.createFile(favoriteFile2).then(resp => favoriteFile2Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile(favoriteFile2).then(resp => favoriteFile2Id = resp.entry.id))
.then(() => apis.user.nodes.createFolder(favoriteFolder1).then(resp => favoriteFolder1Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFolder(favoriteFolder1).then(resp => favoriteFolder1Id = resp.entry.id))
.then(() => apis.user.nodes.createFolder(favoriteFolder2).then(resp => favoriteFolder2Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFolder(favoriteFolder2).then(resp => favoriteFolder2Id = resp.entry.id))
.then(() => apis.user.nodes.createFile(favoriteFile3, favoriteFolder1Id)) .then(() => apis.user.nodes.createFile(favoriteFile3, favoriteFolder1Id))
.then(() => apis.user.nodes.createFile(favoriteFile4, favoriteFolder2Id).then(resp => favoriteFile4Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile(favoriteFile4, favoriteFolder2Id).then(resp => favoriteFile4Id = resp.entry.id))
.then(() => apis.user.nodes.lockFile(favoriteFile4Id)) .then(() => apis.user.nodes.lockFile(favoriteFile4Id))
.then(() => apis.user.nodes.createFile(favoriteFileLocked1).then(resp => favoriteFileLocked1Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile(favoriteFileLocked1).then(resp => favoriteFileLocked1Id = resp.entry.id))
.then(() => apis.user.nodes.lockFile(favoriteFileLocked1Id)) .then(() => apis.user.nodes.lockFile(favoriteFileLocked1Id))
.then(() => apis.user.favorites.addFavoritesByIds('file', [favoriteFile1Id, favoriteFile2Id, favoriteFileLocked1Id])) .then(() => apis.user.favorites.addFavoritesByIds('file', [favoriteFile1Id, favoriteFile2Id, favoriteFileLocked1Id]))
@ -603,10 +603,10 @@ describe('Delete and undo delete', () => {
const recentFile4 = `recentFile4-${Utils.random()}.txt`; let recentFile4Id; const recentFile4 = `recentFile4-${Utils.random()}.txt`; let recentFile4Id;
beforeAll(done => { beforeAll(done => {
apis.user.nodes.createFile(recentFile1).then(resp => recentFile1Id = resp.data.entry.id) apis.user.nodes.createFile(recentFile1).then(resp => recentFile1Id = resp.entry.id)
.then(() => apis.user.nodes.createFile(recentFile2).then(resp => recentFile2Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile(recentFile2).then(resp => recentFile2Id = resp.entry.id))
.then(() => apis.user.nodes.createFile(recentFile3).then(resp => recentFile3Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile(recentFile3).then(resp => recentFile3Id = resp.entry.id))
.then(() => apis.user.nodes.createFile(recentFile4).then(resp => recentFile4Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile(recentFile4).then(resp => recentFile4Id = resp.entry.id))
.then(() => apis.user.search.waitForApi(username, { expect: 4 })) .then(() => apis.user.search.waitForApi(username, { expect: 4 }))
.then(() => loginPage.loginWith(username)) .then(() => loginPage.loginWith(username))

View File

@ -64,7 +64,7 @@ describe('Edit folder', () => {
.then(() => apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_CONSUMER)) .then(() => apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_CONSUMER))
.then(() => apis.user.nodes.createFolder( parent )) .then(() => apis.user.nodes.createFolder( parent ))
.then(resp => apis.user.nodes.createFolder( folderName, resp.data.entry.id, '', folderDescription )) .then(resp => apis.user.nodes.createFolder( folderName, resp.entry.id, '', folderDescription ))
.then(() => apis.user.nodes.createFolders([ folderNameToEdit, duplicateFolderName ], parent)) .then(() => apis.user.nodes.createFolders([ folderNameToEdit, duplicateFolderName ], parent))
.then(() => loginPage.loginWith(username)) .then(() => loginPage.loginWith(username))

View File

@ -52,11 +52,11 @@ describe('Mark items as favorites', () => {
beforeAll(done => { beforeAll(done => {
apis.admin.people.createUser({ username }) apis.admin.people.createUser({ username })
.then(() => apis.user.nodes.createFile( file1NotFav ).then(resp => file1Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile( file1NotFav ).then(resp => file1Id = resp.entry.id))
.then(() => apis.user.nodes.createFile( file2NotFav ).then(resp => file2Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile( file2NotFav ).then(resp => file2Id = resp.entry.id))
.then(() => apis.user.nodes.createFile( file3Fav ).then(resp => file3Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile( file3Fav ).then(resp => file3Id = resp.entry.id))
.then(() => apis.user.nodes.createFile( file4Fav ).then(resp => file4Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile( file4Fav ).then(resp => file4Id = resp.entry.id))
.then(() => apis.user.nodes.createFolder( folder1 ).then(resp => folder1Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFolder( folder1 ).then(resp => folder1Id = resp.entry.id))
.then(() => apis.user.favorites.addFavoriteById('file', file3Id)) .then(() => apis.user.favorites.addFavoriteById('file', file3Id))
.then(() => apis.user.favorites.addFavoriteById('file', file4Id)) .then(() => apis.user.favorites.addFavoriteById('file', file4Id))

View File

@ -52,9 +52,9 @@ describe('Permanently delete from Trash', () => {
beforeAll(done => { beforeAll(done => {
apis.admin.people.createUser({ username }) apis.admin.people.createUser({ username })
.then(() => apis.user.nodes.createFiles([ file1, file2 ])) .then(() => apis.user.nodes.createFiles([ file1, file2 ]))
.then(resp => filesIds = resp.data.list.entries.map(entries => entries.entry.id)) .then(resp => filesIds = resp.list.entries.map(entries => entries.entry.id))
.then(() => apis.user.nodes.createFolders([ folder1, folder2 ])) .then(() => apis.user.nodes.createFolders([ folder1, folder2 ]))
.then(resp => foldersIds = resp.data.list.entries.map(entries => entries.entry.id)) .then(resp => foldersIds = resp.list.entries.map(entries => entries.entry.id))
.then(() => apis.user.nodes.deleteNodesById(filesIds, false)) .then(() => apis.user.nodes.deleteNodesById(filesIds, false))
.then(() => apis.user.nodes.deleteNodesById(foldersIds, false)) .then(() => apis.user.nodes.deleteNodesById(foldersIds, false))

View File

@ -63,8 +63,8 @@ describe('Restore from Trash', () => {
const folder = `folder-${Utils.random()}`; let folderId; const folder = `folder-${Utils.random()}`; let folderId;
beforeAll(done => { beforeAll(done => {
apis.user.nodes.createFile(file).then(resp => fileId = resp.data.entry.id) apis.user.nodes.createFile(file).then(resp => fileId = resp.entry.id)
.then(() => apis.user.nodes.createFolder(folder).then(resp => folderId = resp.data.entry.id)) .then(() => apis.user.nodes.createFolder(folder).then(resp => folderId = resp.entry.id))
.then(() => apis.user.nodes.deleteNodesById([ fileId, folderId ], false)) .then(() => apis.user.nodes.deleteNodesById([ fileId, folderId ], false))
.then(done); .then(done);
}); });
@ -157,13 +157,13 @@ describe('Restore from Trash', () => {
const folder2 = `folder-${Utils.random()}`; let folder2Id; const folder2 = `folder-${Utils.random()}`; let folder2Id;
beforeAll(done => { beforeAll(done => {
apis.user.nodes.createFolder(folder1).then(resp => folder1Id = resp.data.entry.id) apis.user.nodes.createFolder(folder1).then(resp => folder1Id = resp.entry.id)
.then(() => apis.user.nodes.createFile(file1, folder1Id).then(resp => file1Id1 = resp.data.entry.id)) .then(() => apis.user.nodes.createFile(file1, folder1Id).then(resp => file1Id1 = resp.entry.id))
.then(() => apis.user.nodes.deleteNodeById(file1Id1, false)) .then(() => apis.user.nodes.deleteNodeById(file1Id1, false))
.then(() => apis.user.nodes.createFile(file1, folder1Id).then(resp => file1Id2 = resp.data.entry.id)) .then(() => apis.user.nodes.createFile(file1, folder1Id).then(resp => file1Id2 = resp.entry.id))
.then(() => apis.user.nodes.createFolder(folder2).then(resp => folder2Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFolder(folder2).then(resp => folder2Id = resp.entry.id))
.then(() => apis.user.nodes.createFile(file2, folder2Id).then(resp => file2Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile(file2, folder2Id).then(resp => file2Id = resp.entry.id))
.then(() => apis.user.nodes.deleteNodeById(file2Id, false)) .then(() => apis.user.nodes.deleteNodeById(file2Id, false))
.then(() => apis.user.nodes.deleteNodeById(folder2Id, false)) .then(() => apis.user.nodes.deleteNodeById(folder2Id, false))
@ -215,19 +215,19 @@ describe('Restore from Trash', () => {
const file5 = `file5-${Utils.random()}.txt`; let file5Id; const file5 = `file5-${Utils.random()}.txt`; let file5Id;
beforeAll(done => { beforeAll(done => {
apis.user.nodes.createFolder(folder1).then(resp => folder1Id = resp.data.entry.id) apis.user.nodes.createFolder(folder1).then(resp => folder1Id = resp.entry.id)
.then(() => apis.user.nodes.createFile(file1, folder1Id).then(resp => file1Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile(file1, folder1Id).then(resp => file1Id = resp.entry.id))
.then(() => apis.user.nodes.createFolder(folder2).then(resp => folder2Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFolder(folder2).then(resp => folder2Id = resp.entry.id))
.then(() => apis.user.nodes.createFile(file2, folder2Id).then(resp => file2Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile(file2, folder2Id).then(resp => file2Id = resp.entry.id))
.then(() => apis.user.nodes.deleteNodeById(file1Id, false)) .then(() => apis.user.nodes.deleteNodeById(file1Id, false))
.then(() => apis.user.nodes.deleteNodeById(folder1Id, false)) .then(() => apis.user.nodes.deleteNodeById(folder1Id, false))
.then(() => apis.user.nodes.deleteNodeById(file2Id, false)) .then(() => apis.user.nodes.deleteNodeById(file2Id, false))
.then(() => apis.user.nodes.createFolder(folder3).then(resp => folder3Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFolder(folder3).then(resp => folder3Id = resp.entry.id))
.then(() => apis.user.nodes.createFile(file3, folder3Id).then(resp => file3Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile(file3, folder3Id).then(resp => file3Id = resp.entry.id))
.then(() => apis.user.nodes.createFile(file4, folder3Id).then(resp => file4Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile(file4, folder3Id).then(resp => file4Id = resp.entry.id))
.then(() => apis.user.nodes.createFolder(folder4).then(resp => folder4Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFolder(folder4).then(resp => folder4Id = resp.entry.id))
.then(() => apis.user.nodes.createFile(file5, folder4Id).then(resp => file5Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFile(file5, folder4Id).then(resp => file5Id = resp.entry.id))
.then(() => apis.user.nodes.deleteNodeById(file3Id, false)) .then(() => apis.user.nodes.deleteNodeById(file3Id, false))
.then(() => apis.user.nodes.deleteNodeById(file4Id, false)) .then(() => apis.user.nodes.deleteNodeById(file4Id, false))
.then(() => apis.user.nodes.deleteNodeById(folder3Id, false)) .then(() => apis.user.nodes.deleteNodeById(folder3Id, false))

View File

@ -67,14 +67,14 @@ describe('Toolbar actions - multiple selection : ', () => {
beforeAll(done => { beforeAll(done => {
apis.admin.people.createUser({ username: user1 }) apis.admin.people.createUser({ username: user1 })
.then(() => apis.user.nodes.createFiles([ file1 ]).then(resp => file1Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFiles([ file1 ]).then(resp => file1Id = resp.entry.id))
.then(() => apis.user.nodes.createFiles([ file2 ]).then(resp => file2Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFiles([ file2 ]).then(resp => file2Id = resp.entry.id))
.then(() => apis.user.nodes.createFolders([ folder1 ]).then(resp => folder1Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFolders([ folder1 ]).then(resp => folder1Id = resp.entry.id))
.then(() => apis.user.nodes.createFolders([ folder2 ]).then(resp => folder2Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFolders([ folder2 ]).then(resp => folder2Id = resp.entry.id))
.then(() => apis.user.nodes.createFiles([ fileForDelete1 ]).then(resp => fileForDelete1Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFiles([ fileForDelete1 ]).then(resp => fileForDelete1Id = resp.entry.id))
.then(() => apis.user.nodes.createFiles([ fileForDelete2 ]).then(resp => fileForDelete2Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFiles([ fileForDelete2 ]).then(resp => fileForDelete2Id = resp.entry.id))
.then(() => apis.user.nodes.createFolders([ folderForDelete1 ]).then(resp => folderForDelete1Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFolders([ folderForDelete1 ]).then(resp => folderForDelete1Id = resp.entry.id))
.then(() => apis.user.nodes.createFolders([ folderForDelete2 ]).then(resp => folderForDelete2Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFolders([ folderForDelete2 ]).then(resp => folderForDelete2Id = resp.entry.id))
.then(() => apis.user.shared.shareFilesByIds([ file1Id, file2Id ])) .then(() => apis.user.shared.shareFilesByIds([ file1Id, file2Id ]))
.then(() => apis.user.shared.waitForApi({ expect: 2 })) .then(() => apis.user.shared.waitForApi({ expect: 2 }))

View File

@ -55,10 +55,10 @@ describe('Toolbar actions - single selection : ', () => {
beforeAll(async (done) => { beforeAll(async (done) => {
await apis.admin.people.createUser({ username }); await apis.admin.people.createUser({ username });
fileUserId = (await apis.user.nodes.createFiles([fileUser])).data.entry.id; fileUserId = (await apis.user.nodes.createFiles([fileUser])).entry.id;
fileForDeleteId = (await apis.user.nodes.createFiles([fileForDelete])).data.entry.id; fileForDeleteId = (await apis.user.nodes.createFiles([fileForDelete])).entry.id;
folderForDeleteId = (await apis.user.nodes.createFolders([ folderForDelete ])).data.entry.id; folderForDeleteId = (await apis.user.nodes.createFolders([ folderForDelete ])).entry.id;
folderUserId = (await apis.user.nodes.createFolders([ folderUser ])).data.entry.id; folderUserId = (await apis.user.nodes.createFolders([ folderUser ])).entry.id;
await apis.user.shared.shareFileById(fileUserId); await apis.user.shared.shareFileById(fileUserId);
await apis.user.shared.waitForApi({ expect: 1 }); await apis.user.shared.waitForApi({ expect: 1 });
@ -123,8 +123,8 @@ describe('Toolbar actions - single selection : ', () => {
await apis.admin.sites.createSite(site, SITE_VISIBILITY.PRIVATE); await apis.admin.sites.createSite(site, SITE_VISIBILITY.PRIVATE);
const docLibId = await apis.admin.sites.getDocLibId(site); const docLibId = await apis.admin.sites.getDocLibId(site);
file1Id = (await apis.admin.nodes.createFile(file1, docLibId)).data.entry.id; file1Id = (await apis.admin.nodes.createFile(file1, docLibId)).entry.id;
file2Id = (await apis.admin.nodes.createFile(file2, docLibId)).data.entry.id; file2Id = (await apis.admin.nodes.createFile(file2, docLibId)).entry.id;
await apis.admin.sites.addSiteMember(site, username, SITE_ROLES.SITE_CONSUMER); await apis.admin.sites.addSiteMember(site, username, SITE_ROLES.SITE_CONSUMER);
await apis.admin.nodes.setGranularPermission(file1Id, false, username, SITE_ROLES.SITE_CONSUMER); await apis.admin.nodes.setGranularPermission(file1Id, false, username, SITE_ROLES.SITE_CONSUMER);

View File

@ -46,7 +46,7 @@ describe('Upload files', () => {
beforeAll(done => { beforeAll(done => {
apis.admin.people.createUser({ username }) apis.admin.people.createUser({ username })
.then(() => apis.user.nodes.createFolder(folder1).then(resp => folder1Id = resp.data.entry.id)) .then(() => apis.user.nodes.createFolder(folder1).then(resp => folder1Id = resp.entry.id))
.then(() => loginPage.loginWith(username)) .then(() => loginPage.loginWith(username))
.then(done); .then(done);

View File

@ -58,22 +58,22 @@ describe('Favorites', () => {
const docLibId = await apis.admin.sites.getDocLibId(siteName); const docLibId = await apis.admin.sites.getDocLibId(siteName);
await apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_MANAGER); await apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_MANAGER);
const file1Id = (await apis.admin.nodes.createFile(fileName1, docLibId)).data.entry.id; const file1Id = (await apis.admin.nodes.createFile(fileName1, docLibId)).entry.id;
await apis.user.favorites.addFavoriteById('file', file1Id); await apis.user.favorites.addFavoriteById('file', file1Id);
const folderId = (await apis.user.nodes.createFolder(favFolderName)).data.entry.id; const folderId = (await apis.user.nodes.createFolder(favFolderName)).entry.id;
await apis.user.favorites.addFavoriteById('folder', folderId); await apis.user.favorites.addFavoriteById('folder', folderId);
const parentId = (await apis.user.nodes.createFolder(parentFolder)).data.entry.id; const parentId = (await apis.user.nodes.createFolder(parentFolder)).entry.id;
const file2Id = (await apis.user.nodes.createFile(fileName2, parentId)).data.entry.id; const file2Id = (await apis.user.nodes.createFile(fileName2, parentId)).entry.id;
await apis.user.favorites.addFavoriteById('file', file2Id); await apis.user.favorites.addFavoriteById('file', file2Id);
const file3Id = (await apis.user.nodes.createFile(fileName3, parentId)).data.entry.id; const file3Id = (await apis.user.nodes.createFile(fileName3, parentId)).entry.id;
await apis.user.favorites.addFavoriteById('file', file3Id); await apis.user.favorites.addFavoriteById('file', file3Id);
await apis.user.nodes.deleteNodeById(file3Id, false); await apis.user.nodes.deleteNodeById(file3Id, false);
const file4Id = (await apis.user.nodes.createFile(fileName4, parentId)).data.entry.id; const file4Id = (await apis.user.nodes.createFile(fileName4, parentId)).entry.id;
await apis.user.favorites.addFavoriteById('file', file4Id); await apis.user.favorites.addFavoriteById('file', file4Id);
await apis.user.nodes.deleteNodeById(file4Id, false); await apis.user.nodes.deleteNodeById(file4Id, false);
await apis.user.trashcan.restore(file4Id); await apis.user.trashcan.restore(file4Id);

View File

@ -59,7 +59,7 @@ describe('Special permissions', () => {
apis.admin.sites.createSite(sitePrivate, SITE_VISIBILITY.PRIVATE) apis.admin.sites.createSite(sitePrivate, SITE_VISIBILITY.PRIVATE)
.then(() => apis.admin.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_COLLABORATOR)) .then(() => apis.admin.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_COLLABORATOR))
.then(() => apis.admin.nodes.createFiles([ fileName ], `Sites/${sitePrivate}/documentLibrary`) .then(() => apis.admin.nodes.createFiles([ fileName ], `Sites/${sitePrivate}/documentLibrary`)
.then(resp => fileId = resp.data.entry.id)) .then(resp => fileId = resp.entry.id))
.then(() => apis.user.favorites.addFavoriteById('file', fileId)) .then(() => apis.user.favorites.addFavoriteById('file', fileId))
.then(() => apis.admin.shared.shareFileById(fileId)) .then(() => apis.admin.shared.shareFileById(fileId))
.then(() => apis.user.nodes.editNodeContent(fileId, 'edited by user')) .then(() => apis.user.nodes.editNodeContent(fileId, 'edited by user'))
@ -133,7 +133,7 @@ describe('Special permissions', () => {
.then(() => apis.admin.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_COLLABORATOR)) .then(() => apis.admin.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_COLLABORATOR))
.then(() => apis.admin.sites.getDocLibId(sitePrivate)) .then(() => apis.admin.sites.getDocLibId(sitePrivate))
.then(resp => apis.user.nodes.createFile(fileName, resp)) .then(resp => apis.user.nodes.createFile(fileName, resp))
.then(resp => fileId = resp.data.entry.id) .then(resp => fileId = resp.entry.id)
.then(() => apis.user.favorites.addFavoriteById('file', fileId)) .then(() => apis.user.favorites.addFavoriteById('file', fileId))
.then(() => apis.user.shared.shareFileById(fileId)) .then(() => apis.user.shared.shareFileById(fileId))
.then(() => apis.user.shared.waitForApi({ expect: 1 })) .then(() => apis.user.shared.waitForApi({ expect: 1 }))

View File

@ -129,7 +129,7 @@ describe('Personal Files', () => {
it('navigates to folder - [C213244]', () => { it('navigates to folder - [C213244]', () => {
const getNodeIdPromise = apis.user.nodes const getNodeIdPromise = apis.user.nodes
.getNodeByPath(`/${userFolder}`) .getNodeByPath(`/${userFolder}`)
.then(response => response.data.entry.id); .then(response => response.entry.id);
const navigatePromise = dataTable const navigatePromise = dataTable
.doubleClickOnRowByName(userFolder) .doubleClickOnRowByName(userFolder)

View File

@ -53,14 +53,14 @@ describe('Recent Files', () => {
beforeAll(done => { beforeAll(done => {
apis.admin.people.createUser({ username }) apis.admin.people.createUser({ username })
.then(() => apis.user.nodes.createFolders([ folderName ])).then(resp => folderId = resp.data.entry.id) .then(() => apis.user.nodes.createFolders([ folderName ])).then(resp => folderId = resp.entry.id)
.then(() => apis.user.nodes.createFiles([ fileName1 ], folderName)) .then(() => apis.user.nodes.createFiles([ fileName1 ], folderName))
.then(() => apis.user.nodes.createFiles([ fileName2 ])).then(resp => file2Id = resp.data.entry.id) .then(() => apis.user.nodes.createFiles([ fileName2 ])).then(resp => file2Id = resp.entry.id)
.then(() => apis.user.nodes.createFiles([ fileName3 ]).then(resp => apis.user.nodes.deleteNodeById(resp.data.entry.id, false))) .then(() => apis.user.nodes.createFiles([ fileName3 ]).then(resp => apis.user.nodes.deleteNodeById(resp.entry.id, false)))
.then(() => apis.user.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC)) .then(() => apis.user.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC))
.then(() => apis.user.sites.getDocLibId(siteName)) .then(() => apis.user.sites.getDocLibId(siteName))
.then(resp => apis.user.nodes.createFolder(folderSite, resp)).then(resp => folderSiteId = resp.data.entry.id) .then(resp => apis.user.nodes.createFolder(folderSite, resp)).then(resp => folderSiteId = resp.entry.id)
.then(() => apis.user.nodes.createFile(fileSite, folderSiteId)) .then(() => apis.user.nodes.createFile(fileSite, folderSiteId))
.then(() => apis.user.search.waitForApi(username, { expect: 3 })) .then(() => apis.user.search.waitForApi(username, { expect: 3 }))

View File

@ -57,13 +57,13 @@ describe('Shared Files', () => {
.then(() => apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC)) .then(() => apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC))
.then(() => apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_CONSUMER)) .then(() => apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_CONSUMER))
.then(() => apis.admin.nodes.createFiles([ fileAdmin ], `Sites/${siteName}/documentLibrary`)) .then(() => apis.admin.nodes.createFiles([ fileAdmin ], `Sites/${siteName}/documentLibrary`))
.then(resp => apis.admin.shared.shareFileById(resp.data.entry.id)) .then(resp => apis.admin.shared.shareFileById(resp.entry.id))
.then(() => apis.user.nodes.createFolders([ folderUser ])) .then(() => apis.user.nodes.createFolders([ folderUser ]))
.then(() => apis.user.nodes.createFiles([ file1User ], folderUser)).then(resp => file1Id = resp.data.entry.id) .then(() => apis.user.nodes.createFiles([ file1User ], folderUser)).then(resp => file1Id = resp.entry.id)
.then(() => apis.user.nodes.createFile(file2User)).then(resp => file2Id = resp.data.entry.id) .then(() => apis.user.nodes.createFile(file2User)).then(resp => file2Id = resp.entry.id)
.then(() => apis.user.nodes.createFile(file3User)).then(resp => file3Id = resp.data.entry.id) .then(() => apis.user.nodes.createFile(file3User)).then(resp => file3Id = resp.entry.id)
.then(() => apis.user.nodes.createFile(file4User)).then(resp => file4Id = resp.data.entry.id) .then(() => apis.user.nodes.createFile(file4User)).then(resp => file4Id = resp.entry.id)
.then(() => apis.user.shared.shareFilesByIds([file1Id, file2Id, file3Id, file4Id])) .then(() => apis.user.shared.shareFilesByIds([file1Id, file2Id, file3Id, file4Id]))
.then(() => apis.user.shared.waitForApi({ expect: 5 })) .then(() => apis.user.shared.waitForApi({ expect: 5 }))

View File

@ -59,21 +59,21 @@ describe('File / folder tooltips', () => {
beforeAll(done => { beforeAll(done => {
apis.admin.people.createUser({ username }) apis.admin.people.createUser({ username })
.then(() => apis.user.nodes.createFolder( parent )) .then(() => apis.user.nodes.createFolder( parent ))
.then(resp => parentId = resp.data.entry.id) .then(resp => parentId = resp.entry.id)
.then(() => Promise.all([ .then(() => Promise.all([
apis.user.nodes.createFile(file, parentId).then(resp => file1Id = resp.data.entry.id), apis.user.nodes.createFile(file, parentId).then(resp => file1Id = resp.entry.id),
apis.user.nodes.createFile(fileWithDesc, parentId, '', fileDescription).then(resp => file2Id = resp.data.entry.id), apis.user.nodes.createFile(fileWithDesc, parentId, '', fileDescription).then(resp => file2Id = resp.entry.id),
apis.user.nodes.createFile(fileWithTitle, parentId, fileTitle).then(resp => file3Id = resp.data.entry.id), apis.user.nodes.createFile(fileWithTitle, parentId, fileTitle).then(resp => file3Id = resp.entry.id),
apis.user.nodes.createFile(fileWithTitleAndDesc, parentId, fileTitle, fileDescription) apis.user.nodes.createFile(fileWithTitleAndDesc, parentId, fileTitle, fileDescription)
.then(resp => file4Id = resp.data.entry.id), .then(resp => file4Id = resp.entry.id),
apis.user.nodes.createFile(fileNameEqTitleEqDesc, parentId, fileNameEqTitleEqDesc, fileNameEqTitleEqDesc) apis.user.nodes.createFile(fileNameEqTitleEqDesc, parentId, fileNameEqTitleEqDesc, fileNameEqTitleEqDesc)
.then(resp => file5Id = resp.data.entry.id), .then(resp => file5Id = resp.entry.id),
apis.user.nodes.createFile(fileNameEqTitleDiffDesc, parentId, fileNameEqTitleDiffDesc, fileDescription) apis.user.nodes.createFile(fileNameEqTitleDiffDesc, parentId, fileNameEqTitleDiffDesc, fileDescription)
.then(resp => file6Id = resp.data.entry.id), .then(resp => file6Id = resp.entry.id),
apis.user.nodes.createFile(fileNameEqDescDiffTitle, parentId, fileTitle, fileNameEqDescDiffTitle) apis.user.nodes.createFile(fileNameEqDescDiffTitle, parentId, fileTitle, fileNameEqDescDiffTitle)
.then(resp => file7Id = resp.data.entry.id), .then(resp => file7Id = resp.entry.id),
apis.user.nodes.createFile(fileTitleEqDesc, parentId, fileTitle, fileTitle).then(resp => file8Id = resp.data.entry.id) apis.user.nodes.createFile(fileTitleEqDesc, parentId, fileTitle, fileTitle).then(resp => file8Id = resp.entry.id)
])) ]))
.then(() => apis.user.shared.shareFilesByIds([ file1Id, file2Id, file3Id, file4Id, file5Id, file6Id, file7Id, file8Id ])) .then(() => apis.user.shared.shareFilesByIds([ file1Id, file2Id, file3Id, file4Id, file5Id, file6Id, file7Id, file8Id ]))
@ -265,24 +265,24 @@ describe('File / folder tooltips', () => {
beforeAll(done => { beforeAll(done => {
apis.user.nodes.createFolder( parentForTrash ) apis.user.nodes.createFolder( parentForTrash )
.then(resp => parentForTrashId = resp.data.entry.id) .then(resp => parentForTrashId = resp.entry.id)
.then(() => Promise.all([ .then(() => Promise.all([
apis.user.nodes.createFile(file, parentForTrashId) apis.user.nodes.createFile(file, parentForTrashId)
.then(resp => file1TrashId = resp.data.entry.id), .then(resp => file1TrashId = resp.entry.id),
apis.user.nodes.createFile(fileWithDesc, parentForTrashId, '', fileDescription) apis.user.nodes.createFile(fileWithDesc, parentForTrashId, '', fileDescription)
.then(resp => file2TrashId = resp.data.entry.id), .then(resp => file2TrashId = resp.entry.id),
apis.user.nodes.createFile(fileWithTitle, parentForTrashId, fileTitle) apis.user.nodes.createFile(fileWithTitle, parentForTrashId, fileTitle)
.then(resp => file3TrashId = resp.data.entry.id), .then(resp => file3TrashId = resp.entry.id),
apis.user.nodes.createFile(fileWithTitleAndDesc, parentForTrashId, fileTitle, fileDescription) apis.user.nodes.createFile(fileWithTitleAndDesc, parentForTrashId, fileTitle, fileDescription)
.then(resp => file4TrashId = resp.data.entry.id), .then(resp => file4TrashId = resp.entry.id),
apis.user.nodes.createFile(fileNameEqTitleEqDesc, parentForTrashId, fileNameEqTitleEqDesc, fileNameEqTitleEqDesc) apis.user.nodes.createFile(fileNameEqTitleEqDesc, parentForTrashId, fileNameEqTitleEqDesc, fileNameEqTitleEqDesc)
.then(resp => file5TrashId = resp.data.entry.id), .then(resp => file5TrashId = resp.entry.id),
apis.user.nodes.createFile(fileNameEqTitleDiffDesc, parentForTrashId, fileNameEqTitleDiffDesc, fileDescription) apis.user.nodes.createFile(fileNameEqTitleDiffDesc, parentForTrashId, fileNameEqTitleDiffDesc, fileDescription)
.then(resp => file6TrashId = resp.data.entry.id), .then(resp => file6TrashId = resp.entry.id),
apis.user.nodes.createFile(fileNameEqDescDiffTitle, parentForTrashId, fileTitle, fileNameEqDescDiffTitle) apis.user.nodes.createFile(fileNameEqDescDiffTitle, parentForTrashId, fileTitle, fileNameEqDescDiffTitle)
.then(resp => file7TrashId = resp.data.entry.id), .then(resp => file7TrashId = resp.entry.id),
apis.user.nodes.createFile(fileTitleEqDesc, parentForTrashId, fileTitle, fileTitle) apis.user.nodes.createFile(fileTitleEqDesc, parentForTrashId, fileTitle, fileTitle)
.then(resp => file8TrashId = resp.data.entry.id) .then(resp => file8TrashId = resp.entry.id)
])) ]))
.then(() => apis.user.nodes.deleteNodesById([ .then(() => apis.user.nodes.deleteNodesById([

View File

@ -60,18 +60,18 @@ describe('Trash', () => {
beforeAll(done => { beforeAll(done => {
apis.admin.people.createUser({ username }) apis.admin.people.createUser({ username })
.then(() => apis.admin.nodes.createFiles([ fileAdmin ]).then(resp => fileAdminId = resp.data.entry.id)) .then(() => apis.admin.nodes.createFiles([ fileAdmin ]).then(resp => fileAdminId = resp.entry.id))
.then(() => apis.admin.nodes.createFolders([ folderAdmin ]).then(resp => folderAdminId = resp.data.entry.id)) .then(() => apis.admin.nodes.createFolders([ folderAdmin ]).then(resp => folderAdminId = resp.entry.id))
.then(() => apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC)) .then(() => apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC))
.then(() => apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_MANAGER)) .then(() => apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_MANAGER))
.then(() => apis.admin.nodes.createFiles([ fileSite ], `Sites/${siteName}/documentLibrary`) .then(() => apis.admin.nodes.createFiles([ fileSite ], `Sites/${siteName}/documentLibrary`)
.then(resp => fileSiteId = resp.data.entry.id)) .then(resp => fileSiteId = resp.entry.id))
.then(() => apis.user.nodes.createFiles([ fileUser ]).then(resp => fileUserId = resp.data.entry.id)) .then(() => apis.user.nodes.createFiles([ fileUser ]).then(resp => fileUserId = resp.entry.id))
.then(() => apis.user.nodes.createFolders([ folderUser ]).then(resp => folderUserId = resp.data.entry.id)) .then(() => apis.user.nodes.createFolders([ folderUser ]).then(resp => folderUserId = resp.entry.id))
.then(() => apis.user.nodes.createFolder(folderDeleted).then(resp => folderDeletedId = resp.data.entry.id)) .then(() => apis.user.nodes.createFolder(folderDeleted).then(resp => folderDeletedId = resp.entry.id))
.then(() => apis.user.nodes.createFiles([ fileDeleted ], folderDeleted).then(resp => fileDeletedId = resp.data.entry.id)) .then(() => apis.user.nodes.createFiles([ fileDeleted ], folderDeleted).then(resp => fileDeletedId = resp.entry.id))
.then(() => apis.user.nodes.createFolder(folderNotDeleted).then(resp => folderNotDeletedId = resp.data.entry.id)) .then(() => apis.user.nodes.createFolder(folderNotDeleted).then(resp => folderNotDeletedId = resp.entry.id))
.then(() => apis.user.nodes.createFiles([ fileInFolder ], folderNotDeleted).then(resp => fileInFolderId = resp.data.entry.id)) .then(() => apis.user.nodes.createFiles([ fileInFolder ], folderNotDeleted).then(resp => fileInFolderId = resp.entry.id))
.then(() => apis.admin.nodes.deleteNodesById([ fileAdminId, folderAdminId ], false)) .then(() => apis.admin.nodes.deleteNodesById([ fileAdminId, folderAdminId ], false))
.then(() => apis.user.nodes.deleteNodesById([ fileSiteId, fileUserId, folderUserId, fileInFolderId ], false)) .then(() => apis.user.nodes.deleteNodesById([ fileSiteId, fileUserId, folderUserId, fileInFolderId ], false))

View File

@ -56,19 +56,19 @@ describe('Breadcrumb', () => {
beforeAll(done => { beforeAll(done => {
apis.admin.people.createUser({ username }) apis.admin.people.createUser({ username })
.then(() => apis.user.nodes.createFolder(parent)).then(resp => parentId = resp.data.entry.id) .then(() => apis.user.nodes.createFolder(parent)).then(resp => parentId = resp.entry.id)
.then(() => apis.user.nodes.createFolder(subFolder1, parentId)).then(resp => subFolder1Id = resp.data.entry.id) .then(() => apis.user.nodes.createFolder(subFolder1, parentId)).then(resp => subFolder1Id = resp.entry.id)
.then(() => apis.user.nodes.createFolder(subFolder2, subFolder1Id)).then(resp => subFolder2Id = resp.data.entry.id) .then(() => apis.user.nodes.createFolder(subFolder2, subFolder1Id)).then(resp => subFolder2Id = resp.entry.id)
.then(() => apis.user.nodes.createFile(fileName1, subFolder2Id)) .then(() => apis.user.nodes.createFile(fileName1, subFolder2Id))
.then(() => apis.user.nodes.createFolder(parent2)).then(resp => parent2Id = resp.data.entry.id) .then(() => apis.user.nodes.createFolder(parent2)).then(resp => parent2Id = resp.entry.id)
.then(() => apis.user.nodes.createFolder(folder1, parent2Id)).then(resp => folder1Id = resp.data.entry.id) .then(() => apis.user.nodes.createFolder(folder1, parent2Id)).then(resp => folder1Id = resp.entry.id)
.then(() => apis.user.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC)) .then(() => apis.user.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC))
.then(() => apis.user.sites.getDocLibId(siteName)) .then(() => apis.user.sites.getDocLibId(siteName))
.then(resp => apis.user.nodes.createFolder(parent, resp)).then(resp => parentId = resp.data.entry.id) .then(resp => apis.user.nodes.createFolder(parent, resp)).then(resp => parentId = resp.entry.id)
.then(() => apis.user.nodes.createFolder(subFolder1, parentId)).then(resp => subFolder1Id = resp.data.entry.id) .then(() => apis.user.nodes.createFolder(subFolder1, parentId)).then(resp => subFolder1Id = resp.entry.id)
.then(() => apis.user.nodes.createFolder(subFolder2, subFolder1Id)).then(resp => subFolder2Id = resp.data.entry.id) .then(() => apis.user.nodes.createFolder(subFolder2, subFolder1Id)).then(resp => subFolder2Id = resp.entry.id)
.then(() => apis.user.nodes.createFile(fileName1, subFolder2Id)) .then(() => apis.user.nodes.createFile(fileName1, subFolder2Id))
.then(() => loginPage.loginWith(username)) .then(() => loginPage.loginWith(username))
@ -220,7 +220,7 @@ describe('Breadcrumb', () => {
beforeAll(done => { beforeAll(done => {
logoutPage.load() logoutPage.load()
.then(() => apis.admin.people.createUser({ username: user2 })) .then(() => apis.admin.people.createUser({ username: user2 }))
.then(() => user2Api.nodes.createFolder(userFolder).then(resp => userFolderId = resp.data.entry.id)) .then(() => user2Api.nodes.createFolder(userFolder).then(resp => userFolderId = resp.entry.id))
.then(() => loginPage.loginWithAdmin()) .then(() => loginPage.loginWithAdmin())
.then(done); .then(done);
}); });

View File

@ -81,7 +81,7 @@ describe('Pagination on Favorites', () => {
describe('on single page', () => { describe('on single page', () => {
beforeAll(done => { beforeAll(done => {
nodesApi.createFile(file).then(resp => fileId = resp.data.entry.id) nodesApi.createFile(file).then(resp => fileId = resp.entry.id)
.then(() => favoritesApi.addFavoriteById('file', fileId)) .then(() => favoritesApi.addFavoriteById('file', fileId))
.then(() => loginPage.loginWith(username)) .then(() => loginPage.loginWith(username))
.then(done); .then(done);
@ -105,7 +105,7 @@ describe('Pagination on Favorites', () => {
describe('on multiple pages', () => { describe('on multiple pages', () => {
beforeAll(done => { beforeAll(done => {
nodesApi.createFiles(files, parent) nodesApi.createFiles(files, parent)
.then(resp => filesIds = resp.data.list.entries.map(entries => entries.entry.id)) .then(resp => filesIds = resp.list.entries.map(entries => entries.entry.id))
.then(() => favoritesApi.addFavoritesByIds('file', filesIds)) .then(() => favoritesApi.addFavoritesByIds('file', filesIds))
.then(() => favoritesApi.waitForApi({ expect: 101 })) .then(() => favoritesApi.waitForApi({ expect: 101 }))
.then(() => loginPage.loginWith(username)) .then(() => loginPage.loginWith(username))

View File

@ -80,7 +80,7 @@ describe('Pagination on Personal Files', () => {
describe('on single page', () => { describe('on single page', () => {
beforeAll(done => { beforeAll(done => {
nodesApi.createFile(file).then(resp => fileId = resp.data.entry.id) nodesApi.createFile(file).then(resp => fileId = resp.entry.id)
.then(() => loginPage.loginWith(username)) .then(() => loginPage.loginWith(username))
.then(done); .then(done);
}); });

View File

@ -80,7 +80,7 @@ describe('Pagination on Recent Files', () => {
describe('on single page', () => { describe('on single page', () => {
beforeAll(done => { beforeAll(done => {
nodesApi.createFile(file).then(resp => fileId = resp.data.entry.id) nodesApi.createFile(file).then(resp => fileId = resp.entry.id)
.then(() => searchApi.waitForApi(username, { expect: 1 })) .then(() => searchApi.waitForApi(username, { expect: 1 }))
.then(() => loginPage.loginWith(username)) .then(() => loginPage.loginWith(username))
.then(done); .then(done);

View File

@ -81,7 +81,7 @@ describe('Pagination on Shared Files', () => {
describe('on single page', () => { describe('on single page', () => {
beforeAll(done => { beforeAll(done => {
nodesApi.createFile(file).then(resp => fileId = resp.data.entry.id) nodesApi.createFile(file).then(resp => fileId = resp.entry.id)
.then(() => sharedApi.shareFileById(fileId)) .then(() => sharedApi.shareFileById(fileId))
.then(() => sharedApi.waitForApi({ expect: 1 })) .then(() => sharedApi.waitForApi({ expect: 1 }))
.then(() => loginPage.loginWith(username)) .then(() => loginPage.loginWith(username))
@ -106,7 +106,7 @@ describe('Pagination on Shared Files', () => {
describe('on multiple pages', () => { describe('on multiple pages', () => {
beforeAll(done => { beforeAll(done => {
nodesApi.createFiles(files, parent) nodesApi.createFiles(files, parent)
.then(resp => filesIds = resp.data.list.entries.map(entries => entries.entry.id)) .then(resp => filesIds = resp.list.entries.map(entries => entries.entry.id))
.then(() => sharedApi.shareFilesByIds(filesIds)) .then(() => sharedApi.shareFilesByIds(filesIds))
.then(() => sharedApi.waitForApi({ expect: 101 })) .then(() => sharedApi.waitForApi({ expect: 101 }))

View File

@ -80,7 +80,7 @@ describe('Pagination on Trash', () => {
describe('on single page', () => { describe('on single page', () => {
beforeAll(done => { beforeAll(done => {
nodesApi.createFile(file).then(resp => fileId = resp.data.entry.id) nodesApi.createFile(file).then(resp => fileId = resp.entry.id)
.then(() => nodesApi.deleteNodeById(fileId, false)) .then(() => nodesApi.deleteNodeById(fileId, false))
.then(() => trashApi.waitForApi({ expect: 1 })) .then(() => trashApi.waitForApi({ expect: 1 }))
.then(() => loginPage.loginWith(username)) .then(() => loginPage.loginWith(username))
@ -105,7 +105,7 @@ describe('Pagination on Trash', () => {
describe('on multiple pages', () => { describe('on multiple pages', () => {
beforeAll(done => { beforeAll(done => {
nodesApi.createFiles(filesForDelete) nodesApi.createFiles(filesForDelete)
.then(resp => filesDeletedIds = resp.data.list.entries.map(entries => entries.entry.id)) .then(resp => filesDeletedIds = resp.list.entries.map(entries => entries.entry.id))
.then(() => nodesApi.deleteNodesById(filesDeletedIds, false)) .then(() => nodesApi.deleteNodesById(filesDeletedIds, false))
.then(() => trashApi.waitForApi({expect: 101})) .then(() => trashApi.waitForApi({expect: 101}))

View File

@ -23,96 +23,82 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { promise } from 'protractor';
import { RepoApi } from '../repo-api'; import { RepoApi } from '../repo-api';
import { NodesApi } from '../nodes/nodes-api';
import { RepoClient } from './../../repo-client'; import { RepoClient } from './../../repo-client';
import { Utils } from '../../../../utilities/utils'; import { Utils } from '../../../../utilities/utils';
export class FavoritesApi extends RepoApi { export class FavoritesApi extends RepoApi {
addFavorite(api: RepoClient, nodeType: string, name: string): Promise<any> { constructor(username?, password?) {
return api.nodes.getNodeByPath(name) super(username, password);
.then((response) => {
const { id } = response.data.entry;
return ([{
target: {
[nodeType]: {
guid: id
}
}
}]);
})
.then((data) => {
return this.post(`/people/-me-/favorites`, { data });
})
.catch(this.handleError);
} }
addFavoriteById(nodeType: 'file' | 'folder', id: string): Promise<any> { async addFavorite(api: RepoClient, nodeType: string, name: string) {
const data = [{ const nodeId = (await api.nodes.getNodeByPath(name)).entry.id;
const data = {
target: {
[nodeType]: {
guid: nodeId
}
}
};
return await this.alfrescoJsApi.core.favoritesApi.addFavorite('-me-', data);
}
async addFavoriteById(nodeType: 'file' | 'folder', id: string) {
const data = {
target: { target: {
[nodeType]: { [nodeType]: {
guid: id guid: id
} }
} }
}]; };
return this await this.apiAuth();
.post(`/people/-me-/favorites`, { data }) return await this.alfrescoJsApi.core.favoritesApi.addFavorite('-me-', data);
.catch(this.handleError);
} }
addFavoritesByIds(nodeType: 'file' | 'folder', ids: string[]): Promise<any[]> { async addFavoritesByIds(nodeType: 'file' | 'folder', ids: string[]) {
return ids.reduce((previous, current) => ( await this.apiAuth();
previous.then(() => this.addFavoriteById(nodeType, current)) return await ids.reduce(async (previous, current) => {
), Promise.resolve()); await previous;
await this.addFavoriteById(nodeType, current);
}, Promise.resolve());
} }
getFavorites(): Promise<any> { async getFavorites() {
return this await this.apiAuth();
.get('/people/-me-/favorites') return await this.alfrescoJsApi.core.favoritesApi.getFavorites(this.getUsername());
.catch(this.handleError);
} }
getFavoriteById(nodeId: string): Promise<any> { async getFavoriteById(nodeId: string) {
return this await this.apiAuth();
.get(`/people/-me-/favorites/${nodeId}`) return await this.alfrescoJsApi.core.favoritesApi.getFavorite('-me', nodeId);
.catch(this.handleError);
} }
isFavorite(nodeId: string) { async isFavorite(nodeId: string) {
return this.getFavorites() return JSON.stringify((await this.getFavorites()).list.entries).includes(nodeId);
.then(resp => JSON.stringify(resp.data.list.entries).includes(nodeId));
} }
removeFavorite(api: RepoClient, nodeType: string, name: string): Promise<any> { async removeFavoriteById(nodeId: string) {
return api.nodes.getNodeByPath(name) await this.apiAuth();
.then((response) => { return await this.alfrescoJsApi.core.peopleApi.removeFavoriteSite('-me-', nodeId);
const { id } = response.data.entry;
return this.delete(`/people/-me-/favorites/${id}`);
})
.catch(this.handleError);
} }
removeFavoriteById(nodeId: string) { async removeFavorite(api: RepoClient, name: string) {
return this const nodeId = (await api.nodes.getNodeByPath(name)).entry.id;
.delete(`/people/-me-/favorites/${nodeId}`) return await this.removeFavoriteById(nodeId);
.catch(this.handleError);
} }
waitForApi(data) { async waitForApi(data) {
const favoriteFiles = () => { const favoriteFiles = async () => {
return this.getFavorites() const totalItems = (await this.getFavorites()).list.pagination.totalItems;
.then(response => response.data.list.pagination.totalItems) if ( totalItems < data.expect) {
.then(totalItems => { return Promise.reject(totalItems);
if ( totalItems < data.expect) { } else {
return Promise.reject(totalItems); return Promise.resolve(totalItems);
} else { }
return Promise.resolve(totalItems);
}
});
}; };
return Utils.retryCall(favoriteFiles); return await Utils.retryCall(favoriteFiles);
} }
} }

View File

@ -23,127 +23,125 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { NodeBodyLock } from 'alfresco-js-api-node';
import { RepoApi } from '../repo-api'; import { RepoApi } from '../repo-api';
import { NodeBodyCreate, NODE_TYPE_FILE, NODE_TYPE_FOLDER } from './node-body-create'; import { NodeBodyCreate } from './node-body-create';
import { NodeContentTree, flattenNodeContentTree } from './node-content-tree'; import { NodeContentTree, flattenNodeContentTree } from './node-content-tree';
export class NodesApi extends RepoApi { export class NodesApi extends RepoApi {
constructor(username?, password?) {
super(username, password);
}
// nodes // nodes
getNodeByPath(relativePath: string = '/'): Promise<any> {
return this async getNodeByPath(relativePath: string = '/') {
.get(`/nodes/-my-`, { parameters: { relativePath } }) await this.apiAuth();
.catch(this.handleError); return await this.alfrescoJsApi.core.nodesApi.getNode('-my-', { relativePath });
} }
getNodeById(id: string): Promise<any> { async getNodeById(id: string) {
return this await this.apiAuth();
.get(`/nodes/${id}`) return await this.alfrescoJsApi.core.nodesApi.getNode(id);
.catch(this.handleError);
} }
getNodeDescription(name: string, relativePath: string = '/') { async getNodeDescription(name: string, relativePath: string = '/') {
relativePath = (relativePath === '/') relativePath = (relativePath === '/')
? `${name}` ? `${name}`
: `${relativePath}/${name}`; : `${relativePath}/${name}`;
return this.getNodeByPath(`${relativePath}`) return (await this.getNodeByPath(`${relativePath}`)).entry.properties['cm:description'];
.then(response => response.data.entry.properties['cm:description']);
} }
deleteNodeById(id: string, permanent: boolean = true): Promise<any> { async deleteNodeById(id: string, permanent: boolean = true) {
return this await this.apiAuth();
.delete(`/nodes/${id}?permanent=${permanent}`) return await this.alfrescoJsApi.core.nodesApi.deleteNode(id, { permanent });
.catch(this.handleError);
} }
deleteNodeByPath(path: string, permanent: boolean = true): Promise<any> { async deleteNodeByPath(path: string, permanent: boolean = true) {
return this const id = (await this.getNodeByPath(path)).entry.id;
.getNodeByPath(path) return await this.deleteNodeById(id, permanent);
.then((response: any): string => response.data.entry.id)
.then((id: string): any => this.deleteNodeById(id, permanent))
.catch(this.handleError);
} }
deleteNodes(names: string[], relativePath: string = '', permanent: boolean = true): Promise<any[]> { async deleteNodes(names: string[], relativePath: string = '', permanent: boolean = true) {
return names.reduce((previous, current) => ( return await names.reduce(async (previous, current) => {
previous.then(() => this.deleteNodeByPath(`${relativePath}/${current}`, permanent)) await previous;
), Promise.resolve()); return await this.deleteNodeByPath(`${relativePath}/${current}`, permanent);
}, Promise.resolve());
} }
deleteNodesById(ids: string[], permanent: boolean = true): Promise<any[]> { async deleteNodesById(ids: string[], permanent: boolean = true) {
return ids.reduce((previous, current) => ( return await ids.reduce(async (previous, current) => {
previous.then(() => this.deleteNodeById(current, permanent)) await previous;
), Promise.resolve()); return await this.deleteNodeById(current, permanent);
}, Promise.resolve());
} }
// children // children
getNodeChildren(nodeId: string): Promise<any> {
return this async getNodeChildren(nodeId: string) {
.get(`/nodes/${nodeId}/children`) await this.apiAuth();
.catch(this.handleError); return await this.alfrescoJsApi.core.nodesApi.getNodeChildren(nodeId);
} }
createNode(nodeType: string, name: string, parentId: string = '-my-', title: string = '', description: string = ''): Promise<any> { async createNode(nodeType: string, name: string, parentId: string = '-my-', title: string = '', description: string = '') {
const data = { const nodeBody = {
name: name, name,
nodeType: nodeType, nodeType,
properties: { properties: {
'cm:title': title, 'cm:description': description 'cm:title': title,
'cm:description': description
} }
}; };
return this await this.apiAuth();
.post(`/nodes/${parentId}/children`, { data }) return await this.alfrescoJsApi.core.nodesApi.addNode(parentId, nodeBody);
.catch(this.handleError);
} }
createFile(name: string, parentId: string = '-my-', title: string = '', description: string = ''): Promise<any> { async createFile(name: string, parentId: string = '-my-', title: string = '', description: string = '') {
return this.createNode('cm:content', name, parentId, title, description); return await this.createNode('cm:content', name, parentId, title, description);
} }
createFolder(name: string, parentId: string = '-my-', title: string = '', description: string = ''): Promise<any> { async createFolder(name: string, parentId: string = '-my-', title: string = '', description: string = '') {
return this.createNode('cm:folder', name, parentId, title, description); return await this.createNode('cm:folder', name, parentId, title, description);
} }
createChildren(data: NodeBodyCreate[]): Promise<any> { async createChildren(data: NodeBodyCreate[]) {
return this await this.apiAuth();
.post(`/nodes/-my-/children`, { data }) return await this.alfrescoJsApi.core.nodesApi.addNode('-my-', data);
.catch(this.handleError);
} }
createContent(content: NodeContentTree, relativePath: string = '/'): Promise<any> { async createContent(content: NodeContentTree, relativePath: string = '/') {
return this.createChildren(flattenNodeContentTree(content, relativePath)); return await this.createChildren(flattenNodeContentTree(content, relativePath));
} }
createFolders(names: string[], relativePath: string = '/'): Promise<any> { async createFolders(names: string[], relativePath: string = '/') {
return this.createContent({ folders: names }, relativePath); return await this.createContent({ folders: names }, relativePath);
} }
createFiles(names: string[], relativePath: string = '/'): Promise<any> { async createFiles(names: string[], relativePath: string = '/') {
return this.createContent({ files: names }, relativePath); return await this.createContent({ files: names }, relativePath);
} }
// node content // node content
getNodeContent(nodeId: string): Promise<any> { async getNodeContent(nodeId: string) {
return this await this.apiAuth();
.get(`/nodes/${nodeId}/content`) return await this.alfrescoJsApi.core.nodesApi.getNodeContent(nodeId);
.catch(this.handleError);
} }
editNodeContent(nodeId: string, content: string): Promise<any> { async editNodeContent(nodeId: string, content: string) {
return this await this.apiAuth();
.put(`/nodes/${nodeId}/content`, { data: content }) return await this.alfrescoJsApi.core.nodesApi.updateNodeContent(nodeId, content);
.catch(this.handleError);
} }
renameNode(nodeId: string, newName: string): Promise<any> { async renameNode(nodeId: string, newName: string) {
return this await this.apiAuth();
.put(`/nodes/${nodeId}`, { data: { name: newName } }) return this.alfrescoJsApi.core.nodesApi.updateNode(nodeId, { name: newName });
.catch(this.handleError);
} }
// node permissions // node permissions
setGranularPermission(nodeId: string, inheritPermissions: boolean = false, username: string, role: string): Promise<any> { async setGranularPermission(nodeId: string, inheritPermissions: boolean = false, username: string, role: string) {
const data = { const data = {
permissions: { permissions: {
isInheritanceEnabled: inheritPermissions, isInheritanceEnabled: inheritPermissions,
@ -156,27 +154,26 @@ export class NodesApi extends RepoApi {
} }
}; };
return this await this.apiAuth();
.put(`/nodes/${nodeId}`, { data }) return await this.alfrescoJsApi.core.nodesApi.updateNode(nodeId, data);
.catch(this.handleError);
} }
getNodePermissions(nodeId: string): Promise<any> { async getNodePermissions(nodeId: string) {
return this await this.apiAuth();
.get(`/nodes/${nodeId}?include=permissions`) return await this.alfrescoJsApi.core.nodesApi.getNode(nodeId, { include: ['permissions'] });
.catch(this.handleError);
} }
// lock node // lock node
lockFile(nodeId: string, lockType: string = 'FULL') { async lockFile(nodeId: string, lockType: string = 'FULL') {
return this const data = <NodeBodyLock>{
.post(`/nodes/${nodeId}/lock?include=isLocked`, { data: { 'type': lockType } }) type: lockType
.catch(this.handleError); };
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.lockNode(nodeId, data );
} }
unlockFile(nodeId: string) { async unlockFile(nodeId: string) {
return this await this.apiAuth();
.post(`/nodes/${nodeId}/unlock`) return await this.alfrescoJsApi.core.nodesApi.unlockNode(nodeId);
.catch(this.handleError);
} }
} }

View File

@ -24,9 +24,9 @@
*/ */
import { PersonModel, Person } from './people-api-models'; import { PersonModel, Person } from './people-api-models';
import { RepoApiNew } from '../repo-api-new'; import { RepoApi } from '../repo-api';
export class PeopleApi extends RepoApiNew { export class PeopleApi extends RepoApi {
constructor(username?, password?) { constructor(username?, password?) {
super(username, password); super(username, password);

View File

@ -1,46 +0,0 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 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 <http://www.gnu.org/licenses/>.
*/
import * as AlfrescoApi from 'alfresco-js-api-node';
import { REPO_API_HOST } from '../../../configs';
import { RepoClientAuth } from '../repo-client-models';
export abstract class RepoApiNew {
alfrescoJsApi = new AlfrescoApi({
provider: 'ECM',
hostEcm: REPO_API_HOST
});
constructor(
private username: string = RepoClientAuth.DEFAULT_USERNAME,
private password: string = RepoClientAuth.DEFAULT_PASSWORD
) {}
apiAuth() {
return this.alfrescoJsApi.login(this.username, this.password);
}
}

51
e2e/utilities/repo-client/apis/repo-api.ts Executable file → Normal file
View File

@ -23,49 +23,28 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { RestClient, RestClientArgs, RestClientResponse } from '../../rest-client/rest-client'; import * as AlfrescoApi from 'alfresco-js-api-node';
import { RepoClientAuth, RepoClientConfig } from '../repo-client-models'; import { REPO_API_HOST } from '../../../configs';
import { RepoClientAuth } from '../repo-client-models';
export abstract class RepoApi { export abstract class RepoApi {
private client: RestClient;
private defaults: RepoClientConfig = new RepoClientConfig(); alfrescoJsApi = new AlfrescoApi({
provider: 'ECM',
hostEcm: REPO_API_HOST
});
constructor( constructor(
auth: RepoClientAuth = new RepoClientAuth(), private username: string = RepoClientAuth.DEFAULT_USERNAME,
private config?: RepoClientConfig private password: string = RepoClientAuth.DEFAULT_PASSWORD
) { ) {}
const { username, password } = auth;
this.client = new RestClient(username, password); apiAuth() {
return this.alfrescoJsApi.login(this.username, this.password);
} }
private createEndpointUri(endpoint: string, apiDefinition: string = 'alfresco'): string { getUsername() {
const { defaults, config } = this; return this.username;
const { host, tenant } = Object.assign(defaults, config);
return `${host}/alfresco/api/${tenant}/public/${apiDefinition}/versions/1${endpoint}`;
} }
protected handleError(response: RestClientResponse) {
const { request: { method, path, data }, data: error } = response;
console.log(`ERROR on ${method}\n${path}\n${data}`);
console.log(error);
}
protected get(endpoint: string, args: RestClientArgs = {}, apiDefinition: string = 'alfresco') {
return this.client.get(this.createEndpointUri(endpoint, apiDefinition), args);
}
protected post(endpoint: string, args: RestClientArgs = {}, apiDefinition: string = 'alfresco') {
return this.client.post(this.createEndpointUri(endpoint, apiDefinition), args);
}
protected put(endpoint: string, args: RestClientArgs = {}, apiDefinition: string = 'alfresco') {
return this.client.put(this.createEndpointUri(endpoint, apiDefinition), args);
}
protected delete(endpoint: string, args: RestClientArgs = {}, apiDefinition: string = 'alfresco') {
return this.client.delete(this.createEndpointUri(endpoint, apiDefinition), args);
}
} }

View File

@ -23,10 +23,10 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { RepoApiNew } from '../repo-api-new'; import { RepoApi } from '../repo-api';
import { Utils } from '../../../../utilities/utils'; import { Utils } from '../../../../utilities/utils';
export class SearchApi extends RepoApiNew { export class SearchApi extends RepoApi {
constructor(username?, password?) { constructor(username?, password?) {
super(username, password); super(username, password);

View File

@ -23,10 +23,10 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { RepoApiNew } from '../repo-api-new'; import { RepoApi } from '../repo-api';
import { Utils } from '../../../../utilities/utils'; import { Utils } from '../../../../utilities/utils';
export class SharedLinksApi extends RepoApiNew { export class SharedLinksApi extends RepoApi {
constructor(username?, password?) { constructor(username?, password?) {
super(username, password); super(username, password);

View File

@ -23,11 +23,11 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { RepoApiNew } from '../repo-api-new'; import { RepoApi } from '../repo-api';
import { SiteBody, SiteMemberRoleBody, SiteMemberBody } from 'alfresco-js-api-node'; import { SiteBody, SiteMemberRoleBody, SiteMemberBody } from 'alfresco-js-api-node';
import { SITE_VISIBILITY } from '../../../../configs'; import { SITE_VISIBILITY } from '../../../../configs';
export class SitesApi extends RepoApiNew { export class SitesApi extends RepoApi {
constructor(username?, password?) { constructor(username?, password?) {
super(username, password); super(username, password);

View File

@ -23,10 +23,10 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { RepoApiNew } from '../repo-api-new'; import { RepoApi } from '../repo-api';
import { Utils } from '../../../../utilities/utils'; import { Utils } from '../../../../utilities/utils';
export class TrashcanApi extends RepoApiNew { export class TrashcanApi extends RepoApi {
constructor(username?, password?) { constructor(username?, password?) {
super(username, password); super(username, password);

View File

@ -25,9 +25,7 @@
import { import {
ADMIN_USERNAME, ADMIN_USERNAME,
ADMIN_PASSWORD, ADMIN_PASSWORD
REPO_API_HOST,
REPO_API_TENANT
} from '../../configs'; } from '../../configs';
export class RepoClientAuth { export class RepoClientAuth {
@ -39,8 +37,3 @@ export class RepoClientAuth {
public password: string = RepoClientAuth.DEFAULT_PASSWORD public password: string = RepoClientAuth.DEFAULT_PASSWORD
) {} ) {}
} }
export class RepoClientConfig {
host?: string = REPO_API_HOST;
tenant?: string = REPO_API_TENANT;
}

View File

@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/ */
import { RepoClientAuth, RepoClientConfig } from './repo-client-models'; import { RepoClientAuth } from './repo-client-models';
import { PeopleApi } from './apis/people/people-api'; import { PeopleApi } from './apis/people/people-api';
import { NodesApi } from './apis/nodes/nodes-api'; import { NodesApi } from './apis/nodes/nodes-api';
@ -36,8 +36,7 @@ import { SearchApi } from './apis/search/search-api';
export class RepoClient { export class RepoClient {
constructor( constructor(
private username: string = RepoClientAuth.DEFAULT_USERNAME, private username: string = RepoClientAuth.DEFAULT_USERNAME,
private password: string = RepoClientAuth.DEFAULT_PASSWORD, private password: string = RepoClientAuth.DEFAULT_PASSWORD
private config?: RepoClientConfig
) {} ) {}
private get auth(): RepoClientAuth { private get auth(): RepoClientAuth {
@ -50,7 +49,7 @@ export class RepoClient {
} }
get nodes() { get nodes() {
return new NodesApi(this.auth, this.config); return new NodesApi(this.auth.username, this.auth.password);
} }
get sites() { get sites() {
@ -58,7 +57,7 @@ export class RepoClient {
} }
get favorites() { get favorites() {
return new FavoritesApi(this.auth, this.config); return new FavoritesApi(this.auth.username, this.auth.password);
} }
get shared() { get shared() {

View File

@ -1,63 +0,0 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 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 <http://www.gnu.org/licenses/>.
*/
interface RequestConfig {
timeout?: number;
noDelay?: boolean;
keepAlive?: boolean;
keepAliveDelay?: number;
}
interface ResponseConfig {
timeout?: number;
}
interface ResponseRequest {
method: string;
path: string;
data: string;
}
export interface NodeRestClient {
get(uri: string, callback: Function): Function;
post(uri: string, callback: Function): Function;
put(uri: string, callback: Function): Function;
delete(uri: string, callback: Function): Function;
}
export interface RestClientArgs {
data?: any;
parameters?: any;
headers?: any;
requestConfig?: RequestConfig;
responseConfig?: ResponseConfig;
}
export interface RestClientResponse {
request: ResponseRequest;
data: any;
statusMessage: string;
statusCode: number;
}

View File

@ -1,89 +0,0 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 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 <http://www.gnu.org/licenses/>.
*/
import { Client } from 'node-rest-client';
import { NodeRestClient, RestClientArgs, RestClientResponse } from './rest-client-models';
export * from './rest-client-models';
export class RestClient {
private static DEFAULT_HEADERS = {
'Content-Type': 'application/json',
'Accept': 'application/json'
};
private client: NodeRestClient;
constructor(user: string, password: string) {
this.client = <NodeRestClient>(new Client({ user, password }));
}
get(uri: string, args: RestClientArgs = {}): Promise<RestClientResponse> {
return this.promisify('get', uri, args);
}
post(uri: string, args: RestClientArgs = {}): Promise<RestClientResponse> {
return this.promisify('post', uri, args);
}
put(uri: string, args: RestClientArgs = {}): Promise<RestClientResponse> {
return this.promisify('put', uri, args);
}
delete(uri: string, args: RestClientArgs = {}): Promise<RestClientResponse> {
return this.promisify('delete', uri, args);
}
private createArgs(args: RestClientArgs = {}): RestClientArgs {
const data = JSON.stringify(args.data);
return Object.assign({}, RestClient.DEFAULT_HEADERS, args, { data });
}
private promisify(fnName: string, uri: string, args: RestClientArgs): Promise<RestClientResponse> {
const fn: Function = this.client[fnName];
const fnArgs = [ encodeURI(uri), this.createArgs(args) ];
return new Promise((resolve, reject) => {
const fnCallback = (data, rawResponse) => {
const {
statusCode, statusMessage,
req: { method, path }
} = rawResponse;
const response: RestClientResponse = {
data, statusCode, statusMessage,
request: { method, path, data: args.data }
};
(response.statusCode >= 400)
? reject(response)
: resolve(response);
};
fn(...fnArgs, fnCallback);
});
}
}

6052
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -81,7 +81,6 @@
"karma-coverage-istanbul-reporter": "^1.2.1", "karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0", "karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2", "karma-jasmine-html-reporter": "^0.2.2",
"node-rest-client": "^3.1.0",
"protractor": "5.3.2", "protractor": "5.3.2",
"rimraf": "2.6.2", "rimraf": "2.6.2",
"selenium-webdriver": "4.0.0-alpha.1", "selenium-webdriver": "4.0.0-alpha.1",