From 2908bcc1a1b1babe966e86a18c01bd0e7ec6e869 Mon Sep 17 00:00:00 2001 From: Mykyta Maliarchuk Date: Tue, 9 Jan 2024 10:07:39 +0100 Subject: [PATCH 1/3] [ACS-5994] remove redundant deleteNodes method [ci:force] --- .../actions/delete/delete-undo-delete.test.ts | 2 +- .../actions/delete/permanently-delete.test.ts | 2 +- .../suites/actions/delete/restore.test.ts | 20 +++++++++---------- .../suites/actions/edit/edit-offline.test.ts | 2 +- .../actions/favorite/mark-favorite.test.ts | 2 +- .../actions/upload-download/download.test.ts | 2 +- .../upload-download/upload-file.test.ts | 2 +- .../upload-new-version.test.ts | 2 +- .../upload-download/version-actions.test.ts | 2 +- .../suites/viewer/viewer-actions.test.ts | 8 ++++---- .../src/api/nodes-api.ts | 4 +--- .../repo-client/apis/nodes/nodes-api.ts | 4 +--- .../src/utilities/user-actions.ts | 15 -------------- 13 files changed, 24 insertions(+), 43 deletions(-) diff --git a/e2e/protractor/suites/actions/delete/delete-undo-delete.test.ts b/e2e/protractor/suites/actions/delete/delete-undo-delete.test.ts index 95cd605303..841e25acb0 100755 --- a/e2e/protractor/suites/actions/delete/delete-undo-delete.test.ts +++ b/e2e/protractor/suites/actions/delete/delete-undo-delete.test.ts @@ -117,7 +117,7 @@ describe('Delete and undo delete', () => { try { await userActions.login(username, username); await userActions.unlockNodes([fileLocked1Id, fileLocked2Id, fileLocked3Id, fileLocked4Id]); - await userActions.deleteNodes([parentId]); + await apis.user.nodes.deleteNodeById(parentId); await userActions.emptyTrashcan(); } catch {} }); diff --git a/e2e/protractor/suites/actions/delete/permanently-delete.test.ts b/e2e/protractor/suites/actions/delete/permanently-delete.test.ts index 1cc1c1ddfb..7c15ec236d 100755 --- a/e2e/protractor/suites/actions/delete/permanently-delete.test.ts +++ b/e2e/protractor/suites/actions/delete/permanently-delete.test.ts @@ -58,7 +58,7 @@ describe('Permanently delete from Trash', () => { await apis.user.sites.createSite(site); await userActions.login(username, username); - await userActions.deleteNodes([...filesIds, ...foldersIds], false); + await apis.user.nodes.deleteNodesById([...filesIds, ...foldersIds], false); await userActions.deleteSites([site], false); await loginPage.loginWith(username); diff --git a/e2e/protractor/suites/actions/delete/restore.test.ts b/e2e/protractor/suites/actions/delete/restore.test.ts index 3cc1fbee39..56dacc0aa0 100755 --- a/e2e/protractor/suites/actions/delete/restore.test.ts +++ b/e2e/protractor/suites/actions/delete/restore.test.ts @@ -61,7 +61,7 @@ describe('Restore from Trash', () => { await apis.user.sites.createSite(site); await userActions.login(username, username); - await userActions.deleteNodes([fileId, folderId], false); + await apis.user.nodes.deleteNodesById([fileId, folderId], false); await userActions.deleteSites([site], false); }); @@ -85,7 +85,7 @@ describe('Restore from Trash', () => { await page.clickPersonalFilesAndWait(); expect(await page.dataTable.isItemPresent(file)).toBe(true, 'Item not displayed in list'); - await userActions.deleteNodes([fileId], false); + await apis.user.nodes.deleteNodeById(fileId, false); }); it('[C280438] restore folder', async () => { @@ -99,7 +99,7 @@ describe('Restore from Trash', () => { await page.clickPersonalFilesAndWait(); expect(await page.dataTable.isItemPresent(folder)).toBe(true, 'Item not displayed in list'); - await userActions.deleteNodes([folderId], false); + await apis.user.nodes.deleteNodeById(folderId, false); }); it('[C290104] restore library', async () => { @@ -127,7 +127,7 @@ describe('Restore from Trash', () => { expect(await page.dataTable.isItemPresent(file)).toBe(true, 'Item not displayed in list'); expect(await page.dataTable.isItemPresent(folder)).toBe(true, 'Item not displayed in list'); - await userActions.deleteNodes([fileId, folderId], false); + await apis.user.nodes.deleteNodesById([fileId, folderId], false); }); it('[C217181] View from notification', async () => { @@ -138,7 +138,7 @@ describe('Restore from Trash', () => { expect(await page.sidenav.isActive('Personal Files')).toBe(true, 'Personal Files sidebar link not active'); expect(await browser.getCurrentUrl()).toContain(APP_ROUTES.PERSONAL_FILES); - await userActions.deleteNodes([fileId], false); + await apis.user.nodes.deleteNodeById(fileId, false); }); }); @@ -159,13 +159,13 @@ describe('Restore from Trash', () => { file1Id1 = (await apis.user.nodes.createFile(file1, folder1Id)).entry.id; await userActions.login(username, username); - await userActions.deleteNodes([file1Id1], false); + await apis.user.nodes.deleteNodeById(file1Id1, false); file1Id2 = (await apis.user.nodes.createFile(file1, folder1Id)).entry.id; folder2Id = (await apis.user.nodes.createFolder(folder2)).entry.id; file2Id = (await apis.user.nodes.createFile(file2, folder2Id)).entry.id; - await userActions.deleteNodes([file2Id, folder2Id], false); + await apis.user.nodes.deleteNodesById([file2Id, folder2Id], false); }); beforeEach(async () => { @@ -174,7 +174,7 @@ describe('Restore from Trash', () => { afterAll(async () => { await userActions.login(username, username); - await userActions.deleteNodes([file1Id2]); + await apis.user.nodes.deleteNodeById(file1Id2); await userActions.emptyTrashcan(); }); @@ -220,7 +220,7 @@ describe('Restore from Trash', () => { file2Id = (await apis.user.nodes.createFile(file2, folder2Id)).entry.id; await userActions.login(username, username); - await userActions.deleteNodes([file1Id, folder1Id, file2Id], false); + await apis.user.nodes.deleteNodesById([file1Id, folder1Id, file2Id], false); folder3Id = (await apis.user.nodes.createFolder(folder3)).entry.id; file3Id = (await apis.user.nodes.createFile(file3, folder3Id)).entry.id; @@ -228,7 +228,7 @@ describe('Restore from Trash', () => { folder4Id = (await apis.user.nodes.createFolder(folder4)).entry.id; file5Id = (await apis.user.nodes.createFile(file5, folder4Id)).entry.id; - await userActions.deleteNodes([file3Id, file4Id, folder3Id, file5Id], false); + await apis.user.nodes.deleteNodesById([file3Id, file4Id, folder3Id, file5Id], false); await loginPage.loginWith(username); } catch {} }); diff --git a/e2e/protractor/suites/actions/edit/edit-offline.test.ts b/e2e/protractor/suites/actions/edit/edit-offline.test.ts index ce69bc5838..1c316ed451 100755 --- a/e2e/protractor/suites/actions/edit/edit-offline.test.ts +++ b/e2e/protractor/suites/actions/edit/edit-offline.test.ts @@ -77,7 +77,7 @@ describe('Edit offline', () => { afterAll(async () => { await userActions.login(username, username); - await userActions.deleteNodes([parentPFId]); + await apis.user.nodes.deleteNodeById(parentPFId); }); it('[C297538] File is locked and downloaded when clicking Edit Offline', async () => { diff --git a/e2e/protractor/suites/actions/favorite/mark-favorite.test.ts b/e2e/protractor/suites/actions/favorite/mark-favorite.test.ts index f0702856f8..43e3b1fa4b 100644 --- a/e2e/protractor/suites/actions/favorite/mark-favorite.test.ts +++ b/e2e/protractor/suites/actions/favorite/mark-favorite.test.ts @@ -102,7 +102,7 @@ describe('Mark items as favorites', () => { }); afterAll(async () => { - await userActions.deleteNodes([parentId]); + await apis.user.nodes.deleteNodeById(parentId); }); afterEach(async () => { diff --git a/e2e/protractor/suites/actions/upload-download/download.test.ts b/e2e/protractor/suites/actions/upload-download/download.test.ts index 9a9056e0a0..b645bf7ff8 100755 --- a/e2e/protractor/suites/actions/upload-download/download.test.ts +++ b/e2e/protractor/suites/actions/upload-download/download.test.ts @@ -112,7 +112,7 @@ describe('Download', () => { afterAll(async () => { await userActions.login(username, username); - await userActions.deleteNodes([parentId]); + await apis.user.nodes.deleteNodeById(parentId); await userActions.emptyTrashcan(); }); diff --git a/e2e/protractor/suites/actions/upload-download/upload-file.test.ts b/e2e/protractor/suites/actions/upload-download/upload-file.test.ts index e8b7a6b4b7..d42a2f81c5 100755 --- a/e2e/protractor/suites/actions/upload-download/upload-file.test.ts +++ b/e2e/protractor/suites/actions/upload-download/upload-file.test.ts @@ -60,7 +60,7 @@ describe('Upload files', () => { }); afterAll(async () => { - await userActions.deleteNodes([folder1Id]); + await apis.user.nodes.deleteNodeById(folder1Id); }); it('Upload a file', async () => { diff --git a/e2e/protractor/suites/actions/upload-download/upload-new-version.test.ts b/e2e/protractor/suites/actions/upload-download/upload-new-version.test.ts index f4a216eedf..85089e2c30 100755 --- a/e2e/protractor/suites/actions/upload-download/upload-new-version.test.ts +++ b/e2e/protractor/suites/actions/upload-download/upload-new-version.test.ts @@ -112,7 +112,7 @@ describe('Upload new version', () => { afterAll(async () => { await userActions.login(username, username); - await userActions.deleteNodes([parentPFId, parentSFId, parentRFId, parentFavId, parentSearchId]); + await apis.user.nodes.deleteNodesById([parentPFId, parentSFId, parentRFId, parentFavId, parentSearchId]); }); describe('on Search Results', () => { diff --git a/e2e/protractor/suites/actions/upload-download/version-actions.test.ts b/e2e/protractor/suites/actions/upload-download/version-actions.test.ts index 65ce054b34..b6c9d0a695 100644 --- a/e2e/protractor/suites/actions/upload-download/version-actions.test.ts +++ b/e2e/protractor/suites/actions/upload-download/version-actions.test.ts @@ -90,7 +90,7 @@ describe('Version actions', () => { }); afterAll(async () => { - await userActions.deleteNodes([parentFolderId]); + await apis.user.nodes.deleteNodeById(parentFolderId); }); describe('on Personal Files', () => { diff --git a/e2e/protractor/suites/viewer/viewer-actions.test.ts b/e2e/protractor/suites/viewer/viewer-actions.test.ts index 93896995ce..cff6a6e2c4 100755 --- a/e2e/protractor/suites/viewer/viewer-actions.test.ts +++ b/e2e/protractor/suites/viewer/viewer-actions.test.ts @@ -126,7 +126,7 @@ describe('Viewer actions', () => { afterAll(async () => { try { await userActions.login(username, username); - await userActions.deleteNodes([parentId, destinationId]); + await apis.user.nodes.deleteNodesById([parentId, destinationId]); await userActions.emptyTrashcan(); } catch {} }); @@ -228,7 +228,7 @@ describe('Viewer actions', () => { afterAll(async () => { try { await userActions.login(username, username); - await userActions.deleteNodes([parentId, destinationId]); + await apis.user.nodes.deleteNodesById([parentId, destinationId]); await userActions.emptyTrashcan(); } catch {} }); @@ -329,7 +329,7 @@ describe('Viewer actions', () => { afterAll(async () => { try { await userActions.login(username, username); - await userActions.deleteNodes([parentId, destinationId]); + await apis.user.nodes.deleteNodesById([parentId, destinationId]); await userActions.emptyTrashcan(); } catch {} }); @@ -402,7 +402,7 @@ describe('Viewer actions', () => { afterAll(async () => { try { await userActions.login(username, username); - await userActions.deleteNodes([parentId, destinationId]); + await apis.user.nodes.deleteNodesById([parentId, destinationId]); await userActions.emptyTrashcan(); } catch {} }); diff --git a/projects/aca-playwright-shared/src/api/nodes-api.ts b/projects/aca-playwright-shared/src/api/nodes-api.ts index 50d9609eab..47ac6f8f66 100755 --- a/projects/aca-playwright-shared/src/api/nodes-api.ts +++ b/projects/aca-playwright-shared/src/api/nodes-api.ts @@ -144,9 +144,7 @@ export class NodesApi { */ async deleteNodes(nodeIds: string[], permanent: boolean = true): Promise { try { - for (const nodeId of nodeIds) { - await this.apiService.nodes.deleteNode(nodeId, { permanent }); - } + await this.apiService.nodes.deleteNodes(nodeIds, { permanent }); } catch (error) { console.error(`${this.constructor.name} ${this.deleteNodes.name}`, error); } diff --git a/projects/aca-testing-shared/src/utilities/repo-client/apis/nodes/nodes-api.ts b/projects/aca-testing-shared/src/utilities/repo-client/apis/nodes/nodes-api.ts index 8039da2421..e7110b16d0 100755 --- a/projects/aca-testing-shared/src/utilities/repo-client/apis/nodes/nodes-api.ts +++ b/projects/aca-testing-shared/src/utilities/repo-client/apis/nodes/nodes-api.ts @@ -166,9 +166,7 @@ export class NodesApi extends RepoApi { async deleteNodesById(ids: string[], permanent: boolean = true): Promise { try { await this.apiAuth(); - for (const id of ids) { - await this.nodesApi.deleteNode(id, { permanent }); - } + await this.nodesApi.deleteNodes(ids, { permanent }); } catch (error) { this.handleError(`${this.constructor.name} ${this.deleteNodesById.name}`, error); } diff --git a/projects/aca-testing-shared/src/utilities/user-actions.ts b/projects/aca-testing-shared/src/utilities/user-actions.ts index 13527c7d68..297a5cd82b 100644 --- a/projects/aca-testing-shared/src/utilities/user-actions.ts +++ b/projects/aca-testing-shared/src/utilities/user-actions.ts @@ -69,21 +69,6 @@ export class UserActions { } } - /** - * Delete multiple nodes. - * @param nodeIds The list of node IDs to delete. - * @param permanent Delete permanently, without moving to the trashcan? (default: true) - */ - async deleteNodes(nodeIds: string[], permanent: boolean = true): Promise { - try { - for (const nodeId of nodeIds) { - await this.nodesApi.deleteNode(nodeId, { permanent }); - } - } catch (error) { - this.handleError('User Actions - deleteNodes failed : ', error); - } - } - /** * Empties the trashcan. Uses multiple batches 1000 nodes each. */ From f7cdf1de09c4c0cad531cc45db8457729b083fcc Mon Sep 17 00:00:00 2001 From: Mykyta Maliarchuk Date: Mon, 19 Feb 2024 12:33:13 +0100 Subject: [PATCH 2/3] [link-adf:dev-mmaliarchuk/ACS-5994-fix-jsApi-deleteNodes][affected:*][ci:force] From 4e0b6f25c8d290b04a5ca71290d54e8e9b5c43cd Mon Sep 17 00:00:00 2001 From: Mykyta Maliarchuk Date: Tue, 20 Feb 2024 12:11:53 +0100 Subject: [PATCH 3/3] rebase