initial e2e integration (#329)

* e2e integration with ci

* update travis config

* try always build image

* build the app in production mode

* try to stop previous

* stop default postgresql service

* try upgrade selenium-webdriver

* disable Gecko for webdriver-manager

* use stable chrome and latest protractor
This commit is contained in:
Denys Vuika
2018-04-23 12:21:41 +01:00
committed by Cilibiu Bogdan
parent 54a7f3679c
commit 09aeeff204
72 changed files with 10493 additions and 161 deletions

View File

@@ -0,0 +1,278 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from 'protractor';
import { SIDEBAR_LABELS, SITE_VISIBILITY, SITE_ROLES } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { CreateOrEditFolderDialog } from '../../components/dialog/create-edit-folder-dialog';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Create folder', () => {
const username = `user-${Utils.random()}`;
const parent = `parent-${Utils.random()}`;
const folderName1 = `folder-${Utils.random()}`;
const folderName2 = `folder-${Utils.random()}`;
const folderDescription = 'description of my folder';
const duplicateFolderName = `folder-${Utils.random()}`;
const nameWithSpaces = ` folder-${Utils.random()} `;
const siteName = `site-private-${Utils.random()}`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const personalFilesPage = new BrowsingPage();
const createDialog = new CreateOrEditFolderDialog();
const { dataTable } = personalFilesPage;
beforeAll(done => {
apis.admin.people.createUser(username)
.then(() => apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PRIVATE))
.then(() => apis.admin.nodes.createFolders([ folderName1 ], `Sites/${siteName}/documentLibrary`))
.then(() => apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_CONSUMER))
.then(() => apis.user.nodes.createFolders([ duplicateFolderName ], parent))
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
personalFilesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterEach(done => {
browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform().then(done);
});
afterAll(done => {
Promise
.all([
apis.admin.sites.deleteSite(siteName),
apis.user.nodes.deleteNodes([ parent ]),
logoutPage.load()
])
.then(done);
});
it('option is enabled when having enough permissions', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => personalFilesPage.sidenav.openNewMenu())
.then(menu => {
const isEnabled = menu.getItemByLabel('Create folder').isEnabled();
expect(isEnabled).toBe(true, 'Create folder is not enabled');
});
});
it('creates new folder with name', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => personalFilesPage.sidenav.openCreateDialog())
.then(() => createDialog.waitForDialogToOpen())
.then(() => createDialog.enterName(folderName1))
.then(() => createDialog.clickCreate())
.then(() => createDialog.waitForDialogToClose())
.then(() => dataTable.waitForHeader())
.then(() => {
const isPresent = dataTable.getRowName(folderName1).isPresent();
expect(isPresent).toBe(true, 'Folder not displayed in list view');
});
});
it('creates new folder with name and description', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => personalFilesPage.sidenav.openCreateDialog())
.then(() => createDialog.waitForDialogToOpen())
.then(() => createDialog.enterName(folderName2))
.then(() => createDialog.enterDescription(folderDescription))
.then(() => createDialog.clickCreate())
.then(() => createDialog.waitForDialogToClose())
.then(() => dataTable.waitForHeader())
.then(() => expect(dataTable.getRowName(folderName2).isPresent()).toBe(true, 'Folder not displayed'))
.then(() => apis.user.nodes.getNodeDescription(folderName2, parent))
.then(desc => expect(desc).toEqual(folderDescription));
});
it('enabled option tooltip', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => personalFilesPage.sidenav.openNewMenu())
.then(menu => browser.actions().mouseMove(menu.getItemByLabel('Create folder')).perform()
.then(() => menu))
.then(menu => {
expect(menu.getItemTooltip('Create folder')).toContain('Create new folder');
});
});
it('option is disabled when not enough permissions', () => {
const fileLibrariesPage = new BrowsingPage();
fileLibrariesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES)
.then(() => fileLibrariesPage.dataTable.doubleClickOnItemName(siteName))
.then(() => fileLibrariesPage.dataTable.doubleClickOnItemName(folderName1))
.then(() => fileLibrariesPage.sidenav.openNewMenu())
.then(menu => {
const isEnabled = menu.getItemByLabel('Create folder').isEnabled();
expect(isEnabled).toBe(false, 'Create folder is not disabled');
});
});
it('disabled option tooltip', () => {
const fileLibrariesPage = new BrowsingPage();
fileLibrariesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES)
.then(() => fileLibrariesPage.dataTable.doubleClickOnItemName(siteName))
.then(() => fileLibrariesPage.dataTable.doubleClickOnItemName(folderName1))
.then(() => fileLibrariesPage.sidenav.openNewMenu())
.then(menu => browser.actions().mouseMove(menu.getItemByLabel('Create folder')).perform()
.then(() => menu))
.then(menu => {
const tooltip = menu.getItemTooltip('Create folder');
expect(tooltip).toContain(`You can't create a folder here`);
});
});
it('dialog UI elements', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => personalFilesPage.sidenav.openCreateDialog())
.then(() => createDialog.waitForDialogToOpen())
.then(() => {
const dialogTitle = createDialog.getTitle();
const isFolderNameDisplayed = createDialog.nameInput.isDisplayed();
const isDescriptionDisplayed = createDialog.descriptionTextArea.isDisplayed();
const isCreateEnabled = createDialog.createButton.isEnabled();
const isCancelEnabled = createDialog.cancelButton.isEnabled();
expect(dialogTitle).toMatch('Create new folder');
expect(isFolderNameDisplayed).toBe(true, 'Name input is not displayed');
expect(isDescriptionDisplayed).toBe(true, 'Description field is not displayed');
expect(isCreateEnabled).toBe(false, 'Create button is not disabled');
expect(isCancelEnabled).toBe(true, 'Cancel button is not enabled');
});
});
it('with empty folder name', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => personalFilesPage.sidenav.openCreateDialog())
.then(() => createDialog.waitForDialogToOpen())
.then(() => createDialog.deleteNameWithBackspace())
.then(() => {
const isCreateEnabled = createDialog.createButton.isEnabled();
const validationMessage = createDialog.getValidationMessage();
expect(isCreateEnabled).toBe(false, 'Create button is enabled');
expect(validationMessage).toMatch('Folder name is required');
});
});
it('with folder name ending with a dot "."', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => personalFilesPage.sidenav.openCreateDialog())
.then(() => createDialog.waitForDialogToOpen())
.then(() => createDialog.enterName('folder-name.'))
.then(() => {
const isCreateEnabled = createDialog.createButton.isEnabled();
const validationMessage = createDialog.getValidationMessage();
expect(isCreateEnabled).toBe(false, 'Create button is not disabled');
expect(validationMessage).toMatch(`Folder name can't end with a period .`);
});
});
it('with folder name containing special characters', () => {
const namesWithSpecialChars = [ 'a*a', 'a"a', 'a<a', 'a>a', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a' ];
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => personalFilesPage.sidenav.openCreateDialog())
.then(() => createDialog.waitForDialogToOpen())
.then(() => namesWithSpecialChars.forEach(name => {
createDialog.enterName(name);
const isCreateEnabled = createDialog.createButton.isEnabled();
const validationMessage = createDialog.getValidationMessage();
expect(isCreateEnabled).toBe(false, 'Create button is not disabled');
expect(validationMessage).toContain(`Folder name can't contain these characters`);
}));
});
it('with folder name containing only spaces', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => personalFilesPage.sidenav.openCreateDialog())
.then(() => createDialog.waitForDialogToOpen())
.then(() => createDialog.enterName(' '))
.then(() => {
const isCreateEnabled = createDialog.createButton.isEnabled();
const validationMessage = createDialog.getValidationMessage();
expect(isCreateEnabled).toBe(false, 'Create button is not disabled');
expect(validationMessage).toMatch(`Folder name can't contain only spaces`);
});
});
it('cancel folder creation', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => personalFilesPage.sidenav.openCreateDialog())
.then(() => createDialog.waitForDialogToOpen())
.then(() => createDialog.enterName('test'))
.then(() => createDialog.enterDescription('test description'))
.then(() => createDialog.clickCancel())
.then(() => {
expect(createDialog.component.isPresent()).not.toBe(true, 'dialog is not closed');
});
});
it('duplicate folder name', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => personalFilesPage.sidenav.openCreateDialog())
.then(() => createDialog.waitForDialogToOpen())
.then(() => createDialog.enterName(duplicateFolderName))
.then(() => createDialog.clickCreate())
.then(() => personalFilesPage.getSnackBarMessage())
.then(message => {
expect(message).toEqual(`There's already a folder with this name. Try a different name.`);
expect(createDialog.component.isPresent()).toBe(true, 'dialog is not present');
});
});
it('trim ending spaces from folder name', () => {
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => personalFilesPage.sidenav.openCreateDialog())
.then(() => createDialog.waitForDialogToOpen())
.then(() => createDialog.enterName(nameWithSpaces))
.then(() => createDialog.clickCreate())
.then(() => createDialog.waitForDialogToClose())
.then(() => dataTable.waitForHeader())
.then(() => {
const isPresent = dataTable.getRowName(nameWithSpaces.trim()).isPresent();
expect(isPresent).toBe(true, 'Folder not displayed in list view');
});
});
});

503
e2e/suites/actions/delete.test.ts Executable file
View File

@@ -0,0 +1,503 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from 'protractor';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { SIDEBAR_LABELS } from '../../configs';
import { RepoClient } from '../../utilities/repo-client/repo-client';
import { Utils } from '../../utilities/utils';
describe('Delete content', () => {
const username = `user-${Utils.random()}`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, toolbar } = page;
beforeAll(done => {
apis.admin.people.createUser(username).then(done);
});
afterAll(done => {
apis.admin.trashcan.emptyTrash().then(done);
});
xit('');
describe('on Personal Files', () => {
const file1 = `file1-${Utils.random()}.txt`; let file1Id;
const file2 = `file2-${Utils.random()}.txt`; let file2Id;
const file3 = `file3-${Utils.random()}.txt`;
const file4 = `file4-${Utils.random()}.txt`; let file4Id;
const folder1 = `folder1-${Utils.random()}`; let folder1Id;
const folder2 = `folder2-${Utils.random()}`; let folder2Id;
const fileLocked1 = `fileLocked-${Utils.random()}.txt`; let fileLocked1Id;
beforeAll(done => {
apis.user.nodes.createFile(file1).then(resp => file1Id = resp.data.entry.id)
.then(() => apis.user.nodes.createFile(file2).then(resp => file2Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFolder(folder1).then(resp => folder1Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFolder(folder2).then(resp => folder2Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFile(file3, folder1Id))
.then(() => apis.user.nodes.createFile(file4, folder2Id).then(resp => file4Id = resp.data.entry.id))
.then(() => apis.user.nodes.lockFile(file4Id))
.then(() => apis.user.nodes.createFile(fileLocked1).then(resp => fileLocked1Id = resp.data.entry.id))
.then(() => apis.user.nodes.lockFile(fileLocked1Id))
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterEach(done => {
page.refresh().then(done);
});
afterAll(done => {
Promise.all([
logoutPage.load(),
apis.user.nodes.unlockFile(file4Id)
.then(() => apis.user.nodes.unlockFile(fileLocked1Id))
.then(() => apis.user.nodes.deleteNodesById([file1Id, file2Id, folder1Id, folder2Id, fileLocked1Id]))
])
.then(done);
});
it('delete a file and check notification', () => {
let items: number;
page.dataTable.countRows().then(number => { items = number; });
dataTable.clickOnItemName(file1)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.getSnackBarMessage())
.then(message => {
expect(message).toContain(`${file1} deleted`);
expect(dataTable.getRowName(file1).isPresent()).toBe(false, 'Item was not removed from list');
items--;
expect(page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
})
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH))
.then(() => expect(dataTable.getRowName(file1).isPresent()).toBe(true, 'Item is not in trash'))
.then(() => apis.user.trashcan.restore(file1Id));
});
it('delete multiple files and check notification', () => {
let items: number;
page.dataTable.countRows().then(number => { items = number; });
dataTable.selectMultipleItems([file1, file2])
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.getSnackBarMessage())
.then(message => {
expect(message).toContain(`Deleted 2 items`);
expect(dataTable.getRowName(file1).isPresent()).toBe(false, `${file1} was not removed from list`);
expect(dataTable.getRowName(file2).isPresent()).toBe(false, `${file2} was not removed from list`);
items = items - 2;
expect(page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
})
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH))
.then(() => {
expect(dataTable.getRowName(file1).isPresent()).toBe(true, `${file1} is not in trash`);
expect(dataTable.getRowName(file2).isPresent()).toBe(true, `${file2} is not in trash`);
})
.then(() => apis.user.trashcan.restore(file1Id))
.then(() => apis.user.trashcan.restore(file2Id));
});
it('delete a folder with content', () => {
let items: number;
page.dataTable.countRows().then(number => { items = number; });
dataTable.clickOnItemName(folder1)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => {
expect(dataTable.getRowName(folder1).isPresent()).toBe(false, 'Item was not removed from list');
items--;
expect(page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
})
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH))
.then(() => {
expect(dataTable.getRowName(folder1).isPresent()).toBe(true, 'Item is not in trash');
expect(dataTable.getRowName(file3).isPresent()).toBe(false, 'Item is in trash');
})
.then(() => apis.user.trashcan.restore(folder1Id));
});
it('delete a folder containing locked files', () => {
dataTable.clickOnItemName(folder2)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.getSnackBarMessage())
.then(message => {
expect(message).toContain(`${folder2} couldn't be deleted`);
expect(dataTable.getRowName(folder2).isPresent()).toBe(true, 'Item was removed from list');
})
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH))
.then(() => {
expect(dataTable.getRowName(folder2).isPresent()).toBe(false, 'Item is in trash');
expect(dataTable.getRowName(file4).isPresent()).toBe(false, 'Item is in trash');
});
});
it('notification on multiple items deletion - some items fail to delete', () => {
dataTable.selectMultipleItems([file1, folder2])
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.getSnackBarMessage())
.then(message => expect(message).toContain(`Deleted 1 item, 1 couldn't be deleted`))
.then(() => apis.user.trashcan.restore(file1Id));
});
it('Notification on multiple items deletion - all items fail to delete', () => {
dataTable.selectMultipleItems([fileLocked1, folder2])
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.getSnackBarMessage())
.then(message => expect(message).toEqual(`2 items couldn't be deleted`));
});
});
describe('on Shared Files', () => {
const sharedFile1 = `sharedFile1-${Utils.random()}.txt`; let sharedFile1Id;
const sharedFile2 = `sharedFile2-${Utils.random()}.txt`; let sharedFile2Id;
const sharedFile3 = `sharedFile3-${Utils.random()}.txt`; let sharedFile3Id;
beforeAll(done => {
apis.user.nodes.createFile(sharedFile1).then(resp => sharedFile1Id = resp.data.entry.id)
.then(() => apis.user.nodes.createFile(sharedFile2).then(resp => sharedFile2Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFile(sharedFile3).then(resp => sharedFile3Id = resp.data.entry.id))
.then(() => apis.user.shared.shareFilesByIds([sharedFile1Id, sharedFile2Id, sharedFile3Id]))
.then(() => apis.user.shared.waitForApi({ expect: 3 }))
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterEach(done => {
page.refresh().then(done);
});
afterAll(done => {
Promise.all([
logoutPage.load(),
apis.user.nodes.deleteNodesById([sharedFile1Id, sharedFile2Id, sharedFile3Id])
])
.then(done);
});
it('delete a file and check notification', () => {
dataTable.clickOnItemName(sharedFile1)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.getSnackBarMessage())
.then(message => {
expect(message).toContain(`${sharedFile1} deleted`);
expect(dataTable.getRowName(sharedFile1).isPresent()).toBe(false, 'Item was not removed from list');
})
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH))
.then(() => expect(dataTable.getRowName(sharedFile1).isPresent()).toBe(true, 'Item is not in trash'))
.then(() => apis.user.trashcan.restore(sharedFile1Id));
});
it('delete multiple files and check notification', () => {
dataTable.selectMultipleItems([sharedFile2, sharedFile3])
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.getSnackBarMessage())
.then(message => {
expect(message).toContain(`Deleted 2 items`);
expect(dataTable.getRowName(sharedFile2).isPresent()).toBe(false, `${sharedFile2} was not removed from list`);
expect(dataTable.getRowName(sharedFile3).isPresent()).toBe(false, `${sharedFile3} was not removed from list`);
})
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH))
.then(() => {
expect(dataTable.getRowName(sharedFile2).isPresent()).toBe(true, `${sharedFile2} is not in trash`);
expect(dataTable.getRowName(sharedFile3).isPresent()).toBe(true, `${sharedFile3} is not in trash`);
})
.then(() => apis.user.trashcan.restore(sharedFile2Id))
.then(() => apis.user.trashcan.restore(sharedFile3Id));
});
});
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 favoriteFileLocked1 = `favFileLocked-${Utils.random()}.txt`; let favoriteFileLocked1Id;
beforeAll(done => {
apis.user.nodes.createFile(favoriteFile1).then(resp => favoriteFile1Id = resp.data.entry.id)
.then(() => apis.user.nodes.createFile(favoriteFile2).then(resp => favoriteFile2Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFolder(favoriteFolder1).then(resp => favoriteFolder1Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFolder(favoriteFolder2).then(resp => favoriteFolder2Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFile(favoriteFile3, favoriteFolder1Id))
.then(() => apis.user.nodes.createFile(favoriteFile4, favoriteFolder2Id).then(resp => favoriteFile4Id = resp.data.entry.id))
.then(() => apis.user.nodes.lockFile(favoriteFile4Id))
.then(() => apis.user.nodes.createFile(favoriteFileLocked1).then(resp => favoriteFileLocked1Id = resp.data.entry.id))
.then(() => apis.user.nodes.lockFile(favoriteFileLocked1Id))
.then(() => apis.user.favorites.addFavoritesByIds('file', [favoriteFile1Id, favoriteFile2Id, favoriteFileLocked1Id]))
.then(() => apis.user.favorites.addFavoritesByIds('folder', [favoriteFolder1Id, favoriteFolder2Id]))
.then(() => apis.user.favorites.waitForApi({ expect: 5 }))
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterEach(done => {
page.refresh().then(done);
});
afterAll(done => {
Promise.all([
logoutPage.load(),
apis.user.nodes.unlockFile(favoriteFile4Id)
.then(() => apis.user.nodes.unlockFile(favoriteFileLocked1Id))
.then(() => apis.user.nodes.deleteNodesById([
favoriteFile1Id, favoriteFile2Id, favoriteFolder1Id, favoriteFolder2Id, favoriteFileLocked1Id
]))
])
.then(done);
});
it('delete a file and check notification', () => {
let items: number;
page.dataTable.countRows().then(number => { items = number; });
dataTable.clickOnItemName(favoriteFile1)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.getSnackBarMessage())
.then(message => {
expect(message).toContain(`${favoriteFile1} deleted`);
expect(dataTable.getRowName(favoriteFile1).isPresent()).toBe(false, 'Item was not removed from list');
items--;
expect(page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
})
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH))
.then(() => expect(dataTable.getRowName(favoriteFile1).isPresent()).toBe(true, 'Item is not in trash'))
.then(() => apis.user.trashcan.restore(favoriteFile1Id));
});
it('delete multiple files and check notification', () => {
let items: number;
page.dataTable.countRows().then(number => { items = number; });
dataTable.selectMultipleItems([favoriteFile1, favoriteFile2])
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.getSnackBarMessage())
.then(message => {
expect(message).toContain(`Deleted 2 items`);
expect(dataTable.getRowName(favoriteFile1).isPresent()).toBe(false, `${favoriteFile1} was not removed from list`);
expect(dataTable.getRowName(favoriteFile2).isPresent()).toBe(false, `${favoriteFile2} was not removed from list`);
items = items - 2;
expect(page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
})
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH))
.then(() => {
expect(dataTable.getRowName(favoriteFile1).isPresent()).toBe(true, `${favoriteFile1} is not in trash`);
expect(dataTable.getRowName(favoriteFile2).isPresent()).toBe(true, `${favoriteFile2} is not in trash`);
})
.then(() => apis.user.trashcan.restore(favoriteFile1Id))
.then(() => apis.user.trashcan.restore(favoriteFile2Id));
});
it('delete a folder with content', () => {
let items: number;
page.dataTable.countRows().then(number => { items = number; });
dataTable.clickOnItemName(favoriteFolder1)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => {
expect(dataTable.getRowName(favoriteFolder1).isPresent()).toBe(false, 'Item was not removed from list');
items--;
expect(page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
})
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH))
.then(() => {
expect(dataTable.getRowName(favoriteFolder1).isPresent()).toBe(true, 'Item is not in trash');
expect(dataTable.getRowName(favoriteFile3).isPresent()).toBe(false, 'Item is in trash');
})
.then(() => apis.user.trashcan.restore(favoriteFolder1Id));
});
it('delete a folder containing locked files', () => {
dataTable.clickOnItemName(favoriteFolder2)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.getSnackBarMessage())
.then(message => {
expect(message).toContain(`${favoriteFolder2} couldn't be deleted`);
expect(dataTable.getRowName(favoriteFolder2).isPresent()).toBe(true, 'Item was removed from list');
})
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH))
.then(() => {
expect(dataTable.getRowName(favoriteFolder2).isPresent()).toBe(false, 'Item is in trash');
expect(dataTable.getRowName(favoriteFile4).isPresent()).toBe(false, 'Item is in trash');
});
});
it('notification on multiple items deletion - some items fail to delete', () => {
dataTable.selectMultipleItems([favoriteFile1, favoriteFolder2])
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.getSnackBarMessage())
.then(message => {
expect(message).toContain(`Deleted 1 item, 1 couldn't be deleted`);
})
.then(() => apis.user.trashcan.restore(favoriteFile1Id));
});
it('Notification on multiple items deletion - all items fail to delete', () => {
dataTable.selectMultipleItems([favoriteFileLocked1, favoriteFolder2])
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.getSnackBarMessage())
.then(message => {
expect(message).toEqual(`2 items couldn't be deleted`);
});
});
});
describe('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;
beforeAll(done => {
apis.user.nodes.createFile(recentFile1).then(resp => recentFile1Id = resp.data.entry.id)
.then(() => apis.user.nodes.createFile(recentFile2).then(resp => recentFile2Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFile(recentFile3).then(resp => recentFile3Id = resp.data.entry.id))
.then(() => apis.user.search.waitForApi(username, { expect: 3 }))
.then(() => loginPage.loginWith(username))
.then((): any => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES)
.then(() => dataTable.isEmptyList())
.then(empty => {
if (empty) {
browser.sleep(6000).then(() => page.refresh());
}
})
)
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterEach(done => {
page.refresh().then(done);
});
afterAll(done => {
Promise.all([
logoutPage.load(),
apis.user.nodes.deleteNodesById([recentFile1Id, recentFile2Id, recentFile3Id])
])
.then(done);
});
it('delete a file and check notification', () => {
dataTable.clickOnItemName(recentFile1)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.getSnackBarMessage())
.then(message => {
expect(message).toContain(`${recentFile1} deleted`);
expect(dataTable.getRowName(recentFile1).isPresent()).toBe(false, 'Item was not removed from list');
})
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH))
.then(() => expect(dataTable.getRowName(recentFile1).isPresent()).toBe(true, 'Item is not in trash'))
.then(() => apis.user.trashcan.restore(recentFile1Id));
});
it('delete multiple files and check notification', () => {
dataTable.selectMultipleItems([recentFile2, recentFile3])
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.getSnackBarMessage())
.then(message => {
expect(message).toContain(`Deleted 2 items`);
expect(dataTable.getRowName(recentFile2).isPresent()).toBe(false, `${recentFile2} was not removed from list`);
expect(dataTable.getRowName(recentFile3).isPresent()).toBe(false, `${recentFile3} was not removed from list`);
})
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH))
.then(() => {
expect(dataTable.getRowName(recentFile2).isPresent()).toBe(true, `${recentFile2} is not in trash`);
expect(dataTable.getRowName(recentFile3).isPresent()).toBe(true, `${recentFile3} is not in trash`);
})
.then(() => apis.user.trashcan.restore(recentFile2Id))
.then(() => apis.user.trashcan.restore(recentFile3Id));
});
});
});

