From 940161927bca15426b13185ef27db8da23419a83 Mon Sep 17 00:00:00 2001 From: Mykyta Maliarchuk Date: Fri, 24 Nov 2023 12:47:11 +0100 Subject: [PATCH] [ACS-6081] remove adf-cli logger from e2es --- .../actions/src/tests/create-folder.spec.ts | 7 +-- .../actions/src/tests/create-library.spec.ts | 7 +-- .../src/api/api-client-factory.ts | 9 ++- .../src/api/nodes-api.ts | 55 +++++++++---------- .../src/api/shared-links-api.ts | 9 ++- .../src/api/sites-api.ts | 11 ++-- .../src/api/trashcan-api.ts | 3 +- .../src/utils/exclude-tests.ts | 6 +- 8 files changed, 49 insertions(+), 58 deletions(-) diff --git a/e2e/playwright/actions/src/tests/create-folder.spec.ts b/e2e/playwright/actions/src/tests/create-folder.spec.ts index ae13e6e8ff..649118cc3b 100644 --- a/e2e/playwright/actions/src/tests/create-folder.spec.ts +++ b/e2e/playwright/actions/src/tests/create-folder.spec.ts @@ -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(); @@ -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}`); } }); @@ -77,7 +76,7 @@ test.describe('Create folders', () => { await personalFiles.navigate(); await personalFiles.selectCreateFolder(); } catch (error) { - logger.error(`beforeEach failed : ${error}`); + console.error(`beforeEach failed : ${error}`); } }); @@ -85,7 +84,7 @@ test.describe('Create folders', () => { try { await nodesApi.deleteCurrentUserNodes(); } catch (error) { - logger.error(`afterAll failed : ${error}`); + console.error(`afterAll failed : ${error}`); } }); diff --git a/e2e/playwright/actions/src/tests/create-library.spec.ts b/e2e/playwright/actions/src/tests/create-library.spec.ts index bde61ce502..75b0fae39e 100644 --- a/e2e/playwright/actions/src/tests/create-library.spec.ts +++ b/e2e/playwright/actions/src/tests/create-library.spec.ts @@ -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(); @@ -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}`); } }); @@ -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}`); } }); @@ -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}`); } }); diff --git a/projects/aca-playwright-shared/src/api/api-client-factory.ts b/projects/aca-playwright-shared/src/api/api-client-factory.ts index 23c646a69d..7adaa41133 100644 --- a/projects/aca-playwright-shared/src/api/api-client-factory.ts +++ b/projects/aca-playwright-shared/src/api/api-client-factory.ts @@ -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'; @@ -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; } } @@ -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; } } @@ -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; } } @@ -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; } } diff --git a/projects/aca-playwright-shared/src/api/nodes-api.ts b/projects/aca-playwright-shared/src/api/nodes-api.ts index 7267b471f0..c83f563888 100755 --- a/projects/aca-playwright-shared/src/api/nodes-api.ts +++ b/projects/aca-playwright-shared/src/api/nodes-api.ts @@ -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 { @@ -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; } } @@ -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; } } @@ -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; } } @@ -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; } } @@ -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; } } @@ -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); } } @@ -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); } } @@ -165,7 +164,7 @@ 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); } } @@ -173,7 +172,7 @@ export class NodesApi { 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; } } @@ -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; } } @@ -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 ''; } } @@ -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; } } @@ -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); } } @@ -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); } } @@ -237,7 +236,7 @@ export class NodesApi { await this.deleteNodeById(nodeId); } } catch (error) { - logger.error('Admin Actions - cleanupSpaceTemplatesFolder failed : ', error); + console.error('Admin Actions - cleanupSpaceTemplatesFolder failed : ', error); } } @@ -245,7 +244,7 @@ export class NodesApi { 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 ''; } } @@ -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 { return this.getNodeIdFromParent('Data Dictionary', '-root-').catch((error) => { - logger.error('Admin Actions - getDataDictionaryId failed : ', error); + console.error('Admin Actions - getDataDictionaryId failed : ', error); return ''; }); } @@ -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; } } @@ -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; } } @@ -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; } } @@ -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; } } @@ -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; } } @@ -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; } } @@ -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; } } @@ -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; } } @@ -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; } } diff --git a/projects/aca-playwright-shared/src/api/shared-links-api.ts b/projects/aca-playwright-shared/src/api/shared-links-api.ts index c90089c6d9..48800b8cc9 100755 --- a/projects/aca-playwright-shared/src/api/shared-links-api.ts +++ b/projects/aca-playwright-shared/src/api/shared-links-api.ts @@ -22,7 +22,6 @@ * along with Alfresco. If not, see . */ -import { logger } from '@alfresco/adf-cli/scripts/logger'; import { ApiClientFactory } from './api-client-factory'; import { SharedLinkEntry, SharedLinkPaging } from '@alfresco/js-api'; import { Utils } from '../utils'; @@ -61,7 +60,7 @@ export class SharedLinksApi { } } } catch (error) { - logger.error(`SharedLinksApi shareFilesByIds : catch : `, error); + console.error(`SharedLinksApi shareFilesByIds : catch : `, error); } return sharedLinks; } @@ -73,7 +72,7 @@ export class SharedLinksApi { }; return await this.apiService.share.listSharedLinks(opts); } catch (error) { - logger.error(`SharedLinksApi getSharedLinks : catch : `, error); + console.error(`SharedLinksApi getSharedLinks : catch : `, error); return new SharedLinkPaging; } } @@ -92,8 +91,8 @@ export class SharedLinksApi { return Utils.retryCall(sharedFile); } catch (error) { - logger.error(`SharedLinksApi waitForFilesToBeShared : catch : ${error}`); - logger.error(`\tWait timeout reached waiting for files to be shared`); + console.error(`SharedLinksApi waitForFilesToBeShared : catch : ${error}`); + console.error(`\tWait timeout reached waiting for files to be shared`); } } } diff --git a/projects/aca-playwright-shared/src/api/sites-api.ts b/projects/aca-playwright-shared/src/api/sites-api.ts index 15625fb415..f30c6afd41 100755 --- a/projects/aca-playwright-shared/src/api/sites-api.ts +++ b/projects/aca-playwright-shared/src/api/sites-api.ts @@ -24,7 +24,6 @@ import { ApiClientFactory } from './api-client-factory'; import { Site, SiteBodyCreate, SiteEntry, SiteMemberEntry, SiteMembershipBodyCreate, SiteMembershipBodyUpdate } from '@alfresco/js-api'; -import { logger } from '@alfresco/adf-cli/scripts/logger'; export class SitesApi { private apiService: ApiClientFactory; @@ -49,7 +48,7 @@ export class SitesApi { try { return await this.apiService.sites.createSite(site); } catch (error) { - logger.error(`SitesApi createSite : catch : `, error); + console.error(`SitesApi createSite : catch : `, error); return null; } } @@ -58,7 +57,7 @@ export class SitesApi { try { return (await this.apiService.sites.listSiteContainers(siteId)).list.entries[0].entry.id; } catch (error) { - logger.error(`SitesApi getDocLibId : catch : `, error); + console.error(`SitesApi getDocLibId : catch : `, error); return null; } } @@ -76,7 +75,7 @@ export class SitesApi { } } } catch (error) { - logger.error(`${this.constructor.name} ${this.deleteSites.name}`, error); + console.error(`${this.constructor.name} ${this.deleteSites.name}`, error); } } @@ -88,7 +87,7 @@ export class SitesApi { try { return await this.apiService.sites.updateSiteMembership(siteId, userId, siteRole); } catch (error) { - logger.error(`SitesApi updateSiteMember : catch : `, error); + console.error(`SitesApi updateSiteMember : catch : `, error); return new SiteMemberEntry; } } @@ -105,7 +104,7 @@ export class SitesApi { if (error.status === 409) { return this.updateSiteMember(siteId, userId, role); } else { - logger.error(`SitesApi addSiteMember : catch : `, error); + console.error(`SitesApi addSiteMember : catch : `, error); return new SiteMemberEntry; } } diff --git a/projects/aca-playwright-shared/src/api/trashcan-api.ts b/projects/aca-playwright-shared/src/api/trashcan-api.ts index b5a4be5949..0bfeb462c6 100644 --- a/projects/aca-playwright-shared/src/api/trashcan-api.ts +++ b/projects/aca-playwright-shared/src/api/trashcan-api.ts @@ -23,7 +23,6 @@ */ import { ApiClientFactory } from './api-client-factory'; -import { logger } from '@alfresco/adf-cli/scripts/logger'; export class TrashcanApi { private apiService = new ApiClientFactory(); @@ -51,7 +50,7 @@ export class TrashcanApi { } } } catch (error) { - logger.error('User Actions - emptyTrashcan failed : ', error); + console.error('User Actions - emptyTrashcan failed : ', error); } } diff --git a/projects/aca-playwright-shared/src/utils/exclude-tests.ts b/projects/aca-playwright-shared/src/utils/exclude-tests.ts index aa89a8a291..223e77a224 100644 --- a/projects/aca-playwright-shared/src/utils/exclude-tests.ts +++ b/projects/aca-playwright-shared/src/utils/exclude-tests.ts @@ -6,16 +6,14 @@ * agreement is prohibited. */ -import { logger } from '@alfresco/adf-cli/scripts/logger'; - export const getExcludedTestsRegExpArray = (excludedJson: any, projectName: string) => { const prefix = `[ 🎭 Playwright Excludes - ${projectName} ]`; const objectKeys = Object.keys(excludedJson); if (!objectKeys.length) { - logger.info(`${prefix} ✅ No excluded tests 🎉 `); + console.info(`${prefix} ✅ No excluded tests 🎉 `); } else { - logger.warn(`${prefix} ❌ Tests excluded because of 🐛 : ${objectKeys}`); + console.warn(`${prefix} ❌ Tests excluded because of 🐛 : ${objectKeys}`); } return objectKeys.map((key) => new RegExp(key));