[ACA-1921] automate tests for Create folder from template (#1320)

* automate tests for Create folder from template
added unit test for exclusion of folder links

* fix stupid mistake
This commit is contained in:
Adina Parpalita
2020-01-23 17:47:25 +02:00
committed by Cilibiu Bogdan
parent 1eab186340
commit 2733c69c9a
10 changed files with 597 additions and 85 deletions

View File

@@ -54,6 +54,10 @@ export class AdminActions {
return await this.adminApi.nodes.getNodeIdFromParent('Node Templates', await this.getDataDictionaryId());
}
async getSpaceTemplatesFolderId(): Promise<string> {
return await this.adminApi.nodes.getNodeIdFromParent('Space Templates', await this.getDataDictionaryId());
}
async createUser(user: PersonModel): Promise<PersonEntry> {
return await this.adminApi.people.createUser(user);
}
@@ -68,19 +72,47 @@ export class AdminActions {
return await this.adminApi.nodes.createContent(hierarchy, `Data Dictionary/Node Templates`);
}
async removeUserAccessOnNode(nodeName: string): Promise<NodeEntry> {
async createSpaceTemplate(name: string, title: string = '', description: string = ''): Promise<NodeEntry> {
const templatesRootFolderId: string = await this.getSpaceTemplatesFolderId();
return await this.adminApi.nodes.createFolder(name, templatesRootFolderId, title, description);
}
async createSpaceTemplatesHierarchy(hierarchy: NodeContentTree): Promise<any> {
return await this.adminApi.nodes.createContent(hierarchy, `Data Dictionary/Space Templates`);
}
async removeUserAccessOnNodeTemplate(nodeName: string): Promise<NodeEntry> {
const templatesRootFolderId = await this.getNodeTemplatesFolderId();
const nodeId: string = await this.adminApi.nodes.getNodeIdFromParent(nodeName, templatesRootFolderId);
return await this.adminApi.nodes.setInheritPermissions(nodeId, false);
}
async cleanNodeTemplatesFolder(): Promise<void> {
async removeUserAccessOnSpaceTemplate(nodeName: string): Promise<NodeEntry> {
const templatesRootFolderId = await this.getSpaceTemplatesFolderId();
const nodeId: string = await this.adminApi.nodes.getNodeIdFromParent(nodeName, templatesRootFolderId);
return await this.adminApi.nodes.setInheritPermissions(nodeId, false);
}
async cleanupNodeTemplatesFolder(): Promise<void> {
return await this.adminApi.nodes.deleteNodeChildren(await this.getNodeTemplatesFolderId());
}
async cleanupSpaceTemplatesFolder(): Promise<void> {
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.adminApi.nodes.getNodeChildren(spaceTemplatesNodeId)).list.entries
.filter(node => (node.entry.nodeType !== 'app:folderlink') && (node.entry.name !== 'Software Engineering Project'))
.map(node => node.entry.id);
return await this.adminApi.nodes.deleteNodesById(nodesToDelete);
}
async createLinkToFileId(originalFileId: string, destinationParentId: string): Promise<NodeEntry> {
return await this.adminApi.nodes.createNodeLink(originalFileId, destinationParentId);
return await this.adminApi.nodes.createFileLink(originalFileId, destinationParentId);
}
async createLinkToFileName(originalFileName: string, originalFileParentId: string, destinationParentId?: string): Promise<NodeEntry> {
@@ -93,4 +125,18 @@ export class AdminActions {
return await this.createLinkToFileId(nodeId, destinationParentId);
}
async createLinkToFolderId(originalFolderId: string, destinationParentId: string): Promise<NodeEntry> {
return await this.adminApi.nodes.createFolderLink(originalFolderId, destinationParentId);
}
async createLinkToFolderName(originalFolderName: string, originalFolderParentId: string, destinationParentId?: string): Promise<NodeEntry> {
if (!destinationParentId) {
destinationParentId = originalFolderParentId
};
const nodeId = await this.adminApi.nodes.getNodeIdFromParent(originalFolderName, originalFolderParentId);
return await this.createLinkToFolderId(nodeId, destinationParentId);
}
}