View File

@@ -0,0 +1,187 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { protractor, browser } from 'protractor';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { SIDEBAR_LABELS, SITE_VISIBILITY, SITE_ROLES } from '../../configs';
import { RepoClient } from '../../utilities/repo-client/repo-client';
import { CreateOrEditFolderDialog } from '../../components/dialog/create-edit-folder-dialog';
import { Utils } from '../../utilities/utils';
describe('Edit folder', () => {
const username = `user-${Utils.random()}`;
const parent = `parent-${Utils.random()}`;
const folderName = `folder-${Utils.random()}`;
const folderDescription = 'my folder description';
const folderNameToEdit = `folder-${Utils.random()}`;
const duplicateFolderName = `folder-${Utils.random()}`;
const folderNameEdited = `folder-${Utils.random()}`;
const folderDescriptionEdited = 'description edited';
const siteName = `site-private-${Utils.random()}`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const personalFilesPage = new BrowsingPage();
const editDialog = new CreateOrEditFolderDialog();
const { dataTable } = personalFilesPage;
const editButton = personalFilesPage.toolbar.actions.getButtonByTitleAttribute('Edit');
beforeAll(done => {
apis.admin.people.createUser(username)
.then(() => apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PRIVATE))
.then(() => apis.admin.nodes.createFolders([ folderName ], `Sites/${siteName}/documentLibrary`))
.then(() => apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_CONSUMER))
.then(() => apis.user.nodes.createFolder( parent ))
.then(resp => apis.user.nodes.createFolder( folderName, resp.data.entry.id, '', folderDescription ))
.then(() => apis.user.nodes.createFolders([ folderNameToEdit, duplicateFolderName ], parent))
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
personalFilesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => dataTable.waitForHeader())
.then(() => dataTable.doubleClickOnItemName(parent))
.then(() => dataTable.waitForHeader())
.then(done);
});
afterEach(done => {
browser.actions().sendKeys(protractor.Key.ESCAPE).perform().then(done);
});
afterAll(done => {
Promise
.all([
apis.admin.sites.deleteSite(siteName),
apis.user.nodes.deleteNodes([ parent ]),
logoutPage.load()
])
.then(done);
});
it('dialog UI defaults', () => {
dataTable.clickOnItemName(folderName)
.then(() => editButton.click())
.then(() => {
expect(editDialog.getTitle()).toEqual('Edit folder');
expect(editDialog.nameInput.getAttribute('value')).toBe(folderName);
expect(editDialog.descriptionTextArea.getAttribute('value')).toBe(folderDescription);
expect(editDialog.updateButton.isEnabled()).toBe(true, 'upload button is not enabled');
expect(editDialog.cancelButton.isEnabled()).toBe(true, 'cancel button is not enabled');
});
});
it('properties are modified when pressing OK', () => {
dataTable.clickOnItemName(folderNameToEdit)
.then(() => editButton.click())
.then(() => editDialog.waitForDialogToOpen())
.then(() => editDialog.enterDescription(folderDescriptionEdited))
.then(() => editDialog.enterName(folderNameEdited))
.then(() => editDialog.clickUpdate())
.then(() => editDialog.waitForDialogToClose())
.then(() => dataTable.waitForHeader())
.then(() => expect(dataTable.getRowName(folderNameEdited).isPresent()).toBe(true, 'Folder not displayed'))
.then(() => apis.user.nodes.getNodeDescription(folderNameEdited, parent))
.then(desc => expect(desc).toEqual(folderDescriptionEdited));
});
it('with empty folder name', () => {
dataTable.clickOnItemName(folderName)
.then(() => editButton.click())
.then(() => editDialog.deleteNameWithBackspace())
.then(() => {
expect(editDialog.updateButton.isEnabled()).toBe(false, 'upload button is not enabled');
expect(editDialog.getValidationMessage()).toMatch('Folder name is required');
});
});
it('with name with special characters', () => {
const namesWithSpecialChars = [ 'a*a', 'a"a', 'a<a', 'a>a', `a\\a`, 'a/a', 'a?a', 'a:a', 'a|a' ];
dataTable.clickOnItemName(folderName)
.then(() => editButton.click())
.then(() => namesWithSpecialChars.forEach(name => {
editDialog.enterName(name);
expect(editDialog.updateButton.isEnabled()).toBe(false, 'upload button is not disabled');
expect(editDialog.getValidationMessage()).toContain(`Folder name can't contain these characters`);
}));
});
it('with name ending with a dot', () => {
dataTable.clickOnItemName(folderName)
.then(() => editButton.click())
.then(() => editDialog.nameInput.sendKeys('.'))
.then(() => {
expect(editDialog.updateButton.isEnabled()).toBe(false, 'upload button is not enabled');
expect(editDialog.getValidationMessage()).toMatch(`Folder name can't end with a period .`);
});
});
it('Cancel button', () => {
dataTable.clickOnItemName(folderName)
.then(() => editButton.click())
.then(() => editDialog.clickCancel())
.then(() => {
expect(editDialog.component.isPresent()).not.toBe(true, 'dialog is not closed');
});
});
it('with duplicate folder name', () => {
dataTable.clickOnItemName(folderName)
.then(() => editButton.click())
.then(() => editDialog.enterName(duplicateFolderName))
.then(() => editDialog.clickUpdate())
.then(() => personalFilesPage.getSnackBarMessage())
.then(message => {
expect(message).toEqual(`There's already a folder with this name. Try a different name.`);
expect(editDialog.component.isPresent()).toBe(true, 'dialog is not present');
});
});
it('trim ending spaces', () => {
dataTable.clickOnItemName(folderName)
.then(() => editButton.click())
.then(() => editDialog.nameInput.sendKeys(' '))
.then(() => editDialog.clickUpdate())
.then(() => editDialog.waitForDialogToClose())
.then(() => {
expect(personalFilesPage.snackBar.isPresent()).not.toBe(true, 'notification appears');
expect(dataTable.getRowName(folderName).isPresent()).toBe(true, 'Folder not displayed in list view');
});
});
});

View File

