Skip to content

Commit

Permalink
[ACS-6081] remove adf-cli logger from e2es
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-web-ua committed Nov 24, 2023
1 parent 4e78284 commit 9401619
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 58 deletions.
7 changes: 3 additions & 4 deletions e2e/playwright/actions/src/tests/create-folder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {
errorStrings,
test
} from '@alfresco/playwright-shared';
import { logger } from '@alfresco/adf-cli/scripts/logger';

test.describe('Create folders', () => {
const apiClientFactory = new ApiClientFactory();
Expand All @@ -56,7 +55,7 @@ test.describe('Create folders', () => {
nodesApi = await NodesApi.initialize(username, username);
await nodesApi.createFolder(commonFolderName);
} catch (error) {
logger.error(`beforeAll failed : ${error}`);
console.error(`beforeAll failed : ${error}`);
}
});

Expand All @@ -77,15 +76,15 @@ test.describe('Create folders', () => {
await personalFiles.navigate();
await personalFiles.selectCreateFolder();
} catch (error) {
logger.error(`beforeEach failed : ${error}`);
console.error(`beforeEach failed : ${error}`);
}
});

test.afterAll(async () => {
try {
await nodesApi.deleteCurrentUserNodes();
} catch (error) {
logger.error(`afterAll failed : ${error}`);
console.error(`afterAll failed : ${error}`);
}
});

Expand Down
7 changes: 3 additions & 4 deletions e2e/playwright/actions/src/tests/create-library.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import {
Breadcrumb,
TrashcanApi
} from '@alfresco/playwright-shared';
import { logger } from '@alfresco/adf-cli/scripts/logger';

test.describe('Create Libraries ', () => {
const apiClientFactory = new ApiClientFactory();
Expand Down Expand Up @@ -70,7 +69,7 @@ test.describe('Create Libraries ', () => {
await sitesApi.createSite(commonTrashLibraryName);
await sitesApi.deleteSites([commonTrashLibraryName], false);
} catch (error) {
logger.error(`beforeAll failed : ${error}`);
console.error(`beforeAll failed : ${error}`);
}
});

Expand All @@ -91,7 +90,7 @@ test.describe('Create Libraries ', () => {
await myLibrariesPage.navigate();
await myLibrariesPage.selectCreateLibrary();
} catch (error) {
logger.error(`beforeEach failed : ${error}`);
console.error(`beforeEach failed : ${error}`);
}
});

Expand All @@ -101,7 +100,7 @@ test.describe('Create Libraries ', () => {
const trashcanApi = await TrashcanApi.initialize(username, username);
await trashcanApi.emptyTrashcan();
} catch (error) {
logger.error(`afterAll failed : ${error}`);
console.error(`afterAll failed : ${error}`);
}
});

Expand Down
9 changes: 4 additions & 5 deletions projects/aca-playwright-shared/src/api/api-client-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import {
TrashcanApi,
PersonEntry
} from '@alfresco/js-api';
import { logger } from '@alfresco/adf-cli/scripts/logger';
import { ActionTypes, Rule } from './rules-api';
import { users } from '../base-config';
import { Person, PersonModel } from './people-api-models';
Expand Down Expand Up @@ -145,7 +144,7 @@ export class ApiClientFactory {
try {
e = await this.alfrescoApi.login(user, userPassword);
} catch (error) {
logger.error(`[API Client Factory] Log in user ${user} failed ${e}`);
console.error(`[API Client Factory] Log in user ${user} failed ${e}`);
throw error;
}
}
Expand All @@ -155,7 +154,7 @@ export class ApiClientFactory {
try {
e = await this.alfrescoApi.login(user.username, user.password);
} catch (error) {
logger.error(`[API Client Factory] Log in user ${user.username} failed ${e}`);
console.error(`[API Client Factory] Log in user ${user.username} failed ${e}`);
throw error;
}
}
Expand All @@ -167,7 +166,7 @@ export class ApiClientFactory {
try {
return peopleApi.createPerson(person);
} catch (error) {
logger.error('[API Client Factory] createUser failed : ', error);
console.error('[API Client Factory] createUser failed : ', error);
return null;
}
}
Expand All @@ -178,7 +177,7 @@ export class ApiClientFactory {
try {
return peopleApi.updatePerson(username, { password: newPassword });
} catch (error) {
logger.error('[API Client Factory] changePassword failed : ', error);
console.error('[API Client Factory] changePassword failed : ', error);
return null;
}
}
Expand Down
55 changes: 27 additions & 28 deletions projects/aca-playwright-shared/src/api/nodes-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

import { ApiClientFactory } from './api-client-factory';
import { NodeChildAssociationPaging, NodeEntry, NodePaging } from '@alfresco/js-api';
import { logger } from '@alfresco/adf-cli/scripts/logger';
import { NodeContentTree, flattenNodeContentTree } from './node-content-tree';

