Optimize e2e framework (#1428)

* reduce breadcrumb page

* imrpove readability of code

* reduce data-table page size

* reduce datetime-picker code

* fix datatable page

* header and info drawer

* update datatable page

* toolbar cleanup

* more test components cleanup

* even move component cleanup

* move wait utils to the Utils

* unified waits

* cleanup menu page

* code fixes

* fix code

* code improvements

* rename api

* fix code

* fix code

* cleanup dialog pages

* more fixes and dead code removal

* code fixes

* try to fix the flaky teset

* fix code

* fix code

* update code

* fix lint

* unified text input

* fix lint

* add missing await

* reduce the wrapper method around clear text

* resolve element value

Co-authored-by: Cilibiu Bogdan <bogdan.cilibiu@ness.com>
This commit is contained in:
Denys Vuika
2020-04-29 08:40:55 +01:00
committed by GitHub
parent ebdaa39209
commit 5259f840a8
78 changed files with 1521 additions and 2486 deletions

View File

@@ -23,71 +23,54 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ElementFinder, by, browser, until } from 'protractor';
import { by, browser } from 'protractor';
import { Component } from '../component';
import { UserInfo } from './user-info';
import { Menu } from '../menu/menu';
import { Toolbar } from './../toolbar/toolbar';
import { SearchInput } from '../search/search-input';
import { BROWSER_WAIT_TIMEOUT } from '../../configs';
import { waitElement } from '../../utilities/utils';
export class Header extends Component {
private static selectors = {
root: 'app-header',
logoLink: by.css('.app-menu__title'),
userInfo: by.css('aca-current-user'),
moreActions: by.id('app.header.more'),
logoLink = this.byCss('.app-menu__title');
moreActions = browser.element(by.id('app.header.more'));
sidenavToggle = this.byCss(`[id='adf-sidebar-toggle-start']`);
sidenavToggle: `[id='adf-sidebar-toggle-start']`,
expandedSidenav: by.css(`[data-automation-id='expanded']`),
collapsedSidenav: by.css(`[data-automation-id='collapsed']`)
};
logoLink: ElementFinder = this.component.element(Header.selectors.logoLink);
moreActions: ElementFinder = browser.element(Header.selectors.moreActions);
sidenavToggle: ElementFinder = this.component.element(by.css(Header.selectors.sidenavToggle));
userInfo: UserInfo = new UserInfo();
menu: Menu = new Menu();
toolbar: Toolbar = new Toolbar();
searchInput: SearchInput = new SearchInput();
userInfo = new UserInfo();
menu = new Menu();
toolbar = new Toolbar();
searchInput = new SearchInput();
constructor(ancestor?: string) {
super('adf-layout-header', ancestor);
}
async openMoreMenu() {
async openMoreMenu(): Promise<void> {
await this.moreActions.click();
await this.menu.waitForMenuToOpen();
}
async isSignOutDisplayed() {
async isSignOutDisplayed(): Promise<boolean> {
return this.userInfo.menu.isMenuItemPresent('Sign out');
}
async clickSidenavToggle() {
await this.sidenavToggle.click();
async isSidenavExpanded(): Promise<boolean> {
return browser.isElementPresent(by.css(`[data-automation-id='expanded']`));
}
async isSidenavExpanded() {
return browser.isElementPresent(Header.selectors.expandedSidenav);
}
async expandSideNav() {
async expandSideNav(): Promise<void> {
const expanded = await this.isSidenavExpanded();
if ( !expanded ) {
await this.clickSidenavToggle();
await browser.wait(until.elementLocated(Header.selectors.expandedSidenav), BROWSER_WAIT_TIMEOUT, '--- timeout waiting for expanded sidenav' );
if (!expanded) {
await this.sidenavToggle.click();
await waitElement(`[data-automation-id='expanded']`);
}
}
async collapseSideNav() {
async collapseSideNav(): Promise<void> {
const expanded = await this.isSidenavExpanded();
if ( expanded ) {
await this.clickSidenavToggle();
await browser.wait(until.elementLocated(Header.selectors.collapsedSidenav), BROWSER_WAIT_TIMEOUT, '--- timeout waiting for collapsed sidenav')
if (expanded) {
await this.sidenavToggle.click();
await waitElement(`[data-automation-id='collapsed']`);
}
}
}