@@ -0,0 +1,419 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { SIDEBAR_LABELS } from '../../configs';
import { RepoClient } from '../../utilities/repo-client/repo-client';
import { Utils } from '../../utilities/utils';
import { browser } from 'protractor';
describe('Mark items as favorites', () => {
const username = `user-${Utils.random()}`;
const file1NotFav = `file-${Utils.random()}.txt`;
const file2NotFav = `file-${Utils.random()}.txt`;
const file3Fav = `file-${Utils.random()}.txt`;
const file4Fav = `file-${Utils.random()}.txt`;
const folder1 = `folder-${Utils.random()}`;
let file1Id, file2Id, file3Id, file4Id, folder1Id;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, toolbar } = page;
beforeAll(done => {
apis.admin.people.createUser(username)
.then(() => apis.user.nodes.createFile( file1NotFav ).then(resp => file1Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFile( file2NotFav ).then(resp => file2Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFile( file3Fav ).then(resp => file3Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFile( file4Fav ).then(resp => file4Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFolder( folder1 ).then(resp => folder1Id = resp.data.entry.id))
.then(() => apis.user.favorites.addFavoriteById('file', file3Id))
.then(() => apis.user.favorites.addFavoriteById('file', file4Id))
.then(() => loginPage.loginWith(username))
.then(done);
});
afterAll(done => {
Promise.all([
apis.user.nodes.deleteNodesById([ file1Id, file2Id, file3Id, file4Id, folder1Id ]),
logoutPage.load()
])
.then(done);
});
xit('');
describe('on Personal Files', () => {
beforeAll(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterEach(done => {
// browser.actions().sendKeys(protractor.Key.ESCAPE).perform().then(done);
browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform().then(done);
});
it('Favorite action has empty star icon for unfavorited item', () => {
dataTable.clickOnItemName(file1NotFav)
.then(() => toolbar.actions.openMoreMenu())
.then(() => expect(toolbar.actions.menu.getItemIconText('Favorite')).toEqual('star_border'));
});
it('Favorite action has empty star icon for multiple selection of items when some are not favorite', () => {
dataTable.selectMultipleItems([ file1NotFav, file3Fav ])
.then(() => toolbar.actions.openMoreMenu())
.then(() => expect(toolbar.actions.menu.getItemIconText('Favorite')).toEqual('star_border'));
});
it('Favorite action has full star icon for favorited items', () => {
dataTable.clickOnItemName(file3Fav)
.then(() => toolbar.actions.openMoreMenu())
.then(() => expect(toolbar.actions.menu.getItemIconText('Favorite')).toEqual('star'));
});
it('favorite a file', () => {
dataTable.clickOnItemName(file1NotFav)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Favorite'))
.then(() => apis.user.favorites.waitForApi({ expect: 3 }))
.then(() => apis.user.favorites.isFavorite(file1Id))
.then(isFavorite => expect(isFavorite).toBe(true, `${file1NotFav} not marked as favorite`))
.then(() => apis.user.favorites.removeFavoriteById(file1Id));
});
it('favorite a folder', () => {
dataTable.clickOnItemName(folder1)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Favorite'))
.then(() => apis.user.favorites.waitForApi({ expect: 3 }))
.then(() => apis.user.favorites.isFavorite(folder1Id))
.then(isFavorite => expect(isFavorite).toBe(true, `${folder1} not marked as favorite`))
.then(() => apis.user.favorites.removeFavoriteById(folder1Id));
});
it('unfavorite an item', () => {
dataTable.clickOnItemName(file3Fav)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Favorite'))
.then(() => apis.user.favorites.waitForApi({ expect: 1 }))
.then(() => apis.user.favorites.isFavorite(file3Id))
.then(isFavorite => expect(isFavorite).toBe(false, `${file3Fav} is marked as favorite`))
.then(() => apis.user.favorites.addFavoriteById('file', file3Id));
});
it('favorite multiple items - all unfavorite', () => {
dataTable.selectMultipleItems([ file1NotFav, file2NotFav ])
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Favorite'))
.then(() => apis.user.favorites.waitForApi({ expect: 4 }))
.then(() => Promise.all([
apis.user.favorites.isFavorite(file1Id),
apis.user.favorites.isFavorite(file2Id)
]))
.then(resp => {
expect(resp[0]).toBe(true, 'item not marked as favorite');
expect(resp[1]).toBe(true, 'item not marked as favorite');
})
.then(() => apis.user.favorites.removeFavoriteById(file1Id))
.then(() => apis.user.favorites.removeFavoriteById(file2Id));
});
it('favorite multiple items - some favorite and some unfavorite', () => {
dataTable.selectMultipleItems([ file1NotFav, file3Fav ])
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Favorite'))
.then(() => apis.user.favorites.waitForApi({ expect: 3 }))
.then(() => Promise.all([
apis.user.favorites.isFavorite(file1Id),
apis.user.favorites.isFavorite(file3Id)
]))
.then(resp => {
expect(resp[0]).toBe(true, 'item not marked as favorite');
expect(resp[1]).toBe(true, 'item not marked as favorite');
})
.then(() => apis.user.favorites.removeFavoriteById(file1Id));
});
it('unfavorite multiple items', () => {
dataTable.selectMultipleItems([ file3Fav, file4Fav ])
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Favorite'))
.then(() => browser.sleep(2000))
.then(() => Promise.all([
apis.user.favorites.isFavorite(file3Id),
apis.user.favorites.isFavorite(file4Id)
]))
.then(resp => {
expect(resp[0]).toBe(false, 'item marked as favorite');
expect(resp[1]).toBe(false, 'item marked as favorite');
})
.then(() => apis.user.favorites.addFavoriteById('file', file3Id))
.then(() => apis.user.favorites.addFavoriteById('file', file4Id));
});
});
describe('on Recent Files', () => {
beforeAll(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterEach(done => {
// browser.actions().sendKeys(protractor.Key.ESCAPE).perform().then(done);
browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform().then(done);
});
it('favorite a file', () => {
dataTable.clickOnItemName(file1NotFav)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Favorite'))
.then(() => apis.user.favorites.waitForApi({ expect: 3 }))
.then(() => apis.user.favorites.isFavorite(file1Id))
.then(isFavorite => expect(isFavorite).toBe(true, `${file1NotFav} not marked as favorite`))
.then(() => apis.user.favorites.removeFavoriteById(file1Id));
});
it('unfavorite an item', () => {
dataTable.clickOnItemName(file3Fav)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Favorite'))
.then(() => apis.user.favorites.waitForApi({ expect: 1 }))
.then(() => apis.user.favorites.isFavorite(file3Id))
.then(isFavorite => expect(isFavorite).toBe(false, `${file3Fav} is marked as favorite`))
.then(() => apis.user.favorites.addFavoriteById('file', file3Id));
});
it('favorite multiple items - all unfavorite', () => {
dataTable.selectMultipleItems([ file1NotFav, file2NotFav ])
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Favorite'))
.then(() => apis.user.favorites.waitForApi({ expect: 4 }))
.then(() => Promise.all([
apis.user.favorites.isFavorite(file1Id),
apis.user.favorites.isFavorite(file2Id)
]))
.then(resp => {
expect(resp[0]).toBe(true, 'item not marked as favorite');
expect(resp[1]).toBe(true, 'item not marked as favorite');
})
.then(() => apis.user.favorites.removeFavoriteById(file1Id))
.then(() => apis.user.favorites.removeFavoriteById(file2Id));
});
it('favorite multiple items - some favorite and some unfavorite', () => {
dataTable.selectMultipleItems([ file1NotFav, file3Fav ])
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Favorite'))
.then(() => apis.user.favorites.waitForApi({ expect: 3 }))
.then(() => Promise.all([
apis.user.favorites.isFavorite(file1Id),
apis.user.favorites.isFavorite(file3Id)
]))
.then(resp => {
expect(resp[0]).toBe(true, 'item not marked as favorite');
expect(resp[1]).toBe(true, 'item not marked as favorite');
})
.then(() => apis.user.favorites.removeFavoriteById(file1Id));
});
it('unfavorite multiple items', () => {
dataTable.selectMultipleItems([ file3Fav, file4Fav ])
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Favorite'))
.then(() => browser.sleep(2000))
.then(() => Promise.all([
apis.user.favorites.isFavorite(file3Id),
apis.user.favorites.isFavorite(file4Id)
]))
.then(resp => {
expect(resp[0]).toBe(false, 'item marked as favorite');
expect(resp[1]).toBe(false, 'item marked as favorite');
})
.then(() => apis.user.favorites.addFavoriteById('file', file3Id))
.then(() => apis.user.favorites.addFavoriteById('file', file4Id));
});
});
describe('on Shared Files', () => {
beforeAll(done => {
apis.user.shared.shareFilesByIds([ file1Id, file2Id, file3Id, file4Id ])
.then(() => apis.user.shared.waitForApi({ expect: 4 }))
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES))
.then(() => dataTable.waitForHeader())
.then(done);
});
afterEach(done => {
// browser.actions().sendKeys(protractor.Key.ESCAPE).perform().then(done);
browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform().then(done);
});
it('favorite a file', () => {
dataTable.clickOnItemName(file1NotFav)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Favorite'))
.then(() => apis.user.favorites.waitForApi({ expect: 3 }))
.then(() => apis.user.favorites.isFavorite(file1Id))
.then(isFavorite => expect(isFavorite).toBe(true, `${file1NotFav} not marked as favorite`))
.then(() => apis.user.favorites.removeFavoriteById(file1Id));
});
it('unfavorite an item', () => {
dataTable.clickOnItemName(file3Fav)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Favorite'))
.then(() => apis.user.favorites.waitForApi({ expect: 1 }))
.then(() => apis.user.favorites.isFavorite(file3Id))
.then(isFavorite => expect(isFavorite).toBe(false, `${file3Fav} is marked as favorite`))
.then(() => apis.user.favorites.addFavoriteById('file', file3Id));
});
it('favorite multiple items - all unfavorite', () => {
dataTable.selectMultipleItems([ file1NotFav, file2NotFav ])
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Favorite'))
.then(() => apis.user.favorites.waitForApi({ expect: 4 }))
.then(() => Promise.all([
apis.user.favorites.isFavorite(file1Id),
apis.user.favorites.isFavorite(file2Id)
]))
.then(resp => {
expect(resp[0]).toBe(true, 'item not marked as favorite');
expect(resp[1]).toBe(true, 'item not marked as favorite');
})
.then(() => apis.user.favorites.removeFavoriteById(file1Id))
.then(() => apis.user.favorites.removeFavoriteById(file2Id));
});
it('favorite multiple items - some favorite and some unfavorite', () => {
dataTable.selectMultipleItems([ file1NotFav, file3Fav ])
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Favorite'))
.then(() => apis.user.favorites.waitForApi({ expect: 3 }))
.then(() => Promise.all([
apis.user.favorites.isFavorite(file1Id),
apis.user.favorites.isFavorite(file3Id)
]))
.then(resp => {
expect(resp[0]).toBe(true, 'item not marked as favorite');
expect(resp[1]).toBe(true, 'item not marked as favorite');
})
.then(() => apis.user.favorites.removeFavoriteById(file1Id));
});
it('unfavorite multiple items', () => {
dataTable.selectMultipleItems([ file3Fav, file4Fav ])
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Favorite'))
.then(() => browser.sleep(2000))
.then(() => Promise.all([
apis.user.favorites.isFavorite(file3Id),
apis.user.favorites.isFavorite(file4Id)
]))
.then(resp => {
expect(resp[0]).toBe(false, 'item marked as favorite');
expect(resp[1]).toBe(false, 'item marked as favorite');
})
.then(() => apis.user.favorites.addFavoriteById('file', file3Id))
.then(() => apis.user.favorites.addFavoriteById('file', file4Id));
});
});
describe('on Favorites', () => {
beforeAll(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterEach(done => {
page.refresh().then(done);
});
it('unfavorite an item', () => {
dataTable.clickOnItemName(file3Fav)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Favorite'))
.then(() => apis.user.favorites.waitForApi({ expect: 1 }))
.then(() => apis.user.favorites.isFavorite(file3Id))
.then(isFavorite => {
expect(isFavorite).toBe(false, 'item is marked as favorite');
expect(dataTable.getRowName(file3Fav).isPresent()).toBe(false, 'item still displayed');
})
.then(() => apis.user.favorites.addFavoriteById('file', file3Id));
});
it('unfavorite multiple items', () => {
dataTable.selectMultipleItems([ file3Fav, file4Fav ])
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Favorite'))
.then(() => browser.sleep(2000))
.then(() => apis.user.favorites.isFavorite(file3Id))
.then(resp => {
expect(resp).toBe(false, 'file3 marked as favorite');
expect(dataTable.getRowName(file3Fav).isPresent()).toBe(false, 'file3 still displayed');
})
.then(() => apis.user.favorites.isFavorite(file4Id))
.then(resp => {
expect(resp).toBe(false, 'file4 marked as favorite');
expect(dataTable.getRowName(file4Fav).isPresent()).toBe(false, 'file4 still displayed');
})
.then(() => apis.user.favorites.addFavoriteById('file', file3Id))
.then(() => apis.user.favorites.addFavoriteById('file', file4Id));
});
});
});

View File

@@ -0,0 +1,122 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { SIDEBAR_LABELS } from '../../configs';
import { RepoClient } from '../../utilities/repo-client/repo-client';
import { Utils } from '../../utilities/utils';
describe('Permanently delete from Trash', () => {
const username = `user-${Utils.random()}`;
const file1 = `file-${Utils.random()}.txt`;
const file2 = `file-${Utils.random()}.txt`;
let filesIds;
const folder1 = `folder-${Utils.random()}`;
const folder2 = `folder-${Utils.random()}`;
let foldersIds;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const trashPage = new BrowsingPage();
const { dataTable, toolbar } = trashPage;
beforeAll(done => {
apis.admin.people.createUser(username)
.then(() => apis.user.nodes.createFiles([ file1, file2 ]))
.then(resp => filesIds = resp.data.list.entries.map(entries => entries.entry.id))
.then(() => apis.user.nodes.createFolders([ folder1, folder2 ]))
.then(resp => foldersIds = resp.data.list.entries.map(entries => entries.entry.id))
.then(() => apis.user.nodes.deleteNodesById(filesIds, false))
.then(() => apis.user.nodes.deleteNodesById(foldersIds, false))
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
trashPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
Promise.all([
apis.admin.trashcan.emptyTrash(),
logoutPage.load()
])
.then(done);
});
it('delete file [C217094] [C217091] [C217092]', () => {
dataTable.clickOnItemName(file1)
.then(() => toolbar.actions.getButtonByTitleAttribute('Permanently delete').click())
.then(() => trashPage.waitForDialog())
.then(() => trashPage.getDialogActionByLabel('Delete'))
.then((elm) => elm.click())
.then(() => trashPage.waitForDialogToClose())
.then(() => trashPage.getSnackBarMessage())
.then(text => {
expect(text).toEqual(`${file1} deleted`);
expect(dataTable.getRowName(file1).isPresent()).toBe(false, 'Item was not deleted');
});
});
it('delete folder [C217091] [C217092]', () => {
dataTable.clickOnItemName(folder1)
.then(() => toolbar.actions.getButtonByTitleAttribute('Permanently delete').click())
.then(() => trashPage.waitForDialog())
.then(() => trashPage.getDialogActionByLabel('Delete'))
.then((elm) => elm.click())
.then(() => trashPage.waitForDialogToClose())
.then(() => trashPage.getSnackBarMessage())
.then(text => {
expect(text).toEqual(`${folder1} deleted`);
expect(dataTable.getRowName(folder1).isPresent()).toBe(false, 'Item was not deleted');
});
});
it('delete multiple items [C217093]', () => {
dataTable.selectMultipleItems([ file2, folder2 ])
.then(() => toolbar.actions.getButtonByTitleAttribute('Permanently delete').click())
.then(() => trashPage.waitForDialog())
.then(() => trashPage.getDialogActionByLabel('Delete'))
.then((elm) => elm.click())
.then(() => trashPage.waitForDialogToClose())
.then(() => trashPage.getSnackBarMessage())
.then(text => {
expect(text).toEqual(`2 items deleted`);
expect(dataTable.getRowName(file2).isPresent()).toBe(false, 'Item was not deleted');
expect(dataTable.getRowName(folder2).isPresent()).toBe(false, 'Item was not deleted');
});
});
});

View File

@@ -0,0 +1,268 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from 'protractor';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { APP_ROUTES, SIDEBAR_LABELS } from '../../configs';
import { RepoClient } from '../../utilities/repo-client/repo-client';
import { Utils } from '../../utilities/utils';
describe('Restore from Trash', () => {
const username = `user-${Utils.random()}`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, toolbar } = page;
beforeAll(done => {
apis.admin.people.createUser(username)
.then(() => loginPage.loginWith(username))
.then(done);
});
afterAll(done => {
Promise.all([
apis.admin.trashcan.emptyTrash(),
logoutPage.load()
])
.then(done);
});
xit('');
describe('successful restore', () => {
const file = `file-${Utils.random()}.txt`; let fileId;
const folder = `folder-${Utils.random()}`; let folderId;
beforeAll(done => {
apis.user.nodes.createFile(file).then(resp => fileId = resp.data.entry.id)
.then(() => apis.user.nodes.createFolder(folder).then(resp => folderId = resp.data.entry.id))
.then(() => apis.user.nodes.deleteNodesById([ fileId, folderId ], false))
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
apis.user.trashcan.emptyTrash().then(done);
});
it('restore file', () => {
dataTable.clickOnItemName(file)
.then(() => toolbar.actions.getButtonByTitleAttribute('Restore').click())
.then(() => page.getSnackBarMessage())
.then(text => {
expect(text).toContain(`${file} restored`);
expect(text).toContain(`View`);
expect(dataTable.getRowName(file).isPresent()).toBe(false, 'Item was not removed from list');
})
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES))
.then(() => page.dataTable.waitForHeader())
.then(() => {
expect(page.dataTable.getRowName(file).isPresent()).toBe(true, 'Item not displayed in list');
})
.then(() => apis.user.nodes.deleteNodeById(fileId, false));
});
it('restore folder', () => {
dataTable.clickOnItemName(folder)
.then(() => toolbar.actions.getButtonByTitleAttribute('Restore').click())
.then(() => page.getSnackBarMessage())
.then(text => {
expect(text).toContain(`${folder} restored`);
expect(text).toContain(`View`);
expect(dataTable.getRowName(folder).isPresent()).toBe(false, 'Item was not removed from list');
})
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES))
.then(() => page.dataTable.waitForHeader())
.then(() => {
expect(page.dataTable.getRowName(folder).isPresent()).toBe(true, 'Item not displayed in list');
})
.then(() => apis.user.nodes.deleteNodeById(folderId, false));
});
it('restore multiple items', () => {
dataTable.selectMultipleItems([ file, folder ])
.then(() => toolbar.actions.getButtonByTitleAttribute('Restore').click())
.then(() => page.getSnackBarMessage())
.then(text => {
expect(text).toContain(`Restore successful`);
expect(text).not.toContain(`View`);
expect(dataTable.getRowName(file).isPresent()).toBe(false, 'Item was not removed from list');
expect(dataTable.getRowName(folder).isPresent()).toBe(false, 'Item was not removed from list');
})
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES))
.then(() => page.dataTable.waitForHeader())
.then(() => {
expect(page.dataTable.getRowName(file).isPresent()).toBe(true, 'Item not displayed in list');
expect(page.dataTable.getRowName(folder).isPresent()).toBe(true, 'Item not displayed in list');
})
.then(() => apis.user.nodes.deleteNodesById([ fileId, folderId ], false));
});
it('View from notification', () => {
dataTable.clickOnItemName(file)
.then(() => toolbar.actions.getButtonByTitleAttribute('Restore').click())
.then(() => page.clickSnackBarAction())
.then(() => page.dataTable.waitForHeader())
.then(() => {
expect(page.sidenav.isActiveByLabel('Personal Files')).toBe(true, 'Personal Files sidebar link not active');
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.PERSONAL_FILES);
})
.then(() => apis.user.nodes.deleteNodeById(fileId, false));
});
});
describe('failure to restore', () => {
const file1 = `file-${Utils.random()}.txt`; let file1Id1, file1Id2;
const file2 = `file-${Utils.random()}.txt`; let file2Id;
const folder1 = `folder-${Utils.random()}`; let folder1Id;
const folder2 = `folder-${Utils.random()}`; let folder2Id;
beforeAll(done => {
apis.user.nodes.createFolder(folder1).then(resp => folder1Id = resp.data.entry.id)
.then(() => apis.user.nodes.createFile(file1, folder1Id).then(resp => file1Id1 = resp.data.entry.id))
.then(() => apis.user.nodes.deleteNodeById(file1Id1, false))
.then(() => apis.user.nodes.createFile(file1, folder1Id).then(resp => file1Id2 = resp.data.entry.id))
.then(() => apis.user.nodes.createFolder(folder2).then(resp => folder2Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFile(file2, folder2Id).then(resp => file2Id = resp.data.entry.id))
.then(() => apis.user.nodes.deleteNodeById(file2Id, false))
.then(() => apis.user.nodes.deleteNodeById(folder2Id, false))
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
Promise.all([
apis.user.nodes.deleteNodeById(file1Id2),
apis.user.trashcan.emptyTrash()
])
.then(done);
});
it('Restore a file when another file with same name exists on the restore location', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH)
.then(() => dataTable.clickOnItemName(file1))
.then(() => toolbar.actions.getButtonByTitleAttribute('Restore').click())
.then(() => page.getSnackBarMessage())
.then(text => expect(text).toEqual(`Can't restore, ${file1} already exists`));
});
it('Restore a file when original location no longer exists', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH)
.then(() => dataTable.clickOnItemName(file2))
.then(() => toolbar.actions.getButtonByTitleAttribute('Restore').click())
.then(() => page.getSnackBarMessage())
.then(text => expect(text).toEqual(`Can't restore ${file2}, the original location no longer exists`));
});
});
describe('Notification on partial success', () => {
const folder1 = `folder1-${Utils.random()}.txt`; let folder1Id;
const folder2 = `folder2-${Utils.random()}.txt`; let folder2Id;
const file1 = `file-${Utils.random()}.txt`; let file1Id;
const file2 = `file-${Utils.random()}.txt`; let file2Id;
const folder3 = `folder3-${Utils.random()}.txt`; let folder3Id;
const folder4 = `folder4-${Utils.random()}.txt`; let folder4Id;
const file3 = `file3-${Utils.random()}.txt`; let file3Id;
const file4 = `file4-${Utils.random()}.txt`; let file4Id;
const file5 = `file5-${Utils.random()}.txt`; let file5Id;
beforeAll(done => {
apis.user.nodes.createFolder(folder1).then(resp => folder1Id = resp.data.entry.id)
.then(() => apis.user.nodes.createFile(file1, folder1Id).then(resp => file1Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFolder(folder2).then(resp => folder2Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFile(file2, folder2Id).then(resp => file2Id = resp.data.entry.id))
.then(() => apis.user.nodes.deleteNodeById(file1Id, false))
.then(() => apis.user.nodes.deleteNodeById(folder1Id, false))
.then(() => apis.user.nodes.deleteNodeById(file2Id, false))
.then(() => apis.user.nodes.createFolder(folder3).then(resp => folder3Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFile(file3, folder3Id).then(resp => file3Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFile(file4, folder3Id).then(resp => file4Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFolder(folder4).then(resp => folder4Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFile(file5, folder4Id).then(resp => file5Id = resp.data.entry.id))
.then(() => apis.user.nodes.deleteNodeById(file3Id, false))
.then(() => apis.user.nodes.deleteNodeById(file4Id, false))
.then(() => apis.user.nodes.deleteNodeById(folder3Id, false))
.then(() => apis.user.nodes.deleteNodeById(file5Id, false))
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
Promise.all([
apis.user.trashcan.emptyTrash(),
logoutPage.load()
])
.then(done);
});
it('one failure', () => {
dataTable.selectMultipleItems([ file1, file2 ])
.then(() => toolbar.actions.getButtonByTitleAttribute('Restore').click())
.then(() => page.getSnackBarMessage())
.then(text => expect(text).toEqual(`Can't restore ${file1}, the original location no longer exists`));
});
it('multiple failures', () => {
dataTable.selectMultipleItems([ file3, file4, file5 ])
.then(() => toolbar.actions.getButtonByTitleAttribute('Restore').click())
.then(() => page.getSnackBarMessage())
.then(text => expect(text).toEqual('2 items not restored because of issues with the restore location'));
});
});
});

View File

@@ -0,0 +1,543 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser, protractor } from 'protractor';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { SITE_VISIBILITY, SITE_ROLES, SIDEBAR_LABELS } from '../../configs';
import { RepoClient } from '../../utilities/repo-client/repo-client';
import { Utils } from '../../utilities/utils';
describe('Toolbar actions - multiple selection : ', () => {
const user1 = `user-${Utils.random()}`;
const user2 = `user-${Utils.random()}`;
const file1 = `file-${Utils.random()}.txt`;
let file1Id;
const file2 = `file-${Utils.random()}.txt`;
let file2Id;
const folder1 = `folder-${Utils.random()}`;
let folder1Id;
const folder2 = `folder-${Utils.random()}`;
let folder2Id;
const fileForDelete1 = `file-${Utils.random()}.txt`; let fileForDelete1Id;
const fileForDelete2 = `file-${Utils.random()}.txt`; let fileForDelete2Id;
const folderForDelete1 = `folder-${Utils.random()}`; let folderForDelete1Id;
const folderForDelete2 = `folder-${Utils.random()}`; let folderForDelete2Id;
const siteName = `site-private-${Utils.random()}`;
const file1Admin = `file-${Utils.random()}.txt`;
const file2Admin = `file-${Utils.random()}.txt`;
const folder1Admin = `folder-${Utils.random()}`;
const folder2Admin = `folder-${Utils.random()}`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(user1, user1)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable } = page;
const { toolbar } = page;
beforeAll(done => {
apis.admin.people.createUser(user1)
.then(() => apis.user.nodes.createFiles([ file1 ]).then(resp => file1Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFiles([ file2 ]).then(resp => file2Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFolders([ folder1 ]).then(resp => folder1Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFolders([ folder2 ]).then(resp => folder2Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFiles([ fileForDelete1 ]).then(resp => fileForDelete1Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFiles([ fileForDelete2 ]).then(resp => fileForDelete2Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFolders([ folderForDelete1 ]).then(resp => folderForDelete1Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFolders([ folderForDelete2 ]).then(resp => folderForDelete2Id = resp.data.entry.id))
.then(() => apis.user.shared.shareFilesByIds([ file1Id, file2Id ]))
.then(() => apis.user.favorites.addFavoritesByIds('file', [ file1Id, file2Id ]))
.then(() => apis.user.favorites.addFavoritesByIds('folder', [ folder1Id, folder2Id ]))
.then(() => apis.user.nodes.deleteNodesById([
fileForDelete1Id, fileForDelete2Id, folderForDelete1Id, folderForDelete2Id
], false))
.then(done);
});
afterAll(done => {
Promise.all([
apis.user.nodes.deleteNodesById([ file1Id, file2Id, folder1Id, folder2Id ]),
apis.user.trashcan.emptyTrash(),
logoutPage.load()
])
.then(done);
});
xit('');
describe('Personal Files', () => {
beforeAll(done => {
loginPage.loginWith(user1).then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('unselect selected items - single click', () => {
dataTable.selectMultipleItems([ file1, file2, folder1, folder2 ])
.then(() => expect(dataTable.countSelectedRows()).toEqual(4, 'incorrect selected rows number'))
.then(() => dataTable.clickOnItemName(file1))
.then(() => expect(dataTable.countSelectedRows()).toEqual(1, 'incorrect selected rows number'))
.then(() => dataTable.clearSelection());
});
it('unselect selected items - CMD+click', () => {
dataTable.selectMultipleItems([ file1, file2, folder1, folder2 ])
.then(() => expect(dataTable.countSelectedRows()).toEqual(4, 'incorrect selected rows number'))
.then(() => browser.actions().sendKeys(protractor.Key.COMMAND).perform())
.then(() => dataTable.clickOnItemName(file1))
.then(() => dataTable.clickOnItemName(file2))
.then(() => browser.actions().sendKeys(protractor.Key.NULL).perform())
.then(() => expect(dataTable.countSelectedRows()).toEqual(2, 'incorrect selected rows number'))
.then(() => dataTable.clearSelection());
});
it('correct actions appear when multiple files are selected', () => {
dataTable.selectMultipleItems([file1, file2])
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(false, 'View is displayed for selected files');
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, 'Download is not displayed for selected files');
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, 'Edit is displayed for selected files');
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for selected files`);
expect(menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for selected files`);
expect(menu.isMenuItemPresent('Move')).toBe(true, `Move is not displayed for selected files`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for selected files`);
})
// .then(() => browser.$('body').click())
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform())
.then(() => dataTable.clearSelection());
});
it('correct actions appear when multiple folders are selected', () => {
dataTable.selectMultipleItems([folder1, folder2])
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(false, 'View is displayed for selected files');
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, 'Download is not displayed for selected files');
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, 'Edit is displayed for selected files');
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for selected files`);
expect(menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for selected files`);
expect(menu.isMenuItemPresent('Move')).toBe(true, `Move is not displayed for selected files`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for selected files`);
})
// .then(() => browser.$('body').click())
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform())
.then(() => dataTable.clearSelection());
});
it('correct actions appear when both files and folders are selected', () => {
dataTable.selectMultipleItems([file1, file2, folder1, folder2])
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(false, 'View is displayed for selected files');
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, 'Download is not displayed for selected files');
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, 'Edit is displayed for selected files');
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for selected files`);
expect(menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for selected files`);
expect(menu.isMenuItemPresent('Move')).toBe(true, `Move is not displayed for selected files`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for selected files`);
})
// .then(() => browser.$('body').click())
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform())
.then(() => dataTable.clearSelection());
});
});
describe('File Libraries', () => {
beforeAll(done => {
apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC)
.then(() => apis.admin.people.createUser(user2))
.then(() => apis.admin.sites.addSiteMember(siteName, user1, SITE_ROLES.SITE_MANAGER))
.then(() => apis.admin.sites.addSiteMember(siteName, user2, SITE_ROLES.SITE_CONSUMER))
.then(() => apis.admin.nodes.createFiles([ file1Admin, file2Admin ], `Sites/${siteName}/documentLibrary`))
.then(() => apis.admin.nodes.createFolders([ folder1Admin, folder2Admin ], `Sites/${siteName}/documentLibrary`))
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES)
.then(() => dataTable.waitForHeader())
.then(() => dataTable.doubleClickOnItemName(siteName))
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
apis.admin.sites.deleteSite(siteName).then(done);
});
xit('');
describe('user is Manager', () => {
beforeAll(done => {
loginPage.loginWith(user1).then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('correct actions appear when multiple files are selected', () => {
dataTable.selectMultipleItems([file1Admin, file2Admin])
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(false, 'View is displayed for selected files');
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, 'Download is not displayed for selected files');
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, 'Edit is displayed for selected files');
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for selected files`);
expect(menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for selected files`);
expect(menu.isMenuItemPresent('Move')).toBe(true, `Move is not displayed for selected files`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for selected files`);
})
// .then(() => browser.$('body').click())
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform())
.then(() => dataTable.clearSelection());
});
it('correct actions appear when multiple folders are selected', () => {
dataTable.selectMultipleItems([folder1Admin, folder2Admin])
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(false, 'View is displayed for selected files');
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, 'Download is not displayed for selected files');
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, 'Edit is displayed for selected files');
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for selected files`);
expect(menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for selected files`);
expect(menu.isMenuItemPresent('Move')).toBe(true, `Move is not displayed for selected files`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for selected files`);
})
// .then(() => browser.$('body').click())
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform())
.then(() => dataTable.clearSelection());
});
it('correct actions appear when both files and folders are selected', () => {
dataTable.selectMultipleItems([file1Admin, file2Admin, folder1Admin, folder2Admin])
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(false, 'View is displayed for selected files');
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, 'Download is not displayed for selected files');
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, 'Edit is displayed for selected files');
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for selected files`);
expect(menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for selected files`);
expect(menu.isMenuItemPresent('Move')).toBe(true, `Move is not displayed for selected files`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for selected files`);
})
// .then(() => browser.$('body').click())
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform())
.then(() => dataTable.clearSelection());
});
});
describe('user is Consumer', () => {
beforeAll(done => {
loginPage.loginWith(user2).then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('correct actions appear when multiple files are selected', () => {
dataTable.selectMultipleItems([file1Admin, file2Admin])
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(false, 'View is displayed for selected files');
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, 'Download is not displayed for selected files');
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, 'Edit is displayed for selected files');
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for selected files`);
expect(menu.isMenuItemPresent('Delete')).toBe(false, `Delete is displayed for selected files`);
expect(menu.isMenuItemPresent('Move')).toBe(false, `Move is displayed for selected files`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for selected files`);
})
// .then(() => browser.$('body').click())
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform())
.then(() => dataTable.clearSelection());
});
it('correct actions appear when multiple folders are selected', () => {
dataTable.selectMultipleItems([folder1Admin, folder2Admin])
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(false, 'View is displayed for selected files');
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, 'Download is not displayed for selected files');
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, 'Edit is displayed for selected files');
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for selected files`);
expect(menu.isMenuItemPresent('Delete')).toBe(false, `Delete is displayed for selected files`);
expect(menu.isMenuItemPresent('Move')).toBe(false, `Move is displayed for selected files`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for selected files`);
})
// .then(() => browser.$('body').click())
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform())
.then(() => dataTable.clearSelection());
});
it('correct actions appear when both files and folders are selected', () => {
dataTable.selectMultipleItems([file1Admin, file2Admin, folder1Admin, folder2Admin])
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(false, 'View is displayed for selected files');
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, 'Download is not displayed for selected files');
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, 'Edit is displayed for selected files');
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for selected files`);
expect(menu.isMenuItemPresent('Delete')).toBe(false, `Delete is not displayed for selected files`);
expect(menu.isMenuItemPresent('Move')).toBe(false, `Move is not displayed for selected files`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for selected files`);
})
// .then(() => browser.$('body').click())
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform())
.then(() => dataTable.clearSelection());
});
});
});
describe('Shared Files', () => {
beforeAll(done => {
loginPage.loginWith(user1).then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('correct actions appear when multiple files are selected', () => {
dataTable.selectMultipleItems([file1, file2])
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(false, 'View is displayed for selected files');
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, 'Download is not displayed for selected files');
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, 'Edit is displayed for selected files');
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for selected files`);
expect(menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for selected files`);
expect(menu.isMenuItemPresent('Move')).toBe(true, `Move is not displayed for selected files`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for selected files`);
})
// .then(() => browser.$('body').click())
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform())
.then(() => dataTable.clearSelection());
});
});
describe('Recent Files', () => {
beforeAll(done => {
loginPage.loginWith(user1).then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('correct actions appear when multiple files are selected', () => {
dataTable.selectMultipleItems([file1, file2])
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(false, 'View is displayed for selected files');
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, 'Download is not displayed for selected files');
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, 'Edit is displayed for selected files');
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for selected files`);
expect(menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for selected files`);
expect(menu.isMenuItemPresent('Move')).toBe(true, `Move is not displayed for selected files`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for selected files`);
})
// .then(() => browser.$('body').click())
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform())
.then(() => dataTable.clearSelection());
});
});
describe('Favorites', () => {
beforeAll(done => {
loginPage.loginWith(user1).then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('correct actions appear when multiple files are selected', () => {
dataTable.selectMultipleItems([file1, file2])
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(false, 'View is displayed for selected files');
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, 'Download is not displayed for selected files');
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, 'Edit is displayed for selected files');
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for selected files`);
expect(menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for selected files`);
expect(menu.isMenuItemPresent('Move')).toBe(true, `Move is not displayed for selected files`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for selected files`);
})
// .then(() => browser.$('body').click())
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform())
.then(() => dataTable.clearSelection());
});
it('correct actions appear when multiple folders are selected', () => {
dataTable.selectMultipleItems([folder1, folder2])
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(false, 'View is displayed for selected files');
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, 'Download is not displayed for selected files');
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, 'Edit is displayed for selected files');
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for selected files`);
expect(menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for selected files`);
expect(menu.isMenuItemPresent('Move')).toBe(true, `Move is not displayed for selected files`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for selected files`);
})
// .then(() => browser.$('body').click())
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform())
.then(() => dataTable.clearSelection());
});
it('correct actions appear when both files and folders are selected', () => {
dataTable.selectMultipleItems([file1, file2, folder1, folder2])
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(false, 'View is displayed for selected files');
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, 'Download is not displayed for selected files');
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, 'Edit is displayed for selected files');
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for selected files`);
expect(menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for selected files`);
expect(menu.isMenuItemPresent('Move')).toBe(true, `Move is not displayed for selected files`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for selected files`);
})
// .then(() => browser.$('body').click())
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform())
.then(() => dataTable.clearSelection());
});
});
// [C217090]
describe('Trash', () => {
beforeAll(done => {
loginPage.loginWith(user1).then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('correct actions appear when multiple files are selected', () => {
dataTable.selectMultipleItems([fileForDelete1, fileForDelete2])
.then(() => {
expect(toolbar.actions.isButtonPresent('Permanently delete'))
.toBe(true, 'Permanently delete is displayed for selected files');
expect(toolbar.actions.isButtonPresent('Restore')).toBe(true, 'Restore is not displayed for selected files');
})
.then(() => dataTable.clearSelection());
});
it('correct actions appear when multiple folders are selected', () => {
dataTable.selectMultipleItems([folderForDelete1, folderForDelete2])
.then(() => {
expect(toolbar.actions.isButtonPresent('Permanently delete'))
.toBe(true, 'Permanently delete is displayed for selected files');
expect(toolbar.actions.isButtonPresent('Restore')).toBe(true, 'Restore is not displayed for selected files');
})
.then(() => dataTable.clearSelection());
});
it('correct actions appear when both files and folders are selected', () => {
dataTable.selectMultipleItems([fileForDelete1, fileForDelete2, folderForDelete1, folderForDelete2])
.then(() => {
expect(toolbar.actions.isButtonPresent('Permanently delete'))
.toBe(true, 'Permanently delete is displayed for selected files');
expect(toolbar.actions.isButtonPresent('Restore')).toBe(true, 'Restore is not displayed for selected files');
})
.then(() => dataTable.clearSelection());
});
});
});

View File

@@ -0,0 +1,752 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from 'protractor';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { SITE_VISIBILITY, SITE_ROLES, SIDEBAR_LABELS } from '../../configs';
import { RepoClient } from '../../utilities/repo-client/repo-client';
import { Utils } from '../../utilities/utils';
describe('Toolbar actions - single selection : ', () => {
const username = `user-${Utils.random()}`;
const username2 = `user-${Utils.random()}`;
const fileUser = `file-${Utils.random()}.txt`; let fileUserId;
const folderUser = `folder-${Utils.random()}`; let folderUserId;
const fileForDelete = `file-${Utils.random()}.txt`; let fileForDeleteId;
const folderForDelete = `folder-${Utils.random()}`; let folderForDeleteId;
const siteName = `site-private-${Utils.random()}`;
const fileAdmin = `file-${Utils.random()}.txt`;
const folderAdmin = `folder-${Utils.random()}`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, toolbar } = page;
beforeAll(done => {
apis.admin.people.createUser(username)
.then(() => apis.user.nodes.createFiles([ fileUser ]))
.then(resp => fileUserId = resp.data.entry.id)
.then(() => apis.user.nodes.createFiles([ fileForDelete ]))
.then(resp => fileForDeleteId = resp.data.entry.id)
.then(() => apis.user.nodes.createFolders([ folderForDelete ]))
.then(resp => folderForDeleteId = resp.data.entry.id)
.then(() => apis.user.nodes.createFolders([ folderUser ]))
.then(resp => folderUserId = resp.data.entry.id)
.then(() => apis.user.shared.shareFileById(fileUserId))
.then(() => apis.user.favorites.addFavoriteById('file', fileUserId))
.then(() => apis.user.favorites.addFavoriteById('folder', folderUserId))
.then(done);
});
afterAll(done => {
Promise.all([
apis.user.nodes.deleteNodeById(fileUserId),
apis.user.nodes.deleteNodeById(folderUserId),
logoutPage.load()
])
.then(done);
});
xit('');
describe('General tests', () => {
const userSite = `site-${Utils.random()}`;
beforeAll(done => {
apis.user.sites.createSite(userSite, SITE_VISIBILITY.PUBLIC)
.then(() => loginPage.loginWith(username))
.then(done);
});
afterAll(done => {
Promise.all([
apis.user.sites.deleteSite(userSite),
logoutPage.load()
])
.then(done);
});
it('actions not displayed for top level of File Libraries', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES)
.then(() => dataTable.waitForHeader())
.then(() => dataTable.clickOnItemName(userSite))
.then(() => expect(toolbar.actions.isEmpty()).toBe(true, 'toolbar not empty'));
});
it('selected row is marked with a check circle icon', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => dataTable.waitForHeader())
.then(() => dataTable.clickOnItemName(fileUser))
.then(() => expect(dataTable.hasCheckMarkIcon(fileUser)).toBe(true, 'check mark missing'));
});
describe('granular permissions', () => {
const site = `site-${Utils.random()}`;
const file1 = `file-${Utils.random()}`; let file1Id;
const file2 = `file-${Utils.random()}`; let file2Id;
beforeAll(done => {
apis.admin.sites.createSite(site, SITE_VISIBILITY.PRIVATE)
.then(() => apis.admin.nodes.createFiles([ file1 ], `Sites/${site}/documentLibrary`)
.then(resp => file1Id = resp.data.entry.id))
.then(() => apis.admin.nodes.createFiles([ file2 ], `Sites/${site}/documentLibrary`)
.then(resp => file2Id = resp.data.entry.id))
.then(() => apis.admin.sites.addSiteMember(site, username, SITE_ROLES.SITE_CONSUMER))
.then(() => apis.admin.nodes.setGranularPermission(file1Id, false, username, SITE_ROLES.SITE_CONSUMER))
.then(() => apis.admin.nodes.setGranularPermission(file2Id, false, username, SITE_ROLES.SITE_MANAGER))
.then(() => apis.user.shared.shareFileById(file1Id))
.then(() => apis.admin.shared.shareFileById(file2Id))
.then(() => apis.user.favorites.addFavoritesByIds('file', [file1Id, file2Id]))
.then(() => loginPage.loginWith(username))
.then(done);
});
afterAll(done => {
Promise.all([
apis.admin.sites.deleteSite(site),
logoutPage.load()
])
.then(done);
});
describe('actions update accordingly for files with different granular permissions', () => {
it('on File Libraries', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES)
.then(() => dataTable.waitForHeader())
.then(() => dataTable.doubleClickOnItemName(site))
.then(() => dataTable.waitForHeader())
.then(() => dataTable.clickOnItemName(file1))
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(true, `View is not displayed for ${file1}`);
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not displayed for ${file1}`);
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, `Edit is displayed for ${file1}`);
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for ${file1}`);
expect(menu.isMenuItemPresent('Delete')).toBe(false, `Delete is displayed for ${file1}`);
expect(menu.isMenuItemPresent('Move')).toBe(false, `Move is displayed for ${file1}`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for ${file1}`);
})
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform())
.then(() => dataTable.clickOnItemName(file2))
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(true, `View is not displayed for ${file2}`);
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not displayed for ${file2}`);
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, `Edit is displayed for ${file2}`);
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for ${file2}`);
expect(menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for ${file2}`);
expect(menu.isMenuItemPresent('Move')).toBe(true, `Move is not displayed for ${file2}`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for ${file2}`);
})
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform());
});
it('on Shared Files', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES)
.then(() => dataTable.waitForHeader())
.then(() => dataTable.clickOnItemName(file1))
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(true, `View is not displayed for ${file1}`);
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not displayed for ${file1}`);
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, `Edit is displayed for ${file1}`);
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for ${file1}`);
expect(menu.isMenuItemPresent('Delete')).toBe(false, `Delete is displayed for ${file1}`);
expect(menu.isMenuItemPresent('Move')).toBe(false, `Move is displayed for ${file1}`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for ${file1}`);
})
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform())
.then(() => dataTable.clickOnItemName(file2))
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(true, `View is not displayed for ${file2}`);
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not displayed for ${file2}`);
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, `Edit is displayed for ${file2}`);
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for ${file2}`);
expect(menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for ${file2}`);
expect(menu.isMenuItemPresent('Move')).toBe(true, `Move is not displayed for ${file2}`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for ${file2}`);
})
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform());
});
// disabled until ACA-1184 is done
xit('on Favorites', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES)
.then(() => dataTable.waitForHeader())
.then(() => dataTable.clickOnItemName(file1))
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(true, `View is not displayed for ${file1}`);
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not displayed for ${file1}`);
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, `Edit is displayed for ${file1}`);
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for ${file1}`);
expect(menu.isMenuItemPresent('Delete')).toBe(false, `Delete is displayed for ${file1}`);
expect(menu.isMenuItemPresent('Move')).toBe(false, `Move is displayed for ${file1}`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for ${file1}`);
})
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform())
.then(() => dataTable.clickOnItemName(file2))
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(true, `View is not displayed for ${file2}`);
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not displayed for ${file2}`);
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, `Edit is displayed for ${file2}`);
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for ${file2}`);
expect(menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for ${file2}`);
expect(menu.isMenuItemPresent('Move')).toBe(true, `Move is not displayed for ${file2}`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for ${file2}`);
})
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform());
});
});
describe('correct actions are displayed when selecting multiple files with different granular permissions', () => {
it('on File Libraries', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES)
.then(() => dataTable.waitForHeader())
.then(() => dataTable.doubleClickOnItemName(site))
.then(() => dataTable.waitForHeader())
.then(() => dataTable.selectMultipleItems([ file1, file2 ]))
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(false, `View is displayed for selected files`);
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not displayed for selected files`);
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, `Edit is displayed for selected files`);
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for selected files`);
expect(menu.isMenuItemPresent('Delete')).toBe(false, `Delete is displayed for selected files`);
expect(menu.isMenuItemPresent('Move')).toBe(false, `Move is displayed for selected files`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for selected files`);
})
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform());
});
it('on Shared Files', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES)
.then(() => dataTable.waitForHeader())
.then(() => dataTable.selectMultipleItems([ file1, file2 ]))
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(false, `View is displayed for selected files`);
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not displayed for selected files`);
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, `Edit is displayed for selected files`);
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for selected files`);
expect(menu.isMenuItemPresent('Delete')).toBe(false, `Delete is displayed for selected files`);
expect(menu.isMenuItemPresent('Move')).toBe(false, `Move is displayed for selected files`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for selected files`);
})
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform());
});
// disabled until ACA-1184 is done
xit('on Favorites', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES)
.then(() => dataTable.waitForHeader())
.then(() => dataTable.selectMultipleItems([ file1, file2 ]))
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(false, `View is displayed for selected files`);
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not displayed for selected files`);
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, `Edit is displayed for selected files`);
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for selected files`);
expect(menu.isMenuItemPresent('Delete')).toBe(false, `Delete is displayed for selected files`);
expect(menu.isMenuItemPresent('Move')).toBe(false, `Move is displayed for selected files`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for selected files`);
})
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform());
});
});
xit('');
});
});
describe('Personal Files', () => {
beforeAll(done => {
loginPage.loginWith(username).then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('actions are not displayed when no item is selected', () => {
expect(toolbar.actions.isEmpty()).toBe(true, `actions displayed though nothing selected`);
});
it('actions are displayed when a file is selected', () => {
dataTable.clickOnItemName(fileUser)
.then(() => {
expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${fileUser}`);
});
});
it('actions are displayed when a folder is selected', () => {
dataTable.clickOnItemName(folderUser)
.then(() => {
expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${folderUser}`);
});
});
it('correct actions appear when a file is selected', () => {
dataTable.clickOnItemName(fileUser)
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(true, `View is not displayed for ${fileUser}`);
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not displayed for ${fileUser}`);
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, `Edit is displayed for ${fileUser}`);
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for ${fileUser}`);
expect(menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for ${fileUser}`);
expect(menu.isMenuItemPresent('Move')).toBe(true, `Move is not displayed for ${fileUser}`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for ${fileUser}`);
})
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform());
});
it('correct actions appear when a folder is selected', () => {
dataTable.clickOnItemName(folderUser)
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(false, `View is displayed for ${folderUser}`);
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not enabled for ${folderUser}`);
expect(toolbar.actions.isButtonPresent('Edit')).toBe(true, `Edit is not displayed for ${folderUser}`);
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for ${folderUser}`);
expect(menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for ${folderUser}`);
expect(menu.isMenuItemPresent('Move')).toBe(true, `Move is not displayed for ${folderUser}`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for ${folderUser}`);
})
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform());
});
});
describe('File Libraries', () => {
beforeAll(done => {
apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC)
.then(() => apis.admin.people.createUser(username2))
.then(() => apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_MANAGER))
.then(() => apis.admin.sites.addSiteMember(siteName, username2, SITE_ROLES.SITE_CONSUMER))
.then(() => apis.admin.nodes.createFiles([ fileAdmin ], `Sites/${siteName}/documentLibrary`))
.then(() => apis.admin.nodes.createFolders([ folderAdmin ], `Sites/${siteName}/documentLibrary`))
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES)
.then(() => dataTable.waitForHeader())
.then(() => dataTable.doubleClickOnItemName(siteName))
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
apis.admin.sites.deleteSite(siteName).then(done);
});
xit('');
describe('user is Manager', () => {
beforeAll(done => {
loginPage.loginWith(username).then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('actions are not displayed when no item is selected', () => {
expect(toolbar.actions.isEmpty()).toBe(true, `actions displayed though nothing selected`);
});
it('actions are displayed when a file is selected', () => {
dataTable.clickOnItemName(fileAdmin)
.then(() => {
expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${fileAdmin}`);
});
});
it('actions are displayed when a folder is selected', () => {
dataTable.clickOnItemName(folderAdmin)
.then(() => {
expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${folderAdmin}`);
});
});
it('correct actions appear when a file is selected', () => {
dataTable.clickOnItemName(fileAdmin)
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(true, `View is not displayed for ${fileAdmin}`);
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not displayed for ${fileAdmin}`);
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, `Edit is displayed for ${fileAdmin}`);
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for ${fileAdmin}`);
expect(menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for ${fileAdmin}`);
expect(menu.isMenuItemPresent('Move')).toBe(true, `Move is not displayed for ${fileAdmin}`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for ${fileAdmin}`);
})
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform());
});
it('correct actions appear when a folder is selected', () => {
dataTable.clickOnItemName(folderAdmin)
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(false, `View is displayed for ${folderAdmin}`);
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not enabled for ${folderAdmin}`);
expect(toolbar.actions.isButtonPresent('Edit')).toBe(true, `Edit is not displayed for ${folderAdmin}`);
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for ${folderAdmin}`);
expect(menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for ${folderAdmin}`);
expect(menu.isMenuItemPresent('Move')).toBe(true, `Move is not displayed for ${folderAdmin}`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for ${folderAdmin}`);
})
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform());
});
});
describe('user is Consumer', () => {
beforeAll(done => {
loginPage.loginWith(username2).then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('actions are not displayed when no item is selected', () => {
expect(toolbar.actions.isEmpty()).toBe(true, `actions displayed though nothing selected`);
});
it('actions are displayed when a file is selected', () => {
dataTable.clickOnItemName(fileAdmin)
.then(() => {
expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${fileAdmin}`);
});
});
it('actions are displayed when a folder is selected', () => {
dataTable.clickOnItemName(folderAdmin)
.then(() => {
expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${folderAdmin}`);
});
});
it('correct actions appear when a file is selected', () => {
dataTable.clickOnItemName(fileAdmin)
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(true, `View is not displayed for ${fileAdmin}`);
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not displayed for ${fileAdmin}`);
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, `Edit is displayed for ${fileAdmin}`);
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for ${fileAdmin}`);
expect(menu.isMenuItemPresent('Delete')).toBe(false, `Delete is displayed for ${fileAdmin}`);
expect(menu.isMenuItemPresent('Move')).toBe(false, `Move is displayed for ${fileAdmin}`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for ${fileAdmin}`);
})
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform());
});
it('correct actions appear when a folder is selected', () => {
dataTable.clickOnItemName(folderAdmin)
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(false, `View is displayed for ${folderAdmin}`);
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not enabled for ${folderAdmin}`);
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, `Edit is displayed for ${folderAdmin}`);
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for ${folderAdmin}`);
expect(menu.isMenuItemPresent('Delete')).toBe(false, `Delete is displayed for ${folderAdmin}`);
expect(menu.isMenuItemPresent('Move')).toBe(false, `Move is displayed for ${folderAdmin}`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for ${folderAdmin}`);
})
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform());
});
});
});
describe('Shared Files', () => {
beforeAll(done => {
loginPage.loginWith(username).then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('actions are not displayed when no item is selected', () => {
expect(toolbar.actions.isEmpty()).toBe(true, `actions displayed though nothing selected`);
});
it('actions are displayed when a file is selected', () => {
dataTable.clickOnItemName(fileUser)
.then(() => {
expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${fileUser}`);
});
});
it('correct actions appear when a file is selected', () => {
dataTable.clickOnItemName(fileUser)
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(true, `View is not displayed for ${fileUser}`);
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not displayed for ${fileUser}`);
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, `Edit is displayed for ${fileUser}`);
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for ${fileUser}`);
expect(menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for ${fileUser}`);
expect(menu.isMenuItemPresent('Move')).toBe(true, `Move is not displayed for ${fileUser}`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for ${fileUser}`);
})
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform());
});
});
describe('Recent Files', () => {
beforeAll(done => {
loginPage.loginWith(username).then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('actions are not displayed when no item is selected', () => {
expect(toolbar.actions.isEmpty()).toBe(true, `actions displayed though nothing selected`);
});
it('actions are displayed when a file is selected', () => {
dataTable.clickOnItemName(fileUser)
.then(() => {
expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${fileUser}`);
});
});
it('correct actions appear when a file is selected', () => {
dataTable.clickOnItemName(fileUser)
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(true, `View is not displayed for ${fileUser}`);
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not displayed for ${fileUser}`);
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, `Edit is displayed for ${fileUser}`);
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for ${fileUser}`);
expect(menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for ${fileUser}`);
expect(menu.isMenuItemPresent('Move')).toBe(true, `Move is not displayed for ${fileUser}`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for ${fileUser}`);
})
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform());
});
});
describe('Favorites', () => {
beforeAll(done => {
loginPage.loginWith(username).then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('actions are not displayed when no item is selected', () => {
expect(toolbar.actions.isEmpty()).toBe(true, `actions displayed though nothing selected`);
});
it('actions are displayed when a file is selected', () => {
dataTable.clickOnItemName(fileUser)
.then(() => {
expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${fileUser}`);
});
});
it('actions are displayed when a folder is selected', () => {
dataTable.clickOnItemName(folderUser)
.then(() => {
expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${folderUser}`);
});
});
it('correct actions appear when a file is selected', () => {
dataTable.clickOnItemName(fileUser)
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(true, `View is not displayed for ${fileUser}`);
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not displayed for ${fileUser}`);
expect(toolbar.actions.isButtonPresent('Edit')).toBe(false, `Edit is displayed for ${fileUser}`);
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for ${fileUser}`);
expect(menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for ${fileUser}`);
expect(menu.isMenuItemPresent('Move')).toBe(true, `Move is not displayed for ${fileUser}`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for ${fileUser}`);
})
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform());
});
it('correct actions appear when a folder is selected', () => {
dataTable.clickOnItemName(folderUser)
.then(() => {
expect(toolbar.actions.isButtonPresent('View')).toBe(false, `View is displayed for ${folderUser}`);
expect(toolbar.actions.isButtonPresent('Download')).toBe(true, `Download is not enabled for ${folderUser}`);
expect(toolbar.actions.isButtonPresent('Edit')).toBe(true, `Edit is not displayed for ${folderUser}`);
})
.then(() => toolbar.actions.openMoreMenu())
.then(menu => {
expect(menu.isMenuItemPresent('Copy')).toBe(true, `Copy is not displayed for ${folderUser}`);
expect(menu.isMenuItemPresent('Delete')).toBe(true, `Delete is not displayed for ${folderUser}`);
expect(menu.isMenuItemPresent('Move')).toBe(true, `Move is not displayed for ${folderUser}`);
expect(menu.isMenuItemPresent('Favorite')).toBe(true, `Favorite is not displayed for ${folderUser}`);
})
.then(() => browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform());
});
});
// [C217090]
describe('Trash', () => {
beforeAll(done => {
apis.user.nodes.deleteNodeById(fileForDeleteId, false)
.then(() => apis.user.nodes.deleteNodeById(folderForDeleteId, false))
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
Promise.all([
apis.user.trashcan.permanentlyDelete(fileForDeleteId),
apis.user.trashcan.permanentlyDelete(folderForDeleteId),
logoutPage.load()
])
.then(done);
});
it('actions are not displayed when no item is selected', () => {
expect(toolbar.actions.isEmpty()).toBe(true, `actions displayed though nothing selected`);
});
it('actions are displayed when a file is selected', () => {
dataTable.clickOnItemName(fileForDelete)
.then(() => {
expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${fileForDelete}`);
});
});
it('actions are displayed when a folder is selected', () => {
dataTable.clickOnItemName(folderForDelete)
.then(() => {
expect(toolbar.actions.isEmpty()).toBe(false, `actions not displayed for ${folderForDelete}`);
});
});
it('correct actions appear when a file is selected', () => {
dataTable.clickOnItemName(fileForDelete)
.then(() => {
expect(toolbar.actions.isButtonPresent('Permanently delete'))
.toBe(true, `Permanently delete is not displayed for ${fileForDelete}`);
expect(toolbar.actions.isButtonPresent('Restore')).toBe(true, `Restore is not displayed for ${fileForDelete}`);
});
});
it('correct actions appear when a folder is selected', () => {
dataTable.clickOnItemName(folderForDelete)
.then(() => {
expect(toolbar.actions.isButtonPresent('Permanently delete'))
.toBe(true, `Permanently delete is displayed for ${folderForDelete}`);
expect(toolbar.actions.isButtonPresent('Restore')).toBe(true, `Restore is not enabled for ${folderForDelete}`);
});
});
});
});

