split toolbar and breadcrumb e2e components (#626)

This commit is contained in:
Adina Parpalita
2018-09-13 11:01:16 +03:00
committed by Denys Vuika
parent 28a4fb7ba7
commit aafa606ceb
22 changed files with 398 additions and 444 deletions

View File

@@ -26,18 +26,18 @@
import { ElementFinder, ElementArrayFinder, by, promise } from 'protractor';
import { Component } from '../component';
export class ToolbarBreadcrumb extends Component {
export class Breadcrumb extends Component {
private static selectors = {
root: 'adf-breadcrumb',
item: '.adf-breadcrumb-item',
currentItem: '.adf-breadcrumb-item-current'
};
items: ElementArrayFinder = this.component.all(by.css(ToolbarBreadcrumb.selectors.item));
currentItem: ElementFinder = this.component.element(by.css(ToolbarBreadcrumb.selectors.currentItem));
items: ElementArrayFinder = this.component.all(by.css(Breadcrumb.selectors.item));
currentItem: ElementFinder = this.component.element(by.css(Breadcrumb.selectors.currentItem));
constructor(ancestor?: ElementFinder) {
super(ToolbarBreadcrumb.selectors.root, ancestor);
super(Breadcrumb.selectors.root, ancestor);
}
getNthItem(nth: number): ElementFinder {
@@ -69,7 +69,7 @@ export class ToolbarBreadcrumb extends Component {
}
clickItem(name: string) {
return this.component.element(by.css(`${ToolbarBreadcrumb.selectors.item}[title=${name}]`)).click();
return this.component.element(by.css(`${Breadcrumb.selectors.item}[title=${name}]`)).click();
}
clickNthItem(nth: number) {

View File

@@ -32,4 +32,5 @@ export * from './dialog/create-edit-folder-dialog';
export * from './pagination/pagination';
export * from './sidenav/sidenav';
export * from './toolbar/toolbar';
export * from './breadcrumb/breadcrumb';
export * from './viewer/viewer';

View File

@@ -1,73 +0,0 @@
/*!
* @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 { ElementFinder, ElementArrayFinder, by, promise, protractor, browser } from 'protractor';
import { Menu } from '../menu/menu';
import { Component } from '../component';
export class ToolbarActions extends Component {
private static selectors = {
root: 'adf-toolbar',
button: '.mat-icon-button'
};
menu: Menu = new Menu();
buttons: ElementArrayFinder = this.component.all(by.css(ToolbarActions.selectors.button));
constructor(ancestor?: ElementFinder) {
super(ToolbarActions.selectors.root, ancestor);
}
async isEmpty() {
return await this.buttons.count() === 0;
}
async isButtonPresent(title: string) {
return await this.component.element(by.css(`${ToolbarActions.selectors.button}[title="${title}"]`)).isPresent();
}
getButtonByLabel(label: string) {
return this.component.element(by.cssContainingText(ToolbarActions.selectors.button, label));
}
getButtonByTitleAttribute(title: string) {
return this.component.element(by.css(`${ToolbarActions.selectors.button}[title="${title}"]`));
}
async openMoreMenu() {
await this.getButtonByTitleAttribute('More actions').click();
await this.menu.waitForMenuToOpen();
return this.menu;
}
async closeMoreMenu() {
return await browser.actions().sendKeys(protractor.Key.ESCAPE).perform();
}
async getButtonTooltip(button: ElementFinder) {
return await button.getAttribute('title');
}
}

View File

@@ -23,20 +23,51 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ElementFinder } from 'protractor';
import { ElementFinder, ElementArrayFinder, by, promise, protractor, browser } from 'protractor';
import { Menu } from '../menu/menu';
import { Component } from '../component';
import { ToolbarActions } from './toolbar-actions';
import { ToolbarBreadcrumb } from './toolbar-breadcrumb';
export class Toolbar extends Component {
private static selectors = {
root: '.inner-layout__header'
root: 'adf-toolbar',
button: '.mat-icon-button'
};
actions: ToolbarActions = new ToolbarActions(this.component);
breadcrumb: ToolbarBreadcrumb = new ToolbarBreadcrumb(this.component);
menu: Menu = new Menu();
buttons: ElementArrayFinder = this.component.all(by.css(Toolbar.selectors.button));
constructor(ancestor?: ElementFinder) {
super(Toolbar.selectors.root, ancestor);
}
async isEmpty() {
return await this.buttons.count() === 0;
}
async isButtonPresent(title: string) {
return await this.component.element(by.css(`${Toolbar.selectors.button}[title="${title}"]`)).isPresent();
}
getButtonByLabel(label: string) {
return this.component.element(by.cssContainingText(Toolbar.selectors.button, label));
}
getButtonByTitleAttribute(title: string) {
return this.component.element(by.css(`${Toolbar.selectors.button}[title="${title}"]`));
}
async openMoreMenu() {
await this.getButtonByTitleAttribute('More actions').click();
await this.menu.waitForMenuToOpen();
return this.menu;
}
async closeMoreMenu() {
return await browser.actions().sendKeys(protractor.Key.ESCAPE).perform();
}
async getButtonTooltip(button: ElementFinder) {
return await button.getAttribute('title');
}
}

View File

@@ -26,7 +26,7 @@
import { ElementFinder, by, browser, ExpectedConditions as EC } from 'protractor';
import { Component } from '../component';
import { BROWSER_WAIT_TIMEOUT } from '../../configs';
import { ToolbarActions } from '../toolbar/toolbar-actions';
import { Toolbar } from '../toolbar/toolbar';
export class Viewer extends Component {
private static selectors = {
@@ -46,7 +46,7 @@ export class Viewer extends Component {
fileTitle: ElementFinder = this.component.element(by.css(Viewer.selectors.fileTitle));
viewerExtensionContent: ElementFinder = this.component.element(by.css(Viewer.selectors.viewerExtensionContent));
toolbar = new ToolbarActions(this.component);
toolbar = new Toolbar(this.component);
constructor(ancestor?: ElementFinder) {
super(Viewer.selectors.root, ancestor);