export class NodesApi {
Expand All @@ -51,7 +50,7 @@ export class NodesApi {
try {
return await this.createNode('cm:folder', name, parentId, title, description, null, author, null, aspectNames);
} catch (error) {
logger.error(`${this.constructor.name} ${this.createFolder.name}`, error);
console.error(`${this.constructor.name} ${this.createFolder.name}`, error);
return null;
}
}
Expand All @@ -68,7 +67,7 @@ export class NodesApi {
try {
return await this.createNode('cm:content', name, parentId, title, description, null, author, majorVersion, aspectNames);
} catch (error) {
logger.error(`${this.constructor.name} ${this.createFile.name}`, error);
console.error(`${this.constructor.name} ${this.createFile.name}`, error);
return null;
}
}
Expand All @@ -77,7 +76,7 @@ export class NodesApi {
try {
return await this.createContent({ files: names }, relativePath);
} catch (error) {
logger.error(`${this.constructor.name} ${this.createFiles.name}: ${error}`);
console.error(`${this.constructor.name} ${this.createFiles.name}: ${error}`);
return null;
}
}
Expand Down Expand Up @@ -116,7 +115,7 @@ export class NodesApi {
majorVersion
});
} catch (error) {
logger.error(`${this.constructor.name} ${this.createNode.name}`, error);
console.error(`${this.constructor.name} ${this.createNode.name}`, error);
return null;
}
}
Expand All @@ -125,7 +124,7 @@ export class NodesApi {
try {
return this.apiService.nodes.updateNode(nodeId, { name: newName });
} catch (error) {
logger.error(`${this.constructor.name} ${this.renameNode.name}`, error);
console.error(`${this.constructor.name} ${this.renameNode.name}`, error);
return null;
}
}
Expand All @@ -141,7 +140,7 @@ export class NodesApi {
await this.apiService.nodes.deleteNode(nodeId, { permanent });
}
} catch (error) {
logger.error(`${this.constructor.name} ${this.deleteNodes.name}`, error);
console.error(`${this.constructor.name} ${this.deleteNodes.name}`, error);
}
}

Expand All @@ -155,7 +154,7 @@ export class NodesApi {
const userNodesIds = userNodes.map((nodeChild) => nodeChild.entry.id);
await this.deleteNodes(userNodesIds);
} catch (error) {
logger.error(`${this.constructor.name} ${this.deleteCurrentUserNodes.name}`, error);
console.error(`${this.constructor.name} ${this.deleteCurrentUserNodes.name}`, error);
}
}

Expand All @@ -165,15 +164,15 @@ export class NodesApi {
await this.apiService.nodes.lockNode(nodeId, { type: lockType });
}
} catch (error) {
logger.error(`${this.constructor.name} ${this.lockNodes.name}`, error);
console.error(`${this.constructor.name} ${this.lockNodes.name}`, error);
}
}

async createContent(content: NodeContentTree, relativePath: string = '/'): Promise<NodePaging> {
try {
return await this.apiService.nodes.createNode('-my-', flattenNodeContentTree(content, relativePath) as any);
} catch (error) {
logger.error(`${this.constructor.name} ${this.createContent.name}`, error);
console.error(`${this.constructor.name} ${this.createContent.name}`, error);
return null;
}
}
Expand All @@ -182,7 +181,7 @@ export class NodesApi {
try {
return await this.apiService.nodes.getNode(id);
} catch (error) {
logger.error(`${this.constructor.name} ${this.getNodeById.name}`, error);
console.error(`${this.constructor.name} ${this.getNodeById.name}`, error);
return null;
}
}
Expand All @@ -192,7 +191,7 @@ export class NodesApi {
const children = (await this.getNodeChildren(parentId)).list.entries;
return children.find((elem) => elem.entry.name === name).entry.id || '';
} catch (error) {
logger.error(`${this.constructor.name} ${this.getNodeIdFromParent.name}`, error);
console.error(`${this.constructor.name} ${this.getNodeIdFromParent.name}`, error);
return '';
}
}
Expand All @@ -204,7 +203,7 @@ export class NodesApi {
};
return await this.apiService.nodes.listNodeChildren(nodeId, opts);
} catch (error) {
logger.error(`${this.constructor.name} ${this.getNodeChildren.name}`, error);
console.error(`${this.constructor.name} ${this.getNodeChildren.name}`, error);
return null;
}
}
Expand All @@ -213,7 +212,7 @@ export class NodesApi {
try {
await this.apiService.nodes.deleteNode(id, { permanent });
} catch (error) {
logger.error(`${this.constructor.name} ${this.deleteNodeById.name}`, error);
console.error(`${this.constructor.name} ${this.deleteNodeById.name}`, error);
}
}

