[ACA-1928] e2e improvements - part2 (#884)

* refactor Mark as favourite tests
rename method to be more clear
create separate methods for some checks and actions

* forgot some changes

* refactor delete-undo tests

* some more refactoring

* fix

* small improvements / refactoring
This commit is contained in:
Adina Parpalita
2018-12-21 17:04:13 +02:00
committed by Cilibiu Bogdan
parent b8ce533759
commit 24f5f01900
29 changed files with 511 additions and 493 deletions

View File

@@ -94,7 +94,7 @@ export class DataTable extends Component {
return this.head.all(locator);
}
async getHeaderText() {
async getColumnHeadersText() {
const el = this.getColumnHeaders();
return await el.getText();
}
@@ -319,4 +319,27 @@ export class DataTable extends Component {
async isItemPresent(name: string) {
return await this.getRowByName(name).isPresent();
}
async getEntireDataTableText() {
return this.getRows().map((row) => {
return row.all(this.cell).map(async cell => await cell.getText());
});
}
async getSitesNameAndVisibility() {
const data = await this.getEntireDataTableText();
return data.reduce((acc, cell) => {
acc[cell[1]] = cell[3].toUpperCase();
return acc;
}, {});
}
async getSitesNameAndRole() {
const data = await this.getEntireDataTableText();
return data.reduce((acc, cell) => {
acc[cell[1]] = cell[2];
return acc;
}, {});
}
}

View File

@@ -31,17 +31,17 @@ import { Toolbar } from './../toolbar/toolbar';
import { SearchInput } from '../search/search-input';
export class Header extends Component {
private locators = {
private static selectors = {
root: 'app-header',
logoLink: by.css('.app-menu__title'),
userInfo: by.css('aca-current-user'),
moreActions: by.id('app.header.more')
};
logoLink: ElementFinder = this.component.element(this.locators.logoLink);
userInfo: UserInfo = new UserInfo(this.component);
moreActions: ElementFinder = browser.element(this.locators.moreActions);
logoLink: ElementFinder = this.component.element(Header.selectors.logoLink);
moreActions: ElementFinder = browser.element(Header.selectors.moreActions);
userInfo: UserInfo = new UserInfo(this.component);
menu: Menu = new Menu();
toolbar: Toolbar = new Toolbar();
searchInput: SearchInput = new SearchInput();

View File

@@ -28,14 +28,14 @@ import { Menu } from '../menu/menu';
import { Component } from '../component';
export class UserInfo extends Component {
private locators = {
private static selectors = {
avatar: by.css('.current-user__avatar'),
fullName: by.css('.current-user__full-name'),
menuItems: by.css('[mat-menu-item]')
};
fullName: ElementFinder = this.component.element(this.locators.fullName);
avatar: ElementFinder = this.component.element(this.locators.avatar);
fullName: ElementFinder = this.component.element(UserInfo.selectors.fullName);
avatar: ElementFinder = this.component.element(UserInfo.selectors.avatar);
menu: Menu = new Menu();

View File

@@ -26,7 +26,6 @@
import { ElementFinder, ElementArrayFinder, by, browser, ExpectedConditions as EC } from 'protractor';
import { Component } from '../component';
import { BROWSER_WAIT_TIMEOUT } from '../../configs';
import { Utils } from './../../utilities/utils';
export class InfoDrawer extends Component {
private static selectors = {
@@ -86,6 +85,7 @@ export class InfoDrawer extends Component {
super(InfoDrawer.selectors.root, ancestor);
}
async waitForInfoDrawerToOpen() {
return await browser.wait(EC.presenceOf(this.header), BROWSER_WAIT_TIMEOUT);
}
@@ -95,10 +95,7 @@ export class InfoDrawer extends Component {
}
async isEmpty() {
if (await browser.isElementPresent(by.css(InfoDrawer.selectors.tabs))) {
return false;
}
return true;
return !(await browser.isElementPresent(by.css(InfoDrawer.selectors.tabs)));
}
getTabByTitle(title: string) {
@@ -146,12 +143,6 @@ export class InfoDrawer extends Component {
return this.getFieldByName(fieldName).isEnabled();
}
async isVisibilityEnabled() {
const wrapper = this.getLabelWrapper('Visibility');
const field = wrapper.element(by.xpath('..')).element(by.css(InfoDrawer.selectors.dropDown));
return await field.isEnabled();
}
async getValueOfField(fieldName: string) {
return await this.getFieldByName(fieldName).getText();
}
@@ -162,11 +153,6 @@ export class InfoDrawer extends Component {
return await input.sendKeys(text);
}
async typeTextInInput(fieldName: string, text: string) {
const input = this.getFieldByName(fieldName);
await input.clear();
return await Utils.typeInField(input, text);
}
getButton(button: string) {
return this.component.element(by.cssContainingText(InfoDrawer.selectors.metadataTabAction, button));
@@ -184,15 +170,21 @@ export class InfoDrawer extends Component {
return await this.getButton(button).click();
}
async isButtonDisabled(button: string) {
try {
const disabled = await this.getButton(button).getAttribute('disabled');
return disabled;
} catch (error) {
console.log('----- isButtonDisabled catch: ', error);
}
async waitForVisibilityDropDownToOpen() {
await browser.wait(EC.presenceOf(this.visibilityDropDown), BROWSER_WAIT_TIMEOUT);
}
async waitForVisibilityDropDownToClose() {
await browser.wait(EC.stalenessOf(browser.$('.mat-option .mat-option-text')), BROWSER_WAIT_TIMEOUT);
}
// ---------------
async isAboutTabDisplayed() {
return await this.isTabDisplayed('About');
}
async isMessageDisplayed() {
return await browser.isElementPresent(this.hint);
}
@@ -210,80 +202,59 @@ export class InfoDrawer extends Component {
}
// ---------------
async isNameDisplayed() {
return await this.isFieldDisplayed('Name');
}
async isDescriptionDisplayed() {
return await this.isFieldDisplayed('Description');
}
async isVisibilityDisplayed() {
return await this.isFieldDisplayed('Visibility');
}
async isLibraryIdDisplayed() {
return await this.isFieldDisplayed('Library ID');
}
async getName() {
return await this.getValueOfField('Name');
}
async getVisibility() {
return await this.getValueOfField('Visibility');
}
async getLibraryId() {
return await this.getValueOfField('Library ID');
}
async getDescription() {
return await this.getValueOfField('Description');
}
async isNameEnabled() {
return await this.isInputEnabled('Name');
}
async isLibraryIdEnabled() {
return await this.isInputEnabled('Library ID');
}
async isDescriptionEnabled() {
return await this.isInputEnabled('Description');
async getName() {
return await this.getValueOfField('Name');
}
async enterName(name: string) {
return await this.enterTextInInput('Name', name);
}
async typeName(name: string) {
return await this.typeTextInInput('Name', name);
async isDescriptionDisplayed() {
return await this.isFieldDisplayed('Description');
}
async isDescriptionEnabled() {
return await this.isInputEnabled('Description');
}
async getDescription() {
return await this.getValueOfField('Description');
}
async enterDescription(desc: string) {
return await this.enterTextInInput('Description', desc);
}
async typeDescription(desc: string) {
return await this.typeTextInInput('Description', desc);
async isVisibilityEnabled() {
const wrapper = this.getLabelWrapper('Visibility');
const field = wrapper.element(by.xpath('..')).element(by.css(InfoDrawer.selectors.dropDown));
return await field.isEnabled();
}
async waitForDropDownToOpen() {
await browser.wait(EC.presenceOf(this.visibilityDropDown), BROWSER_WAIT_TIMEOUT);
async isVisibilityDisplayed() {
return await this.isFieldDisplayed('Visibility');
}
async waitForDropDownToClose() {
await browser.wait(EC.stalenessOf(browser.$('.mat-option .mat-option-text')), BROWSER_WAIT_TIMEOUT);
async getVisibility() {
return await this.getValueOfField('Visibility');
}
async setVisibility(visibility: string) {
const val = visibility.toLowerCase();
await this.visibilityDropDown.click();
await this.waitForDropDownToOpen();
await this.waitForVisibilityDropDownToOpen();
if (val === 'public') {
await this.visibilityPublic.click();
@@ -295,7 +266,59 @@ export class InfoDrawer extends Component {
console.log('----- invalid visibility', val);
}
await this.waitForDropDownToClose();
await this.waitForVisibilityDropDownToClose();
}
async isLibraryIdDisplayed() {
return await this.isFieldDisplayed('Library ID');
}
async isLibraryIdEnabled() {
return await this.isInputEnabled('Library ID');
}
async getLibraryId() {
return await this.getValueOfField('Library ID');
}
async isEditEnabled() {
return await this.isButtonEnabled('Edit');
}
async isEditDisplayed() {
return await this.isButtonDisplayed('Edit');
}
async clickEdit() {
return await this.clickButton('Edit');
}
async isUpdateEnabled() {
return await this.isButtonEnabled('Update');
}
async isUpdateDisplayed() {
return await this.isButtonDisplayed('Update');
}
async clickUpdate() {
return await this.clickButton('Update');
}
async isCancelEnabled() {
return await this.isButtonEnabled('Cancel');
}
async isCancelDisplayed() {
return await this.isButtonDisplayed('Cancel');
}
async clickCancel() {
return await this.clickButton('Cancel');
}
}

View File

@@ -27,9 +27,9 @@ import { by, ElementFinder } from 'protractor';
import { Component } from '../component';
export class LoginComponent extends Component {
static selector = 'adf-login';
private static selectors = {
root: 'adf-login',
private locators = {
usernameInput: by.css('input#username'),
passwordInput: by.css('input#password'),
passwordVisibility: by.css('.adf-login-password-icon'),
@@ -38,15 +38,15 @@ export class LoginComponent extends Component {
copyright: by.css('.adf-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(LoginComponent.selectors.usernameInput);
passwordInput: ElementFinder = this.component.element(LoginComponent.selectors.passwordInput);
submitButton: ElementFinder = this.component.element(LoginComponent.selectors.submitButton);
errorMessage: ElementFinder = this.component.element(LoginComponent.selectors.errorMessage);
copyright: ElementFinder = this.component.element(LoginComponent.selectors.copyright);
passwordVisibility: ElementFinder = this.component.element(LoginComponent.selectors.passwordVisibility);
constructor(ancestor?: ElementFinder) {
super(LoginComponent.selector, ancestor);
super(LoginComponent.selectors.root, ancestor);
}
async enterUsername(username: string) {

View File

@@ -26,7 +26,7 @@
import { ElementFinder, by } from 'protractor';
import { Menu } from '../menu/menu';
import { Component } from '../component';
import { browser } from 'protractor';
export class Pagination extends Component {
private static selectors = {
root: 'adf-pagination',
@@ -61,7 +61,6 @@ export class Pagination extends Component {
await maxItemsButton.click();
await menu.waitForMenuToOpen();
// return menu;
}
async openCurrentPageMenu() {
@@ -69,11 +68,6 @@ export class Pagination extends Component {
await pagesButton.click();
await menu.waitForMenuToOpen();
// return menu;
}
async getText(elem: ElementFinder) {
return await elem.getText();
}
async resetToDefaultPageSize() {
@@ -95,4 +89,56 @@ export class Pagination extends Component {
async clickPrevious() {
await this.previousButton.click();
}
async isNextEnabled() {
return await this.nextButton.isEnabled();
}
async isPreviousEnabled() {
return await this.previousButton.isEnabled();
}
async isPagesButtonPresent() {
return await browser.isElementPresent(this.pagesButton);
}
async isRangePresent() {
return await this.range.isPresent();
}
async isMaxItemsPresent() {
return await this.maxItems.isPresent();
}
async isCurrentPagePresent() {
return await this.currentPage.isPresent();
}
async isTotalPagesPresent() {
return await this.totalPages.isPresent();
}
async isPreviousButtonPresent() {
return await this.previousButton.isPresent();
}
async isNextButtonPresent() {
return await this.nextButton.isPresent();
}
async getCurrentPage() {
return await this.currentPage.getText();
}
async getRange() {
return await this.range.getText();
}
async getMaxItems() {
return await this.maxItems.getText();
}
async getTotalPages() {
return await this.totalPages.getText();
}
}