[ADF-4705] - Automate forms checkbox widget (#4881)

* [ADF-4705] - Automate forms checkox widget

* Move methods to a demo-shell page

* Adding 3 new tests
This commit is contained in:
Silviu Popa
2019-07-01 13:33:34 +03:00
committed by Eugenio Romano
parent 4dccc2a49a
commit 43f08441cd
8 changed files with 476 additions and 10 deletions

View File

@@ -1,7 +1,7 @@
<div class="main-content"> <div class="main-content">
<mat-tab-group> <mat-tab-group>
<mat-tab label="Form"> <mat-tab label="Form" class="form-cloud-render">
<div class="adf-form-container"> <div class="adf-form-container">
<adf-cloud-form <adf-cloud-form
[showRefreshButton]="false" [showRefreshButton]="false"
@@ -17,7 +17,7 @@
translate}}</p> translate}}</p>
</div> </div>
</mat-tab> </mat-tab>
<mat-tab label="Editor"> <mat-tab label="Editor" class="form-cloud-editor">
<ngx-monaco-editor <ngx-monaco-editor
id="adf-form-config-editor" id="adf-form-config-editor"
class="adf-form-config-editor" class="adf-form-config-editor"

View File

@@ -0,0 +1,177 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { LoginPage, Widget } from '@alfresco/adf-testing';
import { browser } from 'protractor';
import { AlfrescoApiCompatibility as AlfrescoApi } from '@alfresco/js-api';
import { NavigationBarPage } from '../../pages/adf/navigationBarPage';
import { UsersActions } from '../../actions/users.actions';
import { FormCloudDemoPage } from '../../pages/adf/demo-shell/process-services-cloud/cloudFormDemoPage';
import { checkboxVisibilityForm } from '../../resources/forms/checkbox-visibility-condition';
describe('Visibility conditions', () => {
const loginPage = new LoginPage();
const navigationBarPage = new NavigationBarPage();
const formCloudDemoPage = new FormCloudDemoPage();
const checkboxVisibilityFormJson = JSON.parse(checkboxVisibilityForm);
const widget = new Widget();
let tenantId, user;
let visibleCheckbox;
const widgets = {
textOneId: 'textOne',
textTwoId: 'textTwo'
};
const value = {
displayCheckbox: 'showCheckbox',
notDisplayCheckbox: 'anythingElse'
};
const checkbox = {
checkboxFieldValue : 'CheckboxFieldValue',
checkboxVariableField: 'CheckboxVariableField',
checkboxFieldVariable: 'CheckboxFieldVariable',
checkboxFieldField: 'CheckboxFieldField',
checkboxVariableValue: 'CheckboxVariableValue',
checkboxVariableVariable: 'CheckboxVariableVariable'
};
beforeAll(async (done) => {
this.alfrescoJsApi = new AlfrescoApi({
provider: 'BPM',
hostBpm: browser.params.testConfig.adf.url
});
const users = new UsersActions();
await this.alfrescoJsApi.login(browser.params.testConfig.adf.adminEmail, browser.params.testConfig.adf.adminPassword);
user = await users.createTenantAndUser(this.alfrescoJsApi);
tenantId = user.tenantId;
await this.alfrescoJsApi.login(user.email, user.password);
await loginPage.loginToProcessServicesUsingUserModel(user);
navigationBarPage.clickFormCloudButton();
formCloudDemoPage.setConfigToEditor(checkboxVisibilityFormJson);
done();
});
afterAll(async (done) => {
await this.alfrescoJsApi.login(browser.params.testConfig.adf.adminEmail, browser.params.testConfig.adf.adminPassword);
await this.alfrescoJsApi.activiti.adminTenantsApi.deleteTenant(tenantId);
done();
});
it('[C309647] Should be able to see Checkbox widget when visibility condition refers to another field with specific value', () => {
widget.textWidget().isWidgetVisible(widgets.textOneId);
widget.checkboxWidget().isCheckboxHidden(checkbox.checkboxFieldValue);
widget.textWidget().setValue(widgets.textOneId, value.displayCheckbox);
widget.checkboxWidget().isCheckboxDisplayed(checkbox.checkboxFieldValue);
widget.textWidget().setValue(widgets.textOneId, value.notDisplayCheckbox);
widget.checkboxWidget().isCheckboxHidden(checkbox.checkboxFieldValue);
});
it('[C309648] Should be able to see Checkbox widget when visibility condition refers to a form variable and a field', () => {
widget.textWidget().isWidgetVisible(widgets.textOneId);
widget.checkboxWidget().isCheckboxHidden(checkbox.checkboxVariableField);
widget.textWidget().setValue(widgets.textOneId, value.displayCheckbox);
widget.checkboxWidget().isCheckboxDisplayed(checkbox.checkboxVariableField);
widget.textWidget().setValue(widgets.textOneId, value.notDisplayCheckbox);
widget.checkboxWidget().isCheckboxHidden(checkbox.checkboxVariableField);
});
it('[C309649] Should be able to see Checkbox widget when visibility condition refers to a field and a form variable', () => {
widget.textWidget().isWidgetVisible(widgets.textOneId);
widget.checkboxWidget().isCheckboxHidden(checkbox.checkboxFieldVariable);
widget.textWidget().setValue(widgets.textOneId, value.displayCheckbox);
expect(widget.checkboxWidget().isCheckboxDisplayed(checkbox.checkboxFieldVariable)).toBe(true);
widget.textWidget().setValue(widgets.textOneId, value.notDisplayCheckbox);
widget.checkboxWidget().isCheckboxHidden(checkbox.checkboxFieldVariable);
});
it('[C311425] Should be able to see Checkbox widget when visibility condition refers to a field and another field', () => {
widget.textWidget().isWidgetVisible(widgets.textOneId);
widget.textWidget().isWidgetVisible(widgets.textTwoId);
widget.checkboxWidget().isCheckboxHidden(checkbox.checkboxFieldField);
widget.textWidget().setValue(widgets.textOneId, value.displayCheckbox);
widget.checkboxWidget().isCheckboxHidden(checkbox.checkboxFieldField);
widget.textWidget().setValue(widgets.textTwoId, value.displayCheckbox);
widget.checkboxWidget().isCheckboxDisplayed(checkbox.checkboxFieldField);
widget.textWidget().setValue(widgets.textOneId, value.notDisplayCheckbox);
widget.checkboxWidget().isCheckboxHidden(checkbox.checkboxFieldField);
});
it('[C311424] Should be able to see Checkbox widget when visibility condition refers to a variable with specific value', () => {
formCloudDemoPage.setConfigToEditor(checkboxVisibilityFormJson);
widget.checkboxWidget().isCheckboxDisplayed(checkbox.checkboxVariableValue);
visibleCheckbox = checkboxVisibilityFormJson;
visibleCheckbox.formRepresentation.formDefinition.variables[0].value = value.notDisplayCheckbox;
formCloudDemoPage.setConfigToEditor(visibleCheckbox);
widget.checkboxWidget().isCheckboxHidden(checkbox.checkboxVariableValue);
visibleCheckbox = checkboxVisibilityFormJson;
visibleCheckbox.formRepresentation.formDefinition.variables[0].value = value.displayCheckbox;
formCloudDemoPage.setConfigToEditor(visibleCheckbox);
});
it('[C311426] Should be able to see Checkbox widget when visibility condition refers to form variable and another form variable', () => {
formCloudDemoPage.setConfigToEditor(checkboxVisibilityFormJson);
widget.checkboxWidget().isCheckboxDisplayed(checkbox.checkboxVariableVariable);
visibleCheckbox = checkboxVisibilityFormJson;
visibleCheckbox.formRepresentation.formDefinition.variables[0].value = value.notDisplayCheckbox;
formCloudDemoPage.setConfigToEditor(visibleCheckbox);
widget.checkboxWidget().isCheckboxHidden(checkbox.checkboxVariableVariable);
visibleCheckbox = checkboxVisibilityFormJson;
visibleCheckbox.formRepresentation.formDefinition.variables[1].value = value.notDisplayCheckbox;
formCloudDemoPage.setConfigToEditor(visibleCheckbox);
widget.checkboxWidget().isCheckboxDisplayed(checkbox.checkboxVariableVariable);
visibleCheckbox = checkboxVisibilityFormJson;
visibleCheckbox.formRepresentation.formDefinition.variables[0].value = value.displayCheckbox;
visibleCheckbox.formRepresentation.formDefinition.variables[1].value = value.displayCheckbox;
formCloudDemoPage.setConfigToEditor(visibleCheckbox);
});
});

