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,30 +23,21 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
import { ElementFinder, by, protractor } from 'protractor';
import { by } from 'protractor';
import { GenericDialog } from '../dialog/generic-dialog';
import { isPresentAndDisplayed } from '../../utilities/utils';
import { isPresentAndDisplayed, isPresentAndEnabled, typeText } from '../../utilities/utils';
export class CreateFromTemplateDialog extends GenericDialog {
private static selectors = {
root: '.aca-create-from-template-dialog',
createButton = this.childElement(by.cssContainingText('.mat-dialog-actions button', 'Create'));
cancelButton = this.childElement(by.cssContainingText('.mat-dialog-actions button', 'CANCEL'));
nameInput: 'input[placeholder="Name" i]',
titleInput: 'input[placeholder="Title" i]',
descriptionTextArea: 'textarea[placeholder="Description" i]',
validationMessage: '.mat-error',
createButton: by.cssContainingText('.mat-dialog-actions button', 'Create'),
cancelButton: by.cssContainingText('.mat-dialog-actions button', 'CANCEL')
};
nameInput: ElementFinder = this.rootElem.element(by.css(CreateFromTemplateDialog.selectors.nameInput));
titleInput: ElementFinder = this.rootElem.element(by.css(CreateFromTemplateDialog.selectors.titleInput));
descriptionTextArea: ElementFinder = this.rootElem.element(by.css(CreateFromTemplateDialog.selectors.descriptionTextArea));
validationMessage: ElementFinder = this.rootElem.element(by.css(CreateFromTemplateDialog.selectors.validationMessage));
nameInput = this.childElement(by.css('input[placeholder="Name" i]'));
titleInput = this.childElement(by.css('input[placeholder="Title" i]'));
descriptionTextArea = this.childElement(by.css('textarea[placeholder="Description" i]'));
validationMessage = this.childElement(by.css('.mat-error'));
constructor() {
super(CreateFromTemplateDialog.selectors.root);
super('.aca-create-from-template-dialog');
}
async isValidationMessageDisplayed(): Promise<boolean> {
@@ -54,23 +45,11 @@ export class CreateFromTemplateDialog extends GenericDialog {
}
async isCreateButtonEnabled(): Promise<boolean> {
return this.isButtonEnabled(CreateFromTemplateDialog.selectors.createButton);
return isPresentAndEnabled(this.createButton);
}
async isCancelButtonEnabled(): Promise<boolean> {
return this.isButtonEnabled(CreateFromTemplateDialog.selectors.cancelButton);
}
async isNameFieldDisplayed(): Promise<boolean> {
return this.nameInput.isDisplayed();
}
async isTitleFieldDisplayed(): Promise<boolean> {
return this.titleInput.isDisplayed();
}
async isDescriptionFieldDisplayed(): Promise<boolean> {
return this.descriptionTextArea.isDisplayed();
return isPresentAndEnabled(this.cancelButton);
}
async getValidationMessage(): Promise<string> {
@@ -90,32 +69,19 @@ export class CreateFromTemplateDialog extends GenericDialog {
}
async enterName(name: string): Promise<void> {
await this.nameInput.clear();
await this.nameInput.sendKeys(name);
await typeText(this.nameInput, name);
}
async enterTitle(title: string): Promise<void> {
await this.titleInput.clear();
await this.titleInput.sendKeys(title);
await typeText(this.titleInput, title);
}
async enterDescription(description: string): Promise<void> {
await this.descriptionTextArea.clear();
await this.descriptionTextArea.sendKeys(description);
}
async deleteNameWithBackspace(): Promise<void> {
await this.nameInput.clear();
await this.nameInput.sendKeys(' ', protractor.Key.CONTROL, 'a', protractor.Key.NULL, protractor.Key.BACK_SPACE);
}
async clickCreate(): Promise<void> {
await this.clickButton(CreateFromTemplateDialog.selectors.createButton);
await typeText(this.descriptionTextArea, description);
}
async clickCancel(): Promise<void> {
await this.clickButton(CreateFromTemplateDialog.selectors.cancelButton);
await this.cancelButton.click();
await this.waitForDialogToClose();
}
}