[ACA-990] framework improvements (#96)

* refactoring

* e2e API improvements

* forgot one file
This commit is contained in:
Adina Parpalita 2017-11-28 22:02:47 +02:00 committed by Cilibiu Bogdan
parent 1dade550a1
commit 79f8ec33a9
18 changed files with 184 additions and 151 deletions

View File

@ -34,6 +34,7 @@ export class DataTable extends Component {
row: 'tr',
selectedRow: 'tr.is-selected',
cell: 'td',
nameCell: 'td.app-name-column',
emptyListContainer: 'td.adf-no-content-container',
emptyFolderDragAndDrop: '.adf-empty-list_template .adf-empty-folder',
@ -44,7 +45,6 @@ export class DataTable extends Component {
head: ElementFinder = this.component.element(by.css(DataTable.selectors.head));
body: ElementFinder = this.component.element(by.css(DataTable.selectors.body));
cell = by.css(DataTable.selectors.cell);
emptyList: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyListContainer));
emptyFolderDragAndDrop: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyFolderDragAndDrop));
emptyListTitle: ElementFinder = this.component.element(by.css(DataTable.selectors.emptyListTitle));
@ -113,18 +113,16 @@ export class DataTable extends Component {
}
// Navigation/selection methods
doubleClickOnRowByContainingText(text: string): promise.Promise<void> {
const row = this.getRowByContainingText(text);
const dblClick = browser.actions().mouseMove(row).click().click();
doubleClickOnItemName(name: string): promise.Promise<void> {
const locator = by.cssContainingText(DataTable.selectors.nameCell, name);
const dblClick = browser.actions().mouseMove(this.body.element(locator)).click().click();
return dblClick.perform();
}
clickOnRowByContainingText(text: string): promise.Promise<void> {
const row = this.getRowByContainingText(text);
const click = browser.actions().mouseMove(row).click();
return click.perform();
clickOnItemName(name: string): promise.Promise<void> {
const locator = by.cssContainingText(DataTable.selectors.nameCell, name);
return this.body.element(locator).click();
}
selectMultipleItems(names: string[]): promise.Promise<void> {

View File

@ -47,7 +47,11 @@ export class Menu extends Component {
return this.getItemByLabel(label).getAttribute('title');
}
clicktNthItem(nth: number): promise.Promise<void> {
getItemsCount(): promise.Promise<number> {
return this.items.count();
}
clickNthItem(nth: number): promise.Promise<void> {
return this.getNthItem(nth).click();
}

View File

@ -19,7 +19,7 @@ import { browser, element, by, ElementFinder, promise, ExpectedConditions as EC
import { BROWSER_WAIT_TIMEOUT } from './../configs';
export abstract class Page {
private static USE_HASH_STRATEGY = false;
private static USE_HASH_STRATEGY = true;
private locators = {
app: by.css('app-root'),

View File

@ -87,7 +87,7 @@ describe('Create folder', () => {
});
it('option is enabled when having enough permissions', () => {
personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent)
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => personalFilesPage.sidenav.openNewMenu()
.then((menu) => {
const isEnabled = menu.getItemByLabel('Create folder').getWebElement().isEnabled();
@ -98,7 +98,7 @@ describe('Create folder', () => {
});
it('creates new folder with name', () => {
personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent)
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => openCreateDialog()
.then(() => createDialog.enterName(folderName1).clickCreate())
.then(() => createDialog.waitForDialogToClose())
@ -111,7 +111,7 @@ describe('Create folder', () => {
});
it('creates new folder with name and description', () => {
personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent)
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => openCreateDialog()
.then(() => {
createDialog
@ -133,7 +133,7 @@ describe('Create folder', () => {
});
it('enabled option tooltip', () => {
personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent)
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => personalFilesPage.sidenav.openNewMenu()
.then(menu => {
const action = browser.actions().mouseMove(menu.getItemByLabel('Create folder'));
@ -152,8 +152,8 @@ describe('Create folder', () => {
const fileLibrariesPage = new BrowsingPage(APP_ROUTES.FILE_LIBRARIES);
fileLibrariesPage.sidenav.navigateToLinkByLabel('File Libraries')
.then(() => fileLibrariesPage.dataTable.doubleClickOnRowByContainingText(siteName))
.then(() => fileLibrariesPage.dataTable.doubleClickOnRowByContainingText(folderName1))
.then(() => fileLibrariesPage.dataTable.doubleClickOnItemName(siteName))
.then(() => fileLibrariesPage.dataTable.doubleClickOnItemName(folderName1))
.then(() => fileLibrariesPage.sidenav.openNewMenu())
.then(menu => {
const isEnabled = menu.getItemByLabel('Create folder').getWebElement().isEnabled();
@ -165,8 +165,8 @@ describe('Create folder', () => {
const fileLibrariesPage = new BrowsingPage(APP_ROUTES.FILE_LIBRARIES);
fileLibrariesPage.sidenav.navigateToLinkByLabel('File Libraries')
.then(() => fileLibrariesPage.dataTable.doubleClickOnRowByContainingText(siteName))
.then(() => fileLibrariesPage.dataTable.doubleClickOnRowByContainingText(folderName1))
.then(() => fileLibrariesPage.dataTable.doubleClickOnItemName(siteName))
.then(() => fileLibrariesPage.dataTable.doubleClickOnItemName(folderName1))
.then(() => fileLibrariesPage.sidenav.openNewMenu())
.then(menu => {
const action = browser.actions().mouseMove(menu.getItemByLabel('Create folder'));
@ -179,7 +179,7 @@ describe('Create folder', () => {
});
it('dialog UI elements', () => {
personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent)
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => openCreateDialog().then(() => {
const dialogTitle = createDialog.getTitle();
const isFolderNameDisplayed = createDialog.nameInput.getWebElement().isDisplayed();
@ -197,7 +197,7 @@ describe('Create folder', () => {
});
it('with empty folder name', () => {
personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent)
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => openCreateDialog()
.then(() => {
createDialog.deleteNameWithBackspace();
@ -213,7 +213,7 @@ describe('Create folder', () => {
});
it('with folder name ending with a dot "."', () => {
personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent)
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => openCreateDialog()
.then(() => createDialog.enterName('folder-name.'))
.then((dialog) => {
@ -229,7 +229,7 @@ describe('Create folder', () => {
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.doubleClickOnRowByContainingText(parent)
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => openCreateDialog()
.then(() => {
namesWithSpecialChars.forEach(name => {
@ -246,7 +246,7 @@ describe('Create folder', () => {
});
it('with folder name containing only spaces', () => {
personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent)
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => openCreateDialog()
.then(() => createDialog.enterName(' '))
.then((dialog) => {
@ -260,7 +260,7 @@ describe('Create folder', () => {
});
it('cancel folder creation', () => {
personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent)
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => openCreateDialog()
.then(() => {
createDialog
@ -273,7 +273,7 @@ describe('Create folder', () => {
});
it('duplicate folder name', () => {
personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent)
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => openCreateDialog()
.then(() => createDialog.enterName(duplicateFolderName).clickCreate())
.then(() => {
@ -287,7 +287,7 @@ describe('Create folder', () => {
});
it('trim ending spaces from folder name', () => {
personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent)
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => openCreateDialog()
.then(() => createDialog.enterName(nameWithSpaces).clickCreate())
.then(() => createDialog.waitForDialogToClose())

View File

@ -87,8 +87,8 @@ describe('Edit folder', () => {
});
it('dialog UI defaults', () => {
personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent)
.then(() => dataTable.clickOnRowByContainingText(folderName)
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => dataTable.clickOnItemName(folderName)
.then(() => editButton.click())
.then(() => {
expect(editDialog.getTitle()).toBe('Edit folder');
@ -101,8 +101,8 @@ describe('Edit folder', () => {
});
it('properties are modified when pressing OK', () => {
personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent)
.then(() => dataTable.clickOnRowByContainingText(folderNameToEdit)
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => dataTable.clickOnItemName(folderNameToEdit)
.then(() => editButton.click())
.then(() => {
editDialog
@ -126,8 +126,8 @@ describe('Edit folder', () => {
});
it('with empty folder name', () => {
personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent)
.then(() => dataTable.clickOnRowByContainingText(folderName)
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => dataTable.clickOnItemName(folderName)
.then(() => editButton.click())
.then(() => {
editDialog.deleteNameWithBackspace();
@ -142,8 +142,8 @@ describe('Edit folder', () => {
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' ];
personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent)
.then(() => dataTable.clickOnRowByContainingText(folderName)
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => dataTable.clickOnItemName(folderName)
.then(() => editButton.click())
.then(() => {
namesWithSpecialChars.forEach(name => {
@ -157,8 +157,8 @@ describe('Edit folder', () => {
});
it('with name ending with a dot', () => {
personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent)
.then(() => dataTable.clickOnRowByContainingText(folderName)
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => dataTable.clickOnItemName(folderName)
.then(() => editButton.click())
.then(() => editDialog.nameInput.sendKeys('.'))
.then(() => {
@ -169,8 +169,8 @@ describe('Edit folder', () => {
});
it('Cancel button', () => {
personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent)
.then(() => dataTable.clickOnRowByContainingText(folderName)
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => dataTable.clickOnItemName(folderName)
.then(() => editButton.click())
.then(() => editDialog.clickCancel())
.then(() => {
@ -180,8 +180,8 @@ describe('Edit folder', () => {
});
it('with duplicate folder name', () => {
personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent)
.then(() => dataTable.clickOnRowByContainingText(folderName)
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => dataTable.clickOnItemName(folderName)
.then(() => editButton.click())
.then(() => editDialog.enterName(duplicateFolderName).clickUpdate())
.then(() => {
@ -195,8 +195,8 @@ describe('Edit folder', () => {
});
it('trim ending spaces', () => {
personalFilesPage.dataTable.doubleClickOnRowByContainingText(parent)
.then(() => dataTable.clickOnRowByContainingText(folderName)
personalFilesPage.dataTable.doubleClickOnItemName(parent)
.then(() => dataTable.clickOnItemName(folderName)
.then(() => editButton.click())
.then(() => editDialog.nameInput.sendKeys(' '))
.then(() => editDialog.clickUpdate())

View File

@ -25,14 +25,12 @@ describe('Permanently delete from Trash', () => {
const username = `user-${Utils.random()}`;
const file1 = `file-${Utils.random()}.txt`;
let file1Id;
const file2 = `file-${Utils.random()}.txt`;
let file2Id;
let filesIds;
const folder1 = `folder-${Utils.random()}`;
let folder1Id;
const folder2 = `folder-${Utils.random()}`;
let folder2Id;
let foldersIds;
const apis = {
admin: new RepoClient(),
@ -47,15 +45,13 @@ describe('Permanently delete from Trash', () => {
beforeAll(done => {
apis.admin.people.createUser(username)
.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([ 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.deleteNodeById(file1Id, false))
.then(() => apis.user.nodes.deleteNodeById(file2Id, false))
.then(() => apis.user.nodes.deleteNodeById(folder1Id, false))
.then(() => apis.user.nodes.deleteNodeById(folder2Id, false))
.then(() => apis.user.nodes.deleteNodesById(filesIds, false))
.then(() => apis.user.nodes.deleteNodesById(foldersIds, false))
.then(() => loginPage.load())
.then(() => loginPage.loginWith(username))
@ -70,21 +66,15 @@ describe('Permanently delete from Trash', () => {
afterAll(done => {
Promise.all([
apis.user.trashcan.permanentlyDelete(file1Id),
apis.user.trashcan.permanentlyDelete(file2Id),
apis.user.trashcan.permanentlyDelete(folder1Id),
apis.user.trashcan.permanentlyDelete(folder2Id),
apis.user.trashcan.emptyTrash(),
logoutPage.load()
])
.then(done);
});
it('delete file', () => {
dataTable.clickOnRowByContainingText(file1)
.then(() => {
const button = toolbar.actions.getButtonByTitleAttribute('Permanently delete');
button.click();
})
dataTable.clickOnItemName(file1)
.then(() => toolbar.actions.getButtonByTitleAttribute('Permanently delete').click())
.then(() => trashPage.getSnackBarMessage())
.then(text => {
expect(text).toBe(`${file1} deleted`);
@ -93,11 +83,8 @@ describe('Permanently delete from Trash', () => {
});
it('delete folder', () => {
dataTable.clickOnRowByContainingText(folder1)
.then(() => {
const button = toolbar.actions.getButtonByTitleAttribute('Permanently delete');
button.click();
})
dataTable.clickOnItemName(folder1)
.then(() => toolbar.actions.getButtonByTitleAttribute('Permanently delete').click())
.then(() => trashPage.getSnackBarMessage())
.then(text => {
expect(text).toBe(`${folder1} deleted`);
@ -107,10 +94,7 @@ describe('Permanently delete from Trash', () => {
it('delete multiple items', () => {
dataTable.selectMultipleItems([ file2, folder2 ])
.then(() => {
const button = toolbar.actions.getButtonByTitleAttribute('Permanently delete');
button.click();
})
.then(() => toolbar.actions.getButtonByTitleAttribute('Permanently delete').click())
.then(() => trashPage.getSnackBarMessage())
.then(text => {
expect(text).toBe(`2 items deleted`);

View File

@ -25,16 +25,13 @@ describe('Restore from Trash', () => {
const username = `user-${Utils.random()}`;
const file1 = `file-${Utils.random()}.txt`;
let file1Id;
const file2 = `file-${Utils.random()}.txt`;
let file2Id;
const file3 = `file-${Utils.random()}.txt`;
let file3Id;
let filesIds;
const folder1 = `folder-${Utils.random()}`;
let folder1Id;
const folder2 = `folder-${Utils.random()}`;
let folder2Id;
let foldersIds;
const apis = {
admin: new RepoClient(),
@ -50,17 +47,13 @@ describe('Restore from Trash', () => {
beforeAll(done => {
apis.admin.people.createUser(username)
.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.createFiles([ file3 ]).then(resp => file3Id = 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([ file1, file2, file3 ]))
.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.deleteNodeById(file1Id, false))
.then(() => apis.user.nodes.deleteNodeById(file2Id, false))
.then(() => apis.user.nodes.deleteNodeById(file3Id, false))
.then(() => apis.user.nodes.deleteNodeById(folder1Id, false))
.then(() => apis.user.nodes.deleteNodeById(folder2Id, false))
.then(() => apis.user.nodes.deleteNodesById(filesIds, false))
.then(() => apis.user.nodes.deleteNodesById(foldersIds, false))
.then(() => loginPage.load())
.then(() => loginPage.loginWith(username))
@ -75,18 +68,16 @@ describe('Restore from Trash', () => {
afterAll(done => {
Promise.all([
apis.user.nodes.deleteNodeById(file1Id),
apis.user.nodes.deleteNodeById(file2Id),
apis.user.nodes.deleteNodeById(file3Id),
apis.user.nodes.deleteNodeById(folder1Id),
apis.user.nodes.deleteNodeById(folder2Id),
apis.user.nodes.deleteNodesById(filesIds),
apis.user.nodes.deleteNodesById(foldersIds),
apis.user.trashcan.emptyTrash(),
logoutPage.load()
])
.then(done);
});
it('restore file', () => {
dataTable.clickOnRowByContainingText(file1)
dataTable.clickOnItemName(file1)
.then(() => toolbar.actions.getButtonByTitleAttribute('Restore').click())
.then(() => trashPage.getSnackBarMessage())
.then(text => {
@ -102,7 +93,7 @@ describe('Restore from Trash', () => {
});
it('restore folder', () => {
dataTable.clickOnRowByContainingText(folder1)
dataTable.clickOnItemName(folder1)
.then(() => toolbar.actions.getButtonByTitleAttribute('Restore').click())
.then(() => trashPage.getSnackBarMessage())
.then(text => {
@ -136,7 +127,7 @@ describe('Restore from Trash', () => {
});
it('View from notification', () => {
dataTable.clickOnRowByContainingText(file3)
dataTable.clickOnItemName(file3)
.then(() => toolbar.actions.getButtonByTitleAttribute('Restore').click())
.then(() => trashPage.getSnackBarAction().click())
.then(() => personalFilesPage.dataTable.waitForHeader())

View File

@ -189,7 +189,7 @@ describe('Toolbar actions - multiple selection : ', () => {
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES)
.then(() => dataTable.waitForHeader())
.then(() => dataTable.doubleClickOnRowByContainingText(siteName))
.then(() => dataTable.doubleClickOnItemName(siteName))
.then(() => dataTable.waitForHeader())
.then(done);
});

View File

@ -49,15 +49,18 @@ describe('Toolbar actions - single selection : ', () => {
const loginPage = new LoginPage();
const logoutPage = new LogoutPage();
const page = new BrowsingPage();
const { dataTable } = page;
const { toolbar } = page;
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.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))
@ -97,21 +100,21 @@ describe('Toolbar actions - single selection : ', () => {
});
it('actions are displayed when a file is selected', () => {
dataTable.clickOnRowByContainingText(fileUser)
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.clickOnRowByContainingText(folderUser)
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.clickOnRowByContainingText(fileUser)
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}`);
@ -128,7 +131,7 @@ describe('Toolbar actions - single selection : ', () => {
});
it('correct actions appear when a folder is selected', () => {
dataTable.clickOnRowByContainingText(folderUser)
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}`);
@ -159,7 +162,7 @@ describe('Toolbar actions - single selection : ', () => {
beforeEach(done => {
page.sidenav.navigateToLinkByLabel(SIDEBAR_LABELS.FILE_LIBRARIES)
.then(() => dataTable.waitForHeader())
.then(() => dataTable.doubleClickOnRowByContainingText(siteName))
.then(() => dataTable.doubleClickOnItemName(siteName))
.then(() => dataTable.waitForHeader())
.then(done);
});
@ -186,21 +189,21 @@ describe('Toolbar actions - single selection : ', () => {
});
it('actions are displayed when a file is selected', () => {
dataTable.clickOnRowByContainingText(fileAdmin)
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.clickOnRowByContainingText(folderAdmin)
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.clickOnRowByContainingText(fileAdmin)
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}`);
@ -217,7 +220,7 @@ describe('Toolbar actions - single selection : ', () => {
});
it('correct actions appear when a folder is selected', () => {
dataTable.clickOnRowByContainingText(folderAdmin)
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}`);
@ -250,21 +253,21 @@ describe('Toolbar actions - single selection : ', () => {
});
it('actions are displayed when a file is selected', () => {
dataTable.clickOnRowByContainingText(fileAdmin)
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.clickOnRowByContainingText(folderAdmin)
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.clickOnRowByContainingText(fileAdmin)
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}`);
@ -281,7 +284,7 @@ describe('Toolbar actions - single selection : ', () => {
});
it('correct actions appear when a folder is selected', () => {
dataTable.clickOnRowByContainingText(folderAdmin)
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}`);
@ -321,14 +324,14 @@ describe('Toolbar actions - single selection : ', () => {
});
it('actions are displayed when a file is selected', () => {
dataTable.clickOnRowByContainingText(fileUser)
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.clickOnRowByContainingText(fileUser)
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}`);
@ -367,14 +370,14 @@ describe('Toolbar actions - single selection : ', () => {
});
it('actions are displayed when a file is selected', () => {
dataTable.clickOnRowByContainingText(fileUser)
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.clickOnRowByContainingText(fileUser)
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}`);
@ -413,21 +416,21 @@ describe('Toolbar actions - single selection : ', () => {
});
it('actions are displayed when a file is selected', () => {
dataTable.clickOnRowByContainingText(fileUser)
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.clickOnRowByContainingText(folderUser)
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.clickOnRowByContainingText(fileUser)
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}`);
@ -444,7 +447,7 @@ describe('Toolbar actions - single selection : ', () => {
});
it('correct actions appear when a folder is selected', () => {
dataTable.clickOnRowByContainingText(folderUser)
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}`);
@ -490,21 +493,21 @@ describe('Toolbar actions - single selection : ', () => {
});
it('actions are displayed when a file is selected', () => {
dataTable.clickOnRowByContainingText(fileForDelete)
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.clickOnRowByContainingText(folderForDelete)
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.clickOnRowByContainingText(fileForDelete)
dataTable.clickOnItemName(fileForDelete)
.then(() => {
expect(toolbar.actions.isButtonPresent('Permanently delete'))
.toBe(true, `Permanently delete is not displayed for ${fileForDelete}`);
@ -513,7 +516,7 @@ describe('Toolbar actions - single selection : ', () => {
});
it('correct actions appear when a folder is selected', () => {
dataTable.clickOnRowByContainingText(folderForDelete)
dataTable.clickOnItemName(folderForDelete)
.then(() => {
expect(toolbar.actions.isButtonPresent('Permanently delete'))
.toBe(true, `Permanently delete is displayed for ${folderForDelete}`);

View File

@ -15,8 +15,6 @@
* limitations under the License.
*/
import { browser, by } from 'protractor';
import { APP_ROUTES, SITE_VISIBILITY, SITE_ROLES, SIDEBAR_LABELS } from '../../configs';
import { LoginPage, LogoutPage, BrowsingPage } from '../../pages/pages';
import { Utils } from '../../utilities/utils';

View File

@ -134,7 +134,7 @@ describe('Personal Files', () => {
.then(response => response.data.entry.id);
const navigatePromise = dataTable
.doubleClickOnRowByContainingText(userFolder)
.doubleClickOnItemName(userFolder)
.then(() => dataTable.waitForHeader());
Promise
@ -158,7 +158,7 @@ describe('Personal Files', () => {
const { actions } = personalFilesPage.toolbar;
dataTable
.clickOnRowByContainingText(userFolder)
.clickOnItemName(userFolder)
.then(() => {
expect(actions.isEmpty()).toBe(false, 'Toolbar to be present');
})

View File

@ -65,14 +65,16 @@ describe('Pagination', () => {
beforeEach(done => {
personalFilesPage.load()
.then(() => dataTable.waitForHeader())
.then(() => dataTable.doubleClickOnRowByContainingText(content.name))
.then(() => dataTable.doubleClickOnItemName(content.name))
.then(() => dataTable.sortByColumn('Name'))
.then(done);
});
afterAll(done => {
logoutPage.load()
.then(() => nodesApi.deleteNodes([ content.name ]))
.then(() => {
nodesApi.deleteNodes([ content.name ]);
})
.then(done);
});
@ -116,7 +118,7 @@ describe('Pagination', () => {
it('changes the current page from menu', () => {
pagination.openCurrentPageMenu()
.then(menu => menu.clicktNthItem(3))
.then(menu => menu.clickNthItem(3))
.then(() => dataTable.waitForHeader())
.then(() => {
expect(pagination.range.getText()).toContain('51-75 of 101', 'Range');
@ -140,7 +142,7 @@ describe('Pagination', () => {
it('navigates to previous page', () => {
pagination.openCurrentPageMenu()
.then(menu => menu.clicktNthItem(2))
.then(menu => menu.clickNthItem(2))
.then(() => dataTable.waitForHeader())
.then(() => pagination.previousButton.click())
.then(() => dataTable.waitForHeader())
@ -153,7 +155,7 @@ describe('Pagination', () => {
it('has one item on the last page', () => {
pagination.openCurrentPageMenu()
.then(menu => menu.clicktNthItem(5))
.then(menu => menu.clickNthItem(5))
.then(() => dataTable.waitForHeader())
.then(() => {
expect(dataTable.countRows()).toBe(1, 'Single item on the last page');

View File

@ -52,6 +52,12 @@ export class FavoritesApi extends RepoApi {
.catch(this.handleError);
}
addFavoritesByIds(nodeType: string, ids: string[]): Promise<any[]> {
return ids.reduce((previous, current) => (
previous.then(() => this.addFavoriteById(nodeType, current))
), Promise.resolve());
}
getFavorite(api: RepoClient, name: string): Promise<any> {
return api.nodes.getNodeByPath(name)
.then((response) => {

View File

@ -33,6 +33,12 @@ export class NodesApi extends RepoApi {
.catch(this.handleError);
}
getNodeDescription(name: string): Promise<string> {
return this.getNodeByPath(name)
.then(response => response.data.entry.properties['cm:description'])
.catch(() => Promise.resolve(''));
}
deleteNodeById(id: string, permanent: boolean = true): Promise<any> {
return this
.delete(`/nodes/${id}?permanent=${permanent}`)
@ -47,19 +53,10 @@ export class NodesApi extends RepoApi {
.catch(this.handleError);
}
getNodeDescription(name: string): Promise<string> {
return this.getNodeByPath(name)
.then(response => response.data.entry.properties['cm:description'])
.catch(() => Promise.resolve(''));
}
deleteNodes(names: string[], relativePath: string = '', permanent: boolean = true): Promise<any> {
const deletions = names
.map((name: string): any => {
return this.deleteNodeByPath(`${relativePath}/${name}`, permanent);
});
return Promise.all(deletions);
deleteNodes(names: string[], relativePath: string = '', permanent: boolean = true): Promise<any[]> {
return names.reduce((previous, current) => (
previous.then(() => this.deleteNodeByPath(`${relativePath}/${current}`, permanent))
), Promise.resolve());
}
deleteNodesById(ids: string[], permanent: boolean = true): Promise<any[]> {

View File

@ -28,6 +28,12 @@ export class SharedLinksApi extends RepoApi {
.catch(this.handleError);
}
shareFilesByIds(ids: string[]): Promise<any[]> {
return ids.reduce((previous, current) => (
previous.then(() => this.shareFileById(current))
), Promise.resolve());
}
getSharedLinks(): Promise<any> {
return this.get(`/shared-links`)
.catch(this.handleError);

View File

@ -35,7 +35,7 @@ export class SitesApi extends RepoApi {
.catch(this.handleError);
}
createSite(title: string, visibility: string, details?: Site): Promise<any> {
createOrUpdateSite(title: string, visibility: string, details?: Site): Promise<any> {
const site: Site = new Site(title, visibility, details);
const onSuccess = (response) => response;
const onError = (response) => {
@ -50,12 +50,31 @@ export class SitesApi extends RepoApi {
.catch(this.handleError);
}
createSite(title: string, visibility: string, details?: Site): Promise<any> {
const site: Site = new Site(title, visibility, details);
return this
.post(`/sites`, { data: site })
.catch(this.handleError);
}
createSites(titles: string[], visibility: string): Promise<any[]> {
return titles.reduce((previous, current) => (
previous.then(() => this.createSite(current, visibility))
), Promise.resolve());
}
deleteSite(id: string, permanent: boolean = true): Promise<any> {
return this
.delete(`/sites/${id}?permanent=${permanent}`)
.catch(this.handleError);
}
deleteSites(ids: string[], permanent: boolean = true): Promise<any[]> {
return ids.reduce((previous, current) => (
previous.then(() => this.deleteSite(current))
), Promise.resolve());
}
updateSiteMember(siteId: string, userId: string, role: string): Promise<any> {
return this
.put(`/sites/${siteId}/members/${userId}`, { data: { role } })

View File

@ -23,4 +23,24 @@ export class TrashcanApi extends RepoApi {
.delete(`/deleted-nodes/${id}`)
.catch(this.handleError);
}
getDeletedNodes(): Promise<any> {
return this
.get(`/deleted-nodes?maxItems=1000`)
.catch(this.handleError);
}
emptyTrash(): Promise<any> {
return this.getDeletedNodes()
.then(resp => {
return resp.data.list.entries.map(entries => entries.entry.id);
})
.then(ids => {
return ids.reduce((previous, current) => (
previous.then(() => this.permanentlyDelete(current))
), Promise.resolve());
})
.catch(this.handleError);
}
}

View File

@ -7,6 +7,9 @@ const jasmineReporters = require('jasmine-reporters');
const projectRoot = path.resolve(__dirname);
const width = 1366;
const height = 768;
exports.config = {
allScriptsTimeout: 11000,
@ -55,6 +58,8 @@ exports.config = {
project: 'e2e/tsconfig.e2e.json'
});
browser.manage().window().setSize(width, height);
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({