exclude failing test before the revert of the time modify is finalized (#5794)

* exclude test

* remove exclude and add more log power

* fix

* correct issue
This commit is contained in:
Eugenio Romano
2020-06-19 23:04:21 +01:00
committed by GitHub
parent b7815e6006
commit 2a5fa954bd
11 changed files with 179 additions and 142 deletions

View File

@@ -78,37 +78,39 @@ export class ApiService {
}
async performBpmOperation(path: string, method: string, queryParams: any, postBody: any): Promise<any> {
const uri = this.config.hostBpm + path;
const pathParams = {}, formParams = {};
const contentTypes = ['application/json'];
const accepts = ['application/json'];
return new Promise((resolve, reject) => {
const uri = this.config.hostBpm + path;
const pathParams = {}, formParams = {};
const contentTypes = ['application/json'];
const accepts = ['application/json'];
const headerParams = {
Authorization: 'bearer ' + this.apiService.oauth2Auth.token
};
const headerParams = {
Authorization: 'bearer ' + this.apiService.oauth2Auth.token
};
return this.apiService.processClient.callCustomApi(uri, method, pathParams, queryParams, headerParams, formParams, postBody,
contentTypes, accepts, Object)
.catch((error) => {
throw (error);
});
this.apiService.processClient.callCustomApi(uri, method, pathParams, queryParams, headerParams, formParams, postBody,
contentTypes, accepts, Object)
.then((data) => resolve(data))
.catch((err) => reject(err));
});
}
async performIdentityOperation(path: string, method: string, queryParams: any, postBody: any): Promise<any> {
const uri = this.config.oauth2.host.replace('/realms', '/admin/realms') + path;
const pathParams = {}, formParams = {};
const contentTypes = ['application/json'];
const accepts = ['application/json'];
return new Promise((resolve, reject) => {
const headerParams = {
Authorization: 'bearer ' + this.apiService.oauth2Auth.token
};
const uri = this.config.oauth2.host.replace('/realms', '/admin/realms') + path;
const pathParams = {}, formParams = {};
const contentTypes = ['application/json'];
const accepts = ['application/json'];
return this.apiService.processClient.callCustomApi(uri, method, pathParams, queryParams, headerParams, formParams, postBody,
contentTypes, accepts, Object)
.catch((error) => {
throw (error);
});
const headerParams = {
Authorization: 'bearer ' + this.apiService.oauth2Auth.token
};
return this.apiService.processClient.callCustomApi(uri, method, pathParams, queryParams, headerParams, formParams, postBody,
contentTypes, accepts, Object)
.then((data) => resolve(data))
.catch((err) => reject(err));
});
}
}

View File