Expand All @@ -225,7 +224,7 @@ export class NodesApi {
await this.deleteNodeById(nodeId);
}
} catch (error) {
logger.error('Admin Actions - cleanupNodeTemplatesItems failed : ', error);
console.error('Admin Actions - cleanupNodeTemplatesItems failed : ', error);
}
}

Expand All @@ -237,15 +236,15 @@ export class NodesApi {
await this.deleteNodeById(nodeId);
}
} catch (error) {
logger.error('Admin Actions - cleanupSpaceTemplatesFolder failed : ', error);
console.error('Admin Actions - cleanupSpaceTemplatesFolder failed : ', error);
}
}

async getNodeTemplatesFolderId(): Promise<string> {
try {
return this.getNodeIdFromParent('Node Templates', await this.getDataDictionaryId());
} catch (error) {
logger.error('Admin Actions - getNodeTemplatesFolderId failed : ', error);
console.error('Admin Actions - getNodeTemplatesFolderId failed : ', error);
return '';
}
}
Expand All @@ -254,14 +253,14 @@ export class NodesApi {
try {
return this.getNodeIdFromParent('Space Templates', await this.getDataDictionaryId());
} catch (error) {
logger.error('Admin Actions - getSpaceTemplatesFolderId failed : ', error);
console.error('Admin Actions - getSpaceTemplatesFolderId failed : ', error);
return '';
}
}

private async getDataDictionaryId(): Promise<string> {
return this.getNodeIdFromParent('Data Dictionary', '-root-').catch((error) => {
logger.error('Admin Actions - getDataDictionaryId failed : ', error);
console.error('Admin Actions - getDataDictionaryId failed : ', error);
return '';
});
}
Expand All @@ -282,7 +281,7 @@ export class NodesApi {
try {
return await this.apiService.nodes.updateNode(nodeId, data);
} catch (error) {
logger.error(`${this.constructor.name} ${this.setGranularPermission.name}`, error);
console.error(`${this.constructor.name} ${this.setGranularPermission.name}`, error);
return null;
}
}
Expand All @@ -294,7 +293,7 @@ export class NodesApi {

return this.setInheritPermissions(nodeId, false);
} catch (error) {
logger.error('Admin Actions - removeUserAccessOnNodeTemplate failed : ', error);
console.error('Admin Actions - removeUserAccessOnNodeTemplate failed : ', error);
return null;
}
}
Expand All @@ -306,7 +305,7 @@ export class NodesApi {

return this.setInheritPermissions(nodeId, false);
} catch (error) {
logger.error('Admin Actions - removeUserAccessOnSpaceTemplate failed : ', error);
console.error('Admin Actions - removeUserAccessOnSpaceTemplate failed : ', error);
return null;
}
}
Expand All @@ -321,7 +320,7 @@ export class NodesApi {
try {
return await this.apiService.nodes.updateNode(nodeId, data);
} catch (error) {
logger.error(`${this.constructor.name} ${this.setInheritPermissions.name}`, error);
console.error(`${this.constructor.name} ${this.setInheritPermissions.name}`, error);
return null;
}
}
Expand All @@ -330,7 +329,7 @@ export class NodesApi {
try {
return this.apiService.nodes.updateNode(nodeId, { aspectNames });
} catch (error) {
logger.error(`${this.constructor.name} ${this.addAspects.name}`, error);
console.error(`${this.constructor.name} ${this.addAspects.name}`, error);
return null;
}
}
Expand All @@ -350,7 +349,7 @@ export class NodesApi {
await this.addAspects(originalNodeId, ['app:linked']);
return link;
} catch (error) {
logger.error(`${this.constructor.name} ${this.createFileLink.name}`, error);
console.error(`${this.constructor.name} ${this.createFileLink.name}`, error);
return null;
}
}
Expand All @@ -373,7 +372,7 @@ export class NodesApi {
await this.addAspects(originalNodeId, ['app:linked']);
return link;
} catch (error) {
logger.error(`${this.constructor.name} ${this.createFolderLink.name}`, error);
console.error(`${this.constructor.name} ${this.createFolderLink.name}`, error);
return null;
}
}
Expand All @@ -386,7 +385,7 @@ export class NodesApi {

return this.createFileLink(nodeId, destinationParentId);
} catch (error) {
logger.error('Admin Actions - createLinkToFileName failed : ', error);
console.error('Admin Actions - createLinkToFileName failed : ', error);
return null;
}
}
Expand All @@ -398,7 +397,7 @@ export class NodesApi {
const nodeId = await this.getNodeIdFromParent(originalFolderName, originalFolderParentId);
return this.createFolderLink(nodeId, destinationParentId);
} catch (error) {
logger.error('Admin Actions - createLinkToFolderName failed : ', error);
console.error('Admin Actions - createLinkToFolderName failed : ', error);
return null;
}
}
Expand Down
Loading

0 comments on commit 9401619

Please sign in to comment.