View File

@@ -0,0 +1,423 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from 'protractor';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { SIDEBAR_LABELS } from '../../configs';
import { RepoClient } from '../../utilities/repo-client/repo-client';
import { Utils } from '../../utilities/utils';
describe('Undo delete content', () => {
const username = `user-${Utils.random()}`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, toolbar } = page;
beforeAll(done => {
apis.admin.people.createUser(username).then(done);
});
afterAll(done => {
apis.admin.trashcan.emptyTrash().then(done);
});
xit('');
describe('on Personal Files', () => {
const file1 = `file1-${Utils.random()}.txt`; let file1Id;
const file2 = `file2-${Utils.random()}.txt`; let file2Id;
const file3 = `file3-${Utils.random()}.txt`; let file3Id;
const file4 = `file4-${Utils.random()}.txt`;
const folder1 = `folder1-${Utils.random()}`; let folder1Id;
const folder2 = `folder2-${Utils.random()}`; let folder2Id;
const fileLocked2 = `fileLocked2-${Utils.random()}.txt`; let fileLocked2Id;
beforeAll(done => {
apis.user.nodes.createFile(file1).then(resp => file1Id = resp.data.entry.id)
.then(() => apis.user.nodes.createFile(file2).then(resp => file2Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFile(file3).then(resp => file3Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFolder(folder1).then(resp => folder1Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFile(file4, folder1Id))
.then(() => apis.user.nodes.createFolder(folder2).then(resp => folder2Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFile(fileLocked2, folder2Id).then(resp => fileLocked2Id = resp.data.entry.id))
.then(() => apis.user.nodes.lockFile(fileLocked2Id))
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterEach(done => {
page.refresh().then(done);
});
afterAll(done => {
Promise.all([
logoutPage.load(),
apis.user.nodes.unlockFile(fileLocked2Id)
.then(() => apis.user.nodes.deleteNodesById([file1Id, file2Id, file3Id, folder1Id, folder2Id]))
])
.then(done);
});
it('Successful delete notification shows Undo action', () => {
dataTable.clickOnItemName(file1)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.getSnackBarMessage())
.then(message => {
expect(message).toContain(`Undo`);
})
.then(() => apis.user.trashcan.restore(file1Id));
});
it('Unsuccessful delete notification does not show Undo action', () => {
dataTable.clickOnItemName(folder2)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.getSnackBarMessage())
.then(message => {
expect(message).not.toContain(`Undo`);
});
});
it('Undo delete of file', () => {
let items: number;
page.dataTable.countRows().then(number => { items = number; });
dataTable.clickOnItemName(file1)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.clickSnackBarAction())
.then(() => {
expect(dataTable.getRowName(file1).isPresent()).toBe(true, 'Item was not restored');
expect(page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
});
});
it('Undo delete of folder with content', () => {
let items: number;
page.dataTable.countRows().then(number => { items = number; });
dataTable.clickOnItemName(folder1)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.clickSnackBarAction())
.then(() => {
expect(dataTable.getRowName(folder1).isPresent()).toBe(true, 'Item was not restored');
expect(page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
})
.then(() => dataTable.doubleClickOnItemName(folder1))
.then(() => {
expect(dataTable.getRowName(file4).isPresent()).toBe(true, 'file from folder not restored');
});
});
it('undo delete of multiple files', () => {
let items: number;
page.dataTable.countRows().then(number => { items = number; });
dataTable.selectMultipleItems([file2, file3])
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.clickSnackBarAction())
.then(() => {
expect(dataTable.getRowName(file2).isPresent()).toBe(true, `${file2} was not removed from list`);
expect(dataTable.getRowName(file3).isPresent()).toBe(true, `${file3} was not removed from list`);
expect(page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
});
});
});
describe('on Shared Files', () => {
const sharedFile1 = `sharedFile1-${Utils.random()}`; let sharedFile1Id;
const sharedFile2 = `sharedFile2-${Utils.random()}`; let sharedFile2Id;
const sharedFile3 = `sharedFile3-${Utils.random()}`; let sharedFile3Id;
const sharedFile4 = `sharedFile4-${Utils.random()}`; let sharedFile4Id;
beforeAll(done => {
apis.user.nodes.createFile(sharedFile1).then(resp => sharedFile1Id = resp.data.entry.id)
.then(() => apis.user.nodes.createFile(sharedFile2).then(resp => sharedFile2Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFile(sharedFile3).then(resp => sharedFile3Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFile(sharedFile4).then(resp => sharedFile4Id = resp.data.entry.id))
.then(() => apis.user.shared.shareFilesByIds([sharedFile1Id, sharedFile2Id, sharedFile3Id, sharedFile4Id]))
.then(() => apis.user.shared.waitForApi({ expect: 4 }))
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterEach(done => {
page.refresh().then(done);
});
afterAll(done => {
Promise.all([
logoutPage.load(),
apis.user.nodes.deleteNodesById([sharedFile2Id, sharedFile3Id, sharedFile4Id])
])
.then(done);
});
it('Successful delete notification shows Undo action', () => {
dataTable.clickOnItemName(sharedFile1)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.getSnackBarMessage())
.then(message => expect(message).toContain(`Undo`));
});
it('Undo delete of file', () => {
dataTable.clickOnItemName(sharedFile2)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.clickSnackBarAction())
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH))
.then(() => expect(dataTable.getRowName(sharedFile2).isPresent()).toBe(false, 'Item was not restored'));
});
it('undo delete of multiple files', () => {
dataTable.selectMultipleItems([sharedFile3, sharedFile4])
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.clickSnackBarAction())
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH))
.then(() => {
expect(dataTable.getRowName(sharedFile3).isPresent()).toBe(false, `${sharedFile3} was not restored`);
expect(dataTable.getRowName(sharedFile4).isPresent()).toBe(false, `${sharedFile4} was not restored`);
});
});
});
describe('on Favorites', () => {
const favoriteFile1 = `favFile1-${Utils.random()}.txt`; let favoriteFile1Id;
const favoriteFile2 = `favFile2-${Utils.random()}.txt`; let favoriteFile2Id;
const favoriteFile4 = `favFile4-${Utils.random()}.txt`;
const favoriteFileLocked2 = `favFileLocked2-${Utils.random()}.txt`; let favoriteFileLocked2Id;
const favoriteFolder1 = `favFolder1-${Utils.random()}`; let favoriteFolder1Id;
const favoriteFolder2 = `favFolder2-${Utils.random()}`; let favoriteFolder2Id;
beforeAll(done => {
apis.user.nodes.createFile(favoriteFile1).then(resp => favoriteFile1Id = resp.data.entry.id)
.then(() => apis.user.nodes.createFile(favoriteFile2).then(resp => favoriteFile2Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFolder(favoriteFolder1).then(resp => favoriteFolder1Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFile(favoriteFile4, favoriteFolder1Id))
.then(() => apis.user.nodes.createFolder(favoriteFolder2).then(resp => favoriteFolder2Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFile(favoriteFileLocked2, favoriteFolder2Id)
.then(resp => favoriteFileLocked2Id = resp.data.entry.id))
.then(() => apis.user.nodes.lockFile(favoriteFileLocked2Id))
.then(() => apis.user.favorites.addFavoritesByIds('file', [favoriteFile1Id, favoriteFile2Id]))
.then(() => apis.user.favorites.addFavoritesByIds('folder', [favoriteFolder1Id, favoriteFolder2Id]))
.then(() => apis.user.favorites.waitForApi({ expect: 4 }))
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterEach(done => {
page.refresh().then(done);
});
afterAll(done => {
Promise.all([
logoutPage.load(),
apis.user.nodes.unlockFile(favoriteFileLocked2Id)
.then(() => apis.user.nodes.deleteNodesById([favoriteFile1Id, favoriteFile2Id, favoriteFolder1Id, favoriteFolder2Id]))
])
.then(done);
});
it('Successful delete notification shows Undo action', () => {
dataTable.clickOnItemName(favoriteFile1)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.getSnackBarMessage())
.then(message => expect(message).toContain(`Undo`))
.then(() => apis.user.trashcan.restore(favoriteFile1Id));
});
it('Unsuccessful delete notification does not show Undo action', () => {
dataTable.clickOnItemName(favoriteFolder2)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.getSnackBarMessage())
.then(message => expect(message).not.toContain(`Undo`));
});
it('Undo delete of file', () => {
let items: number;
page.dataTable.countRows().then(number => { items = number; });
dataTable.clickOnItemName(favoriteFile1)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.clickSnackBarAction())
.then(() => {
expect(dataTable.getRowName(favoriteFile1).isPresent()).toBe(true, 'Item was not restored');
expect(page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
});
});
it('Undo delete of folder with content', () => {
let items: number;
page.dataTable.countRows().then(number => { items = number; });
dataTable.clickOnItemName(favoriteFolder1)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.clickSnackBarAction())
.then(() => {
expect(dataTable.getRowName(favoriteFolder1).isPresent()).toBe(true, 'Item was not restored');
expect(page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
})
.then(() => dataTable.doubleClickOnItemName(favoriteFolder1))
.then(() => expect(dataTable.getRowName(favoriteFile4).isPresent()).toBe(true, 'file from folder not restored'));
});
it('undo delete of multiple files', () => {
let items: number;
page.dataTable.countRows().then(number => { items = number; });
dataTable.selectMultipleItems([favoriteFile1, favoriteFile2])
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.clickSnackBarAction())
.then(() => {
expect(dataTable.getRowName(favoriteFile1).isPresent()).toBe(true, `${favoriteFile1} was not removed from list`);
expect(dataTable.getRowName(favoriteFile2).isPresent()).toBe(true, `${favoriteFile2} was not removed from list`);
expect(page.pagination.range.getText()).toContain(`1-${items} of ${items}`);
});
});
});
describe('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;
beforeAll(done => {
apis.user.nodes.createFile(recentFile1).then(resp => recentFile1Id = resp.data.entry.id)
.then(() => apis.user.nodes.createFile(recentFile2).then(resp => recentFile2Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFile(recentFile3).then(resp => recentFile3Id = resp.data.entry.id))
.then(() => apis.user.nodes.createFile(recentFile4).then(resp => recentFile4Id = resp.data.entry.id))
.then(() => apis.user.search.waitForApi(username, { expect: 4 }))
.then(() => loginPage.loginWith(username))
.then((): any => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES)
.then(() => dataTable.isEmptyList())
.then(empty => {
if (empty) {
browser.sleep(6000).then(() => page.refresh());
}
})
)
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterEach(done => {
page.refresh().then(done);
});
afterAll(done => {
Promise.all([
logoutPage.load(),
apis.user.nodes.deleteNodesById([recentFile2Id, recentFile3Id, recentFile4Id])
])
.then(done);
});
it('Successful delete notification shows Undo action', () => {
dataTable.clickOnItemName(recentFile1)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.getSnackBarMessage())
.then(message => expect(message).toContain(`Undo`));
});
// 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
it('Undo delete of file', () => {
dataTable.clickOnItemName(recentFile2)
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.clickSnackBarAction())
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH))
.then(() => expect(dataTable.getRowName(recentFile2).isPresent()).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
it('undo delete of multiple files', () => {
dataTable.selectMultipleItems([recentFile3, recentFile4])
.then(() => toolbar.actions.openMoreMenu())
.then(() => toolbar.actions.menu.clickMenuItem('Delete'))
.then(() => page.clickSnackBarAction())
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH))
.then(() => {
expect(dataTable.getRowName(recentFile3).isPresent()).toBe(false, `${recentFile3} is in Trash`);
expect(dataTable.getRowName(recentFile4).isPresent()).toBe(false, `${recentFile4} is in Trash`);
});
});
});
});

