From 31bec59a165f7e6f39a07c68f87c42267a9c348d Mon Sep 17 00:00:00 2001 From: cristinaj Date: Fri, 30 Aug 2019 14:16:28 +0300 Subject: [PATCH] [ADF-3723]Add visibility conditions on tabs - form rendering component tests (#5022) * Add visibility conditions on tabs - form rendering component tests * no message * Moved the suite to process-services-cloud folder * no message --- .../visibility-condition-tabs.e2e.ts | 215 ++++++ .../forms/tab-visibility-conditions.ts | 673 ++++++++++++++++++ .../src/lib/core/pages/form/formFields.ts | 5 + .../src/lib/core/pages/form/widgets/tab.ts | 36 + .../lib/core/pages/form/widgets/textWidget.ts | 4 + .../src/lib/core/pages/form/widgets/widget.ts | 5 + 6 files changed, 938 insertions(+) create mode 100644 e2e/process-services-cloud/form-field/visibility-condition-tabs.e2e.ts create mode 100644 e2e/resources/forms/tab-visibility-conditions.ts create mode 100644 lib/testing/src/lib/core/pages/form/widgets/tab.ts diff --git a/e2e/process-services-cloud/form-field/visibility-condition-tabs.e2e.ts b/e2e/process-services-cloud/form-field/visibility-condition-tabs.e2e.ts new file mode 100644 index 0000000000..5b853ae447 --- /dev/null +++ b/e2e/process-services-cloud/form-field/visibility-condition-tabs.e2e.ts @@ -0,0 +1,215 @@ +/*! + * @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 { LoginSSOPage, SettingsPage, Widget } from '@alfresco/adf-testing'; +import { browser } from 'protractor'; + +import { AlfrescoApiCompatibility as AlfrescoApi } from '@alfresco/js-api'; +import { NavigationBarPage } from '../../pages/adf/navigationBarPage'; +import { FormCloudDemoPage } from '../../pages/adf/demo-shell/process-services-cloud/cloudFormDemoPage'; +import { tabFieldValueVisibilityJson, tabVarValueVisibilityJson, tabVarFieldVisibilityJson, + tabFieldFieldVisibilityJson, tabFieldVarVisibilityJson, tabVarVarVisibilityJson, + tabNextOperatorsVisibilityJson } from '../../resources/forms/tab-visibility-conditions'; + +describe('Visibility conditions on tabs - cloud', () => { + + const settingsPage = new SettingsPage(); + const loginSSOPage = new LoginSSOPage(); + + const navigationBarPage = new NavigationBarPage(); + const formCloudDemoPage = new FormCloudDemoPage(); + const widget = new Widget(); + + const widgets = { + textOneId: 'TextOne', + textTwoId: 'TextTwo', + textThreeId: 'TextThree' + }; + + const value = { + displayTab: 'showTab', + notDisplayTab: 'anythingElse' + }; + + const tab = { + tabWithFields: 'tabWithFields', + tabFieldValue: 'tabBasicFieldValue', + tabVarValue: 'tabBasicVarValue', + tabVarField: 'tabBasicVarField', + tabFieldField: 'tabBasicFieldField', + tabVarVar: 'tabBasicVarVar', + tabNextOperators: 'tabNextOperators' + }; + + beforeAll(async () => { + this.alfrescoJsApi = new AlfrescoApi({ + provider: 'BPM', + hostBpm: browser.params.testConfig.adf_aps.host + }); + + await settingsPage.setProviderBpmSso( + browser.params.config.bpmHost, + browser.params.config.oauth2.host, + browser.params.config.identityHost); + await loginSSOPage.loginSSOIdentityService(browser.params.testConfig.adf.adminEmail, browser.params.testConfig.adf.adminPassword); + + await navigationBarPage.navigateToFormCloudPage(); + }); + + it('[C309647] Should be able to see tab when visibility condition refers to a field with specific value', async () => { + await formCloudDemoPage.setConfigToEditor(tabFieldValueVisibilityJson); + await widget.tab().checkTabIsDisplayedByLabel(tab.tabWithFields); + await widget.tab().checkTabIsNotDisplayedByLabel(tab.tabFieldValue); + await widget.textWidget().isWidgetVisible(widgets.textOneId); + await widget.textWidget().isWidgetNotVisible(widgets.textTwoId); + await widget.textWidget().setValue(widgets.textOneId, value.displayTab); + await widget.tab().checkTabIsDisplayedByLabel(tab.tabWithFields); + await widget.tab().checkTabIsDisplayedByLabel(tab.tabFieldValue); + + await widget.tab().clickTabByLabel(tab.tabFieldValue); + await widget.textWidget().isWidgetVisible(widgets.textTwoId); + + await widget.tab().clickTabByLabel(tab.tabWithFields); + await widget.textWidget().isWidgetVisible(widgets.textOneId); + await widget.textWidget().setValue(widgets.textOneId, value.notDisplayTab); + await widget.tab().checkTabIsNotDisplayedByLabel(tab.tabFieldValue); + await widget.textWidget().isWidgetNotVisible(widgets.textTwoId); + }); + + it('[C315148] Should be able to see tab when visibility condition refers to a variable with specific value', async () => { + await formCloudDemoPage.setConfigToEditor(tabVarValueVisibilityJson); + await widget.tab().checkTabIsDisplayedByLabel(tab.tabVarValue); + await widget.textWidget().isWidgetVisible(widgets.textTwoId); + + const visibleTab = tabVarValueVisibilityJson; + visibleTab.formRepresentation.formDefinition.variables[0].value = value.notDisplayTab; + await formCloudDemoPage.setConfigToEditor(visibleTab); + + await widget.tab().checkTabIsNotDisplayedByLabel(tab.tabVarValue); + await widget.textWidget().isWidgetNotVisible(widgets.textTwoId); + }); + + it('[C315149] Should be able to see tab when visibility condition refers to a form variable and a field', async () => { + await formCloudDemoPage.setConfigToEditor(tabVarFieldVisibilityJson); + await widget.tab().checkTabIsDisplayedByLabel(tab.tabWithFields); + await widget.tab().checkTabIsNotDisplayedByLabel(tab.tabVarField); + await widget.textWidget().isWidgetVisible(widgets.textOneId); + await widget.textWidget().isWidgetNotVisible(widgets.textTwoId); + await widget.textWidget().setValue(widgets.textOneId, value.displayTab); + await widget.tab().checkTabIsDisplayedByLabel(tab.tabWithFields); + await widget.tab().checkTabIsDisplayedByLabel(tab.tabVarField); + + await widget.tab().clickTabByLabel(tab.tabVarField); + await widget.textWidget().isWidgetVisible(widgets.textTwoId); + + await widget.tab().clickTabByLabel(tab.tabWithFields); + await widget.textWidget().isWidgetVisible(widgets.textOneId); + await widget.textWidget().setValue(widgets.textOneId, value.notDisplayTab); + await widget.tab().checkTabIsNotDisplayedByLabel(tab.tabVarField); + await widget.textWidget().isWidgetNotVisible(widgets.textTwoId); + }); + + it('[C315150] Should be able to see tab when visibility condition refers to a field and another field', async () => { + await formCloudDemoPage.setConfigToEditor(tabFieldFieldVisibilityJson); + await widget.tab().checkTabIsDisplayedByLabel(tab.tabWithFields); + await widget.tab().checkTabIsDisplayedByLabel(tab.tabFieldField); + + await widget.tab().clickTabByLabel(tab.tabWithFields); + await widget.textWidget().isWidgetVisible(widgets.textOneId); + await widget.textWidget().isWidgetVisible(widgets.textThreeId); + await widget.textWidget().isWidgetNotVisible(widgets.textTwoId); + + await widget.textWidget().setValue(widgets.textOneId, value.displayTab); + await widget.tab().checkTabIsNotDisplayedByLabel(tab.tabFieldField); + + await widget.textWidget().setValue(widgets.textThreeId, value.displayTab); + await widget.tab().checkTabIsDisplayedByLabel(tab.tabFieldField); + + await widget.textWidget().setValue(widgets.textOneId, value.notDisplayTab); + await widget.tab().checkTabIsNotDisplayedByLabel(tab.tabFieldField); + }); + + it('[C315151] Should be able to see tab when visibility condition refers to a field and form variable', async () => { + await formCloudDemoPage.setConfigToEditor(tabFieldVarVisibilityJson); + await widget.tab().checkTabIsDisplayedByLabel(tab.tabWithFields); + await widget.tab().checkTabIsNotDisplayedByLabel(tab.tabVarField); + await widget.textWidget().isWidgetVisible(widgets.textOneId); + await widget.textWidget().isWidgetNotVisible(widgets.textTwoId); + await widget.textWidget().setValue(widgets.textOneId, value.displayTab); + await widget.tab().checkTabIsDisplayedByLabel(tab.tabWithFields); + await widget.tab().checkTabIsDisplayedByLabel(tab.tabVarField); + + await widget.tab().clickTabByLabel(tab.tabVarField); + await widget.textWidget().isWidgetVisible(widgets.textTwoId); + + await widget.tab().clickTabByLabel(tab.tabWithFields); + await widget.textWidget().isWidgetVisible(widgets.textOneId); + await widget.textWidget().setValue(widgets.textOneId, value.notDisplayTab); + await widget.tab().checkTabIsNotDisplayedByLabel(tab.tabVarField); + await widget.textWidget().isWidgetNotVisible(widgets.textTwoId); + }); + + it('[C315152] Should be able to see tab when visibility condition refers to form variable and another form variable', async () => { + await formCloudDemoPage.setConfigToEditor(tabVarVarVisibilityJson); + await widget.tab().checkTabIsDisplayedByLabel(tab.tabVarVar); + await widget.textWidget().isWidgetVisible(widgets.textOneId); + + const visibleTab = tabVarVarVisibilityJson; + visibleTab.formRepresentation.formDefinition.variables[0].value = value.notDisplayTab; + await formCloudDemoPage.setConfigToEditor(visibleTab); + await widget.tab().checkTabIsNotDisplayedByLabel(tab.tabVarVar); + await widget.textWidget().isWidgetNotVisible(widgets.textOneId); + + visibleTab.formRepresentation.formDefinition.variables[1].value = value.notDisplayTab; + await formCloudDemoPage.setConfigToEditor(visibleTab); + await widget.tab().checkTabIsDisplayedByLabel(tab.tabVarVar); + await widget.textWidget().isWidgetVisible(widgets.textOneId); + + visibleTab.formRepresentation.formDefinition.variables[0].value = value.displayTab; + await formCloudDemoPage.setConfigToEditor(visibleTab); + await widget.tab().checkTabIsNotDisplayedByLabel(tab.tabVarVar); + await widget.textWidget().isWidgetNotVisible(widgets.textOneId); + }); + + it('[C315153] Should be able to see tab when has multiple visibility conditions and next condition operators', async () => { + await formCloudDemoPage.setConfigToEditor(tabNextOperatorsVisibilityJson); + await widget.tab().checkTabIsDisplayedByLabel(tab.tabWithFields); + await widget.tab().checkTabIsNotDisplayedByLabel(tab.tabNextOperators); + + await widget.tab().clickTabByLabel(tab.tabWithFields); + await widget.textWidget().isWidgetVisible(widgets.textOneId); + await widget.textWidget().isWidgetVisible(widgets.textThreeId); + await widget.textWidget().isWidgetNotVisible(widgets.textTwoId); + + await widget.textWidget().setValue(widgets.textOneId, value.displayTab); + await widget.tab().checkTabIsDisplayedByLabel(tab.tabNextOperators); + + await widget.tab().clickTabByLabel(tab.tabWithFields); + await widget.textWidget().setValue(widgets.textOneId, value.notDisplayTab); + await widget.tab().checkTabIsNotDisplayedByLabel(tab.tabNextOperators); + + await widget.textWidget().setValue(widgets.textThreeId, value.displayTab); + await widget.tab().checkTabIsNotDisplayedByLabel(tab.tabNextOperators); + + await widget.textWidget().setValue(widgets.textOneId, value.displayTab); + await widget.tab().checkTabIsNotDisplayedByLabel(tab.tabNextOperators); + + await widget.textWidget().setValue(widgets.textThreeId, value.notDisplayTab); + await widget.tab().checkTabIsDisplayedByLabel(tab.tabNextOperators); + }); + +}); diff --git a/e2e/resources/forms/tab-visibility-conditions.ts b/e2e/resources/forms/tab-visibility-conditions.ts new file mode 100644 index 0000000000..dcfd1527a9 --- /dev/null +++ b/e2e/resources/forms/tab-visibility-conditions.ts @@ -0,0 +1,673 @@ +/*! + * @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 tabFieldValueVisibilityJson = { + formRepresentation: { + id: 'form-3aff57d3-62af-4adf-9b14-1d8f44a28077', + name: 'tabvisibility', + description: '', + version: 0, + standAlone: true, + formDefinition: { + tabs: [ + { + id: '71da814d-5580-4f1f-972a-8089253aeded', + title: 'tabBasicFieldValue', + visibilityCondition: { + leftType: 'field', + leftValue: 'TextOne', + operator: '==', + rightValue: 'showTab', + rightType: 'value', + nextConditionOperator: '', + nextCondition: null + } + }, + { + id: '442eea0b-65f9-484e-b37f-f5a91d5e1f21', + title: 'tabWithFields', + visibilityCondition: null + } + ], + fields: [ + { + id: 'dcde7e13-2444-48bc-ab30-32902cea549e', + name: 'Label', + type: 'container', + tab: '71da814d-5580-4f1f-972a-8089253aeded', + numberOfColumns: 2, + fields: { + 1: [ + { + 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 + } + } + ], + 2: [] + } + }, + { + id: 'df452297-d0e8-4406-b9d3-10842033549d', + name: 'Label', + type: 'container', + tab: '442eea0b-65f9-484e-b37f-f5a91d5e1f21', + 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 + } + } + ], + 2: [] + } + } + ], + outcomes: [], + metadata: {}, + variables: [] + } + } +}; + +export const tabVarValueVisibilityJson = { + formRepresentation: { + id: 'form-3aff57d3-62af-4adf-9b14-1d8f44a28077', + name: 'tabvisibility', + description: '', + version: 0, + standAlone: true, + formDefinition: { + tabs: [ + { + id: '71da814d-5580-4f1f-972a-8089253aeded', + title: 'tabBasicVarValue', + visibilityCondition: { + leftType: 'variable', + leftValue: 'stringVar', + operator: '==', + rightValue: 'showTab', + rightType: 'value', + nextConditionOperator: '' + } + } + ], + fields: [ + { + id: 'dcde7e13-2444-48bc-ab30-32902cea549e', + name: 'Label', + type: 'container', + tab: '71da814d-5580-4f1f-972a-8089253aeded', + numberOfColumns: 2, + fields: { + 1: [ + { + 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 + } + } + ], + 2: [] + } + } + ], + outcomes: [], + metadata: {}, + variables: [ + { + id: "803269e6-a568-40e2-aec3-75ad2f411688", + name: "stringVar", + type: "string", + value: "showTab" + } + ] + } + } +}; + +export const tabVarFieldVisibilityJson = { + formRepresentation: { + id: 'form-3aff57d3-62af-4adf-9b14-1d8f44a28077', + name: 'tabvisibility', + description: '', + version: 0, + standAlone: true, + formDefinition: { + tabs: [ + { + id: '71da814d-5580-4f1f-972a-8089253aeded', + title: 'tabBasicVarField', + visibilityCondition: { + leftType: 'variable', + leftValue: 'stringVar', + operator: '==', + rightValue: 'TextOne', + rightType: 'field', + nextConditionOperator: '' + } + }, + { + id: '0e538a28-f8d6-4cb8-ae93-dbfb2efdf3b1', + title: 'tabWithFields', + visibilityCondition: null + } + ], + fields: [ + { + id: 'dcde7e13-2444-48bc-ab30-32902cea549e', + name: 'Label', + type: 'container', + tab: '71da814d-5580-4f1f-972a-8089253aeded', + numberOfColumns: 2, + fields: { + 1: [ + { + 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 + } + } + ], + 2: [] + } + }, + { + id: '1308e433-08ce-4448-a62a-0accc1187d15', + name: 'Label', + type: 'container', + tab: '0e538a28-f8d6-4cb8-ae93-dbfb2efdf3b1', + 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 + } + } + ], + 2: [] + } + } + ], + outcomes: [], + metadata: {}, + variables: [ + { + id: "803269e6-a568-40e2-aec3-75ad2f411688", + name: "stringVar", + type: "string", + value: "showTab" + } + ] + } + } +}; + +export const tabFieldFieldVisibilityJson = { + formRepresentation: { + id: 'form-3aff57d3-62af-4adf-9b14-1d8f44a28077', + name: 'tabvisibility', + description: '', + version: 0, + standAlone: true, + formDefinition: { + tabs: [ + { + id: '71da814d-5580-4f1f-972a-8089253aeded', + title: 'tabBasicFieldField', + visibilityCondition: { + leftType: 'field', + leftValue: 'TextThree', + operator: '==', + rightValue: 'TextOne', + rightType: 'field', + nextConditionOperator: '' + } + }, + { + id: '442eea0b-65f9-484e-b37f-f5a91d5e1f21', + title: 'tabWithFields', + visibilityCondition: null + } + ], + fields: [ + { + id: 'dcde7e13-2444-48bc-ab30-32902cea549e', + name: 'Label', + type: 'container', + tab: '71da814d-5580-4f1f-972a-8089253aeded', + numberOfColumns: 2, + fields: { + 1: [ + { + 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 + } + } + ], + 2: [] + } + }, + { + id: 'df452297-d0e8-4406-b9d3-10842033549d', + name: 'Label', + type: 'container', + tab: '442eea0b-65f9-484e-b37f-f5a91d5e1f21', + 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 + } + } + ], + 2: [ + { + id: 'TextThree', + name: 'TextThree', + type: 'text', + required: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 + } + } + ] + } + } + ], + outcomes: [], + metadata: {}, + variables: [] + } + } +}; + +export const tabFieldVarVisibilityJson = { + formRepresentation: { + id: 'form-3aff57d3-62af-4adf-9b14-1d8f44a28077', + name: 'tabvisibility', + description: '', + version: 0, + standAlone: true, + formDefinition: { + tabs: [ + { + id: '71da814d-5580-4f1f-972a-8089253aeded', + title: 'tabBasicVarField', + visibilityCondition: { + leftType: 'field', + leftValue: 'TextOne', + operator: '==', + rightValue: 'stringVar', + rightType: 'variable', + nextConditionOperator: '' + } + }, + { + id: '0e538a28-f8d6-4cb8-ae93-dbfb2efdf3b1', + title: 'tabWithFields', + visibilityCondition: null + } + ], + fields: [ + { + id: 'dcde7e13-2444-48bc-ab30-32902cea549e', + name: 'Label', + type: 'container', + tab: '71da814d-5580-4f1f-972a-8089253aeded', + numberOfColumns: 2, + fields: { + 1: [ + { + 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 + } + } + ], + 2: [] + } + }, + { + id: '1308e433-08ce-4448-a62a-0accc1187d15', + name: 'Label', + type: 'container', + tab: '0e538a28-f8d6-4cb8-ae93-dbfb2efdf3b1', + 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 + } + } + ], + 2: [] + } + } + ], + outcomes: [], + metadata: {}, + variables: [ + { + id: "803269e6-a568-40e2-aec3-75ad2f411688", + name: "stringVar", + type: "string", + value: "showTab" + } + ] + } + } +}; + +export const tabVarVarVisibilityJson = { + formRepresentation: { + id: 'form-3aff57d3-62af-4adf-9b14-1d8f44a28077', + name: 'tabvisibility', + description: '', + version: 0, + standAlone: true, + formDefinition: { + tabs: [ + { + id: 'ef512cb3-0c41-4d12-84ef-a7ef8f0b111a', + title: 'tabBasicVarVar', + visibilityCondition: { + leftType: 'variable', + leftValue: 'showTabOne', + operator: '==', + rightValue: 'showTabTwo', + rightType: 'variable', + nextConditionOperator: '' + } + } + ], + fields: [ + { + id: '6eeb9e54-e51d-44f3-9557-503308f07361', + name: 'Label', + type: 'container', + tab: 'ef512cb3-0c41-4d12-84ef-a7ef8f0b111a', + 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 + } + } + ], + 2: [] + } + } + ], + outcomes: [], + metadata: {}, + variables: [ + { + id: "b116df99-f6b5-45f8-b48c-15b74f7f1c92", + name: "showTabOne", + type: "string", + value: "showTab" + }, + { + id: "6e3e88ab-848c-4f48-8326-a404d1427f60", + name: "showTabTwo", + type: "string", + value: "showTab" + } + ] + } + } +}; + +export const tabNextOperatorsVisibilityJson = { + formRepresentation: { + id: 'form-3aff57d3-62af-4adf-9b14-1d8f44a28077', + name: 'tabvisibility', + description: '', + version: 0, + standAlone: true, + formDefinition: { + tabs: [ + { + id: '71da814d-5580-4f1f-972a-8089253aeded', + title: 'tabNextOperators', + visibilityCondition: { + leftType: 'field', + leftValue: 'TextOne', + operator: '==', + rightValue: 'showTab', + rightType: 'value', + nextConditionOperator: 'and', + nextCondition: { + leftType: 'field', + leftValue: 'TextThree', + operator: '!=', + rightValue: 'showTab', + rightType: 'value', + nextConditionOperator: '', + nextCondition: null + } + } + }, + { + id: '442eea0b-65f9-484e-b37f-f5a91d5e1f21', + title: 'tabWithFields', + visibilityCondition: null + } + ], + fields: [ + { + id: 'dcde7e13-2444-48bc-ab30-32902cea549e', + name: 'Label', + type: 'container', + tab: '71da814d-5580-4f1f-972a-8089253aeded', + numberOfColumns: 2, + fields: { + 1: [ + { + 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 + } + } + ], + 2: [] + } + }, + { + id: 'df452297-d0e8-4406-b9d3-10842033549d', + name: 'Label', + type: 'container', + tab: '442eea0b-65f9-484e-b37f-f5a91d5e1f21', + 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 + } + } + ], + 2: [ + { + id: 'TextThree', + name: 'TextThree', + type: 'text', + required: false, + colspan: 1, + placeholder: null, + minLength: 0, + maxLength: 0, + regexPattern: null, + visibilityCondition: null, + params: { + existingColspan: 1, + maxColspan: 2 + } + } + ] + } + } + ], + outcomes: [], + metadata: {}, + variables: [] + } + } +}; diff --git a/lib/testing/src/lib/core/pages/form/formFields.ts b/lib/testing/src/lib/core/pages/form/formFields.ts index ef66e5a17c..43126953b0 100644 --- a/lib/testing/src/lib/core/pages/form/formFields.ts +++ b/lib/testing/src/lib/core/pages/form/formFields.ts @@ -44,6 +44,11 @@ export class FormFields { await BrowserVisibility.waitUntilElementIsVisible(fieldElement); } + async checkWidgetIsClickable(fieldId): Promise { + const fieldElement = element.all(by.css(`adf-form-field div[id='field-${fieldId}-container']`)).first(); + await BrowserVisibility.waitUntilElementIsClickable(fieldElement); + } + async checkWidgetIsHidden(fieldId): Promise { const hiddenElement = element(by.css(`adf-form-field div[id='field-${fieldId}-container'][hidden]`)); await BrowserVisibility.waitUntilElementIsNotVisible(hiddenElement); diff --git a/lib/testing/src/lib/core/pages/form/widgets/tab.ts b/lib/testing/src/lib/core/pages/form/widgets/tab.ts new file mode 100644 index 0000000000..bbeaaa1284 --- /dev/null +++ b/lib/testing/src/lib/core/pages/form/widgets/tab.ts @@ -0,0 +1,36 @@ +/*! + * @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 { by, element, browser } from 'protractor'; +import { BrowserActions, BrowserVisibility } from '../../../utils/public-api'; + +export class Tab { + + async clickTabByLabel(tabLabel): Promise { + const user = element(by.cssContainingText('.mat-tab-label-content', tabLabel)); + await BrowserActions.click(user); + await browser.sleep(300); + } + + async checkTabIsDisplayedByLabel(tabLabel): Promise { + await BrowserVisibility.waitUntilElementIsVisible(element(by.cssContainingText('.mat-tab-label-content', tabLabel))); + } + + async checkTabIsNotDisplayedByLabel(tabLabel): Promise { + await BrowserVisibility.waitUntilElementIsNotVisible(element(by.cssContainingText('.mat-tab-label-content', tabLabel))); + } +} diff --git a/lib/testing/src/lib/core/pages/form/widgets/textWidget.ts b/lib/testing/src/lib/core/pages/form/widgets/textWidget.ts index 339fea4573..f60387a09e 100644 --- a/lib/testing/src/lib/core/pages/form/widgets/textWidget.ts +++ b/lib/testing/src/lib/core/pages/form/widgets/textWidget.ts @@ -48,6 +48,10 @@ export class TextWidget { await this.formFields.checkWidgetIsVisible(fieldId); } + async isWidgetClickable(fieldId): Promise { + await this.formFields.checkWidgetIsClickable(fieldId); + } + async isWidgetNotVisible(fieldId): Promise { await this.formFields.checkWidgetIsHidden(fieldId); } diff --git a/lib/testing/src/lib/core/pages/form/widgets/widget.ts b/lib/testing/src/lib/core/pages/form/widgets/widget.ts index 3b08de24bb..60fe01534d 100644 --- a/lib/testing/src/lib/core/pages/form/widgets/widget.ts +++ b/lib/testing/src/lib/core/pages/form/widgets/widget.ts @@ -32,6 +32,7 @@ import { NumberWidget } from './numberWidget'; import { AmountWidget } from './amountWidget'; import { ContainerWidget } from './containerWidget'; import { PeopleWidget } from './peopleWidget'; +import { Tab } from './tab'; import { DocumentWidget } from './documentWidget'; import { AttachFileWidgetCloud } from './attachFileWidgetCloud'; @@ -112,4 +113,8 @@ export class Widget { peopleWidget(): PeopleWidget { return new PeopleWidget(); } + + tab(): Tab { + return new Tab(); + } }