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 12, 2024
1 parent 4a301d3 commit 93428af
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
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 @@ -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);
});

Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand Down Expand Up @@ -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 () => {
Expand All @@ -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);
});
});

Expand All @@ -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 () => {
Expand All @@ -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();
});

Expand Down Expand Up @@ -220,15 +220,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 {}
});
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 @@ -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();
});

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 @@ -90,7 +90,7 @@ describe('Version actions', () => {
});

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

describe('on Personal Files', () => {
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 @@ -97,7 +97,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 @@ -58,7 +58,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 @@ -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 {}
});
Expand Down Expand Up @@ -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 {}
});
Expand Down Expand Up @@ -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 {}
});
Expand Down Expand Up @@ -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 {}
});
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 @@ -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<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 93428af

Please sign in to comment.