mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-05-26 17:24:45 +00:00
* compare arrays of actions instead of checking the available actions one by one add more tests for more file types reorganise and separate test files use correct capitalisation of “Leave Library”, according to ACA-2473 add some try catch blocks * fix test and rebalance suites * remove hidden old info button - that exists in DOM, even though hidden, after fix of [ACA-2288] issue * change actions order after ACA-2649
261 lines
8.0 KiB
TypeScript
Executable File
261 lines
8.0 KiB
TypeScript
Executable File
/*!
|
|
* @license
|
|
* Alfresco Example Content Application
|
|
*
|
|
* Copyright (C) 2005 - 2019 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, 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',
|
|
|
|
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));
|
|
|
|
constructor(ancestor?: ElementFinder) {
|
|
super(Toolbar.selectors.root, ancestor);
|
|
}
|
|
|
|
async isEmpty() {
|
|
const count = await this.buttons.count();
|
|
return count === 0;
|
|
}
|
|
|
|
async numberOfAvailableActions() {
|
|
return await this.buttons.count();
|
|
}
|
|
|
|
async getButtons(): Promise<string[]> {
|
|
return this.buttons.map(async elem => {
|
|
return await elem.getAttribute('title');
|
|
});
|
|
}
|
|
|
|
async isButtonPresent(title: string) {
|
|
const elem = this.component.element(by.css(`${Toolbar.selectors.button}[title="${title}"]`));
|
|
return await elem.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}"]`));
|
|
}
|
|
|
|
getButtonById(id: string) {
|
|
return this.component.element(by.id(id));
|
|
}
|
|
|
|
async openMoreMenu() {
|
|
await this.isButtonPresent('More Actions');
|
|
const moreMenu = this.getButtonByTitleAttribute('More Actions');
|
|
await moreMenu.click();
|
|
await this.menu.waitForMenuToOpen();
|
|
}
|
|
|
|
async closeMoreMenu() {
|
|
await Utils.pressEscape();
|
|
}
|
|
|
|
async getButtonTooltip(button: ElementFinder) {
|
|
return await button.getAttribute('title');
|
|
}
|
|
|
|
async clickButton(title: string) {
|
|
const btn = this.getButtonByTitleAttribute(title);
|
|
await btn.click();
|
|
}
|
|
|
|
|
|
async isSharedLinkSettingsPresent() {
|
|
return await browser.isElementPresent(this.shareEditButton);
|
|
}
|
|
|
|
async isSharePresent() {
|
|
return await browser.isElementPresent(this.shareButton);
|
|
}
|
|
|
|
async isViewPresent() {
|
|
return await browser.isElementPresent(this.viewButton);
|
|
}
|
|
|
|
async isToggleSearchFiltersPresent() {
|
|
return await browser.isElementPresent(this.searchFiltersToggleButton);
|
|
}
|
|
|
|
async isDownloadPresent() {
|
|
return await browser.isElementPresent(this.downloadButton);
|
|
}
|
|
|
|
async isPermanentlyDeletePresent() {
|
|
return await browser.isElementPresent(this.permanentlyDeleteButton);
|
|
}
|
|
|
|
async isRestorePresent() {
|
|
return await browser.isElementPresent(this.restoreButton);
|
|
}
|
|
|
|
async isEditFolderPresent() {
|
|
return await browser.isElementPresent(this.editFolderButton);
|
|
}
|
|
|
|
async isViewDetailsPresent() {
|
|
return await browser.isElementPresent(this.viewDetailsButton);
|
|
}
|
|
|
|
async isPrintPresent() {
|
|
return await browser.isElementPresent(this.printButton);
|
|
}
|
|
|
|
async isFullScreenPresent() {
|
|
return await browser.isElementPresent(this.fullScreenButton);
|
|
}
|
|
|
|
|
|
async clickShare() {
|
|
const btn = this.shareButton;
|
|
await btn.click();
|
|
}
|
|
|
|
async clickSharedLinkSettings() {
|
|
const btn = this.shareEditButton;
|
|
await btn.click();
|
|
}
|
|
|
|
async clickView() {
|
|
return await this.viewButton.click();
|
|
}
|
|
|
|
async clickEditFolder() {
|
|
return await this.editFolderButton.click();
|
|
}
|
|
|
|
async clickViewDetails() {
|
|
return await this.viewDetailsButton.click();
|
|
}
|
|
|
|
async clickDownload() {
|
|
return await this.downloadButton.click();
|
|
}
|
|
|
|
async clickJoin() {
|
|
return await this.joinButton.click();
|
|
}
|
|
|
|
async clickLeave() {
|
|
return await this.leaveButton.click();
|
|
}
|
|
|
|
async clickPermanentlyDelete() {
|
|
return await this.permanentlyDeleteButton.click();
|
|
}
|
|
async clickRestore() {
|
|
return await this.restoreButton.click();
|
|
}
|
|
|
|
|
|
async clickMoreActionsFavorite() {
|
|
await this.openMoreMenu();
|
|
return await this.menu.clickMenuItem('Favorite');
|
|
}
|
|
|
|
async clickMoreActionsRemoveFavorite() {
|
|
await this.openMoreMenu();
|
|
return await this.menu.clickMenuItem('Remove Favorite');
|
|
}
|
|
|
|
async clickMoreActionsDelete() {
|
|
await this.openMoreMenu();
|
|
return await this.menu.clickMenuItem('Delete');
|
|
}
|
|
|
|
async clickMoreActionsManageVersions() {
|
|
await this.openMoreMenu();
|
|
return await this.menu.clickMenuItem('Manage Versions');
|
|
}
|
|
|
|
async clickMoreActionsMove() {
|
|
await this.openMoreMenu();
|
|
return await this.menu.clickMenuItem('Move');
|
|
}
|
|
|
|
async clickMoreActionsCopy() {
|
|
await this.openMoreMenu();
|
|
return await this.menu.clickMenuItem('Copy');
|
|
}
|
|
|
|
async clickMoreActionsEditOffline() {
|
|
await this.openMoreMenu();
|
|
return await this.menu.clickMenuItem('Edit Offline');
|
|
}
|
|
|
|
async clickMoreActionsCancelEditing() {
|
|
await this.openMoreMenu();
|
|
return await this.menu.clickMenuItem('Cancel Editing');
|
|
}
|
|
|
|
async clickMoreActionsUploadNewVersion() {
|
|
await this.openMoreMenu();
|
|
return await this.menu.clickMenuItem('Upload New Version');
|
|
}
|
|
|
|
async clickFullScreen() {
|
|
return await this.fullScreenButton.click();
|
|
}
|
|
|
|
}
|