diff --git a/e2e/process-services-cloud/form-field/date-widget.e2e.ts b/e2e/process-services-cloud/form-field/date-widget.e2e.ts index a3f128dac7..be0fa9d9bb 100644 --- a/e2e/process-services-cloud/form-field/date-widget.e2e.ts +++ b/e2e/process-services-cloud/form-field/date-widget.e2e.ts @@ -17,8 +17,7 @@ import { LoginSSOPage, - Widget, - BrowserActions, FormPage + BrowserActions, FormPage, ProcessCloudWidgetPage } from '@alfresco/adf-testing'; import { browser } from 'protractor'; import { customDateFormAPS2 } from '../../resources/forms/custom-date-form'; @@ -26,7 +25,7 @@ import { FormCloudDemoPage } from '../../pages/adf/demo-shell/process-services-c describe('Form Field Component - Dropdown Widget', () => { const loginSSOPage = new LoginSSOPage(); - const widget = new Widget(); + const widget = new ProcessCloudWidgetPage(); const dateWidget = widget.dateWidget(); const formDemoPage = new FormCloudDemoPage(); diff --git a/e2e/process-services-cloud/form-field/dropdown-widget.e2e.ts b/e2e/process-services-cloud/form-field/dropdown-widget.e2e.ts index aae3336370..4b07a89148 100644 --- a/e2e/process-services-cloud/form-field/dropdown-widget.e2e.ts +++ b/e2e/process-services-cloud/form-field/dropdown-widget.e2e.ts @@ -17,9 +17,9 @@ import { ApiService, AppListCloudPage, GroupIdentityService, IdentityService, - LoginSSOPage, NotificationHistoryPage, ProcessDefinitionsService, + LoginSSOPage, NotificationHistoryPage, ProcessCloudWidgetPage, ProcessDefinitionsService, ProcessInstancesService, QueryService, TaskFormCloudComponent, TaskHeaderCloudPage, - TasksService, Widget + TasksService } from '@alfresco/adf-testing'; import { browser } from 'protractor'; import { TasksCloudDemoPage } from '../../pages/adf/demo-shell/process-services/tasksCloudDemoPage'; @@ -33,7 +33,7 @@ describe('Form Field Component - Dropdown Widget', () => { const taskFormCloudComponent = new TaskFormCloudComponent(); const notificationHistoryPage = new NotificationHistoryPage(); const taskHeaderCloudPage = new TaskHeaderCloudPage(); - const widget = new Widget(); + const widget = new ProcessCloudWidgetPage(); const dropdown = widget.dropdown(); const apiService = new ApiService( browser.params.config.oauth2.clientId, diff --git a/e2e/process-services-cloud/form-field/people-group-of-people.e2e.ts b/e2e/process-services-cloud/form-field/people-group-of-people.e2e.ts new file mode 100644 index 0000000000..dca012a9c3 --- /dev/null +++ b/e2e/process-services-cloud/form-field/people-group-of-people.e2e.ts @@ -0,0 +1,157 @@ +/*! + * @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 { + FormPage, + LoginSSOPage, + ProcessCloudWidgetPage +} from '@alfresco/adf-testing'; +import { browser } from 'protractor'; +import { FormCloudDemoPage } from '../../pages/adf/demo-shell/process-services-cloud/cloudFormDemoPage'; +import { peopleJson, peopleMultipleModeJson, peopleRequiredJson, groupSingleJson, groupMultipleJson, groupRequiredJson } from '../../resources/forms/people-group-formwidget-json'; +import { NavigationBarPage } from '../../pages/adf/navigationBarPage'; +import { AlfrescoApiCompatibility as AlfrescoApi } from '@alfresco/js-api'; + +describe('People and Group of people Widgets', () => { + const loginSSOPage = new LoginSSOPage(); + const navigationBarPage = new NavigationBarPage(); + const formCloudDemoPage = new FormCloudDemoPage(); + const widget = new ProcessCloudWidgetPage(); + const peopleCloudWidget = widget.peopleCloudWidget(); + const groupCloudWidget = widget.groupCloudWidget(); + const formPage = new FormPage(); + + const widgets = { + peopleCloudWidgetSingleModeId: 'PeopleSingleMode', + peopleCloudWidgetMultipleModeId: 'PeopleMultipleMode', + peopleCloudWidgetReadOnlyId: 'PeopleReadOnly', + peopleCloudWidgetRequiredId: 'PeopleRequired', + groupCloudWidgetSingleModeId: 'GroupSingleMode', + groupCloudWidgetMultipleModeId: 'GroupMultipleMode', + groupCloudWidgetReadOnlyId: 'GroupReadOnly', + groupCloudWidgetRequiredId: 'GroupRequired' + }; + + const peopleValueString = { + peopleCloudWidgetSingleModeField: 'PeopleSingleMode', + peopleCloudWidgetMultipleModeField: 'PeopleMultipleMode', + peopleCloudWidgetReadOnlyField: 'PeopleReadOnly', + peopleCloudWidgetRequiredField: 'PeopleRequired' + }; + + const groupValueString = { + groupCloudWidgetSingleModeField: 'GroupSingleMode', + groupCloudWidgetMultipleModeField: 'GroupMultipleMode', + groupCloudWidgetReadOnlyField: 'GroupReadOnly', + groupCloudWidgetRequiredField: 'GroupRequired' + }; + + beforeAll(async () => { + this.alfrescoJsApi = new AlfrescoApi({ + provider: 'BPM', + hostBpm: browser.params.testConfig.adf_aps.host + }); + + await loginSSOPage.loginSSOIdentityService(browser.params.testConfig.hrUser.email, browser.params.testConfig.hrUser.password); + + await navigationBarPage.navigateToFormCloudPage(); + }); + + it('[C325002] Should be able to add a user in People field when Single mode is chosen', async () => { + await formCloudDemoPage.setConfigToEditor(peopleJson); + await peopleCloudWidget.clickPeopleInput(widgets.peopleCloudWidgetSingleModeId); + await peopleCloudWidget.isPeopleWidgetVisible(peopleValueString.peopleCloudWidgetSingleModeField); + let peopleSingleMode = await peopleCloudWidget.getFieldValue(widgets.peopleCloudWidgetSingleModeId); + await expect(peopleSingleMode).toEqual(''); + + await peopleCloudWidget.searchAssigneeAndSelect('HR User'); + peopleSingleMode = await peopleCloudWidget.getAssigneeFieldContent(); + await expect(peopleSingleMode).toEqual('HR User'); + }); + + it('[C325122] Should be able to add multiple users in People field when Multiple mode is chosen', async () => { + await formCloudDemoPage.setConfigToEditor(peopleMultipleModeJson); + await peopleCloudWidget.clickPeopleInput(widgets.peopleCloudWidgetMultipleModeId); + await peopleCloudWidget.isPeopleWidgetVisible(peopleValueString.peopleCloudWidgetMultipleModeField); + const peopleMultipleMode = await peopleCloudWidget.getFieldValue(widgets.peopleCloudWidgetMultipleModeId); + await expect(peopleMultipleMode).toEqual(''); + + await peopleCloudWidget.searchAssigneeAndSelect('HR User'); + await peopleCloudWidget.searchAssigneeAndSelect('Sales User'); + await peopleCloudWidget.checkSelectedPeople('HR User'); + await peopleCloudWidget.checkSelectedPeople('Sales User'); + }); + + it('[C325004] Should be able to save only for valid input in the People field if the Required option is selected ', async () => { + await formCloudDemoPage.setConfigToEditor(peopleRequiredJson); + await peopleCloudWidget.isPeopleWidgetVisible(peopleValueString.peopleCloudWidgetRequiredField); + await expect(await formPage.isSaveButtonDisabled()).toBe(true); + await expect(await formPage.isValidationIconRed()).toBe(true); + + let requiredPeople = await peopleCloudWidget.getFieldValue(widgets.peopleCloudWidgetRequiredId); + await expect(requiredPeople).toEqual(''); + await peopleCloudWidget.searchAssigneeAndSelect('HR User'); + requiredPeople = await peopleCloudWidget.getAssigneeFieldContent(); + + await expect(requiredPeople).toEqual('HR User'); + await expect(await formPage.isSaveButtonDisabled()).toBe(false); + await expect(await formPage.isValidationIconBlue()).toBe(true); + }); + + it('[C325003] Should be able to add a user in Group of people field when Single mode is chosen', async () => { + await formCloudDemoPage.setConfigToEditor(groupSingleJson); + await groupCloudWidget.isGroupWidgetVisible(groupValueString.groupCloudWidgetSingleModeField); + let groupSingleMode = await groupCloudWidget.getGroupsFieldContent(); + await expect(groupSingleMode).toEqual(''); + + await groupCloudWidget.searchGroups('hr'); + await groupCloudWidget.selectGroupFromList('hr'); + groupSingleMode = await groupCloudWidget.getGroupsFieldContent(); + await expect(groupSingleMode).toEqual('hr'); + }); + + it('[C325123] Should be able to add multiple users in Group of people field when Multiple mode is chosen', async () => { + await formCloudDemoPage.setConfigToEditor(groupMultipleJson); + await groupCloudWidget.isGroupWidgetVisible(groupValueString.groupCloudWidgetMultipleModeField); + const groupSingleMode = await groupCloudWidget.getGroupsFieldContent(); + await expect(groupSingleMode).toEqual(''); + + await groupCloudWidget.searchGroups('hr'); + await groupCloudWidget.selectGroupFromList('hr'); + await groupCloudWidget.searchGroups('sales'); + await groupCloudWidget.selectGroupFromList('sales'); + await groupCloudWidget.checkSelectedGroup('hr'); + await groupCloudWidget.checkSelectedGroup('sales'); + }); + + it('[C325005] Should be able to save only for valid input in the Group of people field if the Required option is selected', async () => { + await formCloudDemoPage.setConfigToEditor(groupRequiredJson); + await groupCloudWidget.isGroupWidgetVisible(groupValueString.groupCloudWidgetRequiredField); + await expect(await formPage.isSaveButtonDisabled()).toBe(true); + await expect(await formPage.isValidationIconRed()).toBe(true); + + let groupRequired = await groupCloudWidget.getGroupsFieldContent(); + await expect(groupRequired).toEqual(''); + await groupCloudWidget.searchGroups('hr'); + await groupCloudWidget.selectGroupFromList('hr'); + groupRequired = await groupCloudWidget.getGroupsFieldContent(); + + await expect(groupRequired).toEqual('hr'); + await expect(await formPage.isSaveButtonDisabled()).toBe(false); + await expect(await formPage.isValidationIconBlue()).toBe(true); + }); +}); 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 index 15ba47e3df..c09333dc70 100644 --- a/e2e/process-services-cloud/form-field/visibility-condition-tabs.e2e.ts +++ b/e2e/process-services-cloud/form-field/visibility-condition-tabs.e2e.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { LoginSSOPage, Widget } from '@alfresco/adf-testing'; +import { LoginSSOPage, ProcessCloudWidgetPage } from '@alfresco/adf-testing'; import { browser } from 'protractor'; import { AlfrescoApiCompatibility as AlfrescoApi } from '@alfresco/js-api'; @@ -31,7 +31,7 @@ describe('Visibility conditions on tabs - cloud', () => { const navigationBarPage = new NavigationBarPage(); const formCloudDemoPage = new FormCloudDemoPage(); - const widget = new Widget(); + const widget = new ProcessCloudWidgetPage(); const widgets = { textOneId: 'TextOne', diff --git a/e2e/process-services-cloud/form-field/visibility-condition.e2e.ts b/e2e/process-services-cloud/form-field/visibility-condition.e2e.ts index c1c87e4284..9aaf18540f 100644 --- a/e2e/process-services-cloud/form-field/visibility-condition.e2e.ts +++ b/e2e/process-services-cloud/form-field/visibility-condition.e2e.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { LoginSSOPage, Widget } from '@alfresco/adf-testing'; +import { LoginSSOPage, ProcessCloudWidgetPage } from '@alfresco/adf-testing'; import { browser } from 'protractor'; import { AlfrescoApiCompatibility as AlfrescoApi } from '@alfresco/js-api'; @@ -31,7 +31,7 @@ describe('Visibility conditions - cloud', () => { const navigationBarPage = new NavigationBarPage(); const formCloudDemoPage = new FormCloudDemoPage(); - const widget = new Widget(); + const widget = new ProcessCloudWidgetPage(); let visibleCheckbox; diff --git a/e2e/process-services-cloud/start-task-form-cloud.e2e.ts b/e2e/process-services-cloud/start-task-form-cloud.e2e.ts index 45cda4e953..482543118c 100644 --- a/e2e/process-services-cloud/start-task-form-cloud.e2e.ts +++ b/e2e/process-services-cloud/start-task-form-cloud.e2e.ts @@ -28,7 +28,6 @@ import { SettingsPage, GroupIdentityService, TaskFormCloudComponent, - Widget, LocalStorageUtil, StartProcessCloudPage, TaskHeaderCloudPage, @@ -38,7 +37,7 @@ import { ContentNodeSelectorDialogPage, ProcessInstancesService, ProcessDefinitionsService, - FileBrowserUtil + FileBrowserUtil, ProcessCloudWidgetPage } from '@alfresco/adf-testing'; import { StartProcessCloudConfiguration } from './config/start-process-cloud.config'; import { ProcessCloudDemoPage } from '../pages/adf/demo-shell/process-services/processCloudDemoPage'; @@ -60,7 +59,7 @@ describe('Start Task Form', () => { const breadCrumbDropdownPage = new BreadCrumbDropdownPage(); const processDetailsCloudDemoPage = new ProcessDetailsCloudDemoPage(); const settingsPage = new SettingsPage(); - const widget = new Widget(); + const widget = new ProcessCloudWidgetPage(); const startProcessPage = new StartProcessCloudPage(); const processCloudDemoPage = new ProcessCloudDemoPage(); const taskHeaderCloudPage = new TaskHeaderCloudPage(); diff --git a/e2e/process-services-cloud/task-form-cloud-component-tab.e2e.ts b/e2e/process-services-cloud/task-form-cloud-component-tab.e2e.ts index f4ba084ea0..ae5ed182af 100644 --- a/e2e/process-services-cloud/task-form-cloud-component-tab.e2e.ts +++ b/e2e/process-services-cloud/task-form-cloud-component-tab.e2e.ts @@ -26,7 +26,7 @@ import { ProcessInstancesService, TaskHeaderCloudPage, TaskFormCloudComponent, - Widget, IdentityService, GroupIdentityService + IdentityService, GroupIdentityService, ProcessCloudWidgetPage } from '@alfresco/adf-testing'; import { NavigationBarPage } from '../pages/adf/navigationBarPage'; import { TasksCloudDemoPage } from '../pages/adf/demo-shell/process-services/tasksCloudDemoPage'; @@ -40,7 +40,7 @@ describe('Task form cloud component', () => { const tasksCloudDemoPage = new TasksCloudDemoPage(); const taskHeaderCloudPage = new TaskHeaderCloudPage(); const taskFormCloudComponent = new TaskFormCloudComponent(); - const widget = new Widget(); + const widget = new ProcessCloudWidgetPage(); let processDefinitionService: ProcessDefinitionsService; let processInstancesService: ProcessInstancesService; diff --git a/e2e/process-services-cloud/task-form-cloud-component.e2e.ts b/e2e/process-services-cloud/task-form-cloud-component.e2e.ts index c4700a727a..bd6761ea22 100644 --- a/e2e/process-services-cloud/task-form-cloud-component.e2e.ts +++ b/e2e/process-services-cloud/task-form-cloud-component.e2e.ts @@ -26,7 +26,7 @@ import { ProcessInstancesService, TaskHeaderCloudPage, TaskFormCloudComponent, - Widget, QueryService + QueryService, ProcessCloudWidgetPage } from '@alfresco/adf-testing'; import { NavigationBarPage } from '../pages/adf/navigationBarPage'; import { TasksCloudDemoPage } from '../pages/adf/demo-shell/process-services/tasksCloudDemoPage'; @@ -40,7 +40,7 @@ describe('Task form cloud component', () => { const tasksCloudDemoPage = new TasksCloudDemoPage(); const taskHeaderCloudPage = new TaskHeaderCloudPage(); const taskFormCloudComponent = new TaskFormCloudComponent(); - const widget = new Widget(); + const widget = new ProcessCloudWidgetPage(); let processDefinitionService: ProcessDefinitionsService; let processInstancesService: ProcessInstancesService; diff --git a/e2e/resources/forms/people-group-formwidget-json.ts b/e2e/resources/forms/people-group-formwidget-json.ts new file mode 100644 index 0000000000..b579c74e09 --- /dev/null +++ b/e2e/resources/forms/people-group-formwidget-json.ts @@ -0,0 +1,316 @@ +/*! + * @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 peopleJson = { + "formRepresentation": { + "id": "form-d74a4136-af83-4333-ac37-a6a74ac7aa84", + "name": "singlepeople", + "description": "", + "version": 0, + "standAlone": true, + "formDefinition": { + "tabs": [], + "fields": [ + { + "id": "7c9ea025-4ae6-4a5a-9184-da8f7d5c5543", + "name": "Label", + "type": "container", + "tab": null, + "numberOfColumns": 2, + "fields": { + "1": [ + { + "id": "PeopleSingleMode", + "name": "People", + "type": "people", + "readOnly": false, + "required": false, + "colspan": 1, + "optionType": "single", + "visibilityCondition": null, + "params": { + "existingColspan": 1, + "maxColspan": 2 + } + } + ], + "2": [] + } + } + ], + "outcomes": [], + "metadata": {}, + "variables": [] + } + } +}; + +export const peopleMultipleModeJson = { + "formRepresentation": { + "id": "form-0fec4293-a33a-4408-923c-ba2d0645459c", + "name": "people", + "description": "", + "version": 0, + "standAlone": true, + "formDefinition": { + "tabs": [], + "fields": [ + { + "id": "44e485d4-c286-425a-b488-3fda1707d319", + "name": "Label", + "type": "container", + "tab": null, + "numberOfColumns": 2, + "fields": { + "1": [ + { + "id": "PeopleMultipleMode", + "name": "People", + "type": "people", + "readOnly": false, + "required": false, + "colspan": 1, + "optionType": "multiple", + "visibilityCondition": null, + "params": { + "existingColspan": 1, + "maxColspan": 2 + } + } + ], + "2": [] + } + } + ], + "outcomes": [], + "metadata": {}, + "variables": [ + { + "id": "d6060d6b-1cb0-45dc-a18b-4d7898a9a5ad", + "name": "people", + "type": "string", + "value": "user1" + } + ] + } + } +}; + +export const peopleRequiredJson = { + "formRepresentation": { + "id": "form-0fec4293-a33a-4408-923c-ba2d0645459c", + "name": "people", + "description": "", + "version": 0, + "standAlone": true, + "formDefinition": { + "tabs": [], + "fields": [ + { + "id": "44e485d4-c286-425a-b488-3fda1707d319", + "name": "Label", + "type": "container", + "tab": null, + "numberOfColumns": 2, + "fields": { + "1": [ + { + "id": "PeopleRequired", + "name": "People", + "type": "people", + "readOnly": false, + "required": true, + "colspan": 1, + "optionType": "single", + "visibilityCondition": null, + "params": { + "existingColspan": 1, + "maxColspan": 2 + } + } + ], + "2": [] + } + } + ], + "outcomes": [], + "metadata": {}, + "variables": [ + { + "id": "d6060d6b-1cb0-45dc-a18b-4d7898a9a5ad", + "name": "people", + "type": "string", + "value": "user1" + } + ] + } + } +}; + +export const groupSingleJson = { + "formRepresentation": { + "id": "form-0fec4293-a33a-4408-923c-ba2d0645459c", + "name": "people", + "description": "", + "version": 0, + "standAlone": true, + "formDefinition": { + "tabs": [], + "fields": [ + { + "id": "abccf2c9-b526-45c7-abd4-b969bdf8ce15", + "name": "Label", + "type": "container", + "tab": null, + "numberOfColumns": 2, + "fields": { + "1": [ + { + "id": "GroupSingleMode", + "name": "Group of people", + "type": "functional-group", + "readOnly": false, + "required": false, + "colspan": 1, + "optionType": "single", + "visibilityCondition": null, + "params": { + "existingColspan": 1, + "maxColspan": 2 + } + } + ], + "2": [] + } + } + ], + "outcomes": [], + "metadata": {}, + "variables": [ + { + "id": "d6060d6b-1cb0-45dc-a18b-4d7898a9a5ad", + "name": "people", + "type": "string", + "value": "user1" + } + ] + } + } +}; + +export const groupMultipleJson = { + "formRepresentation": { + "id": "form-0fec4293-a33a-4408-923c-ba2d0645459c", + "name": "people", + "description": "", + "version": 0, + "standAlone": true, + "formDefinition": { + "tabs": [], + "fields": [ + { + "id": "abccf2c9-b526-45c7-abd4-b969bdf8ce15", + "name": "Label", + "type": "container", + "tab": null, + "numberOfColumns": 2, + "fields": { + "1": [ + { + "id": "GroupMultipleMode", + "name": "Group of people", + "type": "functional-group", + "readOnly": false, + "required": false, + "colspan": 1, + "optionType": "multiple", + "visibilityCondition": null, + "params": { + "existingColspan": 1, + "maxColspan": 2 + } + } + ], + "2": [] + } + } + ], + "outcomes": [], + "metadata": {}, + "variables": [ + { + "id": "d6060d6b-1cb0-45dc-a18b-4d7898a9a5ad", + "name": "people", + "type": "string", + "value": "user1" + } + ] + } + } +} + +export const groupRequiredJson = { + "formRepresentation": { + "id": "form-0fec4293-a33a-4408-923c-ba2d0645459c", + "name": "people", + "description": "", + "version": 0, + "standAlone": true, + "formDefinition": { + "tabs": [], + "fields": [ + { + "id": "abccf2c9-b526-45c7-abd4-b969bdf8ce15", + "name": "Label", + "type": "container", + "tab": null, + "numberOfColumns": 2, + "fields": { + "1": [ + { + "id": "GroupRequired", + "name": "Group of people", + "type": "functional-group", + "readOnly": false, + "required": true, + "colspan": 1, + "optionType": "single", + "visibilityCondition": null, + "params": { + "existingColspan": 1, + "maxColspan": 2 + } + } + ], + "2": [] + } + } + ], + "outcomes": [], + "metadata": {}, + "variables": [ + { + "id": "d6060d6b-1cb0-45dc-a18b-4d7898a9a5ad", + "name": "people", + "type": "string", + "value": "user1" + } + ] + } + } +} diff --git a/lib/testing/src/lib/core/pages/form/formPage.ts b/lib/testing/src/lib/core/pages/form/formPage.ts index b54890cde4..fa99ff467c 100644 --- a/lib/testing/src/lib/core/pages/form/formPage.ts +++ b/lib/testing/src/lib/core/pages/form/formPage.ts @@ -46,4 +46,34 @@ export class FormPage { await BrowserActions.click(this.saveButton); } + async isSaveButtonDisabled(): Promise { + const saveButtonDisabled = element(by.css('.adf-form-mat-card-actions [disabled]')); + try { + await saveButtonDisabled.isDisplayed(); + return true; + } catch { + return false; + } + } + + async isValidationIconBlue(): Promise { + const validationIcon = element(by.css('#adf-valid-form-icon')); + try { + await validationIcon.isDisplayed(); + return true; + } catch { + return false; + } + } + + async isValidationIconRed(): Promise { + const validationIcon = element(by.css('#adf-invalid-form-icon')); + try { + await validationIcon.isDisplayed(); + return true; + } catch { + return false; + } + } + } diff --git a/lib/testing/src/lib/process-services-cloud/pages/form/public-api.ts b/lib/testing/src/lib/process-services-cloud/pages/form/public-api.ts new file mode 100644 index 0000000000..6327b00ba9 --- /dev/null +++ b/lib/testing/src/lib/process-services-cloud/pages/form/public-api.ts @@ -0,0 +1,18 @@ +/*! + * @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. + */ + +export * from './widget/public-api'; diff --git a/lib/testing/src/lib/process-services-cloud/pages/form/widget/process-cloud-widget.page.ts b/lib/testing/src/lib/process-services-cloud/pages/form/widget/process-cloud-widget.page.ts new file mode 100644 index 0000000000..2699782bb9 --- /dev/null +++ b/lib/testing/src/lib/process-services-cloud/pages/form/widget/process-cloud-widget.page.ts @@ -0,0 +1,32 @@ +/*! + * @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 { Widget } from '../../../../core/pages/form/widgets/widget'; +import { PeopleCloudComponentPage } from '../../people-cloud-component.page'; +import { GroupCloudComponentPage } from '../../group-cloud-component.page'; + +export class ProcessCloudWidgetPage extends Widget { + + peopleCloudWidget(): PeopleCloudComponentPage { + return new PeopleCloudComponentPage(); + } + + groupCloudWidget(): GroupCloudComponentPage { + return new GroupCloudComponentPage(); + } + +} diff --git a/lib/testing/src/lib/process-services-cloud/pages/form/widget/public-api.ts b/lib/testing/src/lib/process-services-cloud/pages/form/widget/public-api.ts new file mode 100644 index 0000000000..308c7bf789 --- /dev/null +++ b/lib/testing/src/lib/process-services-cloud/pages/form/widget/public-api.ts @@ -0,0 +1,18 @@ +/*! + * @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. + */ + +export * from './process-cloud-widget.page'; diff --git a/lib/testing/src/lib/process-services-cloud/pages/group-cloud-component.page.ts b/lib/testing/src/lib/process-services-cloud/pages/group-cloud-component.page.ts index 96c7c7af4e..6ae4764a6d 100644 --- a/lib/testing/src/lib/process-services-cloud/pages/group-cloud-component.page.ts +++ b/lib/testing/src/lib/process-services-cloud/pages/group-cloud-component.page.ts @@ -18,10 +18,12 @@ import { browser, by, element, ElementFinder } from 'protractor'; import { BrowserVisibility } from '../../core/utils/browser-visibility'; import { BrowserActions } from '../../core/utils/browser-actions'; +import { FormFields } from '../../core/pages/form/formFields'; export class GroupCloudComponentPage { groupCloudSearch: ElementFinder = element(by.css('input[data-automation-id="adf-cloud-group-search-input"]')); + formFields: FormFields = new FormFields(); async searchGroups(name: string): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.groupCloudSearch); @@ -36,7 +38,6 @@ export class GroupCloudComponentPage { async getGroupsFieldContent(): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.groupCloudSearch); return this.groupCloudSearch.getAttribute('value'); - } async selectGroupFromList(name: string): Promise { @@ -69,4 +70,13 @@ export class GroupCloudComponentPage { await BrowserActions.click(locator); } + async isGroupWidgetVisible(fieldId: string): Promise { + try { + await this.formFields.checkWidgetIsVisible(fieldId); + return true; + } catch { + return false; + } + } + } diff --git a/lib/testing/src/lib/process-services-cloud/pages/people-cloud-component.page.ts b/lib/testing/src/lib/process-services-cloud/pages/people-cloud-component.page.ts index f5d945ba85..cf973d0917 100644 --- a/lib/testing/src/lib/process-services-cloud/pages/people-cloud-component.page.ts +++ b/lib/testing/src/lib/process-services-cloud/pages/people-cloud-component.page.ts @@ -15,14 +15,18 @@ * limitations under the License. */ -import { browser, by, element, ElementFinder, protractor } from 'protractor'; +import { browser, by, element, ElementFinder, Locator, protractor } from 'protractor'; import { BrowserVisibility } from '../../core/utils/browser-visibility'; import { BrowserActions } from '../../core/utils/browser-actions'; +import { FormFields } from '../../core/pages/form/formFields'; export class PeopleCloudComponentPage { peopleCloudSearch: ElementFinder = element(by.css('input[data-automation-id="adf-people-cloud-search-input"]')); assigneeField: ElementFinder = element(by.css('input[data-automation-id="adf-people-cloud-search-input"]')); + formFields: FormFields = new FormFields(); + labelLocator: Locator = by.css("label[class*='adf-label']"); + inputLocator: Locator = by.css('input'); async clearAssignee(): Promise { await BrowserActions.clearSendKeys(this.peopleCloudSearch, ' '); @@ -80,7 +84,38 @@ export class PeopleCloudComponentPage { await BrowserVisibility.waitUntilElementIsVisible(this.assigneeField); await browser.sleep(1000); return this.assigneeField.getAttribute('value'); + } + getFieldLabel(fieldId): Promise { + return this.formFields.getFieldLabel(fieldId, this.labelLocator); + } + + getFieldValue(fieldId): Promise { + return this.formFields.getFieldValue(fieldId, this.inputLocator); + } + + async isPeopleWidgetVisible(fieldId: string): Promise { + try { + await this.formFields.checkWidgetIsVisible(fieldId); + return true; + } catch { + return false; + } + } + + async checkPeopleWidgetIsHidden(fieldId: string): Promise { + const hiddenElement = element(by.css(`adf-form-field div[id='field-${fieldId}-container'][hidden]`)); + try { + await BrowserVisibility.waitUntilElementIsNotVisible(hiddenElement); + return true; + } catch { + return false; + } + } + + async clickPeopleInput(fieldId): Promise { + const peopleInput = element.all(by.css(`div[id="field-${fieldId}-container"] `)).first(); + await BrowserActions.click(peopleInput); } } diff --git a/lib/testing/src/lib/process-services-cloud/pages/public-api.ts b/lib/testing/src/lib/process-services-cloud/pages/public-api.ts index 56c2c2b11c..5f11f1e54d 100644 --- a/lib/testing/src/lib/process-services-cloud/pages/public-api.ts +++ b/lib/testing/src/lib/process-services-cloud/pages/public-api.ts @@ -28,5 +28,5 @@ export * from './task-filters-cloud-component.page'; export * from './task-list-cloud-component.page'; export * from './start-process-cloud-component.page'; export * from './task-form-cloud-component.page'; - export * from './dialog/public-api'; +export * from './form/public-api';