[ADF-4807] Automation tests for date min/max validation (#5008)

* Trigger alpha

* [ADF-4807] Automation tests for date min/max validation

* Removing identityUser changes
This commit is contained in:
Marouan Bentaleb 2019-09-16 17:07:06 +01:00 committed by Eugenio Romano
parent 53471eae84
commit 8ee3e25caf
9 changed files with 421 additions and 85 deletions

View File

@ -16,8 +16,8 @@
*/
import { ConfigEditorPage } from '../../configEditorPage';
import { BrowserActions } from '@alfresco/adf-testing';
import { by, element, browser, ElementFinder } from 'protractor';
import { BrowserActions, BrowserVisibility } from '@alfresco/adf-testing';
import { by, element, ElementFinder } from 'protractor';
export class FormCloudDemoPage {
@ -35,10 +35,12 @@ export class FormCloudDemoPage {
}
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 browser.sleep(2000);
await BrowserVisibility.waitUntilElementIsVisible(configEditor);
await this.configEditorPage.enterBulkConfiguration(text);
await this.goToRenderedForm();
await browser.sleep(2000);
await BrowserVisibility.waitUntilElementIsVisible(form);
}
}

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 { BrowserActions, BrowserVisibility } from '@alfresco/adf-testing';
import { by, element, ElementFinder } from 'protractor';
export class FormDemoPage {
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-form'));
await this.goToEditor();
await BrowserVisibility.waitUntilElementIsVisible(configEditor);
await this.configEditorPage.enterBulkConfiguration(text);
await this.goToRenderedForm();
await BrowserVisibility.waitUntilElementIsVisible(form);
}
}

View File

