[AAE-1453] added e2e tests for checking different configurations for people/group cloud widgets (#5446)

This commit is contained in:
Alexandra Abrudan
2020-02-06 01:18:30 +00:00
committed by GitHub
parent 4b1471d9c3
commit 9276333352
12 changed files with 213 additions and 42 deletions
-46
View File
@@ -1,46 +0,0 @@
/*!
* @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 { element, by, browser, ElementFinder } from 'protractor';
import { BrowserVisibility, BrowserActions } from '@alfresco/adf-testing';
export class ConfigEditorPage {
textField: ElementFinder = element(by.css('#adf-form-config-editor div.overflow-guard > textarea'));
async enterConfiguration(text): Promise<void> {
await BrowserActions.clearSendKeys(this.textField, text);
}
async clickSaveButton(): Promise<void> {
const saveButton: ElementFinder = element(by.id('app-form-config-save'));
await BrowserActions.click(saveButton);
}
async clickClearButton(): Promise<void> {
await BrowserVisibility.waitUntilElementIsVisible(this.textField);
const clearButton: ElementFinder = element(by.id('app-form-config-clear'));
await BrowserActions.click(clearButton);
}
async enterBulkConfiguration(text): Promise<void> {
await this.clickClearButton();
await BrowserVisibility.waitUntilElementIsVisible(this.textField);
await browser.executeScript('this.monaco.editor.getModels()[0].setValue(`' + JSON.stringify(text) + '`)');
await this.clickSaveButton();
}
}
@@ -1,46 +0,0 @@
/*!
* @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 { BrowserActions, BrowserVisibility } from '@alfresco/adf-testing';
import { by, element, ElementFinder } from 'protractor';
export class FormCloudDemoPage {
formCloudEditor: ElementFinder = element.all(by.css('.mat-tab-list .mat-tab-label')).get(1);
formCloudRender: ElementFinder = element.all(by.css('.mat-tab-list .mat-tab-label')).get(0);
configEditorPage = new ConfigEditorPage();
async goToEditor(): Promise<void> {
await BrowserActions.click(this.formCloudEditor);
}
async goToRenderedForm(): Promise<void> {
await BrowserActions.click(this.formCloudRender);
}
async setConfigToEditor(text): Promise<void> {
const configEditor = element(by.id('adf-form-config-editor'));
const form = element(by.css('adf-cloud-form'));
await this.goToEditor();
await BrowserVisibility.waitUntilElementIsVisible(configEditor);
await this.configEditorPage.enterBulkConfiguration(text);
await this.goToRenderedForm();
await BrowserVisibility.waitUntilElementIsVisible(form);
}
}
@@ -15,8 +15,7 @@
* limitations under the License.
*/
import { ConfigEditorPage } from '../../configEditorPage';
import { BrowserActions, BrowserVisibility } from '@alfresco/adf-testing';
import { BrowserActions, BrowserVisibility, ConfigEditorPage } from '@alfresco/adf-testing';
import { by, element, ElementFinder } from 'protractor';
export class FormDemoPage {
@@ -17,18 +17,17 @@
import {
LoginSSOPage,
BrowserActions, FormPage, ProcessCloudWidgetPage
BrowserActions, FormPage, ProcessCloudWidgetPage, FormCloudComponentPage
} from '@alfresco/adf-testing';
import { browser } from 'protractor';
import { customDateFormAPS2 } from '../../resources/forms/custom-date-form';
import { FormCloudDemoPage } from '../../pages/adf/demo-shell/process-services-cloud/cloudFormDemoPage';
describe('Form Field Component - Dropdown Widget', () => {
const loginSSOPage = new LoginSSOPage();
const widget = new ProcessCloudWidgetPage();
const dateWidget = widget.dateWidget();
const formDemoPage = new FormCloudDemoPage();
const formDemoPage = new FormCloudComponentPage();
const formJson = JSON.parse(customDateFormAPS2);
const formPage = new FormPage();
@@ -16,20 +16,29 @@
*/
import {
FormCloudComponentPage,
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 {
peopleSingleModeFormMock,
peopleMultipleModeFormMock,
peopleRequiredFormMock,
groupSingleModeFormMock,
groupMultipleModeFormMock,
groupRequiredFormMock,
peopleReadOnlyFormMock,
groupReadOnlyFormMock
} from '../../resources/forms/people-group-formwidget-mocks';
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 formCloudComponentPage = new FormCloudComponentPage();
const widget = new ProcessCloudWidgetPage();
const peopleCloudWidget = widget.peopleCloudWidget();
const groupCloudWidget = widget.groupCloudWidget();
@@ -72,7 +81,8 @@ describe('People and Group of people Widgets', () => {
});
it('[C325002] Should be able to add a user in People field when Single mode is chosen', async () => {
await formCloudDemoPage.setConfigToEditor(peopleJson);
await formCloudComponentPage.setConfigToEditor(peopleSingleModeFormMock);
await peopleCloudWidget.clickPeopleInput(widgets.peopleCloudWidgetSingleModeId);
await peopleCloudWidget.isPeopleWidgetVisible(peopleValueString.peopleCloudWidgetSingleModeField);
const peopleSingleMode = await peopleCloudWidget.getFieldValue(widgets.peopleCloudWidgetSingleModeId);
@@ -83,7 +93,8 @@ describe('People and Group of people Widgets', () => {
});
it('[C325122] Should be able to add multiple users in People field when Multiple mode is chosen', async () => {
await formCloudDemoPage.setConfigToEditor(peopleMultipleModeJson);
await formCloudComponentPage.setConfigToEditor(peopleMultipleModeFormMock);
await peopleCloudWidget.clickPeopleInput(widgets.peopleCloudWidgetMultipleModeId);
await peopleCloudWidget.isPeopleWidgetVisible(peopleValueString.peopleCloudWidgetMultipleModeField);
const peopleMultipleMode = await peopleCloudWidget.getFieldValue(widgets.peopleCloudWidgetMultipleModeId);
@@ -95,8 +106,19 @@ describe('People and Group of people Widgets', () => {
await peopleCloudWidget.checkSelectedPeople('Sales User');
});
it('[C325182] Should not be able to type in the People field if the readOnly option is checked', async () => {
await formCloudComponentPage.setConfigToEditor(peopleReadOnlyFormMock);
const readOnlyAttribute = await peopleCloudWidget.checkPeopleWidgetIsReadOnly();
const activePeopleField = await peopleCloudWidget.checkPeopleActiveField('HR User');
await expect (readOnlyAttribute).toBe(true);
await expect (activePeopleField).toBe(false);
});
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 formCloudComponentPage.setConfigToEditor(peopleRequiredFormMock);
await peopleCloudWidget.isPeopleWidgetVisible(peopleValueString.peopleCloudWidgetRequiredField);
await expect(await formPage.isSaveButtonDisabled()).toBe(true);
await expect(await formPage.isValidationIconRed()).toBe(true);
@@ -111,7 +133,8 @@ describe('People and Group of people Widgets', () => {
});
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 formCloudComponentPage.setConfigToEditor(groupSingleModeFormMock);
await groupCloudWidget.isGroupWidgetVisible(groupValueString.groupCloudWidgetSingleModeField);
const groupSingleMode = await groupCloudWidget.getGroupsFieldContent();
await expect(groupSingleMode).toEqual('');
@@ -122,7 +145,8 @@ describe('People and Group of people Widgets', () => {
});
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 formCloudComponentPage.setConfigToEditor(groupMultipleModeFormMock);
await groupCloudWidget.isGroupWidgetVisible(groupValueString.groupCloudWidgetMultipleModeField);
const groupSingleMode = await groupCloudWidget.getGroupsFieldContent();
await expect(groupSingleMode).toEqual('');
@@ -135,8 +159,19 @@ describe('People and Group of people Widgets', () => {
await groupCloudWidget.checkSelectedGroup('sales');
});
it('[C325183] Should not be able to type in the Group field if the readOnly option is checked', async () => {
await formCloudComponentPage.setConfigToEditor(groupReadOnlyFormMock);
const readOnlyGroupAttribute = await groupCloudWidget.checkGroupWidgetIsReadOnly();
const activeGroupField = await groupCloudWidget.checkGroupActiveField('hr');
await expect (readOnlyGroupAttribute).toBe(true);
await expect (activeGroupField).toBe(false);
});
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 formCloudComponentPage.setConfigToEditor(groupRequiredFormMock);
await groupCloudWidget.isGroupWidgetVisible(groupValueString.groupCloudWidgetRequiredField);
await expect(await formPage.isSaveButtonDisabled()).toBe(true);
await expect(await formPage.isValidationIconRed()).toBe(true);
@@ -150,4 +185,5 @@ describe('People and Group of people Widgets', () => {
await expect(await formPage.isSaveButtonDisabled()).toBe(false);
await expect(await formPage.isValidationIconBlue()).toBe(true);
});
});
@@ -15,12 +15,11 @@
* limitations under the License.
*/
import { LoginSSOPage, ProcessCloudWidgetPage } from '@alfresco/adf-testing';
import { FormCloudComponentPage, LoginSSOPage, ProcessCloudWidgetPage } 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';
@@ -30,7 +29,7 @@ describe('Visibility conditions on tabs - cloud', () => {
const loginSSOPage = new LoginSSOPage();
const navigationBarPage = new NavigationBarPage();
const formCloudDemoPage = new FormCloudDemoPage();
const formCloudDemoPage = new FormCloudComponentPage();
const widget = new ProcessCloudWidgetPage();
const widgets = {
@@ -15,12 +15,11 @@
* limitations under the License.
*/
import { LoginSSOPage, ProcessCloudWidgetPage } from '@alfresco/adf-testing';
import { FormCloudComponentPage, LoginSSOPage, ProcessCloudWidgetPage } 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 { checkboxVisibilityFormJson, multipleCheckboxVisibilityFormJson } from '../../resources/forms/checkbox-visibility-condition';
import { multipleVisibilityFormJson } from '../../resources/forms/multiple-visibility-conditions';
import { displayValueTextJson } from '../../resources/forms/displayValue-visibilityConditions';
@@ -30,7 +29,7 @@ describe('Visibility conditions - cloud', () => {
const loginSSOPage = new LoginSSOPage();
const navigationBarPage = new NavigationBarPage();
const formCloudDemoPage = new FormCloudDemoPage();
const formCloudDemoPage = new FormCloudComponentPage();
const widget = new ProcessCloudWidgetPage();
let visibleCheckbox;
@@ -16,7 +16,7 @@
*/
/* tslint:disable */
export const peopleJson = {
export const peopleSingleModeFormMock = {
"formRepresentation": {
"id": "form-d74a4136-af83-4333-ac37-a6a74ac7aa84",
"name": "singlepeople",
@@ -60,7 +60,7 @@ export const peopleJson = {
}
};
export const peopleMultipleModeJson = {
export const peopleMultipleModeFormMock = {
"formRepresentation": {
"id": "form-0fec4293-a33a-4408-923c-ba2d0645459c",
"name": "people",
@@ -111,7 +111,7 @@ export const peopleMultipleModeJson = {
}
};
export const peopleRequiredJson = {
export const peopleRequiredFormMock = {
"formRepresentation": {
"id": "form-0fec4293-a33a-4408-923c-ba2d0645459c",
"name": "people",
@@ -162,7 +162,7 @@ export const peopleRequiredJson = {
}
};
export const groupSingleJson = {
export const groupSingleModeFormMock = {
"formRepresentation": {
"id": "form-0fec4293-a33a-4408-923c-ba2d0645459c",
"name": "people",
@@ -213,7 +213,7 @@ export const groupSingleJson = {
}
};
export const groupMultipleJson = {
export const groupMultipleModeFormMock = {
"formRepresentation": {
"id": "form-0fec4293-a33a-4408-923c-ba2d0645459c",
"name": "people",
@@ -262,9 +262,9 @@ export const groupMultipleJson = {
]
}
}
}
};
export const groupRequiredJson = {
export const groupRequiredFormMock = {
"formRepresentation": {
"id": "form-0fec4293-a33a-4408-923c-ba2d0645459c",
"name": "people",
@@ -313,4 +313,106 @@ export const groupRequiredJson = {
]
}
}
}
};
export const peopleReadOnlyFormMock = {
"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": "PeopleReadOnly",
"name": "People",
"type": "people",
"readOnly": true,
"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 groupReadOnlyFormMock = {
"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": "GroupReadOnly",
"name": "Group of people",
"type": "functional-group",
"readOnly": true,
"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"
}
]
}
}
};