[ACA-1928] e2e improvements - part1 (#883)

* refactor Mark as favourite tests
rename method to be more clear
create separate methods for some checks and actions

* forgot some changes

* refactor delete-undo tests

* some more refactoring

* fix
This commit is contained in:
Adina Parpalita
2018-12-20 11:27:54 +02:00
committed by Suzana Dirla
parent 0882686172
commit b8ce533759
54 changed files with 2310 additions and 2069 deletions

View File

@@ -23,7 +23,6 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from 'protractor';
import { LoginPage, BrowsingPage } from '../../pages/pages';
import { RepoClient } from '../../utilities/repo-client/repo-client';
import { Utils } from '../../utilities/utils';
@@ -53,192 +52,181 @@ describe('Delete and undo delete', () => {
xit('');
describe('on Personal Files', () => {
const file1 = `file1-${Utils.random()}.txt`; let file1Id;
const file2 = `file2-${Utils.random()}.txt`; let file2Id;
const file1 = `file1-${Utils.random()}.txt`;
const file2 = `file2-${Utils.random()}.txt`;
const file3 = `file3-${Utils.random()}.txt`;
const file4 = `file4-${Utils.random()}.txt`; let file4Id;
const file4 = `file4-${Utils.random()}.txt`;
const file5 = `file5-${Utils.random()}.txt`;
const file6 = `file6-${Utils.random()}.txt`;
const file7 = `file7-${Utils.random()}.txt`;
const folder1 = `folder1-${Utils.random()}`; let folder1Id;
const folder2 = `folder2-${Utils.random()}`; let folder2Id;
const folder3 = `folder3-${Utils.random()}`; let folder3Id;
const folder4 = `folder4-${Utils.random()}`; let folder4Id;
const folder5 = `folder5-${Utils.random()}`; let folder5Id;
const folder6 = `folder6-${Utils.random()}`; let folder6Id;
const file1InFolder = `file1InFolder-${Utils.random()}.txt`;
const file2InFolder = `file2InFolder-${Utils.random()}.txt`;
const fileLocked1 = `fileLocked1-${Utils.random()}.txt`; let fileLocked1Id;
const fileLocked2 = `fileLocked2-${Utils.random()}.txt`; let fileLocked2Id;
const fileLocked3 = `fileLocked3-${Utils.random()}.txt`; let fileLocked3Id;
const fileLocked4 = `fileLocked4-${Utils.random()}.txt`; let fileLocked4Id;
const parent = `parentPF-${Utils.random()}`; let parentId;
beforeAll(async (done) => {
file1Id = (await apis.user.nodes.createFile(file1)).entry.id;
file2Id = (await apis.user.nodes.createFile(file2)).entry.id;
folder1Id = (await apis.user.nodes.createFolder(folder1)).entry.id;
parentId = (await apis.user.nodes.createFolder(parent)).entry.id;
folder2Id = (await apis.user.nodes.createFolder(folder2)).entry.id;
await apis.user.nodes.createFile(file3, folder1Id);
file4Id = (await apis.user.nodes.createFile(file4, folder2Id)).entry.id;
await apis.user.nodes.lockFile(file4Id);
await apis.user.nodes.createFile(file1, parentId);
await apis.user.nodes.createFile(file2, parentId);
await apis.user.nodes.createFile(file3, parentId);
await apis.user.nodes.createFile(file4, parentId);
await apis.user.nodes.createFile(file5, parentId);
await apis.user.nodes.createFile(file6, parentId);
await apis.user.nodes.createFile(file7, parentId);
folder3Id = (await apis.user.nodes.createFolder(folder3)).entry.id;
folder1Id = (await apis.user.nodes.createFolder(folder1, parentId)).entry.id;
folder2Id = (await apis.user.nodes.createFolder(folder2, parentId)).entry.id;
folder3Id = (await apis.user.nodes.createFolder(folder3, parentId)).entry.id;
folder4Id = (await apis.user.nodes.createFolder(folder4, parentId)).entry.id;
folder5Id = (await apis.user.nodes.createFolder(folder5, parentId)).entry.id;
folder6Id = (await apis.user.nodes.createFolder(folder6, parentId)).entry.id;
await apis.user.nodes.createFile(file1InFolder, folder1Id);
fileLocked1Id = (await apis.user.nodes.createFile(fileLocked1, folder2Id)).entry.id;
fileLocked2Id = (await apis.user.nodes.createFile(fileLocked2, folder3Id)).entry.id;
await apis.user.nodes.lockFile(fileLocked2Id);
fileLocked3Id = (await apis.user.nodes.createFile(fileLocked3, folder4Id)).entry.id;
fileLocked4Id = (await apis.user.nodes.createFile(fileLocked4, folder5Id)).entry.id;
await apis.user.nodes.createFile(file2InFolder, folder6Id);
fileLocked1Id = (await apis.user.nodes.createFile(fileLocked1)).entry.id;
await apis.user.nodes.lockFile(fileLocked1Id);
await apis.user.nodes.lockFile(fileLocked2Id);
await apis.user.nodes.lockFile(fileLocked3Id);
await apis.user.nodes.lockFile(fileLocked4Id);
await loginPage.loginWith(username);
done();
});
beforeEach(async (done) => {
await page.clickPersonalFilesAndWait();
done();
});
afterEach(async (done) => {
await page.refresh();
await page.dataTable.doubleClickOnRowByName(parent);
done();
});
afterAll(async (done) => {
await apis.user.nodes.unlockFile(file4Id);
await apis.user.nodes.unlockFile(fileLocked1Id);
await apis.user.nodes.unlockFile(fileLocked2Id);
await apis.user.nodes.deleteNodesById([file1Id, file2Id, folder1Id, folder2Id, folder3Id, fileLocked1Id]);
await apis.user.search.waitForApi(username, {expect: 0});
await apis.user.nodes.unlockFile(fileLocked3Id);
await apis.user.nodes.unlockFile(fileLocked4Id);
await apis.user.nodes.deleteNodeById(parentId);
await apis.user.trashcan.emptyTrash();
done();
});
xit('delete a file and check notification - [C217125]', async () => {
it('delete a file and check notification - [C217125]', async () => {
let items = await page.dataTable.countRows();
await dataTable.selectItem(file1);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
await toolbar.clickMoreActionsDelete();
const message = await page.getSnackBarMessage();
expect(message).toContain(`${file1} deleted`);
expect(await dataTable.getRowByName(file1).isPresent()).toBe(false, 'Item was not removed from list');
expect(message).toContain(`Undo`);
expect(await dataTable.isItemPresent(file1)).toBe(false, 'Item was not removed from list');
items--;
expect(await page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
await page.clickTrash();
expect(await dataTable.getRowByName(file1).isPresent()).toBe(true, 'Item is not in trash');
await apis.user.trashcan.restore(file1Id);
expect(await dataTable.isItemPresent(file1)).toBe(true, 'Item is not in trash');
});
xit('delete multiple files and check notification - [C280502]', async () => {
it('delete multiple files and check notification - [C280502]', async () => {
let items = await page.dataTable.countRows();
await dataTable.selectMultipleItems([file1, file2]);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
await dataTable.selectMultipleItems([file2, file3]);
await toolbar.clickMoreActionsDelete();
const message = await page.getSnackBarMessage();
expect(message).toContain(`Deleted 2 items`);
expect(await dataTable.getRowByName(file1).isPresent()).toBe(false, `${file1} was not removed from list`);
expect(await dataTable.getRowByName(file2).isPresent()).toBe(false, `${file2} was not removed from list`);
expect(await dataTable.isItemPresent(file2)).toBe(false, `${file2} was not removed from list`);
expect(await dataTable.isItemPresent(file3)).toBe(false, `${file3} was not removed from list`);
items = items - 2;
expect(await page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
await page.clickTrash();
expect(await dataTable.getRowByName(file1).isPresent()).toBe(true, `${file1} is not in trash`);
expect(await dataTable.getRowByName(file2).isPresent()).toBe(true, `${file2} is not in trash`);
await apis.user.trashcan.restore(file1Id);
await apis.user.trashcan.restore(file2Id);
expect(await dataTable.isItemPresent(file2)).toBe(true, `${file2} is not in trash`);
expect(await dataTable.isItemPresent(file3)).toBe(true, `${file3} is not in trash`);
});
it('delete a folder with content - [C217126]', async () => {
let items = await page.dataTable.countRows();
await dataTable.selectItem(folder1);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
expect(await dataTable.getRowByName(folder1).isPresent()).toBe(false, 'Item was not removed from list');
await toolbar.clickMoreActionsDelete();
expect(await dataTable.isItemPresent(folder1)).toBe(false, 'Item was not removed from list');
items--;
expect(await page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
await page.clickTrash();
expect(await dataTable.getRowByName(folder1).isPresent()).toBe(true, 'Item is not in trash');
expect(await dataTable.getRowByName(file3).isPresent()).toBe(false, 'Item is in trash');
await apis.user.trashcan.restore(folder1Id);
expect(await dataTable.isItemPresent(folder1)).toBe(true, 'Item is not in trash');
expect(await dataTable.isItemPresent(file1InFolder)).toBe(false, 'Item is in trash');
});
it('delete a folder containing locked files - [C217127]', async () => {
await dataTable.selectItem(folder2);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
await toolbar.clickMoreActionsDelete();
const message = await page.getSnackBarMessage();
expect(message).toContain(`${folder2} couldn't be deleted`);
expect(await dataTable.getRowByName(folder2).isPresent()).toBe(true, 'Item was removed from list');
expect(message).not.toContain(`Undo`);
expect(await dataTable.isItemPresent(folder2)).toBe(true, 'Item was removed from list');
await page.clickTrash();
expect(await dataTable.getRowByName(folder2).isPresent()).toBe(false, 'Item is in trash');
expect(await dataTable.getRowByName(file4).isPresent()).toBe(false, 'Item is in trash');
expect(await dataTable.isItemPresent(folder2)).toBe(false, 'Item is in trash');
expect(await dataTable.isItemPresent(fileLocked1)).toBe(false, 'Item is in trash');
});
it('notification on multiple items deletion - some items fail to delete - [C217129]', async () => {
await dataTable.selectMultipleItems([file1, folder2]);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
await dataTable.selectMultipleItems([file4, folder3]);
await toolbar.clickMoreActionsDelete();
const message = await page.getSnackBarMessage();
expect(message).toContain(`Deleted 1 item, 1 couldn't be deleted`);
await apis.user.trashcan.restore(file1Id);
expect(message).toContain(`Undo`);
});
it('notification on multiple items deletion - all items fail to delete - [C217130]', async () => {
await dataTable.selectMultipleItems([folder3, folder2]);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
await dataTable.selectMultipleItems([folder4, folder5]);
await toolbar.clickMoreActionsDelete();
const message = await page.getSnackBarMessage();
expect(message).toEqual(`2 items couldn't be deleted`);
});
it('successful delete notification shows Undo action - [C217131]', async () => {
await dataTable.selectItem(file1);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
const message = await page.getSnackBarMessage();
expect(message).toContain(`Undo`);
await apis.user.trashcan.restore(file1Id);
});
it('unsuccessful delete notification does not show Undo action - [C217134]', async () => {
await dataTable.selectItem(folder2);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
const message = await page.getSnackBarMessage();
expect(message).not.toContain(`Undo`);
});
it('undo delete of file - [C217132]', async () => {
const items = await page.dataTable.countRows();
await dataTable.selectItem(file1);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
await dataTable.selectItem(file5);
await toolbar.clickMoreActionsDelete();
await page.clickSnackBarAction();
expect(await dataTable.getRowByName(file1).isPresent()).toBe(true, 'Item was not restored');
expect(await dataTable.isItemPresent(file5)).toBe(true, 'Item was not restored');
expect(await page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
});
it('undo delete of folder with content - [C280503]', async () => {
const items = await page.dataTable.countRows();
await dataTable.selectItem(folder1);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
await dataTable.selectItem(folder6);
await toolbar.clickMoreActionsDelete();
await page.clickSnackBarAction();
expect(await dataTable.getRowByName(folder1).isPresent()).toBe(true, 'Item was not restored');
expect(await dataTable.isItemPresent(folder6)).toBe(true, 'Item was not restored');
expect(await page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
await dataTable.doubleClickOnRowByName(folder1);
expect(await dataTable.getRowByName(file3).isPresent()).toBe(true, 'file from folder not restored');
await dataTable.doubleClickOnRowByName(folder6);
expect(await dataTable.isItemPresent(file2InFolder)).toBe(true, 'file from folder not restored');
});
xit('undo delete of multiple files - [C280504]', async () => {
it('undo delete of multiple files - [C280504]', async () => {
const items = await page.dataTable.countRows();
await dataTable.selectMultipleItems([file1, file2]);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
await dataTable.selectMultipleItems([file6, file7]);
await toolbar.clickMoreActionsDelete();
await page.clickSnackBarAction();
expect(await dataTable.getRowByName(file1).isPresent()).toBe(true, `${file1} was not removed from list`);
expect(await dataTable.getRowByName(file2).isPresent()).toBe(true, `${file2} was not removed from list`);
expect(await dataTable.isItemPresent(file6)).toBe(true, `${file6} was not removed from list`);
expect(await dataTable.isItemPresent(file7)).toBe(true, `${file7} was not removed from list`);
expect(await page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
});
});
@@ -248,14 +236,28 @@ describe('Delete and undo delete', () => {
const sharedFile2 = `sharedFile2-${Utils.random()}.txt`; let sharedFile2Id;
const sharedFile3 = `sharedFile3-${Utils.random()}.txt`; let sharedFile3Id;
const sharedFile4 = `sharedFile4-${Utils.random()}.txt`; let sharedFile4Id;
const sharedFile5 = `sharedFile5-${Utils.random()}.txt`; let sharedFile5Id;
const sharedFile6 = `sharedFile6-${Utils.random()}.txt`; let sharedFile6Id;
const parent = `parentSF-${Utils.random()}`; let parentId;
beforeAll(async (done) => {
sharedFile1Id = (await apis.user.nodes.createFile(sharedFile1)).entry.id;
sharedFile2Id = (await apis.user.nodes.createFile(sharedFile2)).entry.id;
sharedFile3Id = (await apis.user.nodes.createFile(sharedFile3)).entry.id;
sharedFile4Id = (await apis.user.nodes.createFile(sharedFile4)).entry.id;
await apis.user.shared.shareFilesByIds([sharedFile1Id, sharedFile2Id, sharedFile3Id, sharedFile4Id]);
await apis.user.shared.waitForApi({ expect: 4 });
parentId = (await apis.user.nodes.createFolder(parent)).entry.id;
sharedFile1Id = (await apis.user.nodes.createFile(sharedFile1, parentId)).entry.id;
sharedFile2Id = (await apis.user.nodes.createFile(sharedFile2, parentId)).entry.id;
sharedFile3Id = (await apis.user.nodes.createFile(sharedFile3, parentId)).entry.id;
sharedFile4Id = (await apis.user.nodes.createFile(sharedFile4, parentId)).entry.id;
sharedFile5Id = (await apis.user.nodes.createFile(sharedFile5, parentId)).entry.id;
sharedFile6Id = (await apis.user.nodes.createFile(sharedFile6, parentId)).entry.id;
await apis.user.shared.shareFilesByIds([
sharedFile1Id,
sharedFile2Id,
sharedFile3Id,
sharedFile4Id,
sharedFile5Id,
sharedFile6Id]);
await apis.user.shared.waitForApi({ expect: 6 });
await loginPage.loginWith(username);
done();
@@ -266,109 +268,112 @@ describe('Delete and undo delete', () => {
done();
});
afterEach(async (done) => {
await page.refresh();
done();
});
afterAll(async (done) => {
await apis.user.nodes.deleteNodesById([sharedFile1Id, sharedFile2Id, sharedFile3Id, sharedFile4Id]);
await apis.user.search.waitForApi(username, {expect: 0});
await apis.user.nodes.deleteNodeById(parentId);
await apis.user.trashcan.emptyTrash();
done();
});
xit('delete a file and check notification - [C280316]', async () => {
it('delete a file and check notification - [C280316]', async () => {
await dataTable.selectItem(sharedFile1);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
await toolbar.clickMoreActionsDelete();
const message = await page.getSnackBarMessage();
expect(message).toContain(`${sharedFile1} deleted`);
expect(await dataTable.getRowByName(sharedFile1).isPresent()).toBe(false, 'Item was not removed from list');
expect(message).toContain(`Undo`);
expect(await dataTable.isItemPresent(sharedFile1)).toBe(false, 'Item was not removed from list');
await page.clickTrash();
expect(await dataTable.getRowByName(sharedFile1).isPresent()).toBe(true, 'Item is not in trash');
await apis.user.trashcan.restore(sharedFile1Id);
await apis.user.shared.shareFilesByIds([ sharedFile1Id ]);
await apis.user.shared.waitForApi({ expect: 4 });
expect(await dataTable.isItemPresent(sharedFile1)).toBe(true, 'Item is not in trash');
});
xit('delete multiple files and check notification - [C280513]', async () => {
it('delete multiple files and check notification - [C280513]', async () => {
await dataTable.selectMultipleItems([sharedFile2, sharedFile3]);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
await toolbar.clickMoreActionsDelete();
const message = await page.getSnackBarMessage();
expect(message).toContain(`Deleted 2 items`);
expect(await dataTable.getRowByName(sharedFile2).isPresent()).toBe(false, `${sharedFile2} was not removed from list`);
expect(await dataTable.getRowByName(sharedFile3).isPresent()).toBe(false, `${sharedFile3} was not removed from list`);
await page.clickTrash();
expect(await dataTable.getRowByName(sharedFile2).isPresent()).toBe(true, `${sharedFile2} is not in trash`);
expect(await dataTable.getRowByName(sharedFile3).isPresent()).toBe(true, `${sharedFile3} is not in trash`);
await apis.user.trashcan.restore(sharedFile2Id);
await apis.user.trashcan.restore(sharedFile3Id);
await apis.user.shared.shareFilesByIds([ sharedFile2Id, sharedFile3Id ]);
await apis.user.shared.waitForApi({ expect: 4 });
});
xit('successful delete notification shows Undo action - [C280323]', async () => {
await dataTable.selectItem(sharedFile1);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
const message = await page.getSnackBarMessage();
expect(message).toContain(`Undo`);
await apis.user.trashcan.restore(sharedFile1Id);
expect(await dataTable.isItemPresent(sharedFile2)).toBe(false, `${sharedFile2} was not removed from list`);
expect(await dataTable.isItemPresent(sharedFile3)).toBe(false, `${sharedFile3} was not removed from list`);
await page.clickTrash();
expect(await dataTable.isItemPresent(sharedFile2)).toBe(true, `${sharedFile2} is not in trash`);
expect(await dataTable.isItemPresent(sharedFile3)).toBe(true, `${sharedFile3} is not in trash`);
});
xit('undo delete of file - [C280324]', async () => {
await dataTable.selectItem(sharedFile2);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
it('undo delete of file - [C280324]', async () => {
await dataTable.selectItem(sharedFile4);
await toolbar.clickMoreActionsDelete();
await page.clickSnackBarAction();
await page.clickTrash();
expect(await dataTable.getRowByName(sharedFile2).isPresent()).toBe(false, 'Item was not restored');
expect(await dataTable.isItemPresent(sharedFile4)).toBe(false, 'Item was not restored');
});
xit('undo delete of multiple files - [C280514]', async () => {
await dataTable.selectMultipleItems([sharedFile3, sharedFile4]);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
it('undo delete of multiple files - [C280514]', async () => {
await dataTable.selectMultipleItems([sharedFile5, sharedFile6]);
await toolbar.clickMoreActionsDelete();
await page.clickSnackBarAction();
await page.clickTrash();
expect(await dataTable.getRowByName(sharedFile3).isPresent()).toBe(false, `${sharedFile3} was not restored`);
expect(await dataTable.getRowByName(sharedFile4).isPresent()).toBe(false, `${sharedFile4} was not restored`);
expect(await dataTable.isItemPresent(sharedFile5)).toBe(false, `${sharedFile5} was not restored`);
expect(await dataTable.isItemPresent(sharedFile6)).toBe(false, `${sharedFile6} was not restored`);
});
});
describe('on Favorites', () => {
const favoriteFile1 = `favFile1-${Utils.random()}.txt`; let favoriteFile1Id;
const favoriteFile2 = `favFile2-${Utils.random()}.txt`; let favoriteFile2Id;
const favoriteFile3 = `favFile3-${Utils.random()}.txt`;
const favoriteFile4 = `favFile4-${Utils.random()}.txt`; let favoriteFile4Id;
const favoriteFolder1 = `favFolder1-${Utils.random()}`; let favoriteFolder1Id;
const favoriteFolder2 = `favFolder2-${Utils.random()}`; let favoriteFolder2Id;
const favoriteFolder3 = `favFolder3-${Utils.random()}`; let favoriteFolder3Id;
const favoriteFileLocked1 = `favFileLocked1-${Utils.random()}.txt`; let favoriteFileLocked1Id;
const favoriteFileLocked2 = `favFileLocked2-${Utils.random()}.txt`; let favoriteFileLocked2Id;
const parent = `parentF-${Utils.random()}`; let parentId;
const favFile1 = `favFile1-${Utils.random()}.txt`; let favFile1Id;
const favFile2 = `favFile2-${Utils.random()}.txt`; let favFile2Id;
const favFile3 = `favFile3-${Utils.random()}.txt`; let favFile3Id;
const favFile4 = `favFile4-${Utils.random()}.txt`; let favFile4Id;
const favFile5 = `favFile5-${Utils.random()}.txt`; let favFile5Id;
const favFile6 = `favFile6-${Utils.random()}.txt`; let favFile6Id;
const favFile7 = `favFile7-${Utils.random()}.txt`; let favFile7Id;
const favFolder1 = `favFolder1-${Utils.random()}`; let favFolder1Id;
const favFolder2 = `favFolder2-${Utils.random()}`; let favFolder2Id;
const favFolder3 = `favFolder3-${Utils.random()}`; let favFolder3Id;
const favFolder4 = `favFolder4-${Utils.random()}`; let favFolder4Id;
const favFolder5 = `favFolder5-${Utils.random()}`; let favFolder5Id;
const favFolder6 = `favFolder6-${Utils.random()}`; let favFolder6Id;
const file1InFolder = `file1InFolder-${Utils.random()}.txt`;
const file2InFolder = `file2InFolder-${Utils.random()}.txt`;
const fileLocked1 = `fileLocked1-${Utils.random()}.txt`; let fileLocked1Id;
const fileLocked2 = `fileLocked2-${Utils.random()}.txt`; let fileLocked2Id;
const fileLocked3 = `fileLocked3-${Utils.random()}.txt`; let fileLocked3Id;
const fileLocked4 = `fileLocked4-${Utils.random()}.txt`; let fileLocked4Id;
beforeAll(async (done) => {
favoriteFile1Id = (await apis.user.nodes.createFile(favoriteFile1)).entry.id;
favoriteFile2Id = (await apis.user.nodes.createFile(favoriteFile2)).entry.id;
favoriteFolder1Id = (await apis.user.nodes.createFolder(favoriteFolder1)).entry.id;
favoriteFolder2Id = (await apis.user.nodes.createFolder(favoriteFolder2)).entry.id;
favoriteFolder3Id = (await apis.user.nodes.createFolder(favoriteFolder3)).entry.id;
await apis.user.nodes.createFile(favoriteFile3, favoriteFolder1Id);
favoriteFile4Id = (await apis.user.nodes.createFile(favoriteFile4, favoriteFolder2Id)).entry.id;
favoriteFileLocked2Id = (await apis.user.nodes.createFile(favoriteFileLocked2, favoriteFolder3Id)).entry.id;
await apis.user.nodes.lockFile(favoriteFile4Id);
await apis.user.nodes.lockFile(favoriteFileLocked2Id);
parentId = (await apis.user.nodes.createFolder(parent)).entry.id;
favoriteFileLocked1Id = (await apis.user.nodes.createFile(favoriteFileLocked1)).entry.id;
await apis.user.nodes.lockFile(favoriteFileLocked1Id);
favFile1Id = (await apis.user.nodes.createFile(favFile1, parentId)).entry.id;
favFile2Id = (await apis.user.nodes.createFile(favFile2, parentId)).entry.id;
favFile3Id = (await apis.user.nodes.createFile(favFile3, parentId)).entry.id;
favFile4Id = (await apis.user.nodes.createFile(favFile4, parentId)).entry.id;
favFile5Id = (await apis.user.nodes.createFile(favFile5, parentId)).entry.id;
favFile6Id = (await apis.user.nodes.createFile(favFile6, parentId)).entry.id;
favFile7Id = (await apis.user.nodes.createFile(favFile7, parentId)).entry.id;
await apis.user.favorites.addFavoritesByIds('file', [ favoriteFile1Id, favoriteFile2Id, favoriteFileLocked1Id ]);
await apis.user.favorites.addFavoritesByIds('folder', [ favoriteFolder1Id, favoriteFolder2Id, favoriteFolder3Id ]);
await apis.user.favorites.waitForApi({ expect: 6 });
favFolder1Id = (await apis.user.nodes.createFolder(favFolder1, parentId)).entry.id;
favFolder2Id = (await apis.user.nodes.createFolder(favFolder2, parentId)).entry.id;
favFolder3Id = (await apis.user.nodes.createFolder(favFolder3, parentId)).entry.id;
favFolder4Id = (await apis.user.nodes.createFolder(favFolder4, parentId)).entry.id;
favFolder5Id = (await apis.user.nodes.createFolder(favFolder5, parentId)).entry.id;
favFolder6Id = (await apis.user.nodes.createFolder(favFolder6, parentId)).entry.id;
await apis.user.nodes.createFile(file1InFolder, favFolder1Id);
fileLocked1Id = (await apis.user.nodes.createFile(fileLocked1, favFolder2Id)).entry.id;
fileLocked2Id = (await apis.user.nodes.createFile(fileLocked2, favFolder3Id)).entry.id;
fileLocked3Id = (await apis.user.nodes.createFile(fileLocked3, favFolder4Id)).entry.id;
fileLocked4Id = (await apis.user.nodes.createFile(fileLocked4, favFolder5Id)).entry.id;
await apis.user.nodes.createFile(file2InFolder, favFolder6Id);
await apis.user.nodes.lockFile(fileLocked1Id);
await apis.user.nodes.lockFile(fileLocked2Id);
await apis.user.nodes.lockFile(fileLocked3Id);
await apis.user.nodes.lockFile(fileLocked4Id);
await apis.user.favorites.addFavoritesByIds('file', [ favFile1Id, favFile2Id, favFile3Id, favFile4Id, favFile5Id, favFile6Id, favFile7Id ]);
await apis.user.favorites.addFavoritesByIds('folder', [ favFolder1Id, favFolder2Id, favFolder3Id, favFolder4Id, favFolder5Id, favFolder6Id ]);
await apis.user.favorites.waitForApi({ expect: 13 });
await loginPage.loginWith(username);
done();
@@ -379,182 +384,145 @@ describe('Delete and undo delete', () => {
done();
});
afterEach(async (done) => {
await page.refresh();
done();
});
afterAll(async (done) => {
await apis.user.nodes.unlockFile(favoriteFile4Id);
await apis.user.nodes.unlockFile(favoriteFileLocked1Id);
await apis.user.nodes.unlockFile(favoriteFileLocked2Id);
await apis.user.nodes.deleteNodesById([
favoriteFile1Id, favoriteFile2Id, favoriteFolder1Id, favoriteFolder2Id, favoriteFileLocked1Id, favoriteFolder3Id
]);
await apis.user.search.waitForApi(username, {expect: 0});
await apis.user.nodes.unlockFile(fileLocked1Id);
await apis.user.nodes.unlockFile(fileLocked2Id);
await apis.user.nodes.unlockFile(fileLocked3Id);
await apis.user.nodes.unlockFile(fileLocked4Id);
await apis.user.nodes.deleteNodeById(parentId);
await apis.user.trashcan.emptyTrash();
done();
});
xit('delete a file and check notification - [C280516]', async () => {
it('delete a file and check notification - [C280516]', async () => {
let items = await page.dataTable.countRows();
await dataTable.selectItem(favoriteFile1);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
await dataTable.selectItem(favFile1);
await toolbar.clickMoreActionsDelete();
const message = await page.getSnackBarMessage();
expect(message).toContain(`${favoriteFile1} deleted`);
expect(await dataTable.getRowByName(favoriteFile1).isPresent()).toBe(false, 'Item was not removed from list');
expect(message).toContain(`${favFile1} deleted`);
expect(message).toContain(`Undo`);
expect(await dataTable.isItemPresent(favFile1)).toBe(false, 'Item was not removed from list');
items--;
expect(await page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
await page.clickTrash();
expect(await dataTable.getRowByName(favoriteFile1).isPresent()).toBe(true, 'Item is not in trash');
await apis.user.trashcan.restore(favoriteFile1Id);
expect(await dataTable.isItemPresent(favFile1)).toBe(true, 'Item is not in trash');
});
xit('delete multiple files and check notification - [C280517]', async () => {
it('delete multiple files and check notification - [C280517]', async () => {
let items = await page.dataTable.countRows();
await dataTable.selectMultipleItems([favoriteFile1, favoriteFile2]);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
await dataTable.selectMultipleItems([favFile2, favFile3]);
await toolbar.clickMoreActionsDelete();
const message = await page.getSnackBarMessage();
expect(message).toContain(`Deleted 2 items`);
expect(await dataTable.getRowByName(favoriteFile1).isPresent()).toBe(false, `${favoriteFile1} was not removed from list`);
expect(await dataTable.getRowByName(favoriteFile2).isPresent()).toBe(false, `${favoriteFile2} was not removed from list`);
expect(message).toContain(`Undo`);
expect(await dataTable.isItemPresent(favFile2)).toBe(false, `${favFile2} was not removed from list`);
expect(await dataTable.isItemPresent(favFile3)).toBe(false, `${favFile3} was not removed from list`);
items = items - 2;
expect(await page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
await page.clickTrash();
expect(await dataTable.getRowByName(favoriteFile1).isPresent()).toBe(true, `${favoriteFile1} is not in trash`);
expect(await dataTable.getRowByName(favoriteFile2).isPresent()).toBe(true, `${favoriteFile2} is not in trash`);
await apis.user.trashcan.restore(favoriteFile1Id);
await apis.user.trashcan.restore(favoriteFile2Id);
expect(await dataTable.isItemPresent(favFile2)).toBe(true, `${favFile2} is not in trash`);
expect(await dataTable.isItemPresent(favFile3)).toBe(true, `${favFile3} is not in trash`);
});
it('delete a folder with content - [C280518]', async () => {
let items = await page.dataTable.countRows();
await dataTable.selectItem(favoriteFolder1);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
expect(await dataTable.getRowByName(favoriteFolder1).isPresent()).toBe(false, 'Item was not removed from list');
await dataTable.selectItem(favFolder1);
await toolbar.clickMoreActionsDelete();
expect(await dataTable.isItemPresent(favFolder1)).toBe(false, 'Item was not removed from list');
items--;
expect(await page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
await page.clickTrash();
expect(await dataTable.getRowByName(favoriteFolder1).isPresent()).toBe(true, 'Item is not in trash');
expect(await dataTable.getRowByName(favoriteFile3).isPresent()).toBe(false, 'Item is in trash');
await apis.user.trashcan.restore(favoriteFolder1Id);
expect(await dataTable.isItemPresent(favFolder1)).toBe(true, 'Item is not in trash');
expect(await dataTable.isItemPresent(file1InFolder)).toBe(false, 'Item is in trash');
});
it('delete a folder containing locked files - [C280519]', async () => {
await dataTable.selectItem(favoriteFolder2);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
await dataTable.selectItem(favFolder2);
await toolbar.clickMoreActionsDelete();
const message = await page.getSnackBarMessage();
expect(message).toContain(`${favoriteFolder2} couldn't be deleted`);
expect(await dataTable.getRowByName(favoriteFolder2).isPresent()).toBe(true, 'Item was removed from list');
expect(message).toContain(`${favFolder2} couldn't be deleted`);
expect(await dataTable.isItemPresent(favFolder2)).toBe(true, 'Item was removed from list');
await page.clickTrash();
expect(await dataTable.getRowByName(favoriteFolder2).isPresent()).toBe(false, 'Item is in trash');
expect(await dataTable.getRowByName(favoriteFile4).isPresent()).toBe(false, 'Item is in trash');
expect(await dataTable.isItemPresent(favFolder2)).toBe(false, 'Item is in trash');
expect(await dataTable.isItemPresent(fileLocked1)).toBe(false, 'Item is in trash');
});
it('notification on multiple items deletion - some items fail to delete - [C280520]', async () => {
await dataTable.selectMultipleItems([favoriteFile1, favoriteFolder2]);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
await dataTable.selectMultipleItems([favFile4, favFolder3]);
await toolbar.clickMoreActionsDelete();
const message = await page.getSnackBarMessage();
expect(message).toContain(`Deleted 1 item, 1 couldn't be deleted`);
await apis.user.trashcan.restore(favoriteFile1Id);
expect(message).toContain(`Undo`);
});
it('notification on multiple items deletion - all items fail to delete - [C280521]', async () => {
await dataTable.selectMultipleItems([favoriteFolder3, favoriteFolder2]);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
await dataTable.selectMultipleItems([favFolder4, favFolder5]);
await toolbar.clickMoreActionsDelete();
const message = await page.getSnackBarMessage();
expect(message).toEqual(`2 items couldn't be deleted`);
});
it('successful delete notification shows Undo action - [C280522]', async () => {
await dataTable.selectItem(favoriteFile1);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
const message = await page.getSnackBarMessage();
expect(message).toContain(`Undo`);
await apis.user.trashcan.restore(favoriteFile1Id);
});
it('unsuccessful delete notification does not show Undo action - [C280523]', async () => {
await dataTable.selectItem(favoriteFolder2);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
const message = await page.getSnackBarMessage();
expect(message).not.toContain(`Undo`);
});
it('undo delete of file - [C280524]', async () => {
const items = await page.dataTable.countRows();
await dataTable.selectItem(favoriteFile1);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
await dataTable.selectItem(favFile5);
await toolbar.clickMoreActionsDelete();
await page.clickSnackBarAction();
expect(await dataTable.getRowByName(favoriteFile1).isPresent()).toBe(true, 'Item was not restored');
expect(await dataTable.isItemPresent(favFile5)).toBe(true, 'Item was not restored');
expect(await page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
});
it('undo delete of folder with content - [C280526]', async () => {
const items = await page.dataTable.countRows();
await dataTable.selectItem(favoriteFolder1);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
await dataTable.selectItem(favFolder6);
await toolbar.clickMoreActionsDelete();
await page.clickSnackBarAction();
expect(await dataTable.getRowByName(favoriteFolder1).isPresent()).toBe(true, 'Item was not restored');
expect(await dataTable.isItemPresent(favFolder6)).toBe(true, 'Item was not restored');
expect(await page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
await dataTable.doubleClickOnRowByName(favoriteFolder1);
expect(await dataTable.getRowByName(favoriteFile3).isPresent()).toBe(true, 'file from folder not restored');
await dataTable.doubleClickOnRowByName(favFolder6);
expect(await dataTable.isItemPresent(file2InFolder)).toBe(true, 'file from folder not restored');
});
it('undo delete of multiple files - [C280525]', async () => {
const items = await page.dataTable.countRows();
await dataTable.selectMultipleItems([favoriteFile1, favoriteFile2]);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
await dataTable.selectMultipleItems([favFile6, favFile7]);
await toolbar.clickMoreActionsDelete();
await page.clickSnackBarAction();
expect(await dataTable.getRowByName(favoriteFile1).isPresent()).toBe(true, `${favoriteFile1} was not removed from list`);
expect(await dataTable.getRowByName(favoriteFile2).isPresent()).toBe(true, `${favoriteFile2} was not removed from list`);
expect(await dataTable.isItemPresent(favFile6)).toBe(true, `${favFile6} was not removed from list`);
expect(await dataTable.isItemPresent(favFile7)).toBe(true, `${favFile7} was not removed from list`);
expect(await page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
});
});
// TODO: try to change search.waitForApi to wait for exact number of items
xdescribe('on Recent Files', () => {
const recentFile1 = `recentFile1-${Utils.random()}.txt`; let recentFile1Id;
const recentFile2 = `recentFile2-${Utils.random()}.txt`; let recentFile2Id;
const recentFile3 = `recentFile3-${Utils.random()}.txt`; let recentFile3Id;
const recentFile4 = `recentFile4-${Utils.random()}.txt`; let recentFile4Id;
describe('on Recent Files', () => {
const parent = `parentRF-${Utils.random()}`; let parentId;
const recentFile1 = `recentFile1-${Utils.random()}.txt`;
const recentFile2 = `recentFile2-${Utils.random()}.txt`;
const recentFile3 = `recentFile3-${Utils.random()}.txt`;
const recentFile4 = `recentFile4-${Utils.random()}.txt`;
const recentFile5 = `recentFile5-${Utils.random()}.txt`;
const recentFile6 = `recentFile6-${Utils.random()}.txt`;
beforeAll(async (done) => {
recentFile1Id = (await apis.user.nodes.createFile(recentFile1)).entry.id;
recentFile2Id = (await apis.user.nodes.createFile(recentFile2)).entry.id;
recentFile3Id = (await apis.user.nodes.createFile(recentFile3)).entry.id;
recentFile4Id = (await apis.user.nodes.createFile(recentFile4)).entry.id;
await apis.user.search.waitForApi(username, { expect: 4 });
parentId = (await apis.user.nodes.createFolder(parent)).entry.id;
await apis.user.nodes.createFile(recentFile1, parentId);
await apis.user.nodes.createFile(recentFile2, parentId);
await apis.user.nodes.createFile(recentFile3, parentId);
await apis.user.nodes.createFile(recentFile4, parentId);
await apis.user.nodes.createFile(recentFile5, parentId);
await apis.user.nodes.createFile(recentFile6, parentId);
await apis.user.search.waitForApi(username, { expect: 6 });
await loginPage.loginWith(username);
await page.clickRecentFiles();
const empty = await dataTable.isEmptyList();
if (empty) {
await browser.sleep(6000);
await browser.refresh();
await page.waitForApp();
}
done();
});
@@ -563,83 +531,59 @@ describe('Delete and undo delete', () => {
done();
});
afterEach(async (done) => {
await page.refresh();
done();
});
afterAll(async (done) => {
await apis.user.nodes.deleteNodesById([recentFile1Id, recentFile2Id, recentFile3Id, recentFile4Id]);
await apis.user.nodes.deleteNodeById(parentId);
await apis.user.trashcan.emptyTrash();
done();
});
xit('delete a file and check notification - [C280528]', async () => {
it('delete a file and check notification - [C280528]', async () => {
await dataTable.selectItem(recentFile1);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
await toolbar.clickMoreActionsDelete();
const message = await page.getSnackBarMessage();
expect(message).toContain(`${recentFile1} deleted`);
expect(await dataTable.getRowByName(recentFile1).isPresent()).toBe(false, 'Item was not removed from list');
expect(message).toContain(`Undo`);
expect(await dataTable.isItemPresent(recentFile1)).toBe(false, 'Item was not removed from list');
await page.clickTrash();
expect(await dataTable.getRowByName(recentFile1).isPresent()).toBe(true, 'Item is not in trash');
await apis.user.trashcan.restore(recentFile1Id);
await apis.user.search.waitForApi(username, { expect: 4 });
expect(await dataTable.isItemPresent(recentFile1)).toBe(true, 'Item is not in trash');
});
xit('delete multiple files and check notification - [C280529]', async () => {
it('delete multiple files and check notification - [C280529]', async () => {
await dataTable.selectMultipleItems([recentFile2, recentFile3]);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
await toolbar.clickMoreActionsDelete();
const message = await page.getSnackBarMessage();
expect(message).toContain(`Deleted 2 items`);
expect(await dataTable.getRowByName(recentFile2).isPresent()).toBe(false, `${recentFile2} was not removed from list`);
expect(await dataTable.getRowByName(recentFile3).isPresent()).toBe(false, `${recentFile3} was not removed from list`);
await page.clickTrash();
expect(await dataTable.getRowByName(recentFile2).isPresent()).toBe(true, `${recentFile2} is not in trash`);
expect(await dataTable.getRowByName(recentFile3).isPresent()).toBe(true, `${recentFile3} is not in trash`);
await apis.user.trashcan.restore(recentFile2Id);
await apis.user.trashcan.restore(recentFile3Id);
await apis.user.search.waitForApi(username, { expect: 4 });
});
xit('successful delete notification shows Undo action - [C280534]', async () => {
await dataTable.selectItem(recentFile1);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
const message = await page.getSnackBarMessage();
expect(message).toContain(`Undo`);
await apis.user.trashcan.restore(recentFile1Id);
await apis.user.search.waitForApi(username, { expect: 4 });
expect(await dataTable.isItemPresent(recentFile2)).toBe(false, `${recentFile2} was not removed from list`);
expect(await dataTable.isItemPresent(recentFile3)).toBe(false, `${recentFile3} was not removed from list`);
await page.clickTrash();
expect(await dataTable.isItemPresent(recentFile2)).toBe(true, `${recentFile2} is not in trash`);
expect(await dataTable.isItemPresent(recentFile3)).toBe(true, `${recentFile3} is not in trash`);
});
// due to the fact that the search api is slow to update,
// we cannot test that the restored file is displayed in the Recent Files list
// without adding a very big browser.sleep followed by a page.refresh
// so for the moment we're testing that the restored file is not displayed in the Trash
xit('undo delete of file - [C280536]', async () => {
await dataTable.selectItem(recentFile2);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
it('undo delete of file - [C280536]', async () => {
await dataTable.selectItem(recentFile4);
await toolbar.clickMoreActionsDelete();
await page.clickSnackBarAction();
await page.clickTrash();
expect(await dataTable.getRowByName(recentFile2).isPresent()).toBe(false, 'Item is in Trash');
expect(await dataTable.isItemPresent(recentFile4)).toBe(false, 'Item is in Trash');
});
// due to the fact that the search api is slow to update,
// we cannot test that the restored file is displayed in the Recent Files list
// without adding a very big browser.sleep followed by a page.refresh
// so for the moment we're testing that the restored file is not displayed in the Trash
xit('undo delete of multiple files - [C280537]', async () => {
await dataTable.selectMultipleItems([recentFile3, recentFile4]);
await toolbar.openMoreMenu();
await toolbar.menu.clickMenuItem('Delete');
it('undo delete of multiple files - [C280537]', async () => {
await dataTable.selectMultipleItems([recentFile5, recentFile6]);
await toolbar.clickMoreActionsDelete();
await page.clickSnackBarAction();
await page.clickTrash();
expect(await dataTable.getRowByName(recentFile3).isPresent()).toBe(false, `${recentFile3} is in Trash`);
expect(await dataTable.getRowByName(recentFile4).isPresent()).toBe(false, `${recentFile4} is in Trash`);
expect(await dataTable.isItemPresent(recentFile5)).toBe(false, `${recentFile5} is in Trash`);
expect(await dataTable.isItemPresent(recentFile6)).toBe(false, `${recentFile6} is in Trash`);
});
});
});