View File

@@ -15,25 +15,35 @@
* limitations under the License. * limitations under the License.
*/ */
import { element, by } from 'protractor'; import { element, by, browser } from 'protractor';
import { BrowserVisibility, BrowserActions } from '@alfresco/adf-testing'; import { BrowserVisibility, BrowserActions } from '@alfresco/adf-testing';
export class ConfigEditorPage { export class ConfigEditorPage {
textField = element(by.css('#adf-form-config-editor div.overflow-guard > textarea'));
enterConfiguration(text) { enterConfiguration(text) {
const textField = element(by.css('#adf-code-configuration-editor div.overflow-guard > textarea'));
BrowserVisibility.waitUntilElementIsVisible(textField); BrowserVisibility.waitUntilElementIsVisible(this.textField);
textField.sendKeys(text); this.textField.sendKeys(text);
return this; return this;
} }
clickSaveButton() { clickSaveButton() {
const saveButton = element(by.id('adf-configuration-save')); const saveButton = element(by.id('adf-form-config-save'));
BrowserActions.click(saveButton); BrowserActions.click(saveButton);
} }
clickClearButton() { clickClearButton() {
const clearButton = element(by.id('adf-configuration-clear')); BrowserVisibility.waitUntilElementIsVisible(this.textField);
const clearButton = element(by.id('adf-form-config-clear'));
BrowserActions.click(clearButton); BrowserActions.click(clearButton);
} }
enterBulkConfiguration(text) {
this.clickClearButton();
BrowserVisibility.waitUntilElementIsVisible(this.textField);
browser.executeScript('this.monaco.editor.getModels()[0].setValue(`' + JSON.stringify(text) + '`)');
this.clickSaveButton();
}
} }