View File

@@ -0,0 +1,74 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
// import { browser, protractor, promise } from 'protractor';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { SIDEBAR_LABELS } from '../../configs';
import { RepoClient } from '../../utilities/repo-client/repo-client';
import { Utils } from '../../utilities/utils';
describe('Upload files', () => {
const username = `user-${Utils.random()}`;
const folder1 = `folder1-${Utils.random()}`; let folder1Id;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable } = page;
beforeAll(done => {
apis.admin.people.createUser(username)
.then(() => apis.user.nodes.createFolder(folder1).then(resp => folder1Id = resp.data.entry.id))
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
Promise.all([
// apis.user.nodes.deleteNodeById(folder1Id),
logoutPage.load()
])
.then(done);
});
it('Upload a file', () => {
dataTable.doubleClickOnItemName(folder1)
.then(() => page.sidenav.openNewMenu())
.then(() => page.sidenav.menu.uploadFile().sendKeys(`${__dirname}/create-folder.test.ts`));
});
});

View File

@@ -0,0 +1,128 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from 'protractor';
import { SIDEBAR_LABELS } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
describe('Page titles', () => {
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
xit('');
describe('on Login / Logout pages', () => {
it('on Login page', () => {
loginPage.load()
.then(() => {
expect(browser.getTitle()).toContain('Sign in');
});
});
it('after logout', () => {
loginPage.loginWithAdmin()
.then(() => page.signOut())
.then(() => {
expect(browser.getTitle()).toContain('Sign in');
});
});
it('when pressing Back after Logout', () => {
loginPage.loginWithAdmin()
.then(() => page.signOut())
.then(() => browser.navigate().back())
.then(() => {
expect(browser.getTitle()).toContain('Sign in');
});
});
});
describe('on list views', () => {
beforeAll(done => {
loginPage.loginWithAdmin().then(done);
});
afterAll(done => {
logoutPage.load()
.then(done);
});
it('Personal Files page', () => {
const label = SIDEBAR_LABELS.PERSONAL_FILES;
page.sidenav.navigateToLinkByLabel(label)
.then(() => {
expect(browser.getTitle()).toContain(label);
});
});
it('File Libraries page', () => {
const label = SIDEBAR_LABELS.FILE_LIBRARIES;
page.sidenav.navigateToLinkByLabel(label)
.then(() => {
expect(browser.getTitle()).toContain(label);
});
});
it('Shared Files page', () => {
const label = SIDEBAR_LABELS.SHARED_FILES;
page.sidenav.navigateToLinkByLabel(label)
.then(() => {
expect(browser.getTitle()).toContain(label);
});
});
it('Recent Files page', () => {
const label = SIDEBAR_LABELS.RECENT_FILES;
page.sidenav.navigateToLinkByLabel(label)
.then(() => {
expect(browser.getTitle()).toContain(label);
});
});
it('Favorites page', () => {
const label = SIDEBAR_LABELS.FAVORITES;
page.sidenav.navigateToLinkByLabel(label)
.then(() => {
expect(browser.getTitle()).toContain(label);
});
});
it('Trash page', () => {
const label = SIDEBAR_LABELS.TRASH;
page.sidenav.navigateToLinkByLabel(label)
.then(() => {
expect(browser.getTitle()).toContain(label);
});
});
});
});

View File

@@ -0,0 +1,237 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from 'protractor';
import { APP_ROUTES } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Login', () => {
const peopleApi = new RepoClient().people;
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const testUser = `user-${Utils.random()}@alfness`;
const russianUser = {
username: `пользвате${Utils.random()}`,
password: '密碼中國'
};
const johnDoe = {
username: `user-${Utils.random()}`,
get password() { return this.username; },
firstName: 'John',
lastName: 'Doe'
};
const disabledUser = `user-${Utils.random()}`;
const testUser2 = {
username: `user-${Utils.random()}`,
password: 'user2 password'
};
const newPassword = 'new password';
beforeAll(done => {
Promise
.all([
peopleApi.createUser(testUser),
peopleApi.createUser(russianUser.username, russianUser.password),
peopleApi.createUser(johnDoe.username, johnDoe.password, {
firstName: johnDoe.firstName,
lastName: johnDoe.lastName
}),
peopleApi.createUser(disabledUser).then(() => peopleApi.disableUser(disabledUser)),
peopleApi.createUser(testUser2.username, testUser2.password)
])
.then(done);
});
afterEach(done => {
logoutPage.load()
.then(() => Utils.clearLocalStorage())
.then(done);
});
xit('');
describe('general tests', () => {
beforeEach(done => {
loginPage.load().then(done);
});
it('login page default values', () => {
expect(loginPage.login.usernameInput.isEnabled()).toBe(true, 'username input is not enabled');
expect(loginPage.login.passwordInput.isEnabled()).toBe(true, 'password input is not enabled');
expect(loginPage.login.submitButton.isEnabled()).toBe(false, 'SIGN IN button is enabled');
expect(loginPage.login.getPasswordVisibility()).toBe(false, 'Password is not hidden by default');
});
it('change password visibility', () => {
loginPage.login.enterPassword('some password');
expect(loginPage.login.isPasswordShown()).toBe(false, 'password is visible');
loginPage.login.passwordVisibility.click()
.then(() => {
expect(loginPage.login.getPasswordVisibility()).toBe(true, 'Password visibility not changed');
expect(loginPage.login.isPasswordShown()).toBe(true, 'password is not visible');
});
});
});
describe('with valid credentials', () => {
it('navigate to "Personal Files"', () => {
const { username } = johnDoe;
loginPage.loginWith(username)
.then(() => {
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.PERSONAL_FILES);
});
});
it(`displays user's name in header`, () => {
const { userInfo } = new BrowsingPage(APP_ROUTES.PERSONAL_FILES).header;
const { username, firstName, lastName } = johnDoe;
loginPage.loginWith(username)
.then(() => {
expect(userInfo.name).toEqual(`${firstName} ${lastName}`);
});
});
it(`logs in with user having username containing "@"`, () => {
loginPage
.loginWith(testUser)
.then(() => {
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.PERSONAL_FILES);
});
});
it('logs in with user with non-latin characters', () => {
const { username, password } = russianUser;
loginPage
.loginWith(username, password)
.then(() => {
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.PERSONAL_FILES);
});
});
it('redirects to Home Page when navigating to the Login page while already logged in', () => {
const { username } = johnDoe;
loginPage
.loginWith(username)
.then(() => browser.get(APP_ROUTES.LOGIN)
.then(() => {
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.PERSONAL_FILES);
})
);
});
it('redirects to Personal Files when pressing browser Back while already logged in ', () => {
const { username } = johnDoe;
loginPage
.loginWith(username)
.then(() => browser.navigate().back())
.then(() => {
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.PERSONAL_FILES);
});
});
it('user is able to login after changing his password', () => {
loginPage.loginWith(testUser2.username, testUser2.password)
.then(() => logoutPage.load())
.then(() => peopleApi.changePassword(testUser2.username, newPassword))
.then(() => loginPage.loginWith(testUser2.username, newPassword))
.then(() => {
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.PERSONAL_FILES);
});
});
});
describe('with invalid credentials', () => {
const { login: loginComponent } = loginPage;
const { submitButton, errorMessage } = loginComponent;
beforeEach(done => {
loginPage.load().then(done);
});
it('disabled submit button when no credentials are entered', () => {
expect(submitButton.isEnabled()).toBe(false);
});
it('disabled submit button when password is empty', () => {
loginComponent.enterUsername('any-username');
expect(submitButton.isEnabled()).toBe(false);
});
it('disabled submit button when username is empty', () => {
loginPage.login.enterPassword('any-password');
expect(submitButton.isEnabled()).toBe(false);
});
it('shows error when entering nonexistent user', () => {
loginPage
.tryLoginWith('nonexistent-user', 'any-password')
.then(() => {
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.LOGIN);
expect(errorMessage.isDisplayed()).toBe(true);
expect(errorMessage.getText()).toBe(`You've entered an unknown username or password`);
});
});
it('shows error when entering invalid password', () => {
const { username } = johnDoe;
loginPage
.tryLoginWith(username, 'incorrect-password')
.then(() => {
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.LOGIN);
expect(errorMessage.isDisplayed()).toBe(true);
expect(errorMessage.getText()).toBe(`You've entered an unknown username or password`);
});
});
it('unauthenticated user is redirected to Login page', () => {
browser.get(APP_ROUTES.PERSONAL_FILES)
.then(() => {
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.LOGIN);
});
});
it('disabled user is not logged in', () => {
loginPage.tryLoginWith(disabledUser)
.then(() => {
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.LOGIN);
expect(errorMessage.isDisplayed()).toBe(true);
expect(errorMessage.getText()).toBe(`You've entered an unknown username or password`);
});
});
});
});

View File

@@ -0,0 +1,82 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from 'protractor';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
import { APP_ROUTES } from '../../configs';
describe('Logout', () => {
const page = new BrowsingPage();
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const peopleApi = new RepoClient().people;
const johnDoe = `user-${Utils.random()}`;
beforeAll((done) => {
peopleApi
.createUser(johnDoe)
.then(done);
});
beforeEach((done) => {
loginPage.loginWith(johnDoe).then(done);
});
afterEach((done) => {
logoutPage.load().then(done);
});
it('Sign out option is available [C213143]', () => {
page.header.userInfo.openMenu()
.then(() => expect(page.header.userInfo.menu.isMenuItemPresent('Sign out')).toBe(true, 'Sign out option not displayed'));
});
it('redirects to Login page on sign out [C213144]', () => {
page.signOut()
.then(() => {
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.LOGIN);
});
});
it('redirects to Login page when pressing browser Back after logout [C213145]', () => {
page.signOut()
.then(() => browser.navigate().back())
.then(() => {
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.LOGIN);
});
});
it('redirects to Login page when trying to access a part of the app after logout [C213146]', () => {
page.signOut()
.then(() => page.load('/favorites'))
.then(() => {
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.LOGIN);
});
});
});

View File

@@ -0,0 +1,108 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { SIDEBAR_LABELS } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Empty list views', () => {
const username = `user-${Utils.random()}`;
const password = username;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, password)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable } = page;
beforeAll(done => {
apis.admin.people.createUser(username)
.then(() => loginPage.loginWith(username))
.then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('empty Personal Files', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => {
expect(dataTable.isEmptyList()).toBe(true, 'list is not empty');
expect(dataTable.getEmptyDragAndDropText()).toContain('Drag and drop');
});
});
it('empty File Libraries [C217099]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES)
.then(() => {
expect(dataTable.isEmptyList()).toBe(true, 'list is not empty');
expect(dataTable.getEmptyStateTitle()).toContain(`You aren't a member of any File Libraries yet`);
expect(dataTable.getEmptyStateSubtitle()).toContain('Join sites to upload, view, and share files.');
});
});
it('empty Shared Files', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES)
.then(() => {
expect(dataTable.isEmptyList()).toBe(true, 'list is not empty');
expect(dataTable.getEmptyStateTitle()).toContain('No shared files or folders');
expect(dataTable.getEmptyStateSubtitle()).toContain('Items you share using the Share option are shown here.');
});
});
it('empty Recent Files [C213169]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES)
.then(() => {
expect(dataTable.isEmptyList()).toBe(true, 'list is not empty');
expect(dataTable.getEmptyStateTitle()).toContain('No recent files');
expect(dataTable.getEmptyStateSubtitle()).toContain('Items you upload or edit in the last 30 days are shown here.');
});
});
it('empty Favorites', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES)
.then(() => {
expect(dataTable.isEmptyList()).toBe(true, 'list is not empty');
expect(dataTable.getEmptyStateTitle()).toContain('No favorite files or folders');
expect(dataTable.getEmptyStateSubtitle()).toContain('Favorite items that you want to easily find later.');
});
});
it('empty Trash', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH)
.then(() => {
expect(dataTable.isEmptyList()).toBe(true, 'list is not empty');
expect(dataTable.getEmptyStateTitle()).toContain('Trash is empty');
expect(dataTable.getEmptyStateText()).toContain('Items you delete are moved to the Trash.');
expect(dataTable.getEmptyStateText()).toContain('Empty Trash to permanently delete items.');
});
});
});

View File

@@ -0,0 +1,156 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { SITE_VISIBILITY, SITE_ROLES, SIDEBAR_LABELS } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Favorites', () => {
const username = `user-${Utils.random()}`;
const password = username;
const siteName = `site-${Utils.random()}`;
const folderName = `folder-${Utils.random()}`;
const fileName1 = `file1-${Utils.random()}.txt`;
const fileName2 = `file2-${Utils.random()}.txt`;
const fileName3 = `file3-${Utils.random()}.txt`; let file3Id;
const fileName4 = `file4-${Utils.random()}.txt`; let file4Id;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, password)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const favoritesPage = new BrowsingPage();
const { dataTable } = favoritesPage;
const { breadcrumb } = favoritesPage.toolbar;
beforeAll(done => {
apis.admin.people.createUser(username)
.then(() => apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC))
.then(() => apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_MANAGER))
.then(() => apis.admin.nodes.createFiles([ fileName1 ], `Sites/${siteName}/documentLibrary`)
.then(resp => apis.user.favorites.addFavoriteById('file', resp.data.entry.id)))
.then(() => apis.user.nodes.createFolders([ folderName ])
.then(resp => apis.user.favorites.addFavoriteById('folder', resp.data.entry.id)))
.then(() => apis.user.nodes.createFiles([ fileName2 ], folderName)
.then(resp => apis.user.favorites.addFavoriteById('file', resp.data.entry.id)))
.then(() => apis.user.nodes.createFiles([ fileName3 ], folderName)
.then(resp => file3Id = resp.data.entry.id)
.then(() => apis.user.favorites.addFavoriteById('file', file3Id))
.then(() => apis.user.nodes.deleteNodeById(file3Id, false)))
.then(() => apis.user.nodes.createFiles([ fileName4 ], folderName)
.then(resp => file4Id = resp.data.entry.id)
.then(() => apis.user.favorites.addFavoriteById('file', file4Id))
.then(() => apis.user.nodes.deleteNodeById(file4Id, false))
.then(() => apis.user.trashcan.restore(file4Id)))
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
favoritesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
Promise.all([
apis.admin.sites.deleteSite(siteName),
apis.user.nodes.deleteNodes([ folderName ]),
apis.admin.trashcan.emptyTrash(),
logoutPage.load()
])
.then(done);
});
it('has the correct columns', () => {
const labels = [ 'Name', 'Location', 'Size', 'Modified', 'Modified by' ];
const elements = labels.map(label => dataTable.getColumnHeaderByLabel(label));
expect(dataTable.getColumnHeaders().count()).toBe(5 + 1, 'Incorrect number of columns');
elements.forEach((element, index) => {
expect(element.isPresent()).toBe(true, `"${labels[index]}" is missing`);
});
});
it('displays the favorite files and folders [C213226]', () => {
expect(dataTable.countRows()).toEqual(4, 'Incorrect number of items displayed');
expect(dataTable.getRowName(fileName1).isPresent()).toBe(true, `${fileName1} not displayed`);
expect(dataTable.getRowName(fileName2).isPresent()).toBe(true, `${fileName2} not displayed`);
expect(dataTable.getRowName(folderName).isPresent()).toBe(true, `${folderName} not displayed`);
});
it(`file not displayed if it's in the Trashcan [C213228]`, () => {
expect(dataTable.getRowName(fileName3).isPresent()).not.toBe(true, `${fileName3} is displayed`);
});
it(`file is displayed after it is restored from Trashcan [C213229]`, () => {
expect(dataTable.getRowName(fileName4).isPresent()).toBe(true, `${fileName4} not displayed`);
});
it('Location column displays the parent folder of the files [C213231]', () => {
expect(dataTable.getItemLocation(fileName1).getText()).toEqual(siteName);
expect(dataTable.getItemLocation(fileName2).getText()).toEqual(folderName);
expect(dataTable.getItemLocation(folderName).getText()).toEqual('Personal Files');
});
it('Location column displays a tooltip with the entire path of the file [C213671]', () => {
expect(dataTable.getItemLocationTooltip(fileName1)).toEqual(`File Libraries/${siteName}`);
expect(dataTable.getItemLocationTooltip(fileName2)).toEqual(`Personal Files/${folderName}`);
expect(dataTable.getItemLocationTooltip(folderName)).toEqual('Personal Files');
});
it('Location column redirect - item in user Home [C213650] [C260968]', () => {
dataTable.clickItemLocation(folderName)
.then(() => expect(breadcrumb.getAllItems()).toEqual([ 'Personal Files' ]));
});
it('Location column redirect - file in folder [C213650] [C260968]', () => {
dataTable.clickItemLocation(fileName2)
.then(() => expect(breadcrumb.getAllItems()).toEqual([ 'Personal Files', folderName ]));
});
it('Location column redirect - file in site [C213650] [C260969]', () => {
dataTable.clickItemLocation(fileName1)
.then(() => expect(breadcrumb.getAllItems()).toEqual([ 'File Libraries', siteName ]));
});
it('Navigate into folder from Favorites [C213230]', () => {
dataTable.doubleClickOnItemName(folderName)
.then(() => dataTable.waitForHeader())
.then(() => breadcrumb.getCurrentItemName())
.then(name => {
expect(name).toBe(folderName);
});
});
});

View File

@@ -0,0 +1,161 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { by } from 'protractor';
import { SITE_VISIBILITY, SITE_ROLES, SIDEBAR_LABELS } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('File Libraries', () => {
const username = `user-${Utils.random()}`;
const password = username;
const sitePrivate = `private-${Utils.random()}`;
const siteModerated = `moderated-${Utils.random()}`;
const sitePublic = `public-${Utils.random()}`;
const siteName = `siteName-${Utils.random()}`;
const siteId1 = Utils.random();
const siteId2 = Utils.random();
const adminSite = `admin-${Utils.random()}`;
const siteDescription = 'my site description';
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, password)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const fileLibrariesPage = new BrowsingPage();
const { dataTable } = fileLibrariesPage;
beforeAll(done => {
Promise
.all([
apis.admin.people.createUser(username),
apis.admin.sites.createSite(sitePublic, SITE_VISIBILITY.PUBLIC),
apis.admin.sites.createSite(siteModerated, SITE_VISIBILITY.MODERATED, { description: siteDescription }),
apis.admin.sites.createSite(sitePrivate, SITE_VISIBILITY.PRIVATE, { description: '' }),
apis.admin.sites.createSite(adminSite, SITE_VISIBILITY.PUBLIC),
apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC, { id: siteId1 }),
apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC, { id: siteId2 })
])
.then(() => apis.admin.sites.addSiteMember(sitePublic, username, SITE_ROLES.SITE_CONSUMER))
.then(() => apis.admin.sites.addSiteMember(siteModerated, username, SITE_ROLES.SITE_MANAGER))
.then(() => apis.admin.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_CONTRIBUTOR))
.then(() => apis.admin.sites.addSiteMember(siteId1, username, SITE_ROLES.SITE_CONTRIBUTOR))
.then(() => apis.admin.sites.addSiteMember(siteId2, username, SITE_ROLES.SITE_CONTRIBUTOR))
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
fileLibrariesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
Promise.all([
apis.admin.sites.deleteSites([
sitePublic,
siteModerated,
sitePrivate,
adminSite,
siteId1,
siteId2
]),
logoutPage.load()
])
.then(done);
});
it('has the correct columns', () => {
const labels = [ 'Title', 'Status' ];
const elements = labels.map(label => dataTable.getColumnHeaderByLabel(label));
expect(dataTable.getColumnHeaders().count()).toBe(2 + 1, 'Incorrect number of columns');
elements.forEach((element, index) => {
expect(element.isPresent()).toBe(true, `"${labels[index]}" is missing`);
});
});
it('User can see only the sites he is a member of [C217095]', () => {
const sitesCount = dataTable.countRows();
const expectedSites = {
[sitePrivate]: SITE_VISIBILITY.PRIVATE,
[siteModerated]: SITE_VISIBILITY.MODERATED,
[sitePublic]: SITE_VISIBILITY.PUBLIC
};
expect(sitesCount).toEqual(5, 'Incorrect number of sites displayed');
expect(dataTable.getRowName(adminSite).isPresent()).toBe(false, 'Incorrect site appears in list');
dataTable.getRows()
.map((row) => {
return row.all(dataTable.cell).map(cell => cell.getText());
})
.then((rowCells) => {
return rowCells.reduce((acc, cell) => {
acc[cell[1]] = cell[2].toUpperCase();
return acc;
}, {});
})
.then((sitesList) => {
Object.keys(expectedSites).forEach((site) => {
expect(sitesList[site]).toEqual(expectedSites[site]);
});
});
});
it('Site ID is displayed when two sites have the same name [C217098]', () => {
const expectedSites = [
`${siteName} (${siteId1})`,
`${siteName} (${siteId2})`
];
dataTable.getCellsContainingName(siteName)
.then(resp => {
const expectedJSON = JSON.stringify(expectedSites.sort());
const actualJSON = JSON.stringify(resp.sort());
expect(actualJSON).toEqual(expectedJSON);
});
});
it('Tooltip for sites without description [C217096]', () => {
const tooltip = dataTable.getItemNameTooltip(sitePrivate);
expect(tooltip).toBe(`${sitePrivate}`);
});
it('Tooltip for sites with description [C217097]', () => {
const tooltip = dataTable.getItemNameTooltip(siteModerated);
expect(tooltip).toBe(`${siteDescription}`);
});
});

