Skip to content

Commit

Permalink
[ACS-5994] remove redundant deleteNodes method [ci:force]
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-web-ua committed Jan 9, 2024
1 parent 487c5ef commit d07708d
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,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 (error) {
Logger.error(`----- afterAll failed : ${error}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,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);
Expand Down
20 changes: 10 additions & 10 deletions e2e/protractor/suites/actions/delete/restore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,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);
});

Expand All @@ -86,7 +86,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 () => {
Expand All @@ -100,7 +100,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 () => {
Expand Down Expand Up @@ -128,7 +128,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 () => {
Expand All @@ -139,7 +139,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);
});
});

Expand All @@ -160,13 +160,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 () => {
Expand All @@ -175,7 +175,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();
});

Expand Down Expand Up @@ -221,15 +221,15 @@ 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;
file4Id = (await apis.user.nodes.createFile(file4, folder3Id)).entry.id;
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 (error) {
Logger.error(`----- beforeAll failed : ${error}`);
Expand Down
2 changes: 1 addition & 1 deletion e2e/protractor/suites/actions/edit/edit-offline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('Mark items as favorites', () => {
});

afterAll(async () => {
await userActions.deleteNodes([parentId]);
await apis.user.nodes.deleteNodeById(parentId);
});

afterEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('Download', () => {

afterAll(async () => {
await userActions.login(username, username);
await userActions.deleteNodes([parentId]);
await apis.user.nodes.deleteNodeById(parentId);
await userActions.emptyTrashcan();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('Upload files', () => {
});

afterAll(async () => {
await userActions.deleteNodes([folder1Id]);
await apis.user.nodes.deleteNodeById(folder1Id);
});

it('Upload a file', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('Version actions', () => {
});

afterAll(async () => {
await userActions.deleteNodes([parentFolderId]);
await apis.user.nodes.deleteNodeById(parentFolderId);
});

describe('on Personal Files', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('Extensions - Context submenu', () => {
});

afterAll(async () => {
await userActions.deleteNodes([fileId, folderId]);
await apis.user.nodes.deleteNodesById([fileId, folderId]);
});

it('[C286717] Displays the submenu actions set from config', async () => {
Expand Down
2 changes: 1 addition & 1 deletion e2e/protractor/suites/extensions/ext-metadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('Extensions - Metadata presets', () => {
});

afterAll(async () => {
await userActions.deleteNodes([fileId]);
await apis.user.nodes.deleteNodeById(fileId);
});

it('[C286636] Set groups of properties to display', async () => {
Expand Down
2 changes: 1 addition & 1 deletion e2e/protractor/suites/info-drawer/comments.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ describe('Comments', () => {

afterAll(async () => {
await userActions.login(username, username);
await userActions.deleteNodes([parentId]);
await apis.user.nodes.deleteNodeById(parentId);
});

afterEach(async () => {
Expand Down
2 changes: 1 addition & 1 deletion e2e/protractor/suites/info-drawer/general.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('General', () => {
});

afterAll(async () => {
await userActions.deleteNodes([parentId]);
await apis.user.nodes.deleteNodeById(parentId);
});

beforeEach(async () => {
Expand Down
8 changes: 4 additions & 4 deletions e2e/protractor/suites/viewer/viewer-actions.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,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 (error) {
Logger.error(`----- afterAll failed : ${error}`);
Expand Down Expand Up @@ -237,7 +237,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 (error) {
Logger.error(`----- afterAll failed : ${error}`);
Expand Down Expand Up @@ -344,7 +344,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 (error) {
Logger.error(`----- afterAll failed : ${error}`);
Expand Down Expand Up @@ -421,7 +421,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 (error) {
Logger.error(`----- afterAll failed : ${error}`);
Expand Down
4 changes: 1 addition & 3 deletions projects/aca-playwright-shared/src/api/nodes-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ export class NodesApi {
*/
async deleteNodes(nodeIds: string[], permanent: boolean = true): Promise<any> {
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,7 @@ export class NodesApi extends RepoApi {
async deleteNodesById(ids: string[], permanent: boolean = true): Promise<void> {
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);
}
Expand Down
15 changes: 0 additions & 15 deletions projects/aca-testing-shared/src/utilities/user-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,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<any> {
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.
*/
Expand Down

0 comments on commit d07708d

Please sign in to comment.