mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-5022] added automation for Display Value Widget (#5302)
* [ADF-5022] added automation for Display Value Widget * [ADF-5022] fixed licences * [ADF-5022] fixed test name format * [ADF-5022] fixed import-BrowserVisibility and adding type for fieldId & re-write methods with try-catch for DisplayValue
This commit is contained in:
@@ -23,6 +23,7 @@ import { NavigationBarPage } from '../../pages/adf/navigationBarPage';
|
|||||||
import { FormCloudDemoPage } from '../../pages/adf/demo-shell/process-services-cloud/cloudFormDemoPage';
|
import { FormCloudDemoPage } from '../../pages/adf/demo-shell/process-services-cloud/cloudFormDemoPage';
|
||||||
import { checkboxVisibilityFormJson, multipleCheckboxVisibilityFormJson } from '../../resources/forms/checkbox-visibility-condition';
|
import { checkboxVisibilityFormJson, multipleCheckboxVisibilityFormJson } from '../../resources/forms/checkbox-visibility-condition';
|
||||||
import { multipleVisibilityFormJson } from '../../resources/forms/multiple-visibility-conditions';
|
import { multipleVisibilityFormJson } from '../../resources/forms/multiple-visibility-conditions';
|
||||||
|
import { displayValueTextJson } from '../../resources/forms/displayValue-visibilityConditions';
|
||||||
|
|
||||||
describe('Visibility conditions - cloud', () => {
|
describe('Visibility conditions - cloud', () => {
|
||||||
|
|
||||||
@@ -39,7 +40,9 @@ describe('Visibility conditions - cloud', () => {
|
|||||||
textTwoId: 'textTwo',
|
textTwoId: 'textTwo',
|
||||||
textThreeId: 'textThree',
|
textThreeId: 'textThree',
|
||||||
checkboxBasicVariable: 'CheckboxBasicVariableField',
|
checkboxBasicVariable: 'CheckboxBasicVariableField',
|
||||||
checkboxBasicField: 'CheckboxBasicFieldValue'
|
checkboxBasicField: 'CheckboxBasicFieldValue',
|
||||||
|
textOneDisplay: 'TextOne',
|
||||||
|
textTwoDisplay: 'TextTwo'
|
||||||
};
|
};
|
||||||
|
|
||||||
const value = {
|
const value = {
|
||||||
@@ -56,6 +59,11 @@ describe('Visibility conditions - cloud', () => {
|
|||||||
checkboxVariableVariable: 'CheckboxVariableVariable',
|
checkboxVariableVariable: 'CheckboxVariableVariable',
|
||||||
checkbox1: 'Checkbox1'
|
checkbox1: 'Checkbox1'
|
||||||
};
|
};
|
||||||
|
const displayValueString = {
|
||||||
|
displayValueNoConditionField: 'DisplayValueNoCondition',
|
||||||
|
displayValueSingleConditionField: 'DisplayValueSingleCondition',
|
||||||
|
displayValueMultipleConditionsField: 'DisplayValueMultipleCondition'
|
||||||
|
};
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
this.alfrescoJsApi = new AlfrescoApi({
|
this.alfrescoJsApi = new AlfrescoApi({
|
||||||
@@ -242,4 +250,79 @@ describe('Visibility conditions - cloud', () => {
|
|||||||
await widget.textWidget().setValue(widgets.textThreeId, 'something');
|
await widget.textWidget().setValue(widgets.textThreeId, 'something');
|
||||||
await widget.textWidget().isWidgetVisible(widgets.textOneId);
|
await widget.textWidget().isWidgetVisible(widgets.textOneId);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('[C309867] Should be able to see the value of a form variable in the Display Value Widget when no visibility conditions are added', async () => {
|
||||||
|
await formCloudDemoPage.setConfigToEditor(displayValueTextJson);
|
||||||
|
|
||||||
|
await widget.displayValueWidget().isDisplayValueWidgetVisible(displayValueString.displayValueNoConditionField);
|
||||||
|
|
||||||
|
const textDisplayWidgetNoCondition = await widget.displayValueWidget().getFieldValue(displayValueString.displayValueNoConditionField);
|
||||||
|
await expect(textDisplayWidgetNoCondition).toEqual('No cats');
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
it('[C309869] Should be able to see Display text widget when visibility condition refers to a form variable and a field', async () => {
|
||||||
|
await formCloudDemoPage.setConfigToEditor(displayValueTextJson);
|
||||||
|
|
||||||
|
await widget.textWidget().isWidgetVisible(widgets.textOneDisplay);
|
||||||
|
let textOneField = await widget.textWidget().getFieldValue(widgets.textOneDisplay);
|
||||||
|
await expect(textOneField).toEqual('');
|
||||||
|
await widget.displayValueWidget().checkDisplayValueWidgetIsHidden(displayValueString.displayValueSingleConditionField);
|
||||||
|
|
||||||
|
await widget.textWidget().setValue(widgets.textOneDisplay, 'cat');
|
||||||
|
textOneField = await widget.textWidget().getFieldValue(widgets.textOneDisplay);
|
||||||
|
await expect(textOneField).toEqual('cat');
|
||||||
|
await widget.displayValueWidget().isDisplayValueWidgetVisible(displayValueString.displayValueSingleConditionField);
|
||||||
|
const textDisplayWidgetSingleCondition = await widget.displayValueWidget().getFieldValue(displayValueString.displayValueSingleConditionField);
|
||||||
|
await expect(textDisplayWidgetSingleCondition).toEqual('cat');
|
||||||
|
|
||||||
|
await widget.textWidget().setValue(widgets.textOneDisplay, 'dog');
|
||||||
|
textOneField = await widget.textWidget().getFieldValue(widgets.textOneDisplay);
|
||||||
|
await expect(textOneField).toEqual('dog');
|
||||||
|
await widget.displayValueWidget().checkDisplayValueWidgetIsHidden(displayValueString.displayValueSingleConditionField);
|
||||||
|
|
||||||
|
});
|
||||||
|
it('[C309871] Should be able to see Display text widget when has multiple visibility conditions and next condition operators', async () => {
|
||||||
|
await formCloudDemoPage.setConfigToEditor(displayValueTextJson);
|
||||||
|
|
||||||
|
await widget.textWidget().isWidgetVisible(widgets.textOneDisplay);
|
||||||
|
let textOneField = await widget.textWidget().getFieldValue(widgets.textOneDisplay);
|
||||||
|
await expect(textOneField).toEqual('');
|
||||||
|
|
||||||
|
await widget.textWidget().isWidgetVisible(widgets.textTwoDisplay);
|
||||||
|
let textTwoField = await widget.textWidget().getFieldValue(widgets.textTwoDisplay);
|
||||||
|
await expect(textTwoField).toEqual('');
|
||||||
|
|
||||||
|
await widget.displayValueWidget().checkDisplayValueWidgetIsHidden(displayValueString.displayValueSingleConditionField);
|
||||||
|
await widget.displayValueWidget().checkDisplayValueWidgetIsHidden(displayValueString.displayValueMultipleConditionsField);
|
||||||
|
|
||||||
|
await widget.textWidget().setValue(widgets.textOneDisplay, 'cat');
|
||||||
|
textOneField = await widget.textWidget().getFieldValue(widgets.textOneDisplay);
|
||||||
|
await expect(textOneField).toEqual('cat');
|
||||||
|
await widget.displayValueWidget().isDisplayValueWidgetVisible(displayValueString.displayValueMultipleConditionsField);
|
||||||
|
const textDisplayWidgetMultipleCondition = await widget.displayValueWidget().getFieldValue(displayValueString.displayValueMultipleConditionsField);
|
||||||
|
await expect(textDisplayWidgetMultipleCondition).toEqual('more cats');
|
||||||
|
|
||||||
|
await widget.textWidget().setValue(widgets.textOneDisplay, 'dog');
|
||||||
|
textOneField = await widget.textWidget().getFieldValue(widgets.textOneDisplay);
|
||||||
|
await expect(textOneField).toEqual('dog');
|
||||||
|
await widget.displayValueWidget().checkDisplayValueWidgetIsHidden(displayValueString.displayValueMultipleConditionsField);
|
||||||
|
|
||||||
|
await widget.textWidget().setValue(widgets.textTwoDisplay, 'cat');
|
||||||
|
textTwoField = await widget.textWidget().getFieldValue(widgets.textTwoDisplay);
|
||||||
|
await expect(textTwoField).toEqual('cat');
|
||||||
|
await widget.displayValueWidget().checkDisplayValueWidgetIsHidden(displayValueString.displayValueMultipleConditionsField);
|
||||||
|
|
||||||
|
await widget.textWidget().setValue(widgets.textOneDisplay, 'cat');
|
||||||
|
textOneField = await widget.textWidget().getFieldValue(widgets.textOneDisplay);
|
||||||
|
await expect(textOneField).toEqual('cat');
|
||||||
|
await widget.displayValueWidget().checkDisplayValueWidgetIsHidden(displayValueString.displayValueMultipleConditionsField);
|
||||||
|
|
||||||
|
await widget.textWidget().setValue(widgets.textTwoDisplay, 'dog');
|
||||||
|
textTwoField = await widget.textWidget().getFieldValue(widgets.textTwoDisplay);
|
||||||
|
await expect(textTwoField).toEqual('dog');
|
||||||
|
await widget.displayValueWidget().isDisplayValueWidgetVisible(displayValueString.displayValueMultipleConditionsField);
|
||||||
|
await expect(textDisplayWidgetMultipleCondition).toEqual('more cats');
|
||||||
|
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
180
e2e/resources/forms/displayValue-visibilityConditions.ts
Normal file
180
e2e/resources/forms/displayValue-visibilityConditions.ts
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
/*!
|
||||||
|
* @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 displayValueTextJson = {
|
||||||
|
formRepresentation : {
|
||||||
|
id : 'form-340a2672-429b-454f-9bb1-7b4d7362bb89' ,
|
||||||
|
name : 'display-one' ,
|
||||||
|
description : '',
|
||||||
|
version : 0,
|
||||||
|
standAlone : true,
|
||||||
|
formDefinition : {
|
||||||
|
tabs : [],
|
||||||
|
fields : [
|
||||||
|
{
|
||||||
|
id : 'ce6459d8-08c8-4424-af02-6117a20548c9' ,
|
||||||
|
name : 'Label' ,
|
||||||
|
type : 'container' ,
|
||||||
|
tab : null,
|
||||||
|
numberOfColumns : 2,
|
||||||
|
fields : {
|
||||||
|
1 : [
|
||||||
|
{
|
||||||
|
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
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id : 'DisplayValueNoCondition' ,
|
||||||
|
name : 'Display value - NoCondition' ,
|
||||||
|
type : 'readonly' ,
|
||||||
|
value : 'No cats' ,
|
||||||
|
colspan : 1,
|
||||||
|
visibilityCondition : null,
|
||||||
|
params : {
|
||||||
|
existingColspan : 1,
|
||||||
|
maxColspan : 2,
|
||||||
|
field : {
|
||||||
|
id : '12f8a718-1e79-4b1d-96f2-7f1a9b15a477',
|
||||||
|
name : 'NoCondition',
|
||||||
|
type : 'string'
|
||||||
|
},
|
||||||
|
responseVariable : true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
2 : [
|
||||||
|
{
|
||||||
|
id : 'DisplayValueSingleCondition' ,
|
||||||
|
name : 'Display value - SingleCondition' ,
|
||||||
|
type : 'readonly' ,
|
||||||
|
value : 'cat' ,
|
||||||
|
colspan : 1,
|
||||||
|
visibilityCondition : {
|
||||||
|
leftType : 'field',
|
||||||
|
leftValue : 'TextOne' ,
|
||||||
|
operator : '==',
|
||||||
|
rightValue : 'cat' ,
|
||||||
|
rightType : 'value',
|
||||||
|
nextConditionOperator : '' ,
|
||||||
|
nextCondition : null
|
||||||
|
},
|
||||||
|
params : {
|
||||||
|
existingColspan : 1,
|
||||||
|
maxColspan : 2,
|
||||||
|
field : {
|
||||||
|
id : '928c5dce-0ee4-4de3-8775-975eda5a4543' ,
|
||||||
|
name : 'StringTextDisplayed' ,
|
||||||
|
type : 'string'
|
||||||
|
},
|
||||||
|
responseVariable : true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id : 'DisplayValueMultipleCondition' ,
|
||||||
|
name : 'Display value - MultipleConditions' ,
|
||||||
|
type : 'readonly' ,
|
||||||
|
value : 'more cats' ,
|
||||||
|
colspan : 1,
|
||||||
|
visibilityCondition : {
|
||||||
|
leftType : 'field',
|
||||||
|
leftValue : 'TextOne',
|
||||||
|
operator : '==',
|
||||||
|
rightValue : 'cat',
|
||||||
|
rightType : 'value' ,
|
||||||
|
nextConditionOperator : 'and' ,
|
||||||
|
nextCondition : {
|
||||||
|
leftType : 'field' ,
|
||||||
|
leftValue : 'TextTwo' ,
|
||||||
|
operator : '!=',
|
||||||
|
rightValue : 'cat' ,
|
||||||
|
rightType : 'value' ,
|
||||||
|
nextConditionOperator :'',
|
||||||
|
nextCondition : null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
params : {
|
||||||
|
existingColspan : 1,
|
||||||
|
maxColspan : 2,
|
||||||
|
field : {
|
||||||
|
id : 'c74e945f-80dd-4adf-8393-fd644772b4a4' ,
|
||||||
|
name : 'MultipleConditions' ,
|
||||||
|
type : 'string'
|
||||||
|
},
|
||||||
|
responseVariable : true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
outcomes : [],
|
||||||
|
metadata : {},
|
||||||
|
variables : [
|
||||||
|
{
|
||||||
|
id : '928c5dce-0ee4-4de3-8775-975eda5a4543' ,
|
||||||
|
name : 'SingleCondition' ,
|
||||||
|
type : 'string',
|
||||||
|
value : 'cat'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id : 'c74e945f-80dd-4adf-8393-fd644772b4a4',
|
||||||
|
name : 'MultipleConditions',
|
||||||
|
type : 'string',
|
||||||
|
value : 'more cats'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id : '12f8a718-1e79-4b1d-96f2-7f1a9b15a477',
|
||||||
|
name : 'NoCondition',
|
||||||
|
type : 'string',
|
||||||
|
value : 'No cats'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@@ -16,7 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { FormFields } from '../formFields';
|
import { FormFields } from '../formFields';
|
||||||
import { by, Locator } from 'protractor';
|
import { by, element, Locator } from 'protractor';
|
||||||
|
import { BrowserVisibility } from '../../../utils/public-api';
|
||||||
|
|
||||||
export class DisplayValueWidget {
|
export class DisplayValueWidget {
|
||||||
|
|
||||||
@@ -32,4 +33,22 @@ export class DisplayValueWidget {
|
|||||||
return this.formFields.getFieldValue(fieldId, this.inputLocator);
|
return this.formFields.getFieldValue(fieldId, this.inputLocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async isDisplayValueWidgetVisible(fieldId: string): Promise<boolean> {
|
||||||
|
try {
|
||||||
|
await this.formFields.checkWidgetIsVisible(fieldId);
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async checkDisplayValueWidgetIsHidden(fieldId: string): Promise<boolean> {
|
||||||
|
const hiddenElement = element(by.css(`adf-form-field div[id='field-${fieldId}-container'][hidden]`));
|
||||||
|
try {
|
||||||
|
await BrowserVisibility.waitUntilElementIsNotVisible(hiddenElement);
|
||||||
|
return true;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user