@@ -41,11 +41,6 @@ export class FormFields {
await BrowserActions.clearSendKeys(fieldElement, value);
}
async clickField(locator, field: string, fieldText?: string): Promise<void> {
const fieldElement = fieldText ? element(locator(field, fieldText)) : element(locator(field));
await BrowserActions.click(fieldElement);
}
async checkWidgetIsVisible(fieldId: string): Promise<void> {
const fieldElement = element.all(by.css(`adf-form-field div[id='field-${fieldId}-container']`)).first();
await BrowserVisibility.waitUntilElementIsVisible(fieldElement);

View File

@@ -26,6 +26,7 @@ export class BrowserActions {
static async click(elementFinder: ElementFinder): Promise<void> {
try {
Logger.info(`Click element: ${elementFinder.locator().toString()}`);
await BrowserVisibility.waitUntilElementIsPresent(elementFinder);
await BrowserVisibility.waitUntilElementIsClickable(elementFinder);
await elementFinder.click();
@@ -40,26 +41,33 @@ export class BrowserActions {
await browser.executeScript(`arguments[0].click();`, elementFinder);
}
static async waitUntilActionMenuIsVisible(): Promise<void> {
const actionMenu = element.all(by.css('div[role="menu"]')).first();
await BrowserVisibility.waitUntilElementIsVisible(actionMenu);
}
static async waitUntilActionMenuIsNotVisible(): Promise<void> {
const actionMenu = element.all(by.css('div[role="menu"]')).first();
await BrowserVisibility.waitUntilElementIsNotVisible(actionMenu);
}
static async getUrl(url: string, timeout: number = 10000): Promise<any> {
return browser.get(url, timeout);
}
static async clickExecuteScript(elementCssSelector: string): Promise<void> {
await BrowserVisibility.waitUntilElementIsPresent(element(by.css(elementCssSelector)));
await browser.executeScript(`document.querySelector('${elementCssSelector}').click();`);
}
static async waitUntilActionMenuIsVisible(): Promise<void> {
Logger.info(`wait Until Action Menu Is Visible`);
const actionMenu = element.all(by.css('div[role="menu"]')).first();
await BrowserVisibility.waitUntilElementIsVisible(actionMenu);
}
static async waitUntilActionMenuIsNotVisible(): Promise<void> {
Logger.info(`wait Until Action Menu Is Not Visible`);
const actionMenu = element.all(by.css('div[role="menu"]')).first();
await BrowserVisibility.waitUntilElementIsNotVisible(actionMenu);
}
static async getUrl(url: string, timeout: number = 10000): Promise<any> {
Logger.info(`Get URL ${url}`);
return browser.get(url, timeout);
}
static async getText(elementFinder: ElementFinder): Promise<string> {
Logger.info(`Get Text ${elementFinder.locator().toString()}`);
const present = await BrowserVisibility.waitUntilElementIsPresent(elementFinder);
if (present) {
return elementFinder.getText();
@@ -69,6 +77,8 @@ export class BrowserActions {
}
static async getInputValue(elementFinder: ElementFinder): Promise<string> {
Logger.info(`Get Input value ${elementFinder.locator().toString()}`);
const present = await BrowserVisibility.waitUntilElementIsPresent(elementFinder);
if (present) {
return elementFinder.getAttribute('value');
@@ -100,6 +110,8 @@ export class BrowserActions {
}
static async clearSendKeys(elementFinder: ElementFinder, text: string): Promise<void> {
Logger.info(`Clear and sendKeys text:${text} locator:${elementFinder.locator().toString()}`);
await this.click(elementFinder);
await elementFinder.sendKeys('');
await elementFinder.clear();
@@ -107,17 +119,23 @@ export class BrowserActions {
}
static async checkIsDisabled(elementFinder: ElementFinder): Promise<void> {
Logger.info(`Check is disabled locator:${elementFinder.locator().toString()}`);
await BrowserVisibility.waitUntilElementIsVisible(elementFinder);
const valueCheck = await elementFinder.getAttribute('disabled');
await expect(valueCheck).toEqual('true');
}
static async rightClick(elementFinder: ElementFinder): Promise<void> {
Logger.info(`Right click locator:${elementFinder.locator().toString()}`);
await browser.actions().mouseMove(elementFinder).mouseDown().mouseMove(elementFinder).perform();
await browser.actions().click(elementFinder, protractor.Button.RIGHT).perform();
}
static async closeMenuAndDialogs(): Promise<void> {
Logger.info(`close Menu And Dialogs`);
const container = element(by.css('div.cdk-overlay-backdrop.cdk-overlay-transparent-backdrop.cdk-overlay-backdrop-showing'));
await browser.actions().sendKeys(protractor.Key.ESCAPE).perform();
await BrowserVisibility.waitUntilElementIsNotVisible(container);

View File

@@ -16,6 +16,7 @@
*/
import { browser, by, element, ElementFinder, protractor } from 'protractor';
import { Logger } from './logger';
const DEFAULT_TIMEOUT = global['TestConfig'] ? global['TestConfig'].main.timeout : 20000;
const NOT_VISIBLE_DEFAULT_TIMEOUT = global['TestConfig'] ? global['TestConfig'].main.timeout : 2000;
@@ -23,12 +24,16 @@ const NOT_VISIBLE_DEFAULT_TIMEOUT = global['TestConfig'] ? global['TestConfig'].
export class BrowserVisibility {
static async waitUntilElementIsPresent(elementToCheck: ElementFinder, waitTimeout: number = DEFAULT_TIMEOUT): Promise<any> {
Logger.info(`Wait Until Element Is Present ${elementToCheck.locator().toString()} for ${waitTimeout}`);
return browser.wait(protractor.ExpectedConditions.presenceOf(elementToCheck), waitTimeout, 'Element is not present ' + elementToCheck.locator());
}
/*
* Wait for element to be visible
*/
static async waitUntilElementIsVisible(elementToCheck: ElementFinder, waitTimeout: number = DEFAULT_TIMEOUT, message: string = 'Element is not visible'): Promise<any> {
Logger.info(`Wait Until Element Is Visible ${elementToCheck.locator().toString()} for ${waitTimeout}`);
return browser.wait(protractor.ExpectedConditions.visibilityOf(elementToCheck), waitTimeout, message + elementToCheck.locator());
}
@@ -36,6 +41,8 @@ export class BrowserVisibility {
* Wait for element to be clickable
*/
static async waitUntilElementIsClickable(elementToCheck: ElementFinder, waitTimeout: number = DEFAULT_TIMEOUT): Promise<any> {
Logger.info(`Wait Until Element Is Clickable ${elementToCheck.locator().toString()} for ${waitTimeout}`);
return browser.wait(protractor.ExpectedConditions.elementToBeClickable(elementToCheck), waitTimeout, 'Element is not Clickable ' + elementToCheck.locator());
}
@@ -43,6 +50,8 @@ export class BrowserVisibility {
* Wait for element to not be present on the page
*/
static async waitUntilElementIsStale(elementToCheck: ElementFinder, waitTimeout: number = DEFAULT_TIMEOUT): Promise<any> {
Logger.info(`Wait Until Element Is Stale ${elementToCheck.locator().toString()} for ${waitTimeout}`);
return browser.wait(protractor.ExpectedConditions.stalenessOf(elementToCheck), waitTimeout, 'Element is not in stale ' + elementToCheck.locator());
}
@@ -50,6 +59,8 @@ export class BrowserVisibility {
* Wait for element to not be visible
*/
static async waitUntilElementIsNotVisible(elementToCheck: ElementFinder, waitTimeout: number = NOT_VISIBLE_DEFAULT_TIMEOUT): Promise<any> {
Logger.info(`Wait Until Element Is Not Visible ${elementToCheck.locator().toString()} for ${waitTimeout}`);
return browser.wait(protractor.ExpectedConditions.invisibilityOf(elementToCheck), waitTimeout, 'Element is Visible and it should not' + elementToCheck.locator());
}
@@ -57,10 +68,14 @@ export class BrowserVisibility {
* Wait for element to have value
*/
static async waitUntilElementHasValue(elementToCheck: ElementFinder, elementValue, waitTimeout: number = DEFAULT_TIMEOUT): Promise<any> {
Logger.info(`Wait Until Element has value ${elementToCheck.locator().toString()} for ${waitTimeout}`);
return browser.wait(protractor.ExpectedConditions.textToBePresentInElementValue(elementToCheck, elementValue), waitTimeout, 'Element doesn\'t have a value ' + elementToCheck.locator());
}
static async waitUntilElementIsNotPresent(elementToCheck: ElementFinder, waitTimeout: number = NOT_VISIBLE_DEFAULT_TIMEOUT): Promise<any> {
Logger.info(`Wait Until Element is not present ${elementToCheck.locator().toString()} for ${waitTimeout}`);
return browser.wait(protractor.ExpectedConditions.stalenessOf(elementToCheck), waitTimeout, 'Element is present ' + elementToCheck.locator());
}

View File

@@ -32,30 +32,30 @@ export class LogLevelsEnum extends Number {
}
export let logLevels: any[] = [
{level: LogLevelsEnum.TRACE, name: 'TRACE'},
{level: LogLevelsEnum.DEBUG, name: 'DEBUG'},
{level: LogLevelsEnum.INFO, name: 'INFO'},
{level: LogLevelsEnum.WARN, name: 'WARN'},
{level: LogLevelsEnum.ERROR, name: 'ERROR'},
{level: LogLevelsEnum.SILENT, name: 'SILENT'}
{ level: LogLevelsEnum.TRACE, name: 'TRACE' },
{ level: LogLevelsEnum.DEBUG, name: 'DEBUG' },
{ level: LogLevelsEnum.INFO, name: 'INFO' },
{ level: LogLevelsEnum.WARN, name: 'WARN' },
{ level: LogLevelsEnum.ERROR, name: 'ERROR' },
{ level: LogLevelsEnum.SILENT, name: 'SILENT' }
];
/* tslint:disable:no-console */
export class Logger {
static info(...messages: string[]): void {
if (browser.params.testConfig && browser.params.testConfig.appConfig.log >= LogLevelsEnum.INFO) {
if (browser.params.testConfig && Logger.getLogLevelByName(browser.params.testConfig.appConfig.log) >= LogLevelsEnum.INFO) {
console.log(infoColor, messages.join(''));
}
}
static log(...messages: string[]): void {
if (browser.params.testConfig && browser.params.testConfig.appConfig.log >= LogLevelsEnum.TRACE) {
if (browser.params.testConfig && Logger.getLogLevelByName(browser.params.testConfig.appConfig.log) >= LogLevelsEnum.TRACE) {
console.log(logColor, messages.join(''));
}
}
static warn(...messages: string[]): void {
if (browser.params.testConfig && browser.params.testConfig.appConfig.log >= LogLevelsEnum.WARN) {
if (browser.params.testConfig && Logger.getLogLevelByName(browser.params.testConfig.appConfig.log) >= LogLevelsEnum.WARN) {
console.log(warnColor, messages.join(''));
}
}
@@ -63,4 +63,12 @@ export class Logger {
static error(...messages: string[]): void {
console.log(errorColor, messages.join(''));
}
private static getLogLevelByName(name: string): number {
const log = logLevels.find((currentLog) => {
return currentLog.name === name;
});
return log.level || 1;
}
}

View File

@@ -27,80 +27,75 @@ export class TasksService {
}
async createStandaloneTask(taskName: string, appName: string, options?: Object): Promise<any> {
try {
const path = '/' + appName + '/rb/v1/tasks';
const method = 'POST';
const path = '/' + appName + '/rb/v1/tasks';
const method = 'POST';
const queryParams = {}, postBody = {
name: taskName,
payloadType: 'CreateTaskPayload',
...options
};
const queryParams = {}, postBody = {
name: taskName,
payloadType: 'CreateTaskPayload',
...options
};
return this.api.performBpmOperation(path, method, queryParams, postBody);
} catch (error) {
Logger.error('Create Task - Service error, Response: ', JSON.parse(JSON.stringify(error)));
}
return this.api.performBpmOperation(path, method, queryParams, postBody)
.catch((error) => {
Logger.error('Create Task - Service error, Response: ', JSON.stringify(error.response.text));
});
}
async createStandaloneTaskWithForm(taskName: string, appName: string, formKey: string, options?: Object): Promise<any> {
try {
const path = '/' + appName + '/rb/v1/tasks';
const method = 'POST';
const path = '/' + appName + '/rb/v1/tasks';
const method = 'POST';
const queryParams = {};
const postBody = {
name: taskName,
payloadType: 'CreateTaskPayload',
formKey: formKey,
...options
};
const queryParams = {};
const postBody = {
name: taskName,
payloadType: 'CreateTaskPayload',
formKey: formKey,
...options
};
return this.api.performBpmOperation(path, method, queryParams, postBody);
} catch (error) {
Logger.error('Create FormTask - Service error, Response: ', JSON.parse(JSON.stringify(error)));
}
return this.api.performBpmOperation(path, method, queryParams, postBody)
.catch((error) => {
Logger.error('Create standalone Task - Service error, Response: ', JSON.stringify(error.response.text));
});
}
async completeTask(taskId: string, appName: string): Promise<any> {
try {
const path = '/' + appName + '/rb/v1/tasks/' + taskId + '/complete';
const method = 'POST';
const path = '/' + appName + '/rb/v1/tasks/' + taskId + '/complete';
const method = 'POST';
const queryParams = {}, postBody = { payloadType: 'CompleteTaskPayload' };
const queryParams = {}, postBody = { payloadType: 'CompleteTaskPayload' };
return this.api.performBpmOperation(path, method, queryParams, postBody);
} catch (error) {
Logger.error('Complete Task - Service error, Response: ', JSON.parse(JSON.stringify(error)).response.text);
}
return this.api.performBpmOperation(path, method, queryParams, postBody)
.catch((error) => {
Logger.error('Complete Task - Service error, Response: ', JSON.stringify(error.response.text));
});
}
async claimTask(taskId: string, appName: string): Promise<any> {
try {
const path = '/' + appName + '/rb/v1/tasks/' + taskId + `/claim`;
const method = 'POST';
const path = '/' + appName + '/rb/v1/tasks/' + taskId + `/claim`;
const method = 'POST';
const queryParams = {};
const postBody = {};
const queryParams = {};
const postBody = {};
return this.api.performBpmOperation(path, method, queryParams, postBody);
} catch (error) {
Logger.error('Claim Task - Service error, Response: ', JSON.parse(JSON.stringify(error)).response.text);
}
return this.api.performBpmOperation(path, method, queryParams, postBody)
.catch((error) => {
Logger.error('claim Task - Service error, Response: ', JSON.stringify(error.response.text));
});
}
async deleteTask(taskId: string, appName: string): Promise<any> {
try {
const path = '/' + appName + '/rb/v1/tasks/' + taskId;
const method = 'DELETE';
const path = '/' + appName + '/rb/v1/tasks/' + taskId;
const method = 'DELETE';
const queryParams = {};
const postBody = {};
const queryParams = {};
const postBody = {};
return this.api.performBpmOperation(path, method, queryParams, postBody);
} catch (error) {
Logger.error('Delete Task - Service error, Response: ', JSON.parse(JSON.stringify(error)).response.text);
}
return this.api.performBpmOperation(path, method, queryParams, postBody)
.catch((error) => {
Logger.error('delete Task - Service error, Response: ', JSON.stringify(error.response.text));
});
}
async createAndCompleteTask(taskName: string, appName: string): Promise<any> {
@@ -111,45 +106,42 @@ export class TasksService {
}
async getTask(taskId: string, appName: string): Promise<any> {
try {
const path = '/' + appName + '/query/v1/tasks/' + taskId;
const method = 'GET';
const path = '/' + appName + '/query/v1/tasks/' + taskId;
const method = 'GET';
const queryParams = {};
const postBody = {};
const queryParams = {};
const postBody = {};
return this.api.performBpmOperation(path, method, queryParams, postBody);
} catch (error) {
Logger.error('Get Task - Service error, Response: ', JSON.parse(JSON.stringify(error)).response.text);
}
return this.api.performBpmOperation(path, method, queryParams, postBody)
.catch((error) => {
Logger.error('Get Task - Service error, Response: ', JSON.stringify(error.response.text));
});
}
async getTaskId(taskName: string, appName: string): Promise<any> {
try {
const path = '/' + appName + '/query/v1/tasks';
const method = 'GET';
const path = '/' + appName + '/query/v1/tasks';
const method = 'GET';
const queryParams = { name: taskName }, postBody = {};
const queryParams = { name: taskName }, postBody = {};
const data = await this.api.performBpmOperation(path, method, queryParams, postBody);
return data.list.entries && data.list.entries.length > 0 ? data.list.entries[0].entry.id : null;
} catch (error) {
Logger.error('Get Task Id - Service error, Response: ', JSON.parse(JSON.stringify(error)).response.text);
}
const data = await this.api.performBpmOperation(path, method, queryParams, postBody)
.catch((error) => {
Logger.error('Get Task Id Service error, Response: ', JSON.stringify(error.response.text));
});
return data.list.entries && data.list.entries.length > 0 ? data.list.entries[0].entry.id : null;
}
async createStandaloneSubtask(parentTaskId: string, appName: string, name: string): Promise<any> {
try {
const path = '/' + appName + '/rb/v1/tasks';
const method = 'POST';
const path = '/' + appName + '/rb/v1/tasks';
const method = 'POST';
const queryParams = {},
postBody = { name: name, parentTaskId: parentTaskId, payloadType: 'CreateTaskPayload' };
const queryParams = {},
postBody = { name: name, parentTaskId: parentTaskId, payloadType: 'CreateTaskPayload' };
return this.api.performBpmOperation(path, method, queryParams, postBody);
} catch (error) {
Logger.error('Create Task - Service error, Response: ', JSON.parse(JSON.stringify(error)).response.text);
}
return this.api.performBpmOperation(path, method, queryParams, postBody)
.catch((error) => {
Logger.error('Create sub Task - Service error, Response: ', JSON.stringify(error.response.text));
});
}
}