View File

@@ -0,0 +1,181 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { SITE_VISIBILITY, SITE_ROLES, SIDEBAR_LABELS } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Special permissions', () => {
const username = `user-${Utils.random()}`;
const password = username;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, password)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const recentFilesPage = new BrowsingPage();
const favoritesPage = new BrowsingPage();
const sharedPage = new BrowsingPage();
const { dataTable } = recentFilesPage;
xit('');
beforeAll(done => {
apis.admin.people.createUser(username).then(done);
});
describe('file not displayed if user no longer has permissions on it', () => {
const sitePrivate = `private-${Utils.random()}`;
const fileName = `file-${Utils.random()}.txt`;
let fileId;
beforeAll(done => {
apis.admin.sites.createSite(sitePrivate, SITE_VISIBILITY.PRIVATE)
.then(() => apis.admin.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_COLLABORATOR))
.then(() => apis.admin.nodes.createFiles([ fileName ], `Sites/${sitePrivate}/documentLibrary`)
.then(resp => fileId = resp.data.entry.id))
.then(() => apis.user.favorites.addFavoriteById('file', fileId))
.then(() => apis.admin.shared.shareFileById(fileId))
.then(() => apis.user.nodes.editNodeContent(fileId, 'edited by user'))
.then(() => apis.user.search.waitForApi(username, { expect: 1 }))
.then(() => apis.user.shared.waitForApi({ expect: 1 }))
.then(() => loginPage.loginWith(username))
.then(done);
});
afterEach(done => {
apis.admin.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_COLLABORATOR).then(done);
});
afterAll(done => {
Promise.all([
apis.admin.sites.deleteSite(sitePrivate),
logoutPage.load()
])
.then(done);
});
it('on Recent Files [C213173]', () => {
recentFilesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES)
.then(() => dataTable.waitForHeader())
.then(() => {
expect(dataTable.countRows()).toBe(1, 'Incorrect number of items');
})
.then(() => apis.admin.sites.deleteSiteMember(sitePrivate, username))
.then(() => recentFilesPage.refresh())
.then(() => {
expect(dataTable.countRows()).toBe(0, 'Incorrect number of items');
});
});
it('on Favorites [C213227]', () => {
favoritesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES)
.then(() => dataTable.waitForHeader())
.then(() => {
expect(dataTable.countRows()).toBe(1, 'Incorrect number of items');
})
.then(() => apis.admin.sites.deleteSiteMember(sitePrivate, username))
.then(() => favoritesPage.refresh())
.then(() => {
expect(dataTable.countRows()).toBe(0, 'Incorrect number of items');
});
});
it('on Shared Files [C213116]', () => {
sharedPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES)
.then(() => dataTable.waitForHeader())
.then(() => {
expect(dataTable.countRows()).toBe(1, 'Incorrect number of items');
})
.then(() => apis.admin.sites.deleteSiteMember(sitePrivate, username))
.then(() => sharedPage.refresh())
.then(() => {
expect(dataTable.countRows()).toBe(0, 'Incorrect number of items');
});
});
});
describe(`Location column is empty if user doesn't have permissions on the file's parent folder`, () => {
const sitePrivate = `private-${Utils.random()}`;
const fileName = `file-${Utils.random()}.txt`;
let fileId;
beforeAll(done => {
apis.admin.sites.createSite(sitePrivate, SITE_VISIBILITY.PRIVATE)
.then(() => apis.admin.sites.addSiteMember(sitePrivate, username, SITE_ROLES.SITE_COLLABORATOR))
.then(() => apis.admin.sites.getDocLibId(sitePrivate))
.then(resp => apis.user.nodes.createFile(fileName, resp))
.then(resp => fileId = resp.data.entry.id)
.then(() => apis.user.favorites.addFavoriteById('file', fileId))
.then(() => apis.user.shared.shareFileById(fileId))
.then(() => apis.user.shared.waitForApi({ expect: 1 }))
.then(() => apis.user.search.waitForApi(username, { expect: 1 }))
.then(() => apis.admin.sites.deleteSiteMember(sitePrivate, username))
.then(() => loginPage.loginWith(username))
.then(done);
});
afterAll(done => {
Promise.all([
apis.admin.sites.deleteSite(sitePrivate),
logoutPage.load()
])
.then(done);
});
it(`on Recent Files [C213178]`, () => {
recentFilesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES)
.then(() => dataTable.waitForHeader())
.then(() => {
expect(dataTable.countRows()).toBe(1, 'Incorrect number of items');
expect(dataTable.getItemLocation(fileName).getText()).toEqual('');
});
});
it(`on Favorites [C213672]`, () => {
favoritesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES)
.then(() => dataTable.waitForHeader())
.then(() => {
expect(dataTable.countRows()).toBe(1, 'Incorrect number of items');
expect(dataTable.getItemLocation(fileName).getText()).toEqual('');
});
});
it(`on Shared Files [C213668]`, () => {
sharedPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES)
.then(() => dataTable.waitForHeader())
.then(() => {
expect(dataTable.countRows()).toBe(1, 'Incorrect number of items');
expect(dataTable.getItemLocation(fileName).getText()).toEqual('');
});
});
});
});

View File

@@ -0,0 +1,176 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from 'protractor';
import { SIDEBAR_LABELS, APP_ROUTES } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Personal Files', () => {
const username = `user-${Utils.random()}`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const personalFilesPage = new BrowsingPage();
const { dataTable } = personalFilesPage;
const adminFolder = `admin-folder-${Utils.random()}`;
const userFolder = `user-folder-${Utils.random()}`;
const userFile = `file-${Utils.random()}.txt`;
beforeAll(done => {
Promise
.all([
apis.admin.people.createUser(username),
apis.admin.nodes.createFolders([ adminFolder ])
])
.then(() => apis.user.nodes.createFolders([ userFolder ]))
.then(() => apis.user.nodes.createFiles([ userFile ], userFolder))
.then(done);
});
afterAll(done => {
Promise
.all([
apis.admin.nodes.deleteNodes([ adminFolder ]),
apis.user.nodes.deleteNodes([ userFolder ])
])
.then(done);
});
xit('');
describe(`Admin user's personal files`, () => {
beforeAll(done => {
loginPage.loginWithAdmin().then(done);
});
beforeEach(done => {
personalFilesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('has "Data Dictionary" folder [C213241]', () => {
expect(dataTable.getRowName('Data Dictionary').isPresent()).toBe(true);
});
it('has created content', () => {
expect(dataTable.getRowName(adminFolder).isPresent()).toBe(true);
});
});
describe(`Regular user's personal files`, () => {
beforeAll(done => {
loginPage.loginWith(username).then(done);
});
beforeEach(done => {
personalFilesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('has the correct columns [C217142]', () => {
const labels = [ 'Name', 'Size', 'Modified', 'Modified by' ];
const elements = labels.map(label => dataTable.getColumnHeaderByLabel(label));
expect(dataTable.getColumnHeaders().count()).toBe(4 + 1, 'Incorrect number of columns');
elements.forEach((element, index) => {
expect(element.isPresent()).toBe(true, `"${labels[index]}" is missing`);
});
});
it('has default sorted column [C217143]', () => {
expect(dataTable.getSortedColumnHeader().getText()).toBe('Modified');
});
it('has user created content [C213242]', () => {
expect(dataTable.getRowName(userFolder).isPresent())
.toBe(true);
});
it('navigates to folder [C213244]', () => {
const getNodeIdPromise = apis.user.nodes
.getNodeByPath(`/${userFolder}`)
.then(response => response.data.entry.id);
const navigatePromise = dataTable
.doubleClickOnItemName(userFolder)
.then(() => dataTable.waitForHeader());
Promise
.all([
getNodeIdPromise,
navigatePromise
])
.then(([ nodeId ]) => {
expect(browser.getCurrentUrl())
.toContain(nodeId, 'Node ID is not in the URL');
expect(dataTable.getRowName(userFile).isPresent())
.toBe(true, 'user file is missing');
});
});
it('redirects to Personal Files on clicking the link from sidebar [C213245]', () => {
personalFilesPage.dataTable.doubleClickOnItemName(userFolder)
.then(() => personalFilesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES))
.then(() => browser.getCurrentUrl())
.then(url => expect(url.endsWith(APP_ROUTES.PERSONAL_FILES)).toBe(true, 'incorrect url'));
});
it('page loads correctly after browser refresh [C213246]', () => {
personalFilesPage.refresh()
.then(() => expect(browser.getCurrentUrl()).toContain(APP_ROUTES.PERSONAL_FILES));
});
it('page load by URL [C213247]', () => {
let url;
browser.getCurrentUrl()
.then(resp => url = resp)
.then(() => personalFilesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH))
.then(() => browser.get(url))
.then(() => expect(browser.getCurrentUrl()).toContain(APP_ROUTES.PERSONAL_FILES));
});
});
});

View File

@@ -0,0 +1,141 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { SITE_VISIBILITY, SIDEBAR_LABELS } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Recent Files', () => {
const username = `user-${Utils.random()}`;
const folderName = `folder-${Utils.random()}`; let folderId;
const fileName1 = `file-${Utils.random()}.txt`;
const fileName2 = `file-${Utils.random()}.txt`; let file2Id;
const fileName3 = `file-${Utils.random()}.txt`;
const siteName = `site-${Utils.random()}`;
const folderSite = `folder2-${Utils.random()}`; let folderSiteId;
const fileSite = `file-${Utils.random()}.txt`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const recentFilesPage = new BrowsingPage();
const { dataTable } = recentFilesPage;
const { breadcrumb } = recentFilesPage.toolbar;
beforeAll(done => {
apis.admin.people.createUser(username)
.then(() => apis.user.nodes.createFolders([ folderName ])).then(resp => folderId = resp.data.entry.id)
.then(() => apis.user.nodes.createFiles([ fileName1 ], folderName))
.then(() => apis.user.nodes.createFiles([ fileName2 ])).then(resp => file2Id = resp.data.entry.id)
.then(() => apis.user.nodes.createFiles([ fileName3 ]).then(resp => apis.user.nodes.deleteNodeById(resp.data.entry.id, false)))
.then(() => apis.user.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC))
.then(() => apis.user.sites.getDocLibId(siteName))
.then(resp => apis.user.nodes.createFolder(folderSite, resp)).then(resp => folderSiteId = resp.data.entry.id)
.then(() => apis.user.nodes.createFile(fileSite, folderSiteId))
.then(() => apis.user.search.waitForApi(username, { expect: 3 }))
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
recentFilesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
Promise.all([
apis.user.nodes.deleteNodesById([ folderId, file2Id ]),
apis.user.sites.deleteSite(siteName),
apis.admin.trashcan.emptyTrash(),
logoutPage.load()
])
.then(done);
});
it('has the correct columns [C213168]', () => {
const labels = [ 'Name', 'Location', 'Size', 'Modified' ];
const elements = labels.map(label => dataTable.getColumnHeaderByLabel(label));
expect(dataTable.getColumnHeaders().count()).toBe(4 + 1, 'Incorrect number of columns');
elements.forEach((element, index) => {
expect(element.isPresent()).toBe(true, `"${labels[index]}" is missing`);
});
});
it('default sorting column [C213171]', () => {
expect(dataTable.getSortedColumnHeader().getText()).toBe('Modified');
expect(dataTable.getSortingOrder()).toBe('desc');
});
it('displays the files added by the current user in the last 30 days [C213170]', () => {
expect(dataTable.countRows()).toEqual(3, 'Incorrect number of files displayed');
expect(dataTable.getRowName(fileName1).isPresent()).toBe(true, `${fileName1} not displayed`);
expect(dataTable.getRowName(fileName2).isPresent()).toBe(true, `${fileName2} not displayed`);
expect(dataTable.getRowName(fileSite).isPresent()).toBe(true, `${fileSite} not displayed`);
});
it(`file not displayed if it's in the Trashcan [C213174]`, () => {
expect(dataTable.getRowName(fileName3).isPresent()).not.toBe(true, `${fileName3} is displayed`);
});
it('Location column displays the parent folder of the file [C213175]', () => {
expect(dataTable.getItemLocation(fileName1).getText()).toEqual(folderName);
expect(dataTable.getItemLocation(fileName2).getText()).toEqual('Personal Files');
expect(dataTable.getItemLocation(fileSite).getText()).toEqual(folderSite);
});
it('Location column displays a tooltip with the entire path of the file [C213177]', () => {
expect(dataTable.getItemLocationTooltip(fileName1)).toEqual(`Personal Files/${folderName}`);
expect(dataTable.getItemLocationTooltip(fileName2)).toEqual('Personal Files');
expect(dataTable.getItemLocationTooltip(fileSite)).toEqual(`File Libraries/${siteName}/${folderSite}`);
});
it('Location column redirect - file in user Home [C213176] [C260968]', () => {
dataTable.clickItemLocation(fileName2)
.then(() => expect(breadcrumb.getAllItems()).toEqual([ 'Personal Files' ]));
});
it('Location column redirect - file in folder [C213176] [C260968]', () => {
dataTable.clickItemLocation(fileName1)
.then(() => expect(breadcrumb.getAllItems()).toEqual([ 'Personal Files', folderName ]));
});
it('Location column redirect - file in site [C213176] [C260969]', () => {
dataTable.clickItemLocation(fileSite)
.then(() => expect(breadcrumb.getAllItems()).toEqual([ 'File Libraries', siteName, folderSite ]));
});
});

View File

@@ -0,0 +1,142 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { SITE_VISIBILITY, SITE_ROLES, SIDEBAR_LABELS } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Shared Files', () => {
const username = `user-${Utils.random()}`;
const password = username;
const siteName = `site-${Utils.random()}`;
const fileAdmin = `file-${Utils.random()}.txt`;
const folderUser = `folder-${Utils.random()}`;
const file1User = `file1-${Utils.random()}.txt`; let file1Id;
const file2User = `file2-${Utils.random()}.txt`; let file2Id;
const file3User = `file3-${Utils.random()}.txt`; let file3Id;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, password)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const sharedFilesPage = new BrowsingPage();
const { dataTable } = sharedFilesPage;
const { breadcrumb } = sharedFilesPage.toolbar;
beforeAll(done => {
apis.admin.people.createUser(username)
.then(() => apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC))
.then(() => apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_CONSUMER))
.then(() => apis.admin.nodes.createFiles([ fileAdmin ], `Sites/${siteName}/documentLibrary`))
.then(resp => apis.admin.shared.shareFileById(resp.data.entry.id))
.then(() => apis.user.nodes.createFolders([ folderUser ]))
.then(() => apis.user.nodes.createFiles([ file1User ], folderUser)).then(resp => file1Id = resp.data.entry.id)
.then(() => apis.user.nodes.createFile(file2User)).then(resp => file2Id = resp.data.entry.id)
.then(() => apis.user.nodes.createFile(file3User)).then(resp => file3Id = resp.data.entry.id)
.then(() => apis.user.shared.shareFilesByIds([file1Id, file2Id, file3Id]))
.then(() => apis.user.shared.waitForApi({ expect: 4 }))
.then(() => apis.user.nodes.deleteNodeById(file2Id))
.then(() => apis.user.shared.unshareFile(file3User))
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
sharedFilesPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterEach(done => {
sharedFilesPage.refresh().then(done);
});
afterAll(done => {
Promise.all([
apis.admin.sites.deleteSite(siteName),
apis.user.nodes.deleteNodes([ folderUser ]),
logoutPage.load()
])
.then(done);
});
it('has the correct columns [C213113]', () => {
const labels = [ 'Name', 'Location', 'Size', 'Modified', 'Modified by', 'Shared by' ];
const elements = labels.map(label => dataTable.getColumnHeaderByLabel(label));
expect(dataTable.getColumnHeaders().count()).toBe(6 + 1, 'Incorrect number of columns');
elements.forEach((element, index) => {
expect(element.isPresent()).toBe(true, `"${labels[index]}" is missing`);
});
});
it('default sorting column [C213115]', () => {
expect(dataTable.getSortedColumnHeader().getText()).toBe('Modified');
expect(dataTable.getSortingOrder()).toBe('desc');
});
it('displays the files shared by everyone [C213114]', () => {
expect(dataTable.getRowName(fileAdmin).isPresent()).toBe(true, `${fileAdmin} not displayed`);
expect(dataTable.getRowName(file1User).isPresent()).toBe(true, `${file1User} not displayed`);
});
it(`file not displayed if it's in the Trashcan [C213117]`, () => {
expect(dataTable.getRowName(file2User).isPresent()).toBe(false, `${file2User} is displayed`);
});
it('unshared file is not displayed [C213118]', () => {
expect(dataTable.getRowName(file3User).isPresent()).toBe(false, `${file3User} is displayed`);
});
it('Location column displays the parent folder of the file [C213665]', () => {
expect(dataTable.getItemLocation(fileAdmin).getText()).toEqual(siteName);
expect(dataTable.getItemLocation(file1User).getText()).toEqual(folderUser);
});
it('Location column redirect - file in user Home [C213666] [C260968]', () => {
dataTable.clickItemLocation(file1User)
.then(() => expect(breadcrumb.getAllItems()).toEqual([ 'Personal Files', folderUser ]));
});
it('Location column redirect - file in site [C213666] [C260969]', () => {
dataTable.clickItemLocation(fileAdmin)
.then(() => expect(breadcrumb.getAllItems()).toEqual([ 'File Libraries', siteName ]));
});
it('Location column displays a tooltip with the entire path of the file [C213667]', () => {
expect(dataTable.getItemLocationTooltip(fileAdmin)).toEqual(`File Libraries/${siteName}`);
expect(dataTable.getItemLocationTooltip(file1User)).toEqual(`Personal Files/${folderUser}`);
});
});

View File

