Skip to content

Commit

Permalink
upgrade to latest JS-API and ADF (#896)
Browse files Browse the repository at this point in the history
* improved update script and latest ADF libs

* upgrade to latest js-api and ADF

* upgrade tests

* update viewer code

* use @alfresco/js-api

* update to latest adf

* fix deprecation issues

* update viewer

* fix copy/move dialog

* change expect

* fix remove site from favorites

* fix unit test

* update adf version

* use ADF upload dialog
  • Loading branch information
DenysVuika authored Jan 22, 2019
1 parent afa6de5 commit f0a3f6f
Show file tree
Hide file tree
Showing 82 changed files with 360 additions and 1,214 deletions.
6 changes: 3 additions & 3 deletions e2e/suites/list-views/permissions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,23 +84,23 @@ describe('Special permissions', () => {
expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items');
await apis.admin.sites.deleteSiteMember(sitePrivate, username);
await page.refresh();
expect(await dataTable.countRows()).toBe(0, 'Incorrect number of items');
expect(await dataTable.isEmptyList()).toBe(true, 'Items are still displayed');
});

it('on Favorites - [C213227]', async () => {
await page.clickFavoritesAndWait();
expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items');
await apis.admin.sites.deleteSiteMember(sitePrivate, username);
await page.refresh();
expect(await dataTable.countRows()).toBe(0, 'Incorrect number of items');
expect(await dataTable.isEmptyList()).toBe(true, 'Items are still displayed');
});

it('on Shared Files - [C213116]', async () => {
await page.clickSharedFilesAndWait();
expect(await dataTable.countRows()).toBe(1, 'Incorrect number of items');
await apis.admin.sites.deleteSiteMember(sitePrivate, username);
await page.refresh();
expect(await dataTable.countRows()).toBe(0, 'Incorrect number of items');
expect(await dataTable.isEmptyList()).toBe(true, 'Items are still displayed');
});
});

Expand Down
16 changes: 9 additions & 7 deletions e2e/utilities/repo-client/apis/favorites/favorites-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,11 @@
import { RepoApi } from '../repo-api';
import { RepoClient } from './../../repo-client';
import { Utils } from '../../../../utilities/utils';
import { FavoritesApi as AdfFavoritesApi, SitesApi as AdfSiteApi } from '@alfresco/js-api';

export class FavoritesApi extends RepoApi {
favoritesApi = new AdfFavoritesApi(this.alfrescoJsApi);
sitesApi = new AdfSiteApi(this.alfrescoJsApi);

constructor(username?, password?) {
super(username, password);
Expand All @@ -42,15 +45,15 @@ export class FavoritesApi extends RepoApi {
}
}
};
return await this.alfrescoJsApi.core.favoritesApi.addFavorite('-me-', data);
return await this.favoritesApi.createFavorite('-me-', data);
}

