[ACA-1628] async await (#693)

* async / await on login component and utils

* more async / awaits

* remove fdescribe

* expect for exact totalItems in waitForApi methods
other async / awaits

* pagination tests

* more tries

* disable selenium promise manager

* try to fix shared-links tests

* re-enable selenium_promise_manager and some more fixes

* add target es2017 to e2e

* set target to es2017 on tsconfig.spec.json

* other tries

* forgotten console.log

* disable pagination tests

* some fixes for pagination

* temporary fix viewer actions tests

* fix some actions tests

* fix some tests for actions

* fix some tests for undo action

* try to fix some more tests

* fixes for toolbar actions

* fix NoSuchElementError for openMoreMenu

* fix NoSuchElementError for rightClickOnMultipleSelection

* fixes for mark as favourite

* more fixes

* more fixes

* change order of some expects

* forgot describe
This commit is contained in:
Adina Parpalita
2018-10-08 11:21:02 +03:00
committed by Denys Vuika
parent 0d4795bfa8
commit 7d73ae309c
53 changed files with 1553 additions and 1662 deletions

View File

@@ -23,83 +23,76 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { by, ElementFinder, promise } from 'protractor';
import { by, ElementFinder } from 'protractor';
import { Component } from '../component';
export class LoginComponent extends Component {
static selector = 'adf-login';
static selector = 'adf-login';
private locators = {
usernameInput: by.css('input#username'),
passwordInput: by.css('input#password'),
passwordVisibility: by.css('.adf-login-password-icon'),
submitButton: by.css('button#login-button'),
errorMessage: by.css('.login-error-message'),
copyright: by.css('.copyright')
};
private locators = {
usernameInput: by.css('input#username'),
passwordInput: by.css('input#password'),
passwordVisibility: by.css('.adf-login-password-icon'),
submitButton: by.css('button#login-button'),
errorMessage: by.css('.login-error-message'),
copyright: by.css('.copyright')
};
usernameInput: ElementFinder = this.component.element(this.locators.usernameInput);
passwordInput: ElementFinder = this.component.element(this.locators.passwordInput);
submitButton: ElementFinder = this.component.element(this.locators.submitButton);
errorMessage: ElementFinder = this.component.element(this.locators.errorMessage);
copyright: ElementFinder = this.component.element(this.locators.copyright);
passwordVisibility: ElementFinder = this.component.element(this.locators.passwordVisibility);
usernameInput: ElementFinder = this.component.element(this.locators.usernameInput);
passwordInput: ElementFinder = this.component.element(this.locators.passwordInput);
submitButton: ElementFinder = this.component.element(this.locators.submitButton);
errorMessage: ElementFinder = this.component.element(this.locators.errorMessage);
copyright: ElementFinder = this.component.element(this.locators.copyright);
passwordVisibility: ElementFinder = this.component.element(this.locators.passwordVisibility);
constructor(ancestor?: ElementFinder) {
super(LoginComponent.selector, ancestor);
constructor(ancestor?: ElementFinder) {
super(LoginComponent.selector, ancestor);
}
async enterUsername(username: string) {
const { usernameInput } = this;
await usernameInput.clear();
await usernameInput.sendKeys(username);
}
async enterPassword(password: string) {
const { passwordInput } = this;
await passwordInput.clear();
await passwordInput.sendKeys(password);
}
async enterCredentials(username: string, password: string) {
await this.enterUsername(username);
await this.enterPassword(password);
}
submit() {
return this.submitButton.click();
}
async getPasswordVisibility() {
const text = await this.passwordVisibility.getText();
if (text.endsWith('visibility_off')) {
return false;
}
enterUsername(username: string): LoginComponent {
const { usernameInput } = this;
usernameInput.clear();
usernameInput.sendKeys(username);
return this;
else {
if (text.endsWith('visibility')) {
return true;
}
}
}
enterPassword(password: string): LoginComponent {
const { passwordInput } = this;
passwordInput.clear();
passwordInput.sendKeys(password);
return this;
async isPasswordShown() {
const type = await this.passwordInput.getAttribute('type');
if (type === 'text') {
return true;
}
enterCredentials(username: string, password: string) {
this.enterUsername(username).enterPassword(password);
return this;
}
submit(): promise.Promise<void> {
return this.submitButton.click();
}
getPasswordVisibility() {
return this.passwordVisibility.getText()
.then(text => {
if (text.endsWith('visibility_off')) {
return false;
} else {
if (text.endsWith('visibility')) {
return true;
}
}
});
}
isPasswordShown() {
return this.passwordInput.getAttribute('type')
.then(type => {
if (type === 'text') {
return true;
} else {
if (type === 'password') {
return false;
}
}
});
else {
if (type === 'password') {
return false;
}
}
}
}