mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
e2e cleanup (#2951)
* reduce the code * reduce code * reduce code * reduce code * cleanup tests * more readable code * cleanup code * fix code * even more cleanup * remove some deprecated apis * code fixes * cleanup files * more files switching to user actions
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
*/
|
||||
|
||||
import { PersonEntry, NodeEntry, PeopleApi } from '@alfresco/js-api';
|
||||
import { PersonModel, SitesApi, UploadApi, NodesApi, FavoritesApi, SearchApi, NodeContentTree, Person, SharedLinksApi } from './repo-client/apis';
|
||||
import { PersonModel, SitesApi, UploadApi, NodesApi, NodeContentTree, Person, SharedLinksApi } from './repo-client/apis';
|
||||
import { UserActions } from './user-actions';
|
||||
import { browser } from 'protractor';
|
||||
|
||||
@@ -36,15 +36,13 @@ export class AdminActions extends UserActions {
|
||||
sites: SitesApi = new SitesApi();
|
||||
upload: UploadApi = new UploadApi();
|
||||
nodes: NodesApi = new NodesApi();
|
||||
favorites: FavoritesApi = new FavoritesApi();
|
||||
search: SearchApi = new SearchApi();
|
||||
shared: SharedLinksApi = new SharedLinksApi();
|
||||
|
||||
async login(username?: string, password?: string) {
|
||||
return super.login(username || browser.params.ADMIN_USERNAME, password || browser.params.ADMIN_PASSWORD);
|
||||
}
|
||||
|
||||
async getDataDictionaryId(): Promise<string> {
|
||||
private async getDataDictionaryId(): Promise<string> {
|
||||
try {
|
||||
return this.nodes.getNodeIdFromParent('Data Dictionary', '-root-');
|
||||
} catch (error) {
|
||||
@@ -108,17 +106,6 @@ export class AdminActions extends UserActions {
|
||||
}
|
||||
}
|
||||
|
||||
async createNodeTemplate(name: string, title: string = '', description: string = '', author: string = ''): Promise<NodeEntry> {
|
||||
try {
|
||||
const templatesRootFolderId: string = await this.getNodeTemplatesFolderId();
|
||||
|
||||
return this.nodes.createFile(name, templatesRootFolderId, title, description, author);
|
||||
} catch (error) {
|
||||
super.handleError('Admin Actions - createNodeTemplate failed : ', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async createNodeTemplatesHierarchy(hierarchy: NodeContentTree): Promise<any> {
|
||||
try {
|
||||
return this.nodes.createContent(hierarchy, `Data Dictionary/Node Templates`);
|
||||
@@ -127,17 +114,6 @@ export class AdminActions extends UserActions {
|
||||
}
|
||||
}
|
||||
|
||||
async createSpaceTemplate(name: string, title: string = '', description: string = ''): Promise<NodeEntry> {
|
||||
try {
|
||||
const templatesRootFolderId: string = await this.getSpaceTemplatesFolderId();
|
||||
|
||||
return this.nodes.createFolder(name, templatesRootFolderId, title, description);
|
||||
} catch (error) {
|
||||
super.handleError('Admin Actions - createSpaceTemplate failed : ', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async createSpaceTemplatesHierarchy(hierarchy: NodeContentTree): Promise<any> {
|
||||
try {
|
||||
return this.nodes.createContent(hierarchy, `Data Dictionary/Space Templates`);
|
||||
@@ -170,14 +146,6 @@ export class AdminActions extends UserActions {
|
||||
}
|
||||
}
|
||||
|
||||
async cleanupNodeTemplatesFolder(): Promise<void> {
|
||||
try {
|
||||
return this.nodes.deleteNodeChildren(await this.getNodeTemplatesFolderId());
|
||||
} catch (error) {
|
||||
super.handleError('Admin Actions - cleanupNodeTemplatesFolder failed : ', error);
|
||||
}
|
||||
}
|
||||
|
||||
async cleanupNodeTemplatesItems(nodeNames: string[]): Promise<void> {
|
||||
try {
|
||||
const templatesFolderId = await this.getNodeTemplatesFolderId();
|
||||
@@ -190,21 +158,6 @@ export class AdminActions extends UserActions {
|
||||
}
|
||||
}
|
||||
|
||||
async cleanupSpaceTemplatesFolder(): Promise<void> {
|
||||
try {
|
||||
const spaceTemplatesNodeId = await this.getSpaceTemplatesFolderId();
|
||||
|
||||
// folder links are deleted automatically when original folder is deleted
|
||||
// Software Engineering Project is the default folder template coming from ACS, should not be deleted
|
||||
const nodesToDelete = (await this.nodes.getNodeChildren(spaceTemplatesNodeId)).list.entries
|
||||
.filter((node) => node.entry.nodeType !== 'app:folderlink' && node.entry.name !== 'Software Engineering Project')
|
||||
.map((node) => node.entry.id);
|
||||
return this.nodes.deleteNodesById(nodesToDelete);
|
||||
} catch (error) {
|
||||
super.handleError('Admin Actions - cleanupSpaceTemplatesFolder failed : ', error);
|
||||
}
|
||||
}
|
||||
|
||||
async cleanupSpaceTemplatesItems(nodeNames: string[]): Promise<void> {
|
||||
try {
|
||||
const spaceTemplatesNodeId = await this.getSpaceTemplatesFolderId();
|
||||
@@ -217,15 +170,6 @@ export class AdminActions extends UserActions {
|
||||
}
|
||||
}
|
||||
|
||||
async createLinkToFileId(originalFileId: string, destinationParentId: string): Promise<NodeEntry> {
|
||||
try {
|
||||
return this.nodes.createFileLink(originalFileId, destinationParentId);
|
||||
} catch (error) {
|
||||
super.handleError('Admin Actions - createLinkToFileId failed : ', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async createLinkToFileName(originalFileName: string, originalFileParentId: string, destinationParentId?: string): Promise<NodeEntry> {
|
||||
if (!destinationParentId) {
|
||||
destinationParentId = originalFileParentId;
|
||||
@@ -234,22 +178,13 @@ export class AdminActions extends UserActions {
|
||||
try {
|
||||
const nodeId = await this.nodes.getNodeIdFromParent(originalFileName, originalFileParentId);
|
||||
|
||||
return this.createLinkToFileId(nodeId, destinationParentId);
|
||||
return this.nodes.createFileLink(nodeId, destinationParentId);
|
||||
} catch (error) {
|
||||
super.handleError('Admin Actions - createLinkToFileName failed : ', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async createLinkToFolderId(originalFolderId: string, destinationParentId: string): Promise<NodeEntry> {
|
||||
try {
|
||||
return this.nodes.createFolderLink(originalFolderId, destinationParentId);
|
||||
} catch (error) {
|
||||
super.handleError('Admin Actions - createLinkToFolderId failed : ', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async createLinkToFolderName(originalFolderName: string, originalFolderParentId: string, destinationParentId?: string): Promise<NodeEntry> {
|
||||
if (!destinationParentId) {
|
||||
destinationParentId = originalFolderParentId;
|
||||
@@ -258,7 +193,7 @@ export class AdminActions extends UserActions {
|
||||
try {
|
||||
const nodeId = await this.nodes.getNodeIdFromParent(originalFolderName, originalFolderParentId);
|
||||
|
||||
return this.createLinkToFolderId(nodeId, destinationParentId);
|
||||
return this.nodes.createFolderLink(nodeId, destinationParentId);
|
||||
} catch (error) {
|
||||
super.handleError('Admin Actions - createLinkToFolderName failed : ', error);
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user