async addFavoriteById(nodeType: 'file' | 'folder' | 'site', id: string) {
let guid;
await this.apiAuth();

if ( nodeType === 'site' ) {
guid = (await this.alfrescoJsApi.core.sitesApi.getSite(id)).entry.guid;
guid = (await this.sitesApi.getSite(id)).entry.guid;
} else {
guid = id;
}
Expand All @@ -62,7 +65,7 @@ export class FavoritesApi extends RepoApi {
}
};
try {
return await this.alfrescoJsApi.core.favoritesApi.addFavorite('-me-', data);
return await this.favoritesApi.createFavorite('-me-', data);
} catch (error) {
// console.log('--- add favorite by id catch ');
}
Expand All @@ -77,12 +80,12 @@ export class FavoritesApi extends RepoApi {

async getFavorites() {
await this.apiAuth();
return await this.alfrescoJsApi.core.favoritesApi.getFavorites(this.getUsername());
return await this.favoritesApi.listFavorites(this.getUsername());
}

async getFavoriteById(nodeId: string) {
await this.apiAuth();
return await this.alfrescoJsApi.core.favoritesApi.getFavorite('-me-', nodeId);
return await this.favoritesApi.getFavorite('-me-', nodeId);
}

async isFavorite(nodeId: string) {
Expand Down Expand Up @@ -111,7 +114,7 @@ export class FavoritesApi extends RepoApi {
async removeFavoriteById(nodeId: string) {
await this.apiAuth();
try {
return await this.alfrescoJsApi.core.peopleApi.removeFavoriteSite('-me-', nodeId);
return await this.favoritesApi.deleteSiteFavorite('-me-', nodeId);
} catch (error) {
// console.log('--- remove favorite by id catch ');
}
Expand Down Expand Up @@ -139,6 +142,5 @@ export class FavoritesApi extends RepoApi {
} catch (error) {
console.log('-----> catch favorites: ', error);
}

}
}
33 changes: 15 additions & 18 deletions e2e/utilities/repo-client/apis/nodes/nodes-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,26 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/

import { NodeBodyLock } from 'alfresco-js-api-node';
import { RepoApi } from '../repo-api';
import { NodeBodyCreate } from './node-body-create';
import { NodeContentTree, flattenNodeContentTree } from './node-content-tree';
import { NodesApi as AdfNodeApi, NodeBodyLock} from '@alfresco/js-api';

export class NodesApi extends RepoApi {
nodesApi = new AdfNodeApi(this.alfrescoJsApi);

constructor(username?, password?) {
super(username, password);
}

// nodes

async getNodeByPath(relativePath: string = '/') {
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.getNode('-my-', { relativePath });
return await this.nodesApi.getNode('-my-', { relativePath });
}

async getNodeById(id: string) {
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.getNode(id);
return await this.nodesApi.getNode(id);
}

async getNodeDescription(name: string, parentId: string) {
Expand Down Expand Up @@ -75,7 +74,7 @@ export class NodesApi extends RepoApi {
async deleteNodeById(id: string, permanent: boolean = true) {
await this.apiAuth();
try {
return await this.alfrescoJsApi.core.nodesApi.deleteNode(id, { permanent });
return await this.nodesApi.deleteNode(id, { permanent });
} catch (error) {
console.log('------ deleteNodeById failed ');
}
Expand All @@ -100,14 +99,12 @@ export class NodesApi extends RepoApi {
}, Promise.resolve());
}

// children

async getNodeChildren(nodeId: string) {
const opts = {
include: [ 'properties' ]
};
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.getNodeChildren(nodeId, opts);
return await this.nodesApi.listNodeChildren(nodeId, opts);
}

async deleteNodeChildren(parentId: string) {
Expand Down Expand Up @@ -138,7 +135,7 @@ export class NodesApi extends RepoApi {
}

await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.addNode(parentId, nodeBody);
return await this.nodesApi.createNode(parentId, nodeBody);
}

async createFile(name: string, parentId: string = '-my-', title: string = '', description: string = '') {
Expand All @@ -155,7 +152,7 @@ export class NodesApi extends RepoApi {

async createChildren(data: NodeBodyCreate[]): Promise<any> {
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.addNode('-my-', data);
return await this.nodesApi.createNode('-my-', <any>data);
}

async createContent(content: NodeContentTree, relativePath: string = '/') {
Expand All @@ -173,17 +170,17 @@ export class NodesApi extends RepoApi {
// node content
async getNodeContent(nodeId: string) {
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.getNodeContent(nodeId);
return await this.nodesApi.getNodeContent(nodeId);
}

async editNodeContent(nodeId: string, content: string) {
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.updateNodeContent(nodeId, content);
return await this.nodesApi.updateNodeContent(nodeId, content);
}

async renameNode(nodeId: string, newName: string) {
await this.apiAuth();
return this.alfrescoJsApi.core.nodesApi.updateNode(nodeId, { name: newName });
return this.nodesApi.updateNode(nodeId, { name: newName });
}

// node permissions
Expand All @@ -201,12 +198,12 @@ export class NodesApi extends RepoApi {
};

await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.updateNode(nodeId, data);
return await this.nodesApi.updateNode(nodeId, data);
}

async getNodePermissions(nodeId: string) {
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.getNode(nodeId, { include: ['permissions'] });
return await this.nodesApi.getNode(nodeId, { include: ['permissions'] });
}

// lock node
Expand All @@ -215,11 +212,11 @@ export class NodesApi extends RepoApi {
type: lockType
};
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.lockNode(nodeId, data );
return await this.nodesApi.lockNode(nodeId, data );
}

async unlockFile(nodeId: string) {
await this.apiAuth();
return await this.alfrescoJsApi.core.nodesApi.unlockNode(nodeId);
return await this.nodesApi.unlockNode(nodeId);
}
}
8 changes: 5 additions & 3 deletions e2e/utilities/repo-client/apis/people/people-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@

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?, password?) {
super(username, password);
Expand All @@ -35,17 +37,17 @@ export class PeopleApi extends RepoApi {
async createUser(user: PersonModel) {
const person = new Person(user);
await this.apiAuth();
return await this.alfrescoJsApi.core.peopleApi.addPerson(person);
return await this.peopleApi.createPerson(person);
}

async getUser(username: string) {
await this.apiAuth();
return await this.alfrescoJsApi.core.peopleApi.getPerson(username);
return await this.peopleApi.getPerson(username);
}

async updateUser(username: string, userDetails?: PersonModel) {
await this.apiAuth();
return this.alfrescoJsApi.core.peopleApi.updatePerson(username, userDetails);
return this.peopleApi.updatePerson(username, userDetails);
}

async disableUser(username: string) {
Expand Down
4 changes: 3 additions & 1 deletion e2e/utilities/repo-client/apis/queries/queries-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@

import { RepoApi } from '../repo-api';
import { Utils } from '../../../../utilities/utils';
import { QueriesApi as AdfQueriesApi } from '@alfresco/js-api';

export class QueriesApi extends RepoApi {
queriesApi = new AdfQueriesApi(this.alfrescoJsApi);

constructor(username?, password?) {
super(username, password);
Expand All @@ -39,7 +41,7 @@ export class QueriesApi extends RepoApi {
};

await this.apiAuth();
return this.alfrescoJsApi.core.queriesApi.findSites(searchTerm, data);
return this.queriesApi.findSites(searchTerm, data);
}

async findNodes(searchTerm: string) {
Expand Down
15 changes: 8 additions & 7 deletions e2e/utilities/repo-client/apis/repo-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,22 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/

import * as AlfrescoApi from 'alfresco-js-api-node';
import { AlfrescoApi } from '@alfresco/js-api';
import { REPO_API_HOST } from '../../../configs';
import { RepoClientAuth } from '../repo-client-models';

export abstract class RepoApi {

alfrescoJsApi = new AlfrescoApi({
provider: 'ECM',
hostEcm: REPO_API_HOST
});
alfrescoJsApi = new AlfrescoApi();

constructor(
private username: string = RepoClientAuth.DEFAULT_USERNAME,
private password: string = RepoClientAuth.DEFAULT_PASSWORD
) {}
) {
this.alfrescoJsApi.setConfig({
provider: 'ECM',
hostEcm: REPO_API_HOST
});
}

apiAuth() {
return this.alfrescoJsApi.login(this.username, this.password);
Expand Down
8 changes: 5 additions & 3 deletions e2e/utilities/repo-client/apis/search/search-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@

import { RepoApi } from '../repo-api';
import { Utils } from '../../../../utilities/utils';
import { SearchApi as AdfSearchApi } from '@alfresco/js-api';

export class SearchApi extends RepoApi {
searchApi = new AdfSearchApi(this.alfrescoJsApi);

constructor(username?, password?) {
super(username, password);
Expand All @@ -46,7 +48,7 @@ export class SearchApi extends RepoApi {
};

await this.apiAuth();
return this.alfrescoJsApi.search.searchApi.search(data);
return this.searchApi.search(data);
}

async queryNodesNames(searchTerm: string) {
Expand All @@ -61,7 +63,7 @@ export class SearchApi extends RepoApi {
};

await this.apiAuth();
return this.alfrescoJsApi.search.searchApi.search(data);
return this.searchApi.search(data);
}

async queryNodesExactNames(searchTerm: string) {
Expand All @@ -76,7 +78,7 @@ export class SearchApi extends RepoApi {
};

await this.apiAuth();
return this.alfrescoJsApi.search.searchApi.search(data);
return this.searchApi.search(data);
}

async waitForApi(username, data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@

import { RepoApi } from '../repo-api';
import { Utils } from '../../../../utilities/utils';
import { SharedlinksApi as AdfSharedlinksApi } from '@alfresco/js-api';

export class SharedLinksApi extends RepoApi {
sharedlinksApi = new AdfSharedlinksApi(this.alfrescoJsApi);

constructor(username?, password?) {
super(username, password);
Expand All @@ -39,7 +41,7 @@ export class SharedLinksApi extends RepoApi {
nodeId: id,
expiresAt: expireDate
};
return await this.alfrescoJsApi.core.sharedlinksApi.addSharedLink(data);
return await this.sharedlinksApi.createSharedLink(data);
} catch (error) {
console.log('---- shareFileById error: ', error);
}
Expand All @@ -60,12 +62,12 @@ export class SharedLinksApi extends RepoApi {

async unshareFile(name: string) {
const id = await this.getSharedIdOfNode(name);
return await this.alfrescoJsApi.core.sharedlinksApi.deleteSharedLink(id);
return await this.sharedlinksApi.deleteSharedLink(id);
}

async getSharedLinks() {
await this.apiAuth();
return await this.alfrescoJsApi.core.sharedlinksApi.findSharedLinks();
return await this.sharedlinksApi.listSharedLinks();
}

async waitForApi(data) {
Expand Down
Loading

0 comments on commit f0a3f6f

Please sign in to comment.