@ -0,0 +1,68 @@
/*!
* @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,
BrowserActions, FormPage
} 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 settingsPage = new SettingsPage();
const widget = new Widget();
const dateWidget = widget.dateWidget();
const formDemoPage = new FormCloudDemoPage();
const formJson = JSON.parse(customDateFormAPS2);
const formPage = new FormPage();
beforeAll(async () => {
await settingsPage.setProviderBpmSso(
browser.params.config.bpmHost,
browser.params.config.oauth2.host,
browser.params.config.identityHost);
await loginSSOPage.loginSSOIdentityService(browser.params.identityUser.email, browser.params.identityUser.password);
});
beforeEach(async () => {
const urlFormDemoPage = `${browser.params.testConfig.adf.url}/form-cloud`;
await BrowserActions.getUrl(urlFormDemoPage);
});
it('[C313199] Should display the validation for min and max date values with custom date format', async () => {
await formDemoPage.setConfigToEditor(formJson);
await dateWidget.setDateInput('datefield', '18-7-19');
await formPage.saveForm();
await expect(await dateWidget.getErrorMessage('datefield'))
.toBe('Can\'t be less than 19-7-19', 'Min date validation is not working');
await dateWidget.clearDateInput('datefield');
await dateWidget.setDateInput('datefield', '20-7-19');
await formPage.saveForm();
await expect(await dateWidget.getErrorMessage('datefield'))
.toBe('Can\'t be greater than 19-8-19', 'Max date validation is not working');
await dateWidget.clearDateInput('datefield');
await dateWidget.setDateInput('datefield', '19-7-19');
await formPage.saveForm();
await dateWidget.checkErrorMessageIsNotDisplayed('datefield');
});
});

View File

@ -124,14 +124,6 @@ describe('Task form cloud component', () => {
await browser.executeScript('window.localStorage.clear();');
});
it('[C307032] Should display the appropriate title for the unclaim option of a Task', async () => {
await appListCloudComponent.goToApp(candidateBaseApp);
await tasksCloudDemoPage.myTasksFilter().clickTaskFilter();
await tasksCloudDemoPage.taskListCloudComponent().checkContentIsDisplayedByName(assigneeTask.entry.name);
await tasksCloudDemoPage.taskListCloudComponent().selectRow(assigneeTask.entry.name);
await expect(await taskFormCloudComponent.getReleaseButtonText()).toBe('RELEASE');
});
it('[C310366] Should refresh buttons and form after an action is complete', async () => {
await appListCloudComponent.goToApp(simpleApp);
await tasksCloudDemoPage.myTasksFilter().clickTaskFilter();
@ -168,60 +160,64 @@ describe('Task form cloud component', () => {
await taskFormCloudComponent.checkCancelButtonIsDisplayed();
});
it('[C310142] Empty content is displayed when having a task without form', async () => {
await appListCloudComponent.goToApp(candidateBaseApp);
await tasksCloudDemoPage.myTasksFilter().clickTaskFilter();
await tasksCloudDemoPage.taskListCloudComponent().checkContentIsDisplayedByName(assigneeTask.entry.name);
await tasksCloudDemoPage.taskListCloudComponent().selectRow(assigneeTask.entry.name);
await taskFormCloudComponent.checkFormIsNotDisplayed();
await expect(await taskFormCloudComponent.getFormTitle()).toBe(assigneeTask.entry.name);
await taskFormCloudComponent.checkFormContentIsEmpty();
await expect(await taskFormCloudComponent.getEmptyFormContentTitle()).toBe(`No form available`);
await expect(await taskFormCloudComponent.getEmptyFormContentSubtitle()).toBe(`Attach a form that can be viewed later`);
});
it('[C310199] Should not be able to complete a task when required field is empty or invalid data is added to a field', async () => {
await appListCloudComponent.goToApp(candidateBaseApp);
await tasksCloudDemoPage.myTasksFilter().clickTaskFilter();
await tasksCloudDemoPage.taskListCloudComponent().checkContentIsDisplayedByName(formValidationsTask.entry.name);
await tasksCloudDemoPage.taskListCloudComponent().selectRow(formValidationsTask.entry.name);
await taskFormCloudComponent.checkFormIsDisplayed();
await taskFormCloudComponent.formFields().checkFormIsDisplayed();
await taskFormCloudComponent.formFields().checkWidgetIsVisible('Text0tma8h');
await taskFormCloudComponent.formFields().checkWidgetIsVisible('Date0m1moq');
await taskFormCloudComponent.formFields().checkWidgetIsVisible('Number0klykr');
await taskFormCloudComponent.formFields().checkWidgetIsVisible('Amount0mtp1h');
await expect(await (await taskFormCloudComponent.getCompleteButton()).isEnabled()).toBe(false);
await widget.textWidget().setValue('Text0tma8h', 'Some random text');
await expect(await (await taskFormCloudComponent.getCompleteButton()).isEnabled()).toBe(true);
await widget.dateWidget().setDateInput('Date0m1moq', 'invalid date');
await browser.actions().sendKeys(protractor.Key.ENTER).perform();
await expect(await (await taskFormCloudComponent.getCompleteButton()).isEnabled()).toBe(false);
await widget.dateWidget().setDateInput('Date0m1moq', '20-10-2018');
await browser.actions().sendKeys(protractor.Key.ENTER).perform();
await expect(await (await taskFormCloudComponent.getCompleteButton()).isEnabled()).toBe(true);
await widget.numberWidget().setFieldValue('Number0klykr', 'invalid number');
await expect(await (await taskFormCloudComponent.getCompleteButton()).isEnabled()).toBe(false);
await widget.numberWidget().setFieldValue('Number0klykr', '26');
await expect(await (await taskFormCloudComponent.getCompleteButton()).isEnabled()).toBe(true);
await widget.amountWidget().setFieldValue('Amount0mtp1h', 'invalid amount');
await expect(await (await taskFormCloudComponent.getCompleteButton()).isEnabled()).toBe(false);
await widget.amountWidget().setFieldValue('Amount0mtp1h', '660');
await expect(await (await taskFormCloudComponent.getCompleteButton()).isEnabled()).toBe(true);
});
describe('Complete task - cloud directive', () => {
describe('Candidate Base App', () => {
beforeEach(async () => {
await appListCloudComponent.goToApp(candidateBaseApp);
});
it('[C307032] Should display the appropriate title for the unclaim option of a Task', async () => {
await tasksCloudDemoPage.myTasksFilter().clickTaskFilter();
await tasksCloudDemoPage.taskListCloudComponent().checkContentIsDisplayedByName(assigneeTask.entry.name);
await tasksCloudDemoPage.taskListCloudComponent().selectRow(assigneeTask.entry.name);
await expect(await taskFormCloudComponent.getReleaseButtonText()).toBe('RELEASE');
});
it('[C310142] Empty content is displayed when having a task without form', async () => {
await tasksCloudDemoPage.myTasksFilter().clickTaskFilter();
await tasksCloudDemoPage.taskListCloudComponent().checkContentIsDisplayedByName(assigneeTask.entry.name);
await tasksCloudDemoPage.taskListCloudComponent().selectRow(assigneeTask.entry.name);
await taskFormCloudComponent.checkFormIsNotDisplayed();
await expect(await taskFormCloudComponent.getFormTitle()).toBe(assigneeTask.entry.name);
await taskFormCloudComponent.checkFormContentIsEmpty();
await expect(await taskFormCloudComponent.getEmptyFormContentTitle()).toBe(`No form available`);
await expect(await taskFormCloudComponent.getEmptyFormContentSubtitle()).toBe(`Attach a form that can be viewed later`);
});
it('[C310199] Should not be able to complete a task when required field is empty or invalid data is added to a field', async () => {
await tasksCloudDemoPage.myTasksFilter().clickTaskFilter();
await tasksCloudDemoPage.taskListCloudComponent().checkContentIsDisplayedByName(formValidationsTask.entry.name);
await tasksCloudDemoPage.taskListCloudComponent().selectRow(formValidationsTask.entry.name);
await taskFormCloudComponent.checkFormIsDisplayed();
await taskFormCloudComponent.formFields().checkFormIsDisplayed();
await taskFormCloudComponent.formFields().checkWidgetIsVisible('Text0tma8h');
await taskFormCloudComponent.formFields().checkWidgetIsVisible('Date0m1moq');
await taskFormCloudComponent.formFields().checkWidgetIsVisible('Number0klykr');
await taskFormCloudComponent.formFields().checkWidgetIsVisible('Amount0mtp1h');
await expect(await taskFormCloudComponent.isCompleteButtonEnabled()).toBe(false);
await widget.textWidget().setValue('Text0tma8h', 'Some random text');
await expect(await taskFormCloudComponent.isCompleteButtonEnabled()).toBe(true);
await widget.dateWidget().setDateInput('Date0m1moq', 'invalid date');
await browser.actions().sendKeys(protractor.Key.ENTER).perform();
await expect(await taskFormCloudComponent.isCompleteButtonEnabled()).toBe(false);
await widget.dateWidget().setDateInput('Date0m1moq', '20-10-2018');
await browser.actions().sendKeys(protractor.Key.ENTER).perform();
await expect(await taskFormCloudComponent.isCompleteButtonEnabled()).toBe(true);
await widget.numberWidget().setFieldValue('Number0klykr', 'invalid number');
await expect(await taskFormCloudComponent.isCompleteButtonEnabled()).toBe(false);
await widget.numberWidget().setFieldValue('Number0klykr', '26');
await expect(await taskFormCloudComponent.isCompleteButtonEnabled()).toBe(true);
await widget.amountWidget().setFieldValue('Amount0mtp1h', 'invalid amount');
await expect(await taskFormCloudComponent.isCompleteButtonEnabled()).toBe(false);
await widget.amountWidget().setFieldValue('Amount0mtp1h', '660');
await expect(await taskFormCloudComponent.isCompleteButtonEnabled()).toBe(true);
});

View File

@ -18,11 +18,13 @@
import { AlfrescoApiCompatibility as AlfrescoApi } from '@alfresco/js-api';
import { AppsActions } from '../../actions/APS/apps.actions';
import { UsersActions } from '../../actions/users.actions';
import { LoginPage, BrowserActions, Widget } from '@alfresco/adf-testing';
import { LoginPage, BrowserActions, Widget, FormPage } from '@alfresco/adf-testing';
import { TasksPage } from '../../pages/adf/process-services/tasksPage';
import CONSTANTS = require('../../util/constants');
import { browser } from 'protractor';
import resources = require('../../util/resources');
import { FormDemoPage } from '../../pages/adf/demo-shell/process-services/formDemoPage';
import { customDateFormAPS1 } from '../../resources/forms/custom-date-form';
describe('Date widget', () => {
@ -30,6 +32,7 @@ describe('Date widget', () => {
let processUserModel;
const taskPage = new TasksPage();
const widget = new Widget();
const dateWidget = widget.dateWidget();
let alfrescoJsApi;
const appsActions = new AppsActions();
let appModel;
@ -60,13 +63,6 @@ describe('Date widget', () => {
});
beforeEach(async () => {
const urlToNavigateTo = `${browser.params.testConfig.adf.url}/activiti/apps/${deployedApp.id}/tasks/`;
await BrowserActions.getUrl(urlToNavigateTo);
await taskPage.filtersPage().goToFilter(CONSTANTS.TASK_FILTERS.MY_TASKS);
await taskPage.formFields().checkFormIsDisplayed();
});
afterAll(async () => {
await alfrescoJsApi.activiti.processApi.deleteProcessInstance(process.id);
await alfrescoJsApi.login(browser.params.testConfig.adf.adminEmail, browser.params.testConfig.adf.adminPassword);
@ -74,21 +70,60 @@ describe('Date widget', () => {
});
it('[C268814] Should be able to set general settings for Date widget', async () => {
await expect(await widget.dateWidget().getDateLabel(app.FIELD.date_input)).toContain('Date');
await expect(await taskPage.formFields().isCompleteFormButtonDisabled()).toBeTruthy();
await widget.dateWidget().setDateInput(app.FIELD.date_input, '20-10-2018');
await taskPage.formFields().saveForm();
await expect(await taskPage.formFields().isCompleteFormButtonDisabled()).toBeFalsy();
describe('Simple App', () => {
beforeEach(async () => {
const urlToNavigateTo = `${browser.params.testConfig.adf.url}/activiti/apps/${deployedApp.id}/tasks/`;
await BrowserActions.getUrl(urlToNavigateTo);
await taskPage.filtersPage().goToFilter(CONSTANTS.TASK_FILTERS.MY_TASKS);
await taskPage.formFields().checkFormIsDisplayed();
});
it('[C268814] Should be able to set general settings for Date widget', async () => {
await expect(await dateWidget.getDateLabel(app.FIELD.date_input)).toContain('Date');
await expect(await taskPage.formFields().isCompleteFormButtonDisabled()).toBeTruthy();
await dateWidget.setDateInput(app.FIELD.date_input, '20-10-2018');
await taskPage.formFields().saveForm();
await expect(await taskPage.formFields().isCompleteFormButtonDisabled()).toBeFalsy();
});
it('[C277234] Should be able to set advanced settings for Date widget ', async () => {
await dateWidget.setDateInput(app.FIELD.date_between_input, '20-10-2017');
await taskPage.formFields().saveForm();
await expect(await dateWidget.getErrorMessage(app.FIELD.date_between_input)).toBe('Can\'t be less than 1-10-2018');
await dateWidget.clearDateInput(app.FIELD.date_between_input);
await dateWidget.setDateInput(app.FIELD.date_between_input, '20-10-2019');
await taskPage.formFields().saveForm();
await expect(await dateWidget.getErrorMessage(app.FIELD.date_between_input)).toBe('Can\'t be greater than 31-10-2018');
});
});
it('[C277234] Should be able to set advanced settings for Date widget ', async () => {
await widget.dateWidget().setDateInput(app.FIELD.date_between_input, '20-10-2017');
await taskPage.formFields().saveForm();
await expect(await widget.dateWidget().getErrorMessage(app.FIELD.date_between_input)).toBe('Can\'t be less than 1-10-2018');
await widget.dateWidget().clearDateInput(app.FIELD.date_between_input);
await widget.dateWidget().setDateInput(app.FIELD.date_between_input, '20-10-2019');
await taskPage.formFields().saveForm();
await expect(await widget.dateWidget().getErrorMessage(app.FIELD.date_between_input)).toBe('Can\'t be greater than 31-10-2018');
describe('Form Demo Page', () => {
const formDemoPage = new FormDemoPage();
const formJson = JSON.parse(customDateFormAPS1);
const formPage = new FormPage();
beforeAll(async () => {
const urlFormDemoPage = `${browser.params.testConfig.adf.url}/form`;
await BrowserActions.getUrl(urlFormDemoPage);
});
it('[C313199] Should display the validation for min and max date values with custom date format', async () => {
await formDemoPage.setConfigToEditor(formJson);
await dateWidget.setDateInput('datefield', '18-7-19');
await formPage.saveForm();
await expect(await dateWidget.getErrorMessage('datefield'))
.toBe('Can\'t be less than 19-7-19', 'Min date validation is not working');
await dateWidget.clearDateInput('datefield');
await dateWidget.setDateInput('datefield', '20-7-19');
await formPage.saveForm();
await expect(await dateWidget.getErrorMessage('datefield'))
.toBe('Can\'t be greater than 19-8-19', 'Max date validation is not working');
await dateWidget.clearDateInput('datefield');
await dateWidget.setDateInput('datefield', '19-7-19');
await formPage.saveForm();
await dateWidget.checkErrorMessageIsNotDisplayed('datefield');
});
});
});

View File

@ -0,0 +1,179 @@
/*!
* @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 customDateFormAPS1 = `{
"id": 18977,
"name": "APS1customDateFrom",
"description": "",
"version": 1,
"lastUpdatedBy": 1,
"lastUpdatedByFullName": " Administrator",
"lastUpdated": "2019-08-21T09:29:18.042+0000",
"stencilSetId": 0,
"referenceId": null,
"formDefinition": {
"tabs": [],
"fields": [
{
"fieldType": "ContainerRepresentation",
"id": "1566223482682",
"name": "Label",
"type": "container",
"value": null,
"required": false,
"readOnly": false,
"overrideId": false,
"colspan": 1,
"placeholder": null,
"minLength": 0,
"maxLength": 0,
"minValue": null,
"maxValue": null,
"regexPattern": null,
"optionType": null,
"hasEmptyValue": null,
"options": null,
"restUrl": null,
"restResponsePath": null,
"restIdProperty": null,
"restLabelProperty": null,
"tab": null,
"className": null,
"dateDisplayFormat": null,
"layout": null,
"sizeX": 2,
"sizeY": 1,
"row": -1,
"col": -1,
"visibilityCondition": null,
"numberOfColumns": 2,
"fields": {
"1": [
{
"fieldType": "FormFieldRepresentation",
"id": "datefield",
"name": "DateField",
"type": "date",
"value": null,
"required": false,
"readOnly": false,
"overrideId": false,
"colspan": 1,
"placeholder": null,
"minLength": 0,
"maxLength": 0,
"minValue": "19-7-2019",
"maxValue": "19-8-2019",
"regexPattern": null,
"optionType": null,
"hasEmptyValue": null,
"options": null,
"restUrl": null,
"restResponsePath": null,
"restIdProperty": null,
"restLabelProperty": null,
"tab": null,
"className": null,
"params": {
"existingColspan": 1,
"maxColspan": 2
},
"dateDisplayFormat": "YY-M-D",
"layout": {
"row": -1,
"column": -1,
"colspan": 1
},
"sizeX": 1,
"sizeY": 1,
"row": -1,
"col": -1,
"visibilityCondition": null
}
],
"2": []
}
}
],
"outcomes": [],
"javascriptEvents": [],
"className": "",
"style": "",
"customFieldTemplates": {},
"metadata": {},
"variables": [],
"customFieldsValueInfo": {},
"gridsterForm": false
}
}`;
export const customDateFormAPS2 = `{
"formRepresentation":{
"id":"form-71f621f5-7113-4bb8-a646-8fe36f27cdf4",
"name":"APS2customDateForm",
"description":"",
"version":0,
"standAlone":true,
"formDefinition":{
"tabs":[
],
"fields":[
{
"id":"c207088c-e0f5-402e-8513-a865f3777c25",
"name":"Label",
"type":"container",
"tab":null,
"numberOfColumns":2,
"fields":{
"1":[
{
"id":"datefield",
"name":"DateField",
"type":"date",
"required":false,
"colspan":1,
"placeholder":null,
"minValue":"2019-07-19",
"maxValue":"2019-08-19",
"visibilityCondition":null,
"params":{
"existingColspan":1,
"maxColspan":2
},
"dateDisplayFormat":"YY-M-D"
}
],
"2":[
]
}
}
],
"outcomes":[
],
"metadata":{
},
"variables":[
]
}
}
}`;

View File

@ -55,6 +55,11 @@ export class DateWidget {
await BrowserActions.click(form);
}
async checkErrorMessageIsNotDisplayed(fieldId): Promise<void> {
const errorMessage = element(by.css(`adf-form-field div[id="field-${fieldId}-container"] div[class="adf-error-text"]`));
await BrowserVisibility.waitUntilElementIsNotVisible(errorMessage);
}
async getErrorMessage(fieldId): Promise<string> {
const errorMessage = element(by.css(`adf-form-field div[id="field-${fieldId}-container"] div[class="adf-error-text"]`));
return BrowserActions.getText(errorMessage);

View File

@ -35,6 +35,11 @@ export class TaskFormCloudComponent {
emptyContentSubtitle: ElementFinder = element(by.css(`div.adf-empty-content div.adf-empty-content__subtitle`));
readOnlyForm = element(by.css('div[class="adf-readonly-form"]'));
async isCompleteButtonEnabled(): Promise<boolean> {
await BrowserVisibility.waitUntilElementIsVisible(this.completeButton);
return this.completeButton.isEnabled();
}
async checkFormIsReadOnly() {
await BrowserVisibility.waitUntilElementIsVisible(this.readOnlyForm);
}