@@ -0,0 +1,330 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { SIDEBAR_LABELS } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('File / folder tooltips', () => {
const username = `user-${Utils.random()}`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const parent = `parent-${Utils.random()}`;
const file = `file1-${Utils.random()}`;
const fileWithDesc = `file2-${Utils.random()}`;
const fileWithTitle = `file3-${Utils.random()}`;
const fileWithTitleAndDesc = `file4-${Utils.random()}`;
const fileNameEqTitleEqDesc = `file5-${Utils.random()}`;
const fileNameEqTitleDiffDesc = `file6-${Utils.random()}`;
const fileNameEqDescDiffTitle = `file7-${Utils.random()}`;
const fileTitleEqDesc = `file8-${Utils.random()}`;
let parentId, file1Id, file2Id, file3Id, file4Id, file5Id, file6Id, file7Id, file8Id;
const fileTitle = 'file title';
const fileDescription = 'file description';
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable } = page;
beforeAll(done => {
apis.admin.people.createUser(username)
.then(() => apis.user.nodes.createFolder( parent ))
.then(resp => parentId = resp.data.entry.id)
.then(() => Promise.all([
apis.user.nodes.createFile(file, parentId).then(resp => file1Id = resp.data.entry.id),
apis.user.nodes.createFile(fileWithDesc, parentId, '', fileDescription).then(resp => file2Id = resp.data.entry.id),
apis.user.nodes.createFile(fileWithTitle, parentId, fileTitle).then(resp => file3Id = resp.data.entry.id),
apis.user.nodes.createFile(fileWithTitleAndDesc, parentId, fileTitle, fileDescription)
.then(resp => file4Id = resp.data.entry.id),
apis.user.nodes.createFile(fileNameEqTitleEqDesc, parentId, fileNameEqTitleEqDesc, fileNameEqTitleEqDesc)
.then(resp => file5Id = resp.data.entry.id),
apis.user.nodes.createFile(fileNameEqTitleDiffDesc, parentId, fileNameEqTitleDiffDesc, fileDescription)
.then(resp => file6Id = resp.data.entry.id),
apis.user.nodes.createFile(fileNameEqDescDiffTitle, parentId, fileTitle, fileNameEqDescDiffTitle)
.then(resp => file7Id = resp.data.entry.id),
apis.user.nodes.createFile(fileTitleEqDesc, parentId, fileTitle, fileTitle).then(resp => file8Id = resp.data.entry.id)
]))
.then(() => apis.user.shared.shareFilesByIds([ file1Id, file2Id, file3Id, file4Id, file5Id, file6Id, file7Id, file8Id ]))
.then(() => apis.user.favorites.addFavoritesByIds('file', [
file1Id, file2Id, file3Id, file4Id, file5Id, file6Id, file7Id, file8Id
]))
.then(() => loginPage.loginWith(username))
.then(done);
});
afterAll(done => {
Promise.all([
apis.user.nodes.deleteNodes([ parent ]),
apis.admin.trashcan.emptyTrash(),
logoutPage.load()
])
.then(done);
});
xit('');
describe('on Personal Files', () => {
beforeAll(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => dataTable.doubleClickOnItemName(parent))
.then(done);
});
it('File with name, no title, no description', () => {
expect(dataTable.getItemNameTooltip(file)).toEqual(`${file}`);
});
it('File with name and description, no title', () => {
expect(dataTable.getItemNameTooltip(fileWithDesc)).toEqual(`${fileWithDesc}\n${fileDescription}`);
});
it('File with name and title, no description', () => {
expect(dataTable.getItemNameTooltip(fileWithTitle)).toEqual(`${fileWithTitle}\n${fileTitle}`);
});
it('File with name and title and description, all different', () => {
expect(dataTable.getItemNameTooltip(fileWithTitleAndDesc)).toEqual(`${fileTitle}\n${fileDescription}`);
});
it('File with name and title and description, all equal', () => {
expect(dataTable.getItemNameTooltip(fileNameEqTitleEqDesc)).toEqual(`${fileNameEqTitleEqDesc}`);
});
it('File with name = title, different description', () => {
expect(dataTable.getItemNameTooltip(fileNameEqTitleDiffDesc)).toEqual(`${fileNameEqTitleDiffDesc}\n${fileDescription}`);
});
it('File with name = description, different title', () => {
expect(dataTable.getItemNameTooltip(fileNameEqDescDiffTitle)).toEqual(`${fileTitle}\n${fileNameEqDescDiffTitle}`);
});
it('File with title = description, different name', () => {
expect(dataTable.getItemNameTooltip(fileTitleEqDesc)).toEqual(`${fileTitle}`);
});
});
describe('on Recent Files', () => {
beforeAll(done => {
apis.user.search.waitForApi(username, { expect: 8 })
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES))
.then(done);
});
it('File with name, no title, no description', () => {
expect(dataTable.getItemNameTooltip(file)).toEqual(`${file}`);
});
it('File with name and description, no title', () => {
expect(dataTable.getItemNameTooltip(fileWithDesc)).toEqual(`${fileWithDesc}\n${fileDescription}`);
});
it('File with name and title, no description', () => {
expect(dataTable.getItemNameTooltip(fileWithTitle)).toEqual(`${fileWithTitle}\n${fileTitle}`);
});
it('File with name and title and description, all different', () => {
expect(dataTable.getItemNameTooltip(fileWithTitleAndDesc)).toEqual(`${fileTitle}\n${fileDescription}`);
});
it('File with name and title and description, all equal', () => {
expect(dataTable.getItemNameTooltip(fileNameEqTitleEqDesc)).toEqual(`${fileNameEqTitleEqDesc}`);
});
it('File with name = title, different description', () => {
expect(dataTable.getItemNameTooltip(fileNameEqTitleDiffDesc)).toEqual(`${fileNameEqTitleDiffDesc}\n${fileDescription}`);
});
it('File with name = description, different title', () => {
expect(dataTable.getItemNameTooltip(fileNameEqDescDiffTitle)).toEqual(`${fileTitle}\n${fileNameEqDescDiffTitle}`);
});
it('File with title = description, different name', () => {
expect(dataTable.getItemNameTooltip(fileTitleEqDesc)).toEqual(`${fileTitle}`);
});
});
// disabled until ACA-518 is done
xdescribe('on Shared Files', () => {
beforeAll(done => {
apis.user.shared.waitForApi({ expect: 8 })
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES))
.then(done);
});
it('File with name, no title, no description', () => {
expect(dataTable.getItemNameTooltip(file)).toEqual(`${file}`);
});
it('File with name and description, no title', () => {
expect(dataTable.getItemNameTooltip(fileWithDesc)).toEqual(`${fileWithDesc}\n${fileDescription}`);
});
it('File with name and title, no description', () => {
expect(dataTable.getItemNameTooltip(fileWithTitle)).toEqual(`${fileWithTitle}\n${fileTitle}`);
});
it('File with name and title and description, all different', () => {
expect(dataTable.getItemNameTooltip(fileWithTitleAndDesc)).toEqual(`${fileTitle}\n${fileDescription}`);
});
it('File with name and title and description, all equal', () => {
expect(dataTable.getItemNameTooltip(fileNameEqTitleEqDesc)).toEqual(`${fileNameEqTitleEqDesc}`);
});
it('File with name = title, different description', () => {
expect(dataTable.getItemNameTooltip(fileNameEqTitleDiffDesc)).toEqual(`${fileNameEqTitleDiffDesc}\n${fileDescription}`);
});
it('File with name = description, different title', () => {
expect(dataTable.getItemNameTooltip(fileNameEqDescDiffTitle)).toEqual(`${fileTitle}\n${fileNameEqDescDiffTitle}`);
});
it('File with title = description, different name', () => {
expect(dataTable.getItemNameTooltip(fileTitleEqDesc)).toEqual(`${fileTitle}`);
});
});
describe('on Favorites', () => {
beforeAll(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES).then(done);
});
it('File with name, no title, no description', () => {
expect(dataTable.getItemNameTooltip(file)).toEqual(`${file}`);
});
it('File with name and description, no title', () => {
expect(dataTable.getItemNameTooltip(fileWithDesc)).toEqual(`${fileWithDesc}\n${fileDescription}`);
});
it('File with name and title, no description', () => {
expect(dataTable.getItemNameTooltip(fileWithTitle)).toEqual(`${fileWithTitle}\n${fileTitle}`);
});
it('File with name and title and description, all different', () => {
expect(dataTable.getItemNameTooltip(fileWithTitleAndDesc)).toEqual(`${fileTitle}\n${fileDescription}`);
});
it('File with name and title and description, all equal', () => {
expect(dataTable.getItemNameTooltip(fileNameEqTitleEqDesc)).toEqual(`${fileNameEqTitleEqDesc}`);
});
it('File with name = title, different description', () => {
expect(dataTable.getItemNameTooltip(fileNameEqTitleDiffDesc)).toEqual(`${fileNameEqTitleDiffDesc}\n${fileDescription}`);
});
it('File with name = description, different title', () => {
expect(dataTable.getItemNameTooltip(fileNameEqDescDiffTitle)).toEqual(`${fileTitle}\n${fileNameEqDescDiffTitle}`);
});
it('File with title = description, different name', () => {
expect(dataTable.getItemNameTooltip(fileTitleEqDesc)).toEqual(`${fileTitle}`);
});
});
describe('on Trash', () => {
const parentForTrash = `parent-${Utils.random()}`;
let parentForTrashId, file1TrashId, file2TrashId, file3TrashId, file4TrashId;
let file5TrashId, file6TrashId, file7TrashId, file8TrashId;
beforeAll(done => {
apis.user.nodes.createFolder( parentForTrash )
.then(resp => parentForTrashId = resp.data.entry.id)
.then(() => Promise.all([
apis.user.nodes.createFile(file, parentForTrashId)
.then(resp => file1TrashId = resp.data.entry.id),
apis.user.nodes.createFile(fileWithDesc, parentForTrashId, '', fileDescription)
.then(resp => file2TrashId = resp.data.entry.id),
apis.user.nodes.createFile(fileWithTitle, parentForTrashId, fileTitle)
.then(resp => file3TrashId = resp.data.entry.id),
apis.user.nodes.createFile(fileWithTitleAndDesc, parentForTrashId, fileTitle, fileDescription)
.then(resp => file4TrashId = resp.data.entry.id),
apis.user.nodes.createFile(fileNameEqTitleEqDesc, parentForTrashId, fileNameEqTitleEqDesc, fileNameEqTitleEqDesc)
.then(resp => file5TrashId = resp.data.entry.id),
apis.user.nodes.createFile(fileNameEqTitleDiffDesc, parentForTrashId, fileNameEqTitleDiffDesc, fileDescription)
.then(resp => file6TrashId = resp.data.entry.id),
apis.user.nodes.createFile(fileNameEqDescDiffTitle, parentForTrashId, fileTitle, fileNameEqDescDiffTitle)
.then(resp => file7TrashId = resp.data.entry.id),
apis.user.nodes.createFile(fileTitleEqDesc, parentForTrashId, fileTitle, fileTitle)
.then(resp => file8TrashId = resp.data.entry.id)
]))
.then(() => apis.user.nodes.deleteNodesById([
file1TrashId, file2TrashId, file3TrashId, file4TrashId, file5TrashId, file6TrashId, file7TrashId, file8TrashId
], false))
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH))
.then(done);
});
afterAll(done => {
apis.user.nodes.deleteNodes([ parentForTrash ]).then(done);
});
it('File with name, no title, no description', () => {
expect(dataTable.getItemNameTooltip(file)).toEqual(`${file}`);
});
it('File with name and description, no title', () => {
expect(dataTable.getItemNameTooltip(fileWithDesc)).toEqual(`${fileWithDesc}\n${fileDescription}`);
});
it('File with name and title, no description', () => {
expect(dataTable.getItemNameTooltip(fileWithTitle)).toEqual(`${fileWithTitle}\n${fileTitle}`);
});
it('File with name and title and description, all different', () => {
expect(dataTable.getItemNameTooltip(fileWithTitleAndDesc)).toEqual(`${fileTitle}\n${fileDescription}`);
});
it('File with name and title and description, all equal', () => {
expect(dataTable.getItemNameTooltip(fileNameEqTitleEqDesc)).toEqual(`${fileNameEqTitleEqDesc}`);
});
it('File with name = title, different description', () => {
expect(dataTable.getItemNameTooltip(fileNameEqTitleDiffDesc)).toEqual(`${fileNameEqTitleDiffDesc}\n${fileDescription}`);
});
it('File with name = description, different title', () => {
expect(dataTable.getItemNameTooltip(fileNameEqDescDiffTitle)).toEqual(`${fileTitle}\n${fileNameEqDescDiffTitle}`);
});
it('File with title = description, different name', () => {
expect(dataTable.getItemNameTooltip(fileTitleEqDesc)).toEqual(`${fileTitle}`);
});
});
});

View File

@@ -0,0 +1,169 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { SITE_VISIBILITY, SITE_ROLES, SIDEBAR_LABELS } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Trash', () => {
const username = `user-${Utils.random()}`;
const siteName = `site-${Utils.random()}`;
const fileSite = `file-${Utils.random()}.txt`; let fileSiteId;
const folderAdmin = `folder-${Utils.random()}`; let folderAdminId;
const fileAdmin = `file-${Utils.random()}.txt`; let fileAdminId;
const folderUser = `folder-${Utils.random()}`; let folderUserId;
const fileUser = `file-${Utils.random()}.txt`; let fileUserId;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const trashPage = new BrowsingPage();
const { dataTable } = trashPage;
const { breadcrumb } = trashPage.toolbar;
beforeAll(done => {
apis.admin.people.createUser(username)
.then(() => apis.admin.nodes.createFiles([ fileAdmin ]).then(resp => fileAdminId = resp.data.entry.id))
.then(() => apis.admin.nodes.createFolders([ folderAdmin ]).then(resp => folderAdminId = resp.data.entry.id))
.then(() => apis.admin.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC))
.then(() => apis.admin.sites.addSiteMember(siteName, username, SITE_ROLES.SITE_MANAGER))
.then(() => apis.admin.nodes.createFiles([ fileSite ], `Sites/${siteName}/documentLibrary`)
.then(resp => fileSiteId = resp.data.entry.id))
.then(() => apis.user.nodes.createFiles([ fileUser ]).then(resp => fileUserId = resp.data.entry.id))
.then(() => apis.user.nodes.createFolders([ folderUser ]).then(resp => folderUserId = resp.data.entry.id))
.then(() => apis.admin.nodes.deleteNodesById([ fileAdminId, folderAdminId ], false))
.then(() => apis.user.nodes.deleteNodesById([ fileSiteId, fileUserId, folderUserId ], false))
.then(done);
});
afterAll(done => {
Promise.all([
apis.admin.sites.deleteSite(siteName),
apis.admin.trashcan.emptyTrash()
])
.then(done);
});
xit('');
describe('as admin', () => {
beforeAll(done => {
loginPage.loginWithAdmin().then(done);
});
beforeEach(done => {
trashPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('has the correct columns', () => {
const labels = [ 'Name', 'Location', 'Size', 'Deleted', 'Deleted by' ];
const elements = labels.map(label => dataTable.getColumnHeaderByLabel(label));
expect(dataTable.getColumnHeaders().count()).toBe(5 + 1, 'Incorrect number of columns');
elements.forEach((element, index) => {
expect(element.isPresent()).toBe(true, `"${labels[index]}" is missing`);
});
});
it('displays the files and folders deleted by everyone [C213217]', () => {
expect(dataTable.countRows()).toEqual(5, 'Incorrect number of deleted items displayed');
expect(dataTable.getRowName(fileAdmin).isPresent()).toBe(true, `${fileAdmin} not displayed`);
expect(dataTable.getRowName(folderAdmin).isPresent()).toBe(true, `${folderAdmin} not displayed`);
expect(dataTable.getRowName(fileUser).isPresent()).toBe(true, `${fileUser} not displayed`);
expect(dataTable.getRowName(folderUser).isPresent()).toBe(true, `${folderUser} not displayed`);
expect(dataTable.getRowName(fileSite).isPresent()).toBe(true, `${fileSite} not displayed`);
});
});
describe('as user', () => {
beforeAll(done => {
loginPage.loginWith(username).then(done);
});
beforeEach(done => {
trashPage.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('has the correct columns', () => {
const labels = [ 'Name', 'Location', 'Size', 'Deleted', 'Deleted by' ];
const elements = labels.map(label => dataTable.getColumnHeaderByLabel(label));
expect(dataTable.getColumnHeaders().count()).toBe(5 + 1, 'Incorrect number of columns');
elements.forEach((element, index) => {
expect(element.isPresent()).toBe(true, `"${labels[index]}" is missing`);
});
});
it('displays the files and folders deleted by the user [C213218]', () => {
expect(dataTable.countRows()).toEqual(3, 'Incorrect number of deleted items displayed');
expect(dataTable.getRowName(fileSite).isPresent()).toBe(true, `${fileSite} not displayed`);
expect(dataTable.getRowName(fileUser).isPresent()).toBe(true, `${fileUser} not displayed`);
expect(dataTable.getRowName(folderUser).isPresent()).toBe(true, `${folderUser} not displayed`);
expect(dataTable.getRowName(fileAdmin).isPresent()).toBe(false, `${fileAdmin} is displayed`);
});
it('default sorting column [C213219]', () => {
expect(dataTable.getSortedColumnHeader().getText()).toBe('Deleted');
expect(dataTable.getSortingOrder()).toBe('desc');
});
it('Location column redirect - file in user Home [C217144] [C260968]', () => {
dataTable.clickItemLocation(fileUser)
.then(() => expect(breadcrumb.getAllItems()).toEqual([ 'Personal Files' ]));
});
it('Location column redirect - file in site [C217144] [C260969]', () => {
dataTable.clickItemLocation(fileSite)
.then(() => expect(breadcrumb.getAllItems()).toEqual([ 'File Libraries', siteName ]));
});
});
});

View File

@@ -0,0 +1,244 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from 'protractor';
import { SIDEBAR_LABELS, SITE_VISIBILITY } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Breadcrumb', () => {
const username = `user-${Utils.random()}`;
const parent = `parent-${Utils.random()}`; let parentId;
const subfolder1 = `subfolder1-${Utils.random()}`; let subfolder1Id;
const subfolder2 = `subfolder2-${Utils.random()}`; let subfolder2Id;
const fileName1 = `file1-${Utils.random()}.txt`;
const siteName = `site-${Utils.random()}`;
const parent2 = `parent2-${Utils.random()}`; let parent2Id;
const folder1 = `folder1-${Utils.random()}`; let folder1Id;
const folder1Renamed = `renamed-${Utils.random()}`;
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { breadcrumb } = page.toolbar;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
beforeAll(done => {
apis.admin.people.createUser(username)
.then(() => apis.user.nodes.createFolder(parent)).then(resp => parentId = resp.data.entry.id)
.then(() => apis.user.nodes.createFolder(subfolder1, parentId)).then(resp => subfolder1Id = resp.data.entry.id)
.then(() => apis.user.nodes.createFolder(subfolder2, subfolder1Id)).then(resp => subfolder2Id = resp.data.entry.id)
.then(() => apis.user.nodes.createFile(fileName1, subfolder2Id))
.then(() => apis.user.nodes.createFolder(parent2)).then(resp => parent2Id = resp.data.entry.id)
.then(() => apis.user.nodes.createFolder(folder1, parent2Id)).then(resp => folder1Id = resp.data.entry.id)
.then(() => apis.user.sites.createSite(siteName, SITE_VISIBILITY.PUBLIC))
.then(() => apis.user.sites.getDocLibId(siteName))
.then(resp => apis.user.nodes.createFolder(parent, resp)).then(resp => parentId = resp.data.entry.id)
.then(() => apis.user.nodes.createFolder(subfolder1, parentId)).then(resp => subfolder1Id = resp.data.entry.id)
.then(() => apis.user.nodes.createFolder(subfolder2, subfolder1Id)).then(resp => subfolder2Id = resp.data.entry.id)
.then(() => apis.user.nodes.createFile(fileName1, subfolder2Id))
.then(() => loginPage.loginWith(username))
.then(done);
});
afterAll(done => {
Promise.all([
apis.user.nodes.deleteNodeById(parentId),
apis.user.nodes.deleteNodeById(parent2Id),
apis.user.sites.deleteSite(siteName),
logoutPage.load()
])
.then(done);
});
it('Personal Files breadcrumb main node [C260964]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => {
expect(breadcrumb.getItemsCount()).toEqual(1, 'Breadcrumb has incorrect number of items');
expect(breadcrumb.getCurrentItemName()).toBe('Personal Files');
});
});
it('File Libraries breadcrumb main node [C260966]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES)
.then(() => {
expect(breadcrumb.getItemsCount()).toEqual(1, 'Breadcrumb has incorrect number of items');
expect(breadcrumb.getCurrentItemName()).toBe('File Libraries');
});
});
it('Recent Files breadcrumb main node [C260971]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES)
.then(() => {
expect(breadcrumb.getItemsCount()).toEqual(1, 'Breadcrumb has incorrect number of items');
expect(breadcrumb.getCurrentItemName()).toBe('Recent Files');
});
});
it('Shared Files breadcrumb main node [C260972]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES)
.then(() => {
expect(breadcrumb.getItemsCount()).toEqual(1, 'Breadcrumb has incorrect number of items');
expect(breadcrumb.getCurrentItemName()).toBe('Shared Files');
});
});
it('Favorites breadcrumb main node [C260973]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES)
.then(() => {
expect(breadcrumb.getItemsCount()).toEqual(1, 'Breadcrumb has incorrect number of items');
expect(breadcrumb.getCurrentItemName()).toBe('Favorites');
});
});
it('Trash breadcrumb main node [C260974]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH)
.then(() => {
expect(breadcrumb.getItemsCount()).toEqual(1, 'Breadcrumb has incorrect number of items');
expect(breadcrumb.getCurrentItemName()).toBe('Trash');
});
});
it('Personal Files breadcrumb for a folder hierarchy [C260965]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => page.dataTable.waitForHeader())
.then(() => page.dataTable.doubleClickOnItemName(parent))
.then(() => page.dataTable.doubleClickOnItemName(subfolder1))
.then(() => page.dataTable.doubleClickOnItemName(subfolder2))
.then(() => {
const expectedBreadcrumb = [ 'Personal Files', parent, subfolder1, subfolder2 ];
expect(breadcrumb.getAllItems()).toEqual(expectedBreadcrumb);
});
});
it('File Libraries breadcrumb for a folder hierarchy [C260967]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES)
.then(() => page.dataTable.waitForHeader())
.then(() => page.dataTable.doubleClickOnItemName(siteName))
.then(() => page.dataTable.doubleClickOnItemName(parent))
.then(() => page.dataTable.doubleClickOnItemName(subfolder1))
.then(() => page.dataTable.doubleClickOnItemName(subfolder2))
.then(() => {
const expectedItems = [ 'File Libraries', siteName, parent, subfolder1, subfolder2 ];
expect(breadcrumb.getAllItems()).toEqual(expectedItems);
});
});
it('User can navigate to any location by clicking on a step from the breadcrumb [C213235]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => page.dataTable.waitForHeader())
.then(() => page.dataTable.doubleClickOnItemName(parent))
.then(() => page.dataTable.doubleClickOnItemName(subfolder1))
.then(() => page.dataTable.doubleClickOnItemName(subfolder2))
.then(() => breadcrumb.clickItem(subfolder1))
.then(() => {
const expectedBreadcrumb = [ 'Personal Files', parent, subfolder1 ];
expect(breadcrumb.getAllItems()).toEqual(expectedBreadcrumb);
});
});
it('Tooltip appears on hover on a step in breadcrumb [C213237]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => page.dataTable.waitForHeader())
.then(() => page.dataTable.doubleClickOnItemName(parent))
.then(() => page.dataTable.doubleClickOnItemName(subfolder1))
.then(() => page.dataTable.doubleClickOnItemName(subfolder2))
.then(() => {
expect(breadcrumb.getNthItemTooltip(3)).toEqual(subfolder1);
});
});
it('Breadcrumb updates correctly when folder is renamed [C213238]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => page.dataTable.waitForHeader())
.then(() => page.dataTable.doubleClickOnItemName(parent2))
.then(() => page.dataTable.doubleClickOnItemName(folder1))
.then(() => page.dataTable.wait())
.then(() => apis.user.nodes.renameNode(folder1Id, folder1Renamed).then(done => done))
.then(() => page.refresh())
.then(() => page.dataTable.wait())
.then(() => {
expect(breadcrumb.getCurrentItemName()).toEqual(folder1Renamed);
});
});
it('Browser back navigates to previous location regardless of breadcrumb steps [C213240]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => page.dataTable.waitForHeader())
.then(() => page.dataTable.doubleClickOnItemName(parent))
.then(() => page.dataTable.doubleClickOnItemName(subfolder1))
.then(() => page.dataTable.doubleClickOnItemName(subfolder2))
.then(() => page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH))
.then(() => page.dataTable.waitForEmptyState())
.then(() => browser.navigate().back())
.then(() => {
const expectedBreadcrumb = [ 'Personal Files', parent, subfolder1, subfolder2 ];
expect(breadcrumb.getAllItems()).toEqual(expectedBreadcrumb);
});
});
// disabled cause of ACA-1039
xdescribe('as admin', () => {
const user2 = 'a_user';
const userFolder = `userFolder-${Utils.random()}`; let userFolderId;
const user2Api = new RepoClient(user2, user2);
beforeAll(done => {
logoutPage.load()
.then(() => apis.admin.people.createUser(user2))
.then(() => user2Api.nodes.createFolder(userFolder).then(resp => userFolderId = resp.data.entry.id))
.then(() => loginPage.loginWithAdmin())
.then(done);
});
afterAll(done => {
Promise.all([
user2Api.nodes.deleteNodeById(userFolderId),
logoutPage.load()
])
.then(done);
});
it(`Breadcrumb on navigation to a user's home [C260970]`, () => {
page.dataTable.doubleClickOnItemName('User Homes')
.then(() => page.dataTable.doubleClickOnItemName(user2))
.then(() => expect(breadcrumb.getAllItems()).toEqual([ 'Personal Files', 'User Homes', user2 ]))
.then(() => page.dataTable.doubleClickOnItemName(userFolder))
.then(() => expect(breadcrumb.getAllItems()).toEqual([ 'Personal Files', 'User Homes', user2, userFolder ]));
});
});
});

View File

@@ -0,0 +1,139 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from 'protractor';
import { APP_ROUTES, SIDEBAR_LABELS } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
describe('Sidebar', () => {
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { sidenav } = page;
beforeAll(done => {
loginPage.loginWithAdmin().then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('has "Personal Files" as default', () => {
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.PERSONAL_FILES);
expect(sidenav.isActiveByLabel('Personal Files')).toBe(true, 'Active link');
});
it('navigates to "File Libraries"', () => {
sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES)
.then(() => {
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.FILE_LIBRARIES);
expect(sidenav.isActiveByLabel(SIDEBAR_LABELS.FILE_LIBRARIES)).toBe(true);
});
});
it('navigates to "Personal Files"', () => {
sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => {
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.PERSONAL_FILES);
expect(sidenav.isActiveByLabel(SIDEBAR_LABELS.PERSONAL_FILES)).toBe(true);
});
});
it('navigates to "Shared Files"', () => {
sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES)
.then(() => {
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.SHARED_FILES);
expect(sidenav.isActiveByLabel(SIDEBAR_LABELS.SHARED_FILES)).toBe(true);
});
});
it('navigates to "Recent Files"', () => {
sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES)
.then(() => {
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.RECENT_FILES);
expect(sidenav.isActiveByLabel(SIDEBAR_LABELS.RECENT_FILES)).toBe(true);
});
});
it('navigates to "Favorites"', () => {
sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES)
.then(() => {
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.FAVORITES);
expect(sidenav.isActiveByLabel(SIDEBAR_LABELS.FAVORITES)).toBe(true);
});
});
it('navigates to "Trash"', () => {
sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH)
.then(() => {
expect(browser.getCurrentUrl()).toContain(APP_ROUTES.TRASHCAN);
expect(sidenav.isActiveByLabel(SIDEBAR_LABELS.TRASH)).toBe(true);
});
});
it('Personal Files tooltip', () => {
sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => {
expect(sidenav.getLinkTooltip(SIDEBAR_LABELS.PERSONAL_FILES)).toContain('View your Personal Files');
});
});
it('File Libraries tooltip', () => {
sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES)
.then(() => {
expect(sidenav.getLinkTooltip(SIDEBAR_LABELS.FILE_LIBRARIES)).toContain('Access File Libraries');
});
});
it('Shared Files tooltip', () => {
sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES)
.then(() => {
expect(sidenav.getLinkTooltip(SIDEBAR_LABELS.SHARED_FILES)).toContain('View files that have been shared');
});
});
it('Recent Files tooltip', () => {
sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES)
.then(() => {
expect(sidenav.getLinkTooltip(SIDEBAR_LABELS.RECENT_FILES)).toContain('View files you recently edited');
});
});
it('Favorites tooltip', () => {
sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES)
.then(() => {
expect(sidenav.getLinkTooltip(SIDEBAR_LABELS.FAVORITES)).toContain('View your favorite files and folders');
});
});
it('Trash tooltip', () => {
sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH)
.then(() => {
expect(sidenav.getLinkTooltip(SIDEBAR_LABELS.TRASH)).toContain('View deleted files in the trash');
});
});
});

View File

