From 184f521e7bde6f0c75c2618dcea49be5f7fdfa29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20=C5=9Awiderski?= Date: Fri, 22 Mar 2024 10:19:05 +0100 Subject: [PATCH] [ACS-7294] Updated hooks - copy-move-actions (#3721) * [ACS-7294] Updated hooks - copy-move-actions * [ACS-7294] fixed one comments test --- .../copy-move-actions/src/tests/copy.test.ts | 35 ++++++++----------- .../tests/destination-picker-dialog.test.ts | 12 +++---- .../info-drawer/src/tests/comments.spec.ts | 1 + .../aca-playwright-shared/src/utils/utils.ts | 4 +-- 4 files changed, 24 insertions(+), 28 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 f1ba47356..105a7d41b 100644 --- a/e2e/playwright/copy-move-actions/src/tests/copy.test.ts +++ b/e2e/playwright/copy-move-actions/src/tests/copy.test.ts @@ -22,11 +22,12 @@ * from Hyland Software. If not, see . */ -import { ApiClientFactory, test, Utils, PersonalFilesPage, NodesApi, LoginPage } from '@alfresco/playwright-shared'; +import { ApiClientFactory, test, Utils, PersonalFilesPage, NodesApi, LoginPage, TrashcanApi } from '@alfresco/playwright-shared'; import { expect } from '@playwright/test'; test.describe('Copy actions', () => { let nodesApi: NodesApi; + let trashcanApi: TrashcanApi; const username = `user-${Utils.random()}`; let sourceFile: string; @@ -44,13 +45,14 @@ test.describe('Copy actions', () => { await apiClientFactory.setUpAcaBackend('admin'); await apiClientFactory.createUser({ username }); nodesApi = await NodesApi.initialize(username, username); - } catch {} + trashcanApi = await TrashcanApi.initialize(username, username); + } catch (error) { + console.error(`beforeAll failed : ${error}`); + } }); - test.afterAll(async ({ nodesApiAction }) => { - try { - await nodesApiAction.deleteCurrentUserNodes(); - } catch {} + test.afterAll(async () => { + await Utils.deleteNodesSitesEmptyTrashcan(nodesApi, trashcanApi, 'afterAll failed'); }); test.beforeEach(async ({ personalFiles, page }) => { @@ -60,21 +62,14 @@ test.describe('Copy actions', () => { destinationFolder = `destination-folder-${Utils.random()}`; const loginPage = new LoginPage(page); - try { - await loginPage.loginUser( - { username, password: username }, - { - withNavigation: true, - waitForLoading: true - } - ); - destinationFolderId = (await nodesApi.createFolder(destinationFolder)).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; + await Utils.tryLoginUser(loginPage, username, username, 'beforeEach failed'); - await personalFiles.navigate(); - } catch {} + destinationFolderId = (await nodesApi.createFolder(destinationFolder)).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; + + await personalFiles.navigate(); }); const copyContentInPersonalFiles = async (personalFilesPage: PersonalFilesPage, sourceFileList: string[], destinationName: string) => { 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 f5730f7cc..c5dcbe561 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 @@ -22,13 +22,14 @@ * from Hyland Software. If not, see . */ -import { ApiClientFactory, MyLibrariesPage, NodesApi, SitesApi, test, Utils } from '@alfresco/playwright-shared'; +import { ApiClientFactory, MyLibrariesPage, NodesApi, SitesApi, test, Utils, TrashcanApi } from '@alfresco/playwright-shared'; import { expect } from '@playwright/test'; import { Site } from '@alfresco/js-api'; test.describe('Copy Move actions', () => { let nodesApi: NodesApi; let sitesApi: SitesApi; + let trashcanApi: TrashcanApi; const site = `site-${Utils.random()}`; const consumerUser = `consumer-${Utils.random()}`; @@ -42,11 +43,13 @@ test.describe('Copy Move actions', () => { test.beforeAll(async () => { try { + const username = `user-${Utils.random()}`; const apiClientFactory = new ApiClientFactory(); await apiClientFactory.setUpAcaBackend('admin'); - const username = `user-${Utils.random()}`; await apiClientFactory.createUser({ username }); + nodesApi = await NodesApi.initialize(username, username); + trashcanApi = await TrashcanApi.initialize(username, username); sitesApi = await SitesApi.initialize(username, username); siteId = (await sitesApi.createSite(site, Site.VisibilityEnum.PRIVATE)).entry.id; @@ -66,10 +69,7 @@ test.describe('Copy Move actions', () => { }); test.afterAll(async () => { - try { - await nodesApi.deleteCurrentUserNodes(); - await sitesApi.deleteSites([siteId]); - } catch {} + await Utils.deleteNodesSitesEmptyTrashcan(nodesApi, trashcanApi, 'afterAll failed', sitesApi, [siteId]); }); const copyContentInMyLibraries = async (myLibrariesPage: MyLibrariesPage) => { diff --git a/e2e/playwright/info-drawer/src/tests/comments.spec.ts b/e2e/playwright/info-drawer/src/tests/comments.spec.ts index c03ef9ae7..3159d6c4a 100755 --- a/e2e/playwright/info-drawer/src/tests/comments.spec.ts +++ b/e2e/playwright/info-drawer/src/tests/comments.spec.ts @@ -98,6 +98,7 @@ test.describe('Info Drawer - Comments', () => { await apiClientFactory.share.createSharedLink({ nodeId: sharedFileId }); await fileActionsApi.waitForNodes(sharedFileName, { expect: 1 }); await sharedPage.navigate(); + await Utils.reloadPageIfRowNotVisible(sharedPage, sharedFileName); await expect(sharedPage.dataTable.getRowByName(sharedFileName)).toBeVisible(); await sharedPage.dataTable.getRowByName(sharedFileName).click(); await sharedPage.acaHeader.viewDetails.click(); diff --git a/projects/aca-playwright-shared/src/utils/utils.ts b/projects/aca-playwright-shared/src/utils/utils.ts index 6706025d3..c1db9e50d 100644 --- a/projects/aca-playwright-shared/src/utils/utils.ts +++ b/projects/aca-playwright-shared/src/utils/utils.ts @@ -24,7 +24,7 @@ const crypto = require('crypto'); import * as path from 'path'; -import { LoginPage, MyLibrariesPage, PersonalFilesPage, FavoritesLibrariesPage, SearchPage } from '../'; +import { LoginPage, MyLibrariesPage, PersonalFilesPage, FavoritesLibrariesPage, SearchPage, SharedPage } from '../'; import { NodesApi, TrashcanApi, SitesApi } from '@alfresco/playwright-shared'; export class Utils { @@ -100,7 +100,7 @@ export class Utils { } static async reloadPageIfRowNotVisible( - pageContext: PersonalFilesPage | MyLibrariesPage | FavoritesLibrariesPage | SearchPage, + pageContext: PersonalFilesPage | MyLibrariesPage | FavoritesLibrariesPage | SearchPage | SharedPage, nodeName: string, errorMessage = 'Error ' ): Promise {