View File

@@ -0,0 +1,46 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { ConfigEditorPage } from '../../configEditorPage';
import { BrowserVisibility } from '@alfresco/adf-testing';
import { by, element, browser } from 'protractor';
export class FormCloudDemoPage {
formCloudEditor = element.all(by.css('.mat-tab-list .mat-tab-label')).get(1);
formCloudRender = element.all(by.css('.mat-tab-list .mat-tab-label')).get(0);
configEditorPage = new ConfigEditorPage();
goToEditor() {
BrowserVisibility.waitUntilElementIsVisible(this.formCloudEditor);
this.formCloudEditor.click();
}
goToRenderedForm() {
BrowserVisibility.waitUntilElementIsVisible(this.formCloudRender);
this.formCloudRender.click();
}
setConfigToEditor(text) {
this.goToEditor();
browser.sleep(2000);
this.configEditorPage.enterBulkConfiguration(text);
this.goToRenderedForm();
browser.sleep(2000);
}
}

View File

@@ -205,6 +205,11 @@ export class NavigationBarPage {
BrowserActions.click(this.formButton); BrowserActions.click(this.formButton);
} }
clickFormCloudButton() {
this.clickMenuButton('Process Cloud');
BrowserActions.click(this.formButton);
}
checkLogoTooltip(logoTooltipTitle) { checkLogoTooltip(logoTooltipTitle) {
const logoTooltip = element(by.css('a[title="' + logoTooltipTitle + '"]')); const logoTooltip = element(by.css('a[title="' + logoTooltipTitle + '"]'));
BrowserVisibility.waitUntilElementIsVisible(logoTooltip); BrowserVisibility.waitUntilElementIsVisible(logoTooltip);

View File

@@ -0,0 +1,222 @@
/*!
* @license
* Copyright 2019 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* tslint:disable */
export const checkboxVisibilityForm = `{
"formRepresentation": {
"id": "form-412cdeab-de90-4099-875f-676366e48fc9",
"name": "test",
"description": "",
"version": 0,
"formDefinition": {
"tabs": [],
"fields": [
{
"id": "85a4f564-2c70-438a-ae0f-b9c8af4887c2",
"name": "Label",
"type": "container",
"tab": null,
"numberOfColumns": 2,
"fields": {
"1": [
{
"id": "CheckboxFieldField",
"name": "CheckboxFieldField",
"type": "boolean",
"required": false,
"colspan": 1,
"visibilityCondition": {
"leftFormFieldId": "textOne",
"leftRestResponseId": "",
"operator": "==",
"rightValue": "",
"rightType": null,
"rightFormFieldId": "textTwo",
"rightRestResponseId": "",
"nextConditionOperator": ""
},
"params": {
"existingColspan": 1,
"maxColspan": 2
}
},
{
"id": "CheckboxFieldVariable",
"name": "CheckboxFieldVariable",
"type": "boolean",
"required": false,
"colspan": 1,
"visibilityCondition": {
"leftFormFieldId": "textOne",
"leftRestResponseId": "",
"operator": "==",
"rightValue": "",
"rightType": null,
"rightFormFieldId": "",
"rightRestResponseId": "cbc51284-04c4-462f-ab72-2b9f8b14907b",
"nextConditionOperator": ""
},
"params": {
"existingColspan": 1,
"maxColspan": 2
}
},
{
"id": "CheckboxFieldValue",
"name": "CheckboxFieldValue",
"type": "boolean",
"required": false,
"colspan": 1,
"visibilityCondition": {
"leftFormFieldId": "textOne",
"leftRestResponseId": "",
"operator": "==",
"rightValue": "showCheckbox",
"rightType": null,
"rightFormFieldId": "",
"rightRestResponseId": "",
"nextConditionOperator": "",
"nextCondition": null
},
"params": {
"existingColspan": 1,
"maxColspan": 2
}
},
{
"id": "CheckboxVariableValue",
"name": "CheckboxVariableValue",
"type": "boolean",
"required": false,
"colspan": 1,
"visibilityCondition": {
"leftFormFieldId": "",
"leftRestResponseId": "cbc51284-04c4-462f-ab72-2b9f8b14907b",
"operator": "==",
"rightValue": "showCheckbox",
"rightType": null,
"rightFormFieldId": "",
"rightRestResponseId": "",
"nextConditionOperator": "",
"nextCondition": null
},
"params": {
"existingColspan": 1,
"maxColspan": 2
}
},
{
"id": "CheckboxVariableVariable",
"name": "CheckboxVariableVariable",
"type": "boolean",
"required": false,
"colspan": 1,
"visibilityCondition": {
"leftFormFieldId": "",
"leftRestResponseId": "cbc51284-04c4-462f-ab72-2b9f8b14907b",
"operator": "==",
"rightValue": "",
"rightType": null,
"rightFormFieldId": "",
"rightRestResponseId": "87df371a-4238-43f8-92e5-ef3f6a19f379",
"nextConditionOperator": "",
"nextCondition": null
},
"params": {
"existingColspan": 1,
"maxColspan": 2
}
},
{
"id": "CheckboxVariableField",
"name": "CheckboxVariableField",
"type": "boolean",
"required": false,
"colspan": 1,
"visibilityCondition": {
"leftFormFieldId": "",
"leftRestResponseId": "cbc51284-04c4-462f-ab72-2b9f8b14907b",
"operator": "==",
"rightValue": "",
"rightType": null,
"rightFormFieldId": "textOne",
"rightRestResponseId": "",
"nextConditionOperator": "",
"nextCondition": null
},
"params": {
"existingColspan": 1,
"maxColspan": 2
}
}
],
"2": [
{
"id": "textOne",
"name": "textOne",
"type": "text",
"required": false,
"colspan": 1,
"placeholder": null,
"minLength": 0,
"maxLength": 0,
"regexPattern": null,
"visibilityCondition": null,
"params": {
"existingColspan": 1,
"maxColspan": 2
}
},
{
"id": "textTwo",
"name": "textTwo",
"type": "text",
"required": false,
"colspan": 1,
"placeholder": null,
"minLength": 0,
"maxLength": 0,
"regexPattern": null,
"visibilityCondition": null,
"params": {
"existingColspan": 1,
"maxColspan": 2
}
}
]
}
}
],
"outcomes": [],
"metadata": {},
"variables": [
{
"id": "cbc51284-04c4-462f-ab72-2b9f8b14907b",
"name": "varString1",
"type": "string",
"value": "showCheckbox"
},
{
"id": "87df371a-4238-43f8-92e5-ef3f6a19f379",
"name": "varString2",
"type": "string",
"value": "showCheckbox"
}
]
}
}
}`;

View File

@@ -42,7 +42,7 @@ export class FormFields {
checkWidgetIsVisible(fieldId) { checkWidgetIsVisible(fieldId) {
const fieldElement = element.all(by.css(`adf-form-field div[id='field-${fieldId}-container']`)).first(); const fieldElement = element.all(by.css(`adf-form-field div[id='field-${fieldId}-container']`)).first();
BrowserVisibility.waitUntilElementIsVisible(fieldElement); BrowserVisibility.waitUntilElementIsOnPage(fieldElement);
} }
checkWidgetIsHidden(fieldId) { checkWidgetIsHidden(fieldId) {
@@ -50,6 +50,12 @@ export class FormFields {
BrowserVisibility.waitUntilElementIsVisible(hiddenElement); BrowserVisibility.waitUntilElementIsVisible(hiddenElement);
} }
checkWidgetIsNotHidden(fieldId) {
this.checkWidgetIsVisible(fieldId);
const hiddenElement = element(by.css(`adf-form-field div[id='field-${fieldId}-container'][hidden]`));
return BrowserVisibility.waitUntilElementIsNotVisible(hiddenElement, 6000);
}
getWidget(fieldId) { getWidget(fieldId) {
const widget = element(by.css(`adf-form-field div[id='field-${fieldId}-container']`)); const widget = element(by.css(`adf-form-field div[id='field-${fieldId}-container']`));
BrowserVisibility.waitUntilElementIsVisible(widget); BrowserVisibility.waitUntilElementIsVisible(widget);

View File

@@ -34,7 +34,7 @@ export class CheckboxWidget {
} }
isCheckboxDisplayed(fieldId) { isCheckboxDisplayed(fieldId) {
return this.formFields.checkWidgetIsVisible(fieldId); return this.formFields.checkWidgetIsNotHidden(fieldId);
} }
isCheckboxHidden(fieldId) { isCheckboxHidden(fieldId) {