@@ -0,0 +1,228 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from 'protractor';
import { SIDEBAR_LABELS } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Pagination on Favorites', () => {
const username = `user-${Utils.random()}`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const { nodes: nodesApi, favorites: favoritesApi } = apis.user;
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
const parent = `parent-${Utils.random()}`;
const files = Array(101)
.fill('file')
.map((name, index): string => `${name}-${index + 1}.txt`);
let filesIds;
const file = `file-${Utils.random()}.txt`; let fileId;
beforeAll(done => {
apis.admin.people.createUser(username).then(done);
});
xit('');
describe('on empty page', () => {
beforeAll(done => {
loginPage.loginWith(username).then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('pagination controls not displayed [C213164]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES)
.then(() => {
expect(pagination.range.isPresent()).toBe(false);
expect(pagination.maxItems.isPresent()).toBe(false);
expect(pagination.currentPage.isPresent()).toBe(false);
expect(pagination.totalPages.isPresent()).toBe(false);
expect(pagination.previousButton.isPresent()).toBe(false);
expect(pagination.nextButton.isPresent()).toBe(false);
});
});
});
describe('on single page', () => {
beforeAll(done => {
nodesApi.createFile(file).then(resp => fileId = resp.data.entry.id)
.then(() => favoritesApi.addFavoriteById('file', fileId))
.then(() => loginPage.loginWith(username))
.then(done);
});
afterAll(done => {
Promise.all([
nodesApi.deleteNodeById(fileId),
logoutPage.load()
])
.then(done);
});
it('page selector not displayed when having a single page [C213165]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES)
.then(() => dataTable.waitForHeader())
.then(() => expect(pagination.pagesButton.isPresent()).toBe(false, 'page selector displayed'));
});
});
describe('on multiple pages', () => {
beforeAll(done => {
nodesApi.createFiles(files, parent)
.then(resp => filesIds = resp.data.list.entries.map(entries => entries.entry.id))
.then(() => favoritesApi.addFavoritesByIds('file', filesIds))
.then(() => favoritesApi.waitForApi({ expect: 101 }))
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FAVORITES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterEach(done => {
browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform().then(done);
});
afterAll(done => {
Promise.all([
nodesApi.deleteNodes([ parent ]),
logoutPage.load()
])
.then(done);
});
it('default values [C213157]', () => {
expect(pagination.range.getText()).toContain('1-25 of 101');
expect(pagination.maxItems.getText()).toContain('25');
expect(pagination.currentPage.getText()).toContain('Page 1');
expect(pagination.totalPages.getText()).toContain('of 5');
expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled');
expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
});
it('page sizes [C213157]', () => {
pagination.openMaxItemsMenu()
.then(() => {
const [ first, second, third ] = [1, 2, 3]
.map(nth => pagination.menu.getNthItem(nth).getText());
expect(first).toBe('25');
expect(second).toBe('50');
expect(third).toBe('100');
})
.then(() => pagination.menu.closeMenu());
});
it('change the page size [C213158]', () => {
pagination.openMaxItemsMenu()
.then(() => pagination.menu.clickMenuItem('50'))
.then(() => {
expect(pagination.getText(pagination.maxItems)).toContain('50');
expect(pagination.getText(pagination.totalPages)).toContain('of 3');
})
.then(() => pagination.openMaxItemsMenu())
.then(() => pagination.menu.clickMenuItem('100'))
.then(() => {
expect(pagination.getText(pagination.maxItems)).toContain('100');
expect(pagination.getText(pagination.totalPages)).toContain('of 2');
})
.then(() => pagination.resetToDefaultPageSize());
});
it('current page menu items', () => {
pagination.openCurrentPageMenu()
.then(() => expect(pagination.menu.getItemsCount()).toBe(5))
.then(() => pagination.menu.closeMenu());
});
it('change the current page from menu [C260518]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(3))
.then(() => {
expect(pagination.getText(pagination.range)).toContain('51-75 of 101');
expect(pagination.getText(pagination.currentPage)).toContain('Page 3');
expect(pagination.previousButton.isEnabled()).toBe(true, 'Previous button is not enabled');
expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
expect(dataTable.getRowName('file-40.txt').isPresent()).toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('navigate to next page [C213160]', () => {
pagination.nextButton.click()
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('26-50 of 101');
expect(dataTable.getRowName('file-70.txt').isPresent()).toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('navigate to previous page [C213160]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(2))
.then(() => dataTable.waitForHeader())
.then(() => pagination.previousButton.click())
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('1-25 of 101');
expect(dataTable.getRowName('file-88.txt').isPresent())
.toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('Previous button is disabled on first page [C260519]', () => {
expect(pagination.currentPage.getText()).toContain('Page 1');
expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled on first page');
});
it('Next button is disabled on last page [C260519]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(5))
.then(() => {
expect(dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page');
expect(pagination.currentPage.getText()).toContain('Page 5');
expect(pagination.nextButton.isEnabled()).toBe(false, 'Next button is enabled on last page');
});
});
});
});

View File

@@ -0,0 +1,228 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from 'protractor';
import { SIDEBAR_LABELS } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Pagination on Personal Files', () => {
const username = `user-${Utils.random()}`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const { nodes: nodesApi } = apis.user;
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
const parent = `parent-${Utils.random()}`;
const files = Array(101)
.fill('file')
.map((name, index): string => `${name}-${index + 1}.txt`);
const file = `file-${Utils.random()}.txt`; let fileId;
beforeAll(done => {
apis.admin.people.createUser(username).then(done);
});
xit('');
describe('on empty page', () => {
beforeAll(done => {
loginPage.loginWith(username).then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('pagination controls not displayed [C213164]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => {
expect(pagination.range.isPresent()).toBe(false);
expect(pagination.maxItems.isPresent()).toBe(false);
expect(pagination.currentPage.isPresent()).toBe(false);
expect(pagination.totalPages.isPresent()).toBe(false);
expect(pagination.previousButton.isPresent()).toBe(false);
expect(pagination.nextButton.isPresent()).toBe(false);
});
});
});
describe('on single page', () => {
beforeAll(done => {
nodesApi.createFile(file).then(resp => fileId = resp.data.entry.id)
.then(() => loginPage.loginWith(username))
.then(done);
});
afterAll(done => {
Promise.all([
nodesApi.deleteNodeById(fileId),
logoutPage.load()
])
.then(done);
});
it('page selector not displayed when having a single page [C213165]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => dataTable.waitForHeader())
.then(() => expect(pagination.pagesButton.isPresent()).toBe(false, 'page selector displayed'));
});
});
describe('on multiple pages', () => {
beforeAll(done => {
nodesApi.createFiles(files, parent)
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.PERSONAL_FILES)
.then(() => dataTable.waitForHeader())
.then(() => dataTable.doubleClickOnItemName(parent))
.then(done);
});
afterEach(done => {
browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform().then(done);
});
afterAll(done => {
Promise.all([
nodesApi.deleteNodes([ parent ]),
logoutPage.load()
])
.then(done);
});
it('default values [C213157]', () => {
expect(pagination.range.getText()).toContain('1-25 of 101');
expect(pagination.maxItems.getText()).toContain('25');
expect(pagination.currentPage.getText()).toContain('Page 1');
expect(pagination.totalPages.getText()).toContain('of 5');
expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled');
expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
});
it('page sizes [C213157]', () => {
pagination.openMaxItemsMenu()
.then(() => {
const [ first, second, third ] = [1, 2, 3]
.map(nth => pagination.menu.getNthItem(nth).getText());
expect(first).toBe('25');
expect(second).toBe('50');
expect(third).toBe('100');
})
.then(() => pagination.menu.closeMenu());
});
it('change the page size [C213158]', () => {
pagination.openMaxItemsMenu()
.then(() => pagination.menu.clickMenuItem('50'))
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.maxItems.getText()).toContain('50');
expect(pagination.totalPages.getText()).toContain('of 3');
})
.then(() => pagination.openMaxItemsMenu())
.then(() => pagination.menu.clickMenuItem('100'))
.then(() => {
expect(pagination.getText(pagination.maxItems)).toContain('100');
expect(pagination.getText(pagination.totalPages)).toContain('of 2');
})
.then(() => pagination.resetToDefaultPageSize());
});
it('current page menu items', () => {
pagination.openCurrentPageMenu()
.then(() => expect(pagination.menu.getItemsCount()).toBe(5))
.then(() => pagination.menu.closeMenu());
});
it('change the current page from menu [C260518]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(3))
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('51-75 of 101');
expect(pagination.currentPage.getText()).toContain('Page 3');
expect(pagination.previousButton.isEnabled()).toBe(true, 'Previous button is not enabled');
expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
expect(dataTable.getRowName('file-60.txt').isPresent()).toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('navigate to next page [C213160]', () => {
pagination.clickNext()
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('26-50 of 101');
expect(dataTable.getRowName('file-30.txt').isPresent()).toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('navigate to previous page [C213160]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(2))
.then(() => dataTable.waitForHeader())
.then(() => pagination.clickPrevious())
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('1-25 of 101');
expect(dataTable.getRowName('file-12.txt').isPresent()).toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('Previous button is disabled on first page [C260519]', () => {
expect(pagination.currentPage.getText()).toContain('Page 1');
expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled on first page');
});
it('Next button is disabled on last page [C260519]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(5))
.then(() => {
expect(dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page');
expect(pagination.currentPage.getText()).toContain('Page 5');
expect(pagination.nextButton.isEnabled()).toBe(false, 'Next button is enabled on last page');
});
});
});
});

View File

@@ -0,0 +1,230 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from 'protractor';
import { SIDEBAR_LABELS } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Pagination on Recent Files', () => {
const username = `user-${Utils.random()}`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const { nodes: nodesApi, search: searchApi } = apis.user;
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
const parent = `parent-${Utils.random()}`;
const files = Array(101)
.fill('file')
.map((name, index): string => `${name}-${index + 1}.txt`);
const file = `file-${Utils.random()}.txt`; let fileId;
beforeAll(done => {
apis.admin.people.createUser(username).then(done);
});
xit('');
describe('on empty page', () => {
beforeAll(done => {
loginPage.loginWith(username).then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('pagination controls not displayed [C213164]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES)
.then(() => {
expect(pagination.range.isPresent()).toBe(false);
expect(pagination.maxItems.isPresent()).toBe(false);
expect(pagination.currentPage.isPresent()).toBe(false);
expect(pagination.totalPages.isPresent()).toBe(false);
expect(pagination.previousButton.isPresent()).toBe(false);
expect(pagination.nextButton.isPresent()).toBe(false);
});
});
});
describe('on single page', () => {
beforeAll(done => {
nodesApi.createFile(file).then(resp => fileId = resp.data.entry.id)
.then(() => searchApi.waitForApi(username, { expect: 1 }))
.then(() => loginPage.loginWith(username))
.then(done);
});
afterAll(done => {
Promise.all([
nodesApi.deleteNodeById(fileId),
logoutPage.load()
])
.then(done);
});
it('page selector not displayed when having a single page [C213165]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES)
.then(() => dataTable.waitForHeader())
.then(() => expect(pagination.pagesButton.isPresent()).toBe(false, 'page selector displayed'));
});
});
describe('on multiple pages', () => {
beforeAll(done => {
nodesApi.createFiles(files, parent)
.then(() => searchApi.waitForApi(username, { expect: 101 }))
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.RECENT_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterEach(done => {
browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform().then(done);
});
afterAll(done => {
Promise.all([
nodesApi.deleteNodes([ parent ]),
logoutPage.load()
])
.then(done);
});
it('default values [C213157]', () => {
expect(pagination.range.getText()).toContain('1-25 of 101');
expect(pagination.maxItems.getText()).toContain('25');
expect(pagination.currentPage.getText()).toContain('Page 1');
expect(pagination.totalPages.getText()).toContain('of 5');
expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled');
expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
});
it('page sizes [C213157]', () => {
pagination.openMaxItemsMenu()
.then(() => {
const [ first, second, third ] = [1, 2, 3]
.map(nth => pagination.menu.getNthItem(nth).getText());
expect(first).toBe('25');
expect(second).toBe('50');
expect(third).toBe('100');
})
.then(() => pagination.menu.closeMenu());
});
it('change the page size [C213158]', () => {
pagination.openMaxItemsMenu()
.then(() => pagination.menu.clickMenuItem('50'))
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.maxItems.getText()).toContain('50');
expect(pagination.totalPages.getText()).toContain('of 3');
})
.then(() => pagination.openMaxItemsMenu())
.then(() => pagination.menu.clickMenuItem('100'))
.then(() => {
expect(pagination.getText(pagination.maxItems)).toContain('100');
expect(pagination.getText(pagination.totalPages)).toContain('of 2');
})
.then(() => pagination.resetToDefaultPageSize());
});
it('current page menu items', () => {
pagination.openCurrentPageMenu()
.then(() => expect(pagination.menu.getItemsCount()).toBe(5))
.then(() => pagination.menu.closeMenu());
});
it('change the current page from menu [C260518]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(3))
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('51-75 of 101');
expect(pagination.currentPage.getText()).toContain('Page 3');
expect(pagination.previousButton.isEnabled()).toBe(true, 'Previous button is not enabled');
expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
expect(dataTable.getRowName('file-40.txt').isPresent()).toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('navigate to next page [C213160]', () => {
pagination.nextButton.click()
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('26-50 of 101');
expect(dataTable.getRowName('file-70.txt').isPresent()).toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('navigate to previous page [C213160]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(2))
.then(() => dataTable.waitForHeader())
.then(() => pagination.previousButton.click())
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('1-25 of 101');
expect(dataTable.getRowName('file-88.txt').isPresent()).toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('Previous button is disabled on first page [C260519]', () => {
expect(pagination.currentPage.getText()).toContain('Page 1');
expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled on first page');
});
it('Next button is disabled on last page [C260519]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(5))
.then(() => {
expect(dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page');
expect(pagination.currentPage.getText()).toContain('Page 5');
expect(pagination.nextButton.isEnabled()).toBe(false, 'Next button is enabled on last page');
});
});
});
});

View File

@@ -0,0 +1,236 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from 'protractor';
import { SIDEBAR_LABELS } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Pagination on Shared Files', () => {
const username = `user-${Utils.random()}`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const { nodes: nodesApi, shared: sharedApi } = apis.user;
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
const parent = `parent-${Utils.random()}`;
const files = Array(101)
.fill('file')
.map((name, index): string => `${name}-${index + 1}.txt`);
let filesIds;
const file = `file-${Utils.random()}.txt`; let fileId;
beforeAll(done => {
apis.admin.people.createUser(username).then(done);
});
xit('');
describe('on empty page', () => {
beforeAll(done => {
loginPage.loginWith(username).then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('pagination controls not displayed [C213164]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES)
.then(() => {
expect(pagination.range.isPresent()).toBe(false);
expect(pagination.maxItems.isPresent()).toBe(false);
expect(pagination.currentPage.isPresent()).toBe(false);
expect(pagination.totalPages.isPresent()).toBe(false);
expect(pagination.previousButton.isPresent()).toBe(false);
expect(pagination.nextButton.isPresent()).toBe(false);
});
});
});
describe('on single page', () => {
beforeAll(done => {
nodesApi.createFile(file).then(resp => fileId = resp.data.entry.id)
.then(() => sharedApi.shareFileById(fileId))
.then(() => sharedApi.waitForApi({ expect: 1 }))
.then(() => loginPage.loginWith(username))
.then(done);
});
afterAll(done => {
Promise.all([
nodesApi.deleteNodeById(fileId),
logoutPage.load()
])
.then(done);
});
it('page selector not displayed when having a single page [C213165]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES)
.then(() => dataTable.waitForHeader())
.then(() => expect(pagination.pagesButton.isPresent()).toBe(false, 'page selector displayed'));
});
});
describe('on multiple pages', () => {
beforeAll(done => {
nodesApi.createFiles(files, parent)
.then(resp => filesIds = resp.data.list.entries.map(entries => entries.entry.id))
.then(() => sharedApi.shareFilesByIds(filesIds))
.then(() => sharedApi.waitForApi({ expect: 101 }))
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.SHARED_FILES)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterEach(done => {
browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform().then(done);
});
afterAll(done => {
Promise.all([
nodesApi.deleteNodes([ parent ]),
logoutPage.load()
])
.then(done);
});
it('default values [C213157]', () => {
expect(pagination.range.getText()).toContain('1-25 of 101');
expect(pagination.maxItems.getText()).toContain('25');
expect(pagination.currentPage.getText()).toContain('Page 1');
expect(pagination.totalPages.getText()).toContain('of 5');
expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled');
expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
});
it('page sizes [C213157]', () => {
pagination.openMaxItemsMenu()
.then(() => {
const [ first, second, third ] = [1, 2, 3]
.map(nth => pagination.menu.getNthItem(nth).getText());
expect(first).toBe('25');
expect(second).toBe('50');
expect(third).toBe('100');
})
.then(() => pagination.menu.closeMenu());
});
it('change the page size [C213158]', () => {
pagination.openMaxItemsMenu()
.then(() => pagination.menu.clickMenuItem('50'))
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.maxItems.getText()).toContain('50');
expect(pagination.totalPages.getText()).toContain('of 3');
})
.then(() => pagination.openMaxItemsMenu())
.then(() => pagination.menu.clickMenuItem('100'))
.then(() => {
expect(pagination.getText(pagination.maxItems)).toContain('100');
expect(pagination.getText(pagination.totalPages)).toContain('of 2');
})
.then(() => pagination.resetToDefaultPageSize());
});
it('current page menu items', () => {
pagination.openCurrentPageMenu()
.then(() => expect(pagination.menu.getItemsCount()).toBe(5))
.then(() => pagination.menu.closeMenu());
});
it('change the current page from menu [C260518]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(3))
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('51-75 of 101');
expect(pagination.currentPage.getText()).toContain('Page 3');
expect(pagination.previousButton.isEnabled()).toBe(true, 'Previous button is not enabled');
expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
expect(dataTable.getRowName('file-40.txt').isPresent())
.toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('navigate to next page [C213160]', () => {
pagination.nextButton.click()
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('26-50 of 101');
expect(dataTable.getRowName('file-70.txt').isPresent()).toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('navigate to previous page [C213160]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(2))
.then(() => dataTable.waitForHeader())
.then(() => pagination.previousButton.click())
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('1-25 of 101');
expect(dataTable.getRowName('file-88.txt').isPresent()).toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('Previous button is disabled on first page [C260519]', () => {
expect(pagination.currentPage.getText()).toContain('Page 1');
expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled on first page');
});
it('Next button is disabled on last page [C260519]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(5))
.then(() => {
expect(dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page');
expect(pagination.currentPage.getText()).toContain('Page 5');
expect(pagination.nextButton.isEnabled()).toBe(false, 'Next button is enabled on last page');
});
});
});
});

View File

@@ -0,0 +1,233 @@
/*!
* @license
* Alfresco Example Content Application
*
* Copyright (C) 2005 - 2018 Alfresco Software Limited
*
* This file is part of the Alfresco Example Content Application.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { browser } from 'protractor';
import { SIDEBAR_LABELS } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';
import { RepoClient } from '../../utilities/repo-client/repo-client';
describe('Pagination on Trash', () => {
const username = `user-${Utils.random()}`;
const apis = {
admin: new RepoClient(),
user: new RepoClient(username, username)
};
const { nodes: nodesApi, trashcan: trashApi } = apis.user;
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable, pagination } = page;
const filesForDelete = Array(101)
.fill('file')
.map((name, index): string => `${name}-${index + 1}.txt`);
let filesDeletedIds;
const file = `file-${Utils.random()}.txt`; let fileId;
beforeAll(done => {
apis.admin.people.createUser(username).then(done);
});
xit('');
describe('on empty page', () => {
beforeAll(done => {
loginPage.loginWith(username).then(done);
});
afterAll(done => {
logoutPage.load().then(done);
});
it('pagination controls not displayed [C213164]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH)
.then(() => {
expect(pagination.range.isPresent()).toBe(false);
expect(pagination.maxItems.isPresent()).toBe(false);
expect(pagination.currentPage.isPresent()).toBe(false);
expect(pagination.totalPages.isPresent()).toBe(false);
expect(pagination.previousButton.isPresent()).toBe(false);
expect(pagination.nextButton.isPresent()).toBe(false);
});
});
});
describe('on single page', () => {
beforeAll(done => {
nodesApi.createFile(file).then(resp => fileId = resp.data.entry.id)
.then(() => nodesApi.deleteNodeById(fileId, false))
.then(() => trashApi.waitForApi({ expect: 1 }))
.then(() => loginPage.loginWith(username))
.then(done);
});
afterAll(done => {
Promise.all([
trashApi.emptyTrash(),
logoutPage.load()
])
.then(done);
});
it('page selector not displayed when having a single page [C213165]', () => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH)
.then(() => dataTable.waitForHeader())
.then(() => expect(pagination.pagesButton.isPresent()).toBe(false, 'page selector displayed'));
});
});
describe('on multiple pages', () => {
beforeAll(done => {
nodesApi.createFiles(filesForDelete)
.then(resp => filesDeletedIds = resp.data.list.entries.map(entries => entries.entry.id))
.then(() => nodesApi.deleteNodesById(filesDeletedIds, false))
.then(() => trashApi.waitForApi({expect: 101}))
.then(() => loginPage.loginWith(username))
.then(done);
});
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.TRASH)
.then(() => dataTable.waitForHeader())
.then(done);
});
afterEach(done => {
browser.actions().mouseMove(browser.$('body'), { x: 0, y: 0 }).click().perform().then(done);
});
afterAll(done => {
Promise.all([
trashApi.emptyTrash(),
logoutPage.load()
])
.then(done);
});
it('default values [C213157]', () => {
expect(pagination.range.getText()).toContain('1-25 of 101');
expect(pagination.maxItems.getText()).toContain('25');
expect(pagination.currentPage.getText()).toContain('Page 1');
expect(pagination.totalPages.getText()).toContain('of 5');
expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled');
expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
});
it('page sizes [C213157]', () => {
pagination.openMaxItemsMenu()
.then(() => {
const [ first, second, third ] = [1, 2, 3]
.map(nth => pagination.menu.getNthItem(nth).getText());
expect(first).toBe('25');
expect(second).toBe('50');
expect(third).toBe('100');
})
.then(() => pagination.menu.closeMenu());
});
it('change the page size [C213158]', () => {
pagination.openMaxItemsMenu()
.then(() => pagination.menu.clickMenuItem('50'))
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.maxItems.getText()).toContain('50');
expect(pagination.totalPages.getText()).toContain('of 3');
})
.then(() => pagination.openMaxItemsMenu())
.then(() => pagination.menu.clickMenuItem('100'))
.then(() => {
expect(pagination.getText(pagination.maxItems)).toContain('100');
expect(pagination.getText(pagination.totalPages)).toContain('of 2');
})
.then(() => pagination.resetToDefaultPageSize());
});
it('current page menu items', () => {
pagination.openCurrentPageMenu()
.then(() => expect(pagination.menu.getItemsCount()).toBe(5))
.then(() => pagination.menu.closeMenu());
});
it('change the current page from menu [C260518]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(3))
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('51-75 of 101');
expect(pagination.currentPage.getText()).toContain('Page 3');
expect(pagination.previousButton.isEnabled()).toBe(true, 'Previous button is not enabled');
expect(pagination.nextButton.isEnabled()).toBe(true, 'Next button is not enabled');
expect(dataTable.getRowName('file-40.txt').isPresent()).toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('navigate to next page [C213160]', () => {
pagination.nextButton.click()
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('26-50 of 101');
expect(dataTable.getRowName('file-70.txt').isPresent()).toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('navigate to previous page [C213160]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(2))
.then(() => dataTable.waitForHeader())
.then(() => pagination.previousButton.click())
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('1-25 of 101');
expect(dataTable.getRowName('file-88.txt').isPresent()).toBe(true, 'File not found on page');
})
.then(() => pagination.resetToDefaultPageNumber());
});
it('Previous button is disabled on first page [C260519]', () => {
expect(pagination.currentPage.getText()).toContain('Page 1');
expect(pagination.previousButton.isEnabled()).toBe(false, 'Previous button is enabled on first page');
});
it('Next button is disabled on last page [C260519]', () => {
pagination.openCurrentPageMenu()
.then(() => pagination.menu.clickNthItem(5))
.then(() => {
expect(dataTable.countRows()).toBe(1, 'Incorrect number of items on the last page');
expect(pagination.currentPage.getText()).toContain('Page 5');
expect(pagination.nextButton.isEnabled()).toBe(false, 'Next button is enabled on last page');
});
});
});
});