Skip to content

Commit

Permalink
exclude failing test before the revert of the time modify is finalized (
Browse files Browse the repository at this point in the history
#5794)

* exclude test

* remove exclude and add more log power

* fix

* correct issue
  • Loading branch information
eromano committed Jun 19, 2020
1 parent b7815e6 commit 2a5fa95
Show file tree
Hide file tree
Showing 11 changed files with 178 additions and 141 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
StringUtil,
StartTasksCloudPage,
TaskFormCloudComponent,
StartProcessCloudPage
StartProcessCloudPage, ProcessCloudWidgetPage
} from '@alfresco/adf-testing';
import { browser, by } from 'protractor';

Expand All @@ -44,6 +44,7 @@ describe('Task cloud visibility', async () => {
const startProcessPage = new StartProcessCloudPage();
const processCloudDemoPage = new ProcessCloudDemoPage();
const loginSSOPage = new LoginSSOPage();
const widget = new ProcessCloudWidgetPage();

const apiService = new ApiService();
const identityService = new IdentityService(apiService);
Expand All @@ -57,7 +58,7 @@ describe('Task cloud visibility', async () => {
beforeAll(async () => {
await apiService.login(browser.params.identityAdmin.email, browser.params.identityAdmin.password);

testUser = await identityService.createIdentityUserWithRole( [identityService.ROLES.ACTIVITI_USER]);
testUser = await identityService.createIdentityUserWithRole([identityService.ROLES.ACTIVITI_USER]);
groupInfo = await groupIdentityService.getGroupInfoByGroupName('hr');
await identityService.addUserToGroup(testUser.idIdentityService, groupInfo.id);

Expand Down Expand Up @@ -146,13 +147,16 @@ describe('Task cloud visibility', async () => {
await tasksCloudDemoPage.taskListCloudComponent().selectRow('boolean_visibility_task');
await taskFormCloudComponent.clickClaimButton();

await browser.sleep(400);

await taskFormCloudComponent.formFields().checkWidgetIsVisible('Checkbox2');
await taskFormCloudComponent.formFields().checkWidgetIsHidden('Checkbox3');
await expect(await taskFormCloudComponent.formFields().isCompleteFormButtonEnabled()).toEqual(false);

await taskFormCloudComponent.formFields().clickField(by.id, 'Checkbox1');
await taskFormCloudComponent.formFields().clickField(by.id, 'Checkbox2');
await taskFormCloudComponent.formFields().checkWidgetIsVisible('Checkbox3');
await widget.checkboxWidget().clickCheckboxInput('Checkbox1');
await widget.checkboxWidget().clickCheckboxInput('Checkbox2');

await widget.checkboxWidget().isCheckboxDisplayed('Checkbox3');
await expect(await taskFormCloudComponent.formFields().isCompleteFormButtonEnabled()).toEqual(true);

await taskFormCloudComponent.clickCompleteButton();
Expand All @@ -172,9 +176,10 @@ describe('Task cloud visibility', async () => {
await taskFormCloudComponent.formFields().checkWidgetIsHidden('Checkbox3');
await expect(await taskFormCloudComponent.formFields().isCompleteFormButtonEnabled()).toEqual(false);

await taskFormCloudComponent.formFields().clickField(by.id, 'Checkbox1');
await taskFormCloudComponent.formFields().clickField(by.id, 'Checkbox2');
await taskFormCloudComponent.formFields().checkWidgetIsVisible('Checkbox3');
await widget.checkboxWidget().clickCheckboxInput('Checkbox1');
await widget.checkboxWidget().clickCheckboxInput('Checkbox2');

await widget.checkboxWidget().isCheckboxDisplayed('Checkbox3');
await expect(await taskFormCloudComponent.formFields().isCompleteFormButtonEnabled()).toEqual(true);

await taskFormCloudComponent.clickCompleteButton();
Expand Down
1 change: 0 additions & 1 deletion e2e/process-services-cloud/task-list-properties.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ describe('Edit task filters and task list properties', () => {
it('[C297476] Filter by taskName', async () => {
await tasksCloudDemoPage.editTaskFilterCloudComponent().setTaskName(createdTask.entry.name);
await expect(await tasksCloudDemoPage.editTaskFilterCloudComponent().getTaskName()).toEqual(createdTask.entry.name);
await tasksCloudDemoPage.taskListCloudComponent().checkContentIsDisplayedByName(createdTask.entry.name);
await tasksCloudDemoPage.taskListCloudComponent().getRowsWithSameName(createdTask.entry.name).then(async (list) => {
await expect(list.length).toEqual(1);
});
Expand Down
1 change: 1 addition & 0 deletions e2e/protractor.excludes.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"C290180": "https://issues.alfresco.com/jira/browse/ACS-364"
}

2 changes: 2 additions & 0 deletions e2e/test.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ const SCREENSHOT_PASSWORD = process.env.SCREENSHOT_PASSWORD || process.env.PASSW
const SCREENSHOT_USERNAME = process.env.SCREENSHOT_USERNAME || process.env.USERNAME_ADF;

const EXTERNAL_ACS_HOST = process.env.EXTERNAL_ACS_HOST;
const LOG_LEVEL = process.env.LOG_LEVEL || 'ERROR' ;

const appConfig = {
"log": LOG_LEVEL,
"ecmHost": HOST_ECM,
"bpmHost": HOST_BPM,
"identityHost": `${OAUTH_HOST}/auth/admin/realms/alfresco`,
Expand Down
60 changes: 31 additions & 29 deletions lib/testing/src/lib/core/actions/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'];

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);
});
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
};

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'];

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);
});
return new Promise((resolve, reject) => {

const uri = this.config.oauth2.host.replace('/realms', '/admin/realms') + path;
const pathParams = {}, formParams = {};
const contentTypes = ['application/json'];
const accepts = ['application/json'];

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));
});
}

}
5 changes: 0 additions & 5 deletions lib/testing/src/lib/core/pages/form/form-fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
28 changes: 23 additions & 5 deletions lib/testing/src/lib/core/utils/browser-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -40,26 +41,33 @@ export class BrowserActions {
await browser.executeScript(`arguments[0].click();`, elementFinder);
}

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 clickExecuteScript(elementCssSelector: string): Promise<void> {
await BrowserVisibility.waitUntilElementIsPresent(element(by.css(elementCssSelector)));
await browser.executeScript(`document.querySelector('${elementCssSelector}').click();`);
}

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();
Expand All @@ -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');
Expand Down Expand Up @@ -100,24 +110,32 @@ 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();
await elementFinder.sendKeys(text);
}

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);
Expand Down
15 changes: 15 additions & 0 deletions lib/testing/src/lib/core/utils/browser-visibility.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,51 +16,66 @@
*/

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;

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());
}

/*
* 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());
}

/*
* 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());
}

/*
* 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());
}

/*
* 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());
}

Expand Down
26 changes: 17 additions & 9 deletions lib/testing/src/lib/core/utils/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,35 +32,43 @@ 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(''));
}
}

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;
}
}

0 comments on commit 2a5fa95

Please sign in to comment.