mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
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:
@@ -23,60 +23,38 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { ElementFinder, ElementArrayFinder, by, browser } from 'protractor';
|
||||
import { ElementFinder, by, browser } from 'protractor';
|
||||
import { Menu } from '../menu/menu';
|
||||
import { Component } from '../component';
|
||||
import { Utils } from '../../utilities/utils';
|
||||
|
||||
export class Toolbar extends Component {
|
||||
private static selectors = {
|
||||
root: '.adf-toolbar',
|
||||
button: 'button',
|
||||
menu = new Menu();
|
||||
|
||||
share: `.mat-icon-button[title='Share']`,
|
||||
shareEdit: `.mat-icon-button[title='Shared Link Settings']`,
|
||||
view: `.mat-icon-button[title='View']`,
|
||||
searchFilterToggle: `.mat-icon-button[title='Toggle search filter']`,
|
||||
download: `.mat-icon-button[title='Download']`,
|
||||
editFolder: 'app.toolbar.editFolder',
|
||||
viewDetails: `.mat-icon-button[title='View Details']`,
|
||||
print: `.mat-icon-button[title='Print']`,
|
||||
fullScreen: `.mat-icon-button[title='Activate full-screen mode']`,
|
||||
joinLibrary: `.mat-icon-button[title='Join']`,
|
||||
leaveLibrary: `.mat-icon-button[title='Leave Library']`,
|
||||
permanentlyDelete: `.mat-icon-button[title='Permanently Delete']`,
|
||||
restore: `.mat-icon-button[title='Restore']`
|
||||
};
|
||||
|
||||
menu: Menu = new Menu();
|
||||
buttons: ElementArrayFinder = this.component.all(by.css(Toolbar.selectors.button));
|
||||
shareButton: ElementFinder = this.component.element(by.css(Toolbar.selectors.share));
|
||||
shareEditButton: ElementFinder = this.component.element(by.css(Toolbar.selectors.shareEdit));
|
||||
viewButton: ElementFinder = this.component.element(by.css(Toolbar.selectors.view));
|
||||
searchFiltersToggleButton: ElementFinder = this.component.element(by.css(Toolbar.selectors.searchFilterToggle));
|
||||
downloadButton: ElementFinder = this.component.element(by.css(Toolbar.selectors.download));
|
||||
editFolderButton: ElementFinder = this.component.element(by.id(Toolbar.selectors.editFolder));
|
||||
viewDetailsButton: ElementFinder = this.component.element(by.css(Toolbar.selectors.viewDetails));
|
||||
printButton: ElementFinder = this.component.element(by.css(Toolbar.selectors.print));
|
||||
fullScreenButton: ElementFinder = this.component.element(by.css(Toolbar.selectors.fullScreen));
|
||||
joinButton: ElementFinder = this.component.element(by.css(Toolbar.selectors.joinLibrary));
|
||||
leaveButton: ElementFinder = this.component.element(by.css(Toolbar.selectors.leaveLibrary));
|
||||
permanentlyDeleteButton: ElementFinder = this.component.element(by.css(Toolbar.selectors.permanentlyDelete));
|
||||
restoreButton: ElementFinder = this.component.element(by.css(Toolbar.selectors.restore));
|
||||
buttons = this.allByCss('button');
|
||||
shareButton = this.byCss(`.mat-icon-button[title='Share']`);
|
||||
shareEditButton = this.byCss(`.mat-icon-button[title='Shared Link Settings']`);
|
||||
viewButton = this.byCss(`.mat-icon-button[title='View']`);
|
||||
searchFiltersToggleButton = this.byCss(`.mat-icon-button[title='Toggle search filter']`);
|
||||
downloadButton = this.byCss(`.mat-icon-button[title='Download']`);
|
||||
editFolderButton = this.byId('app.toolbar.editFolder');
|
||||
viewDetailsButton = this.byCss(`.mat-icon-button[title='View Details']`);
|
||||
printButton = this.byCss(`.mat-icon-button[title='Print']`);
|
||||
fullScreenButton = this.byCss(`.mat-icon-button[title='Activate full-screen mode']`);
|
||||
joinButton = this.byCss(`.mat-icon-button[title='Join']`);
|
||||
leaveButton = this.byCss(`.mat-icon-button[title='Leave Library']`);
|
||||
permanentlyDeleteButton = this.byCss(`.mat-icon-button[title='Permanently Delete']`);
|
||||
restoreButton = this.byCss(`.mat-icon-button[title='Restore']`);
|
||||
|
||||
constructor(ancestor?: string) {
|
||||
super(Toolbar.selectors.root, ancestor);
|
||||
super('.adf-toolbar', ancestor);
|
||||
}
|
||||
|
||||
async isEmpty() {
|
||||
async isEmpty(): Promise<boolean> {
|
||||
const count = await this.buttons.count();
|
||||
return count === 0;
|
||||
}
|
||||
|
||||
async numberOfAvailableActions() {
|
||||
return this.buttons.count();
|
||||
}
|
||||
|
||||
async getButtons(): Promise<string[]> {
|
||||
return this.buttons.map(async elem => {
|
||||
return elem.getAttribute('title');
|
||||
@@ -84,26 +62,24 @@ export class Toolbar extends Component {
|
||||
}
|
||||
|
||||
async isButtonPresent(title: string) {
|
||||
const elem = this.component.element(by.css(`${Toolbar.selectors.button}[title="${title}"]`));
|
||||
return elem.isPresent();
|
||||
}
|
||||
|
||||
getButtonByLabel(label: string) {
|
||||
return this.component.element(by.cssContainingText(Toolbar.selectors.button, label));
|
||||
const element = this.byCss(`button[title="${title}"]`);
|
||||
return element.isPresent();
|
||||
}
|
||||
|
||||
getButtonByTitleAttribute(title: string) {
|
||||
return this.component.element(by.css(`${Toolbar.selectors.button}[title="${title}"]`));
|
||||
return this.byCss(`button[title="${title}"]`);
|
||||
}
|
||||
|
||||
getButtonById(id: string) {
|
||||
return this.component.element(by.id(id));
|
||||
}
|
||||
|
||||
async openMoreMenu() {
|
||||
async openMoreMenu(): Promise<void> {
|
||||
await this.isButtonPresent('More Actions');
|
||||
|
||||
const moreMenu = this.getButtonByTitleAttribute('More Actions');
|
||||
await moreMenu.click();
|
||||
|
||||
await this.menu.waitForMenuToOpen();
|
||||
}
|
||||
|
||||
@@ -111,150 +87,61 @@ export class Toolbar extends Component {
|
||||
await Utils.pressEscape();
|
||||
}
|
||||
|
||||
async getButtonTooltip(button: ElementFinder) {
|
||||
async getButtonTooltip(button: ElementFinder): Promise<string> {
|
||||
return button.getAttribute('title');
|
||||
}
|
||||
|
||||
async clickButton(title: string) {
|
||||
const btn = this.getButtonByTitleAttribute(title);
|
||||
await btn.click();
|
||||
}
|
||||
|
||||
|
||||
async isSharedLinkSettingsPresent() {
|
||||
return browser.isElementPresent(this.shareEditButton);
|
||||
}
|
||||
|
||||
async isSharePresent() {
|
||||
return browser.isElementPresent(this.shareButton);
|
||||
}
|
||||
|
||||
async isViewPresent() {
|
||||
return browser.isElementPresent(this.viewButton);
|
||||
}
|
||||
|
||||
async isToggleSearchFiltersPresent() {
|
||||
return browser.isElementPresent(this.searchFiltersToggleButton);
|
||||
}
|
||||
|
||||
async isDownloadPresent() {
|
||||
return browser.isElementPresent(this.downloadButton);
|
||||
}
|
||||
|
||||
async isPermanentlyDeletePresent() {
|
||||
return browser.isElementPresent(this.permanentlyDeleteButton);
|
||||
}
|
||||
|
||||
async isRestorePresent() {
|
||||
return browser.isElementPresent(this.restoreButton);
|
||||
}
|
||||
|
||||
async isEditFolderPresent() {
|
||||
return browser.isElementPresent(this.editFolderButton);
|
||||
}
|
||||
|
||||
async isViewDetailsPresent() {
|
||||
return browser.isElementPresent(this.viewDetailsButton);
|
||||
async clickButton(title: string): Promise<void> {
|
||||
await this.getButtonByTitleAttribute(title).click();
|
||||
}
|
||||
|
||||
async isPrintPresent() {
|
||||
return browser.isElementPresent(this.printButton);
|
||||
}
|
||||
|
||||
async isFullScreenPresent() {
|
||||
return browser.isElementPresent(this.fullScreenButton);
|
||||
}
|
||||
|
||||
|
||||
async clickShare() {
|
||||
const btn = this.shareButton;
|
||||
await btn.click();
|
||||
}
|
||||
|
||||
async clickSharedLinkSettings() {
|
||||
const btn = this.shareEditButton;
|
||||
await btn.click();
|
||||
}
|
||||
|
||||
async clickView() {
|
||||
await this.viewButton.click();
|
||||
}
|
||||
|
||||
async clickEditFolder() {
|
||||
await this.editFolderButton.click();
|
||||
}
|
||||
|
||||
async clickViewDetails() {
|
||||
await this.viewDetailsButton.click();
|
||||
}
|
||||
|
||||
async clickDownload() {
|
||||
await this.downloadButton.click();
|
||||
}
|
||||
|
||||
async clickJoin() {
|
||||
await this.joinButton.click();
|
||||
}
|
||||
|
||||
async clickLeave() {
|
||||
await this.leaveButton.click();
|
||||
}
|
||||
|
||||
async clickPermanentlyDelete() {
|
||||
await this.permanentlyDeleteButton.click();
|
||||
}
|
||||
async clickRestore() {
|
||||
await this.restoreButton.click();
|
||||
}
|
||||
|
||||
|
||||
async clickMoreActionsFavorite() {
|
||||
async clickMoreActionsFavorite(): Promise<void> {
|
||||
await this.openMoreMenu();
|
||||
await this.menu.clickMenuItem('Favorite');
|
||||
}
|
||||
|
||||
async clickMoreActionsRemoveFavorite() {
|
||||
async clickMoreActionsRemoveFavorite(): Promise<void> {
|
||||
await this.openMoreMenu();
|
||||
await this.menu.clickMenuItem('Remove Favorite');
|
||||
}
|
||||
|
||||
async clickMoreActionsDelete() {
|
||||
async clickMoreActionsDelete(): Promise<void> {
|
||||
await this.openMoreMenu();
|
||||
await this.menu.clickMenuItem('Delete');
|
||||
}
|
||||
|
||||
async clickMoreActionsManageVersions() {
|
||||
async clickMoreActionsManageVersions(): Promise<void> {
|
||||
await this.openMoreMenu();
|
||||
await this.menu.clickMenuItem('Manage Versions');
|
||||
}
|
||||
|
||||
async clickMoreActionsMove() {
|
||||
async clickMoreActionsMove(): Promise<void> {
|
||||
await this.openMoreMenu();
|
||||
await this.menu.clickMenuItem('Move');
|
||||
}
|
||||
|
||||
async clickMoreActionsCopy() {
|
||||
async clickMoreActionsCopy(): Promise<void> {
|
||||
await this.openMoreMenu();
|
||||
await this.menu.clickMenuItem('Copy');
|
||||
}
|
||||
|
||||
async clickMoreActionsEditOffline() {
|
||||
async clickMoreActionsEditOffline(): Promise<void> {
|
||||
await this.openMoreMenu();
|
||||
await this.menu.clickMenuItem('Edit Offline');
|
||||
}
|
||||
|
||||
async clickMoreActionsCancelEditing() {
|
||||
async clickMoreActionsCancelEditing(): Promise<void> {
|
||||
await this.openMoreMenu();
|
||||
await this.menu.clickMenuItem('Cancel Editing');
|
||||
}
|
||||
|
||||
async clickMoreActionsUploadNewVersion() {
|
||||
async clickMoreActionsUploadNewVersion(): Promise<void> {
|
||||
await this.openMoreMenu();
|
||||
await this.menu.clickMenuItem('Upload New Version');
|
||||
}
|
||||
|
||||
async clickFullScreen() {
|
||||
await this.fullScreenButton.click();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user