[ADF-5235] Facet fix and improve search test (#6122)

* improve search test

* fix

* fix

* fix

* changes

* modify

* logout public URL

* improve stability some e2e

* fx lint

* fix

* fix

* improve

* fix

* improve

* fix

* fix

* fix

* fix [skip ci]

* fix

* some fix [skip ci]

* fix

* fix lint

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* convert C291893 in manual test case in testrail

* fix

* fix
This commit is contained in:
Eugenio Romano
2020-09-21 09:35:01 +01:00
committed by GitHub
parent 9c427b3142
commit 46ccda68b3
111 changed files with 987 additions and 604 deletions

View File

@@ -57,6 +57,7 @@ export class AddPermissionsDialogPage {
async searchUserOrGroup(name: string): Promise<void> {
await BrowserActions.clearSendKeys(this.searchUserInput, name);
await this.dataTableComponentPage.waitTillContentLoaded();
}
async checkResultListIsDisplayed(): Promise<void> {
@@ -65,7 +66,7 @@ export class AddPermissionsDialogPage {
async clickUserOrGroup(name: string): Promise<void> {
const userOrGroupName = element(by.cssContainingText('mat-list-option .mat-list-text', name));
await BrowserActions.clickScript(userOrGroupName);
await BrowserActions.click(userOrGroupName);
await BrowserActions.click(this.addButton);
}
@@ -95,8 +96,8 @@ export class AddPermissionsDialogPage {
await BrowserVisibility.waitUntilElementIsVisible(this.noPermissions);
}
async getPermissionInheritedButtonText(): Promise<string> {
return BrowserActions.getText(this.permissionInheritedButton);
async getPermissionInheritedButtonText(text: string): Promise<void> {
await BrowserVisibility.waitUntilElementHasText(this.permissionInheritedButton, text);
}
async checkPermissionsDatatableIsDisplayed(): Promise<void> {

View File

@@ -21,6 +21,7 @@ import { BrowserVisibility } from '../../core/utils/browser-visibility';
import { BrowserActions } from '../../core/utils/browser-actions';
import { DropdownPage } from '../../core/pages/material/dropdown.page';
import { BreadcrumbDropdownPage } from '../pages/breadcrumb/breadcrumb-dropdown.page';
import { Logger } from '../../core/utils/logger';
export class ContentNodeSelectorDialogPage {
dialog = element(by.css(`adf-content-node-selector`));
@@ -96,9 +97,12 @@ export class ContentNodeSelectorDialogPage {
return this.dataTable.numberOfRows();
}
async typeIntoNodeSelectorSearchField(text): Promise<void> {
async typeIntoNodeSelectorSearchField(text: string): Promise<void> {
Logger.log(`Search Node content node selector ${text}`);
await BrowserVisibility.waitUntilElementIsVisible(this.searchInputElement);
await BrowserActions.clearSendKeys(this.searchInputElement, text);
await BrowserActions.clearSendKeys(this.searchInputElement, text, 100);
await this.dataTable.waitTillContentLoaded();
}
async clickContentNodeSelectorResult(name: string): Promise<void> {

View File

@@ -54,6 +54,7 @@ export class SearchCheckListPage {
await this.checkSearchFilterInputIsDisplayed();
await this.searchInFilter(option);
await this.clickCheckListOption(option);
return this;
}

View File

@@ -60,6 +60,8 @@ export class GroupIdentityService {
}
async getGroupInfoByGroupName(groupName: string): Promise<any> {
Logger.log(`Get GroupInfoByGroupName ${groupName}`);
const predicate = (result: any) => {
return !!result;
};
@@ -71,6 +73,9 @@ export class GroupIdentityService {
const queryParams = { search: groupName }, postBody = {};
const data = await this.api.performIdentityOperation(path, method, queryParams, postBody);
Logger.log(`Data ${JSON.stringify(data)}`);
return data[0];
} catch (error) {
Logger.error('Group not found');
@@ -81,6 +86,8 @@ export class GroupIdentityService {
}
async assignRole(groupId: string, roleId: string, roleName: string): Promise<any> {
Logger.log(`Assign to group ${groupId} Role ${roleName}`);
const path = `/groups/${groupId}/role-mappings/realm`;
const method = 'POST';
const queryParams = {};

View File

@@ -41,6 +41,7 @@ export class IdentityService {
}
async createIdentityUser(user: UserModel = new UserModel()): Promise<any> {
Logger.log(`Create Identity User ${user.email}`);
await this.createUser(user);
const userIdentity = await this.getUserInfoByUsername(user.username);
@@ -99,6 +100,8 @@ export class IdentityService {
}
async addUserToGroup(userId: string, groupId: string): Promise<any> {
Logger.log(`Add user to group userId ${userId} ${groupId}`);
try {
const path = `/users/${userId}/groups/${groupId}`;
const method = 'PUT';

View File

@@ -157,6 +157,8 @@ export class DataTableComponentPage {
}
async rightClickOnRow(columnName: string, columnValue: string): Promise<void> {
Logger.log(`Right Click On Row ${columnName} ${columnValue}`);
const row = this.getRow(columnName, columnValue);
await BrowserActions.rightClick(row);
@@ -256,6 +258,7 @@ export class DataTableComponentPage {
}
async checkContentIsDisplayed(columnName: string, columnValue: string): Promise<void> {
Logger.log(`Wait content is displayed ${columnName} ${columnValue}`);
const row = this.getCellElementByValue(columnName, columnValue);
await BrowserVisibility.waitUntilElementIsVisible(row);
}
@@ -289,48 +292,74 @@ export class DataTableComponentPage {
async waitTillContentLoaded(): Promise<void> {
await browser.sleep(500);
if (element(by.tagName('mat-spinner')).isPresent()) {
if (this.isSpinnerPresent()) {
Logger.log('wait datatable loading spinner disappear');
await BrowserVisibility.waitUntilElementIsNotPresent(element(by.tagName('mat-spinner')));
await BrowserVisibility.waitUntilElementIsNotVisible(element(by.tagName('mat-spinner')));
if (this.isEmpty()) {
Logger.log('empty page');
} else {
await this.waitFirstElementPresent();
}
} else {
try {
Logger.log('wait datatable loading spinner is present');
await BrowserVisibility.waitUntilElementIsPresent(element(by.tagName('mat-spinner')));
await BrowserVisibility.waitUntilElementIsVisible(element(by.tagName('mat-spinner')));
} catch (error) {
}
if (this.isEmpty()) {
Logger.log('empty page');
} else {
await this.waitFirstElementPresent();
}
}
}
private async isSpinnerPresent(): Promise<boolean> {
let isSpinnerPresent;
try {
isSpinnerPresent = await element(by.tagName('mat-spinner')).isDisplayed();
} catch (error) {
isSpinnerPresent = false;
}
return isSpinnerPresent;
}
private async waitFirstElementPresent(): Promise<void> {
try {
Logger.log('wait first element is present');
await BrowserVisibility.waitUntilElementIsVisible(this.contents.first());
} catch (error) {
Logger.log('Possible empty page');
}
}
async waitTillContentLoadedInfinitePagination(): Promise<void> {
await browser.sleep(500);
if (element(by.tagName('mat-progress-bar')).isPresent()) {
if (this.isSpinnerPresent()) {
Logger.log('wait datatable loading spinner disappear');
await BrowserVisibility.waitUntilElementIsNotPresent(element(by.tagName('mat-progress-bar')));
await BrowserVisibility.waitUntilElementIsNotVisible(element(by.tagName('mat-progress-bar')));
if (this.isEmpty()) {
Logger.log('empty page');
} else {
await this.waitFirstElementPresent();
}
} else {
try {
Logger.log('wait datatable loading spinner is present');
await BrowserVisibility.waitUntilElementIsPresent(element(by.tagName('mat-progress-bar')));
await BrowserVisibility.waitUntilElementIsVisible(element(by.tagName('mat-progress-bar')));
} catch (error) {
}
}
try {
Logger.log('wait first element is present');
await BrowserVisibility.waitUntilElementIsVisible(this.contents.first(), 1000);
} catch (error) {
Logger.log('Possible empty page');
}
}
if (this.isEmpty()) {
Logger.log('empty page');
} else {
await this.waitFirstElementPresent();
}
} }
async checkColumnIsDisplayed(column: string): Promise<void> {
await BrowserVisibility.waitUntilElementIsVisible(element(by.css(`div[data-automation-id="auto_id_entry.${column}"]`)));
@@ -449,11 +478,18 @@ export class DataTableComponentPage {
}
async isEmpty(): Promise<boolean> {
return this.emptyList.isPresent();
let isDisplayed;
try {
isDisplayed = await this.emptyList.isDisplayed();
} catch (error) {
isDisplayed = false;
}
return isDisplayed;
}
async waitForEmptyState(): Promise<void> {
await BrowserVisibility.waitUntilElementIsPresent(this.emptyList);
await BrowserVisibility.waitUntilElementIsVisible(this.emptyList);
}
async getEmptyStateTitle(): Promise<string> {

View File

@@ -63,6 +63,8 @@ export class LoginPage {
} else {
await this.loginBasicAuth(username, password);
}
await browser.waitForAngular();
}
async loginSSOIdentityService(username: string, password: string) {
@@ -84,8 +86,6 @@ export class LoginPage {
await this.clickLoginButton();
await browser.actions().sendKeys(protractor.Key.ENTER).perform();
await BrowserVisibility.waitUntilElementIsVisible(this.header);
await browser.waitForAngular();
}
async loginBasicAuth(username: string, password: string): Promise<void> {

View File

@@ -35,12 +35,12 @@ export class TabsPage {
}
async getNoOfTabs(): Promise<number> {
BrowserVisibility.waitUntilElementIsVisible(this.tabs.first());
await BrowserVisibility.waitUntilElementIsVisible(this.tabs.first());
return this.tabs.count();
}
async getTabsLabels(): Promise<string> {
BrowserVisibility.waitUntilElementIsVisible(this.tabs.first());
await BrowserVisibility.waitUntilElementIsVisible(this.tabs.first());
return this.tabs.getText();
}
}

View File

@@ -20,6 +20,7 @@ import { TabsPage } from './material/tabs.page';
import { TogglePage } from './material/toggle.page';
import { BrowserVisibility } from '../utils/browser-visibility';
import { element, by, browser, protractor } from 'protractor';
import { Logger } from '../utils/logger';
export class ViewerPage {
@@ -110,6 +111,34 @@ export class ViewerPage {
const fileView = element.all(by.css(`#document-list-container div[data-automation-id="${fileName}"]`)).first();
await BrowserActions.click(fileView);
await browser.actions().sendKeys(protractor.Key.ENTER).perform();
await this.waitTillContentLoaded();
}
async waitTillContentLoaded(): Promise<void> {
await browser.sleep(500);
if (this.isSpinnerPresent()) {
Logger.log('wait spinner disappear');
await BrowserVisibility.waitUntilElementIsNotPresent(element(by.tagName('mat-spinner')));
} else {
try {
Logger.log('wait spinner is present');
await BrowserVisibility.waitUntilElementIsPresent(element(by.tagName('mat-spinner')));
} catch (error) {
}
}
}
private async isSpinnerPresent(): Promise<boolean> {
let isSpinnerPresent;
try {
isSpinnerPresent = await element(by.tagName('mat-spinner')).isDisplayed();
} catch (error) {
isSpinnerPresent = false;
}
return isSpinnerPresent;
}
async clearPageNumber(): Promise<void> {
@@ -338,7 +367,7 @@ export class ViewerPage {
}
async clickInfoButton(): Promise<void> {
await BrowserActions.clickExecuteScript('button[data-automation-id="adf-toolbar-sidebar"]');
await BrowserActions.click(element(by.css('button[data-automation-id="adf-toolbar-sidebar"]')));
}
async clickOnTab(tabName: string): Promise<void> {

View File

@@ -21,32 +21,54 @@ import { Logger } from './logger';
import * as path from 'path';
import * as fs from 'fs';
import { ApiUtil } from '../actions/api.util';
export class BrowserActions {
static async click(elementFinder: ElementFinder): Promise<void> {
static async clickUntilIsNotVisible(elementToClick: ElementFinder, elementToFind: ElementFinder): Promise<void> {
Logger.info(`Click until element is not present: ${elementToClick.locator().toString()}`);
const predicate = (isVisible: boolean) => {
return isVisible;
};
const apiCall = async () => {
await this.click(elementToClick);
try {
return BrowserVisibility.waitUntilElementIsVisible(elementToFind);
return true;
} catch (error) {
return false;
}
};
return ApiUtil.waitForApi(apiCall, predicate, 5, 2000);
}
static async click(elementToClick: ElementFinder): Promise<void> {
try {
Logger.info(`Click element: ${elementFinder.locator().toString()}`);
await BrowserVisibility.waitUntilElementIsPresent(elementFinder);
await BrowserVisibility.waitUntilElementIsClickable(elementFinder);
await elementFinder.click();
Logger.info(`Click element: ${elementToClick.locator().toString()}`);
await BrowserVisibility.waitUntilElementIsVisible(elementToClick);
await BrowserVisibility.waitUntilElementIsClickable(elementToClick);
await elementToClick.click();
} catch (clickErr) {
Logger.warn(`click error element ${elementFinder.locator().toString()} consider to use directly clickScript`);
await this.clickScript(elementFinder);
Logger.warn(`click error element ${elementToClick.locator().toString()} consider to use directly clickScript`);
await this.clickScript(elementToClick);
}
}
static async clickScript(elementFinder: ElementFinder): Promise<void> {
Logger.info(`Click script ${elementFinder.locator().toString()}`);
static async clickScript(elementToClick: ElementFinder): Promise<void> {
Logger.info(`Click script ${elementToClick.locator().toString()}`);
await browser.executeScript(`arguments[0].scrollIntoView();`, elementFinder);
await browser.executeScript(`arguments[0].click();`, elementFinder);
await browser.executeScript(`arguments[0].scrollIntoView();`, elementToClick);
await browser.executeScript(`arguments[0].click();`, elementToClick);
}
static async clickExecuteScript(elementCssSelector: string): Promise<void> {
Logger.info(`Click execute script ${elementCssSelector}`);
await BrowserVisibility.waitUntilElementIsPresent(element(by.css(elementCssSelector)));
await BrowserVisibility.waitUntilElementIsVisible(element(by.css(elementCssSelector)));
await browser.executeScript(`document.querySelector('${elementCssSelector}').click();`);
}
@@ -72,12 +94,14 @@ export class BrowserActions {
static async getText(elementFinder: ElementFinder): Promise<string> {
Logger.info(`Get Text ${elementFinder.locator().toString()}`);
const present = await BrowserVisibility.waitUntilElementIsPresent(elementFinder);
const present = await BrowserVisibility.waitUntilElementIsVisible(elementFinder);
if (present) {
let text = await elementFinder.getText();
if (text === '') { // DO NOT REMOVE BUG sometime wrongly return empty text for cdk elements
Logger.info(`Use backup get text script`);
text = await this.getTextScript(elementFinder);
return text?.trim();
}
@@ -89,14 +113,15 @@ export class BrowserActions {
}
}
static async getTextScript(elementFinder: ElementFinder): Promise<string> {
// Don't make it pub,ic use getText
private static async getTextScript(elementFinder: ElementFinder): Promise<string> {
return browser.executeScript(`return arguments[0].textContent`, elementFinder);
}
static async getInputValue(elementFinder: ElementFinder): Promise<string> {
Logger.info(`Get Input value ${elementFinder.locator().toString()}`);
const present = await BrowserVisibility.waitUntilElementIsPresent(elementFinder);
const present = await BrowserVisibility.waitUntilElementIsVisible(elementFinder);
if (present) {
return elementFinder.getAttribute('value');
} else {
@@ -187,7 +212,7 @@ export class BrowserActions {
const fileWithPath = path.join(screenshotFilePath, filenameWithExt);
const stream = fs.createWriteStream(fileWithPath);
stream.write(new Buffer(pngData, 'base64'));
stream.write(Buffer.from(pngData, 'base64'));
stream.end();
}

View File

@@ -101,7 +101,9 @@ export class BrowserVisibility {
return browser.wait(protractor.ExpectedConditions.stalenessOf(elementToCheck), waitTimeout, 'Element is present ' + elementToCheck.locator());
}
static async waitUntilDialogIsClose(): Promise<any> {
static async waitUntilDialogIsClose(): Promise<void> {
Logger.info(`Wait Until dialog close`);
const dialog = element(by.css('mat-dialog-container'));
await this.waitUntilElementIsNotPresent(dialog);
}

View File

@@ -20,6 +20,7 @@ import { EditTaskFilterDialogPage } from './dialog/edit-task-filter-dialog.page'
import { BrowserVisibility } from '../../core/utils/browser-visibility';
import { BrowserActions } from '../../core/utils/browser-actions';
import { DropdownPage } from '../../core/pages/material/dropdown.page';
import { DataTableComponentPage } from '../../core/pages/data-table-component.page';
export class EditTaskFilterCloudComponentPage {
@@ -51,6 +52,8 @@ export class EditTaskFilterCloudComponentPage {
editTaskFilterDialogPage = new EditTaskFilterDialogPage();
dataTable = new DataTableComponentPage( element(by.css('adf-cloud-task-list')));
editTaskFilterDialog(): EditTaskFilterDialogPage {
return this.editTaskFilterDialogPage;
}
@@ -66,6 +69,7 @@ export class EditTaskFilterCloudComponentPage {
async setStatusFilterDropDown(option: string): Promise<void> {
await this.statusDropdown.selectDropdownOption(option);
await this.dataTable.waitTillContentLoaded();
}
async getStatusFilterDropDownValue(): Promise<string> {
@@ -74,6 +78,7 @@ export class EditTaskFilterCloudComponentPage {
async setSortFilterDropDown(option: string): Promise<void> {
await this.sortDropdown.selectDropdownOption(option);
await this.dataTable.waitTillContentLoaded();
}
async getSortFilterDropDownValue(): Promise<string> {
@@ -82,7 +87,7 @@ export class EditTaskFilterCloudComponentPage {
async setOrderFilterDropDown(option: string): Promise<void> {
await this.orderDropdown.selectDropdownOption(option);
await browser.sleep(1500);
await this.dataTable.waitTillContentLoaded();
}
async getOrderFilterDropDownValue(): Promise<string> {
@@ -124,6 +129,7 @@ export class EditTaskFilterCloudComponentPage {
async setLastModifiedFrom(lastModifiedFromDate: string) {
await this.clearField(this.lastModifiedFrom);
await BrowserActions.clearSendKeys(this.lastModifiedFrom, lastModifiedFromDate);
await this.dataTable.waitTillContentLoaded();
}
async getLastModifiedFrom(): Promise<string> {
@@ -133,6 +139,7 @@ export class EditTaskFilterCloudComponentPage {
async setLastModifiedTo(lastModifiedToDate: string): Promise<void> {
await this.clearField(this.lastModifiedTo);
await BrowserActions.clearSendKeys(this.lastModifiedTo, lastModifiedToDate);
await this.dataTable.waitTillContentLoaded();
}
async getLastModifiedTo(): Promise<string> {
@@ -194,6 +201,7 @@ export class EditTaskFilterCloudComponentPage {
async setAppNameDropDown(option: string): Promise<void> {
await this.appNameDropdown.selectDropdownOption(option);
await this.dataTable.waitTillContentLoaded();
}
async getAppNameDropDownValue(): Promise<string> {
@@ -234,6 +242,7 @@ export class EditTaskFilterCloudComponentPage {
await locator.clear();
await locator.sendKeys(option);
await locator.sendKeys(protractor.Key.ENTER);
await this.dataTable.waitTillContentLoaded();
}
async getProcessInstanceId(): Promise<string> {

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { browser, by, element, ElementFinder } from 'protractor';
import { by, element, ElementFinder } from 'protractor';
import { BrowserVisibility } from '../../core/utils/browser-visibility';
import { BrowserActions } from '../../core/utils/browser-actions';
@@ -34,7 +34,6 @@ export class TaskFiltersCloudComponentPage {
this.filter = this.getTaskFilterLocatorByFilterName(filterName);
await BrowserVisibility.waitUntilElementIsClickable(this.filter);
await BrowserActions.click(this.filter);
await browser.sleep(1500);
}
async checkTaskFilterNotDisplayed(filterName: string): Promise<void> {

View File

@@ -1,6 +1,7 @@
{
"extends": "../tslint.json",
"rules": {
"no-floating-promises": true,
"directive-selector": [
true,
"attribute",