From ae3fde2573c5e49be4d900a94e376bd6eca60f63 Mon Sep 17 00:00:00 2001 From: "swapnil.verma" Date: Wed, 22 Nov 2023 12:24:28 +0530 Subject: [PATCH] [ACS-5014] Addressed code review findings. Moved objects to beforeAll/beforeEach wherever applicable. Added missing await. --- e2e/playwright/copy-move-actions/src/tests/copy.test.ts | 7 +++---- .../src/tests/destination-picker-dialog.test.ts | 4 ++-- e2e/playwright/copy-move-actions/src/tests/move.test.ts | 5 ++--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/e2e/playwright/copy-move-actions/src/tests/copy.test.ts b/e2e/playwright/copy-move-actions/src/tests/copy.test.ts index efca2e9712..50c40818de 100644 --- a/e2e/playwright/copy-move-actions/src/tests/copy.test.ts +++ b/e2e/playwright/copy-move-actions/src/tests/copy.test.ts @@ -28,7 +28,6 @@ import { Logger } from '@alfresco/adf-testing'; test.describe('Copy actions', () => { let nodesApi: NodesApi; - const apiClientFactory = new ApiClientFactory(); const username = `user-${Utils.random()}`; let sourceFile: string; @@ -38,11 +37,11 @@ test.describe('Copy actions', () => { let sourceFileId: string; let sourceFileInsideFolderId: string; - let sourceFolderId: string; let destinationFolderId: string; test.beforeAll(async () => { try { + const apiClientFactory = new ApiClientFactory(); await apiClientFactory.setUpAcaBackend('admin'); await apiClientFactory.createUser({ username }); nodesApi = await NodesApi.initialize(username, username); @@ -75,7 +74,7 @@ test.describe('Copy actions', () => { } ); destinationFolderId = (await nodesApi.createFolder(destinationFolder)).entry.id; - sourceFolderId = (await nodesApi.createFolder(sourceFolder)).entry.id; + const sourceFolderId = (await nodesApi.createFolder(sourceFolder)).entry.id; sourceFileInsideFolderId = (await nodesApi.createFile(sourceFileInsideFolder, sourceFolderId)).entry.id; sourceFileId = (await nodesApi.createFile(sourceFile)).entry.id; @@ -86,7 +85,7 @@ test.describe('Copy actions', () => { }); const copyContentInPersonalFiles = async (personalFilesPage: PersonalFilesPage, sourceFileList: string[], destinationName: string) => { - personalFilesPage.copyOrMoveContentInDatatable(sourceFileList, destinationName, 'Copy'); + await personalFilesPage.copyOrMoveContentInDatatable(sourceFileList, destinationName, 'Copy'); const msg = await personalFilesPage.snackBar.message.innerText(); if (sourceFileList.length === 1) { expect.soft(msg).toContain('Copied 1 item'); diff --git a/e2e/playwright/copy-move-actions/src/tests/destination-picker-dialog.test.ts b/e2e/playwright/copy-move-actions/src/tests/destination-picker-dialog.test.ts index a017b6d89c..6164b0344e 100644 --- a/e2e/playwright/copy-move-actions/src/tests/destination-picker-dialog.test.ts +++ b/e2e/playwright/copy-move-actions/src/tests/destination-picker-dialog.test.ts @@ -30,9 +30,7 @@ import { Logger } from '@alfresco/adf-testing'; test.describe('Copy Move actions', () => { let nodesApi: NodesApi; let sitesApi: SitesApi; - const apiClientFactory = new ApiClientFactory(); - const username = `user-${Utils.random()}`; const site = `site-${Utils.random()}`; const consumerUser = `consumer-${Utils.random()}`; const contributorUser = `contributor-${Utils.random()}`; @@ -45,7 +43,9 @@ test.describe('Copy Move actions', () => { test.beforeAll(async () => { try { + const apiClientFactory = new ApiClientFactory(); await apiClientFactory.setUpAcaBackend('admin'); + const username = `user-${Utils.random()}`; await apiClientFactory.createUser({ username }); nodesApi = await NodesApi.initialize(username, username); sitesApi = await SitesApi.initialize(username, username); diff --git a/e2e/playwright/copy-move-actions/src/tests/move.test.ts b/e2e/playwright/copy-move-actions/src/tests/move.test.ts index 2f3df7cd3a..edb8ea7992 100644 --- a/e2e/playwright/copy-move-actions/src/tests/move.test.ts +++ b/e2e/playwright/copy-move-actions/src/tests/move.test.ts @@ -28,7 +28,6 @@ import { Logger } from '@alfresco/adf-testing'; test.describe('Move actions', () => { let nodesApi: NodesApi; - const apiClientFactory = new ApiClientFactory(); const username = `user-${Utils.random()}`; let sourceFile: string; @@ -38,11 +37,11 @@ test.describe('Move actions', () => { let sourceFileId: string; let sourceFileInsideFolderId: string; - let sourceFolderId: string; let destinationFolderId: string; test.beforeAll(async () => { try { + const apiClientFactory = new ApiClientFactory(); await apiClientFactory.setUpAcaBackend('admin'); await apiClientFactory.createUser({ username }); nodesApi = await NodesApi.initialize(username, username); @@ -75,7 +74,7 @@ test.describe('Move actions', () => { } ); destinationFolderId = (await nodesApi.createFolder(destinationFolder)).entry.id; - sourceFolderId = (await nodesApi.createFolder(sourceFolder)).entry.id; + const sourceFolderId = (await nodesApi.createFolder(sourceFolder)).entry.id; sourceFileInsideFolderId = (await nodesApi.createFile(sourceFileInsideFolder, sourceFolderId)).entry.id; sourceFileId = (await nodesApi.createFile(sourceFile)).entry.id;