[ACA-1683] add tests for viewer - general (#570)

* rename method to be more clear

* change some files to async / await as they were very difficult to follow

* add uploadApi and a few resource files needed by Viewer tests

* add Viewer e2e component and viewer general tests

* add tests for the other list views as well

* add “docx” to dictionary
This commit is contained in:
Adina Parpalita
2018-08-17 14:27:22 +03:00
committed by Denys Vuika
parent 5e4e8ed28c
commit c0321fe449
20 changed files with 747 additions and 449 deletions

View File

@@ -172,7 +172,7 @@ export class DataTable extends Component {
.then(() => browser.actions().mouseMove(item).click().click().perform());
}
clickOnRowByName(name: string): promise.Promise<any> {
selectItem(name: string): promise.Promise<any> {
const item = this.getRowFirstCell(name);
return Utils.waitUntilElementClickable(item)
.then(() => item.click());
@@ -183,7 +183,7 @@ export class DataTable extends Component {
.then(() => browser.actions().sendKeys(protractor.Key.COMMAND).perform())
.then(() => {
names.forEach(name => {
this.clickOnRowByName(name);
this.selectItem(name);
});
})
.then(() => browser.actions().sendKeys(protractor.Key.NULL).perform());

View File

@@ -40,29 +40,34 @@ export class ToolbarActions extends Component {
super(ToolbarActions.selectors.root, ancestor);
}
isEmpty(): promise.Promise<boolean> {
return this.buttons.count().then(count => (count === 0));
async isEmpty() {
return await this.buttons.count() === 0;
}
isButtonPresent(title: string): promise.Promise<boolean> {
return this.component.element(by.css(`${ToolbarActions.selectors.button}[title="${title}"]`)).isPresent();
async isButtonPresent(title: string) {
return await this.component.element(by.css(`${ToolbarActions.selectors.button}[title="${title}"]`)).isPresent();
}
getButtonByLabel(label: string): ElementFinder {
getButtonByLabel(label: string) {
return this.component.element(by.cssContainingText(ToolbarActions.selectors.button, label));
}
getButtonByTitleAttribute(title: string): ElementFinder {
getButtonByTitleAttribute(title: string) {
return this.component.element(by.css(`${ToolbarActions.selectors.button}[title="${title}"]`));
}
openMoreMenu() {
return this.getButtonByTitleAttribute('More actions').click()
.then(() => this.menu.waitForMenuToOpen())
.then(() => this.menu);
async openMoreMenu() {
await this.getButtonByTitleAttribute('More actions').click();
await this.menu.waitForMenuToOpen();
return this.menu;
}
closeMoreMenu() {
return browser.actions().sendKeys(protractor.Key.ESCAPE).perform();
async closeMoreMenu() {
return await browser.actions().sendKeys(protractor.Key.ESCAPE).perform();
}
async getButtonTooltip(button: ElementFinder) {
return await button.getAttribute('title');
}
}

88
e2e/components/viewer/viewer.ts Executable file
View File

@@ -0,0 +1,88 @@
/*!
* @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, by, browser, ExpectedConditions as EC } from 'protractor';
import { Component } from '../component';
import { BROWSER_WAIT_TIMEOUT } from '../../configs';
import { ToolbarActions } from '../toolbar/toolbar-actions';
export class Viewer extends Component {
private static selectors = {
root: 'adf-viewer',
layout: '.adf-viewer-layout-content',
contentContainer: '.adf-viewer-content-container',
closeBtn: '.adf-viewer-close-button',
fileTitle: '.adf-viewer__file-title'
};
viewerLayout: ElementFinder = this.component.element(by.css(Viewer.selectors.layout));
viewerContainer: ElementFinder = this.component.element(by.css(Viewer.selectors.contentContainer));
closeButton: ElementFinder = this.component.element(by.css(Viewer.selectors.closeBtn));
fileTitle: ElementFinder = this.component.element(by.css(Viewer.selectors.fileTitle));
toolbar = new ToolbarActions(this.component);
constructor(ancestor?: ElementFinder) {
super(Viewer.selectors.root, ancestor);
}
async waitForViewerToOpen() {
return await browser.wait(EC.presenceOf(this.viewerContainer), BROWSER_WAIT_TIMEOUT)
.catch(err => err);
}
async isViewerOpened() {
return await browser.isElementPresent(this.viewerLayout);
}
async isViewerContentDisplayed() {
return await browser.isElementPresent(this.viewerContainer);
}
async isViewerToolbarDisplayed() {
return await browser.isElementPresent(this.toolbar.component);
}
async isCloseButtonDisplayed() {
return await browser.isElementPresent(this.closeButton);
}
async isFileTitleDisplayed() {
return await browser.isElementPresent(this.fileTitle);
}
async clickClose() {
return await this.closeButton.click();
}
async getCloseButtonTooltip() {
return await this.toolbar.getButtonTooltip(this.closeButton);
}
async getFileTitle() {
return await this.fileTitle.getText();
}
}