From 15190d7ec91543b56340fa2a2793efe252b9d907 Mon Sep 17 00:00:00 2001 From: jdosti Date: Tue, 7 Aug 2018 19:34:19 +0100 Subject: [PATCH] [ADF-3414] Create automated test for Attach form component (#3665) --- .../adf/process_services/attachFormPage.ts | 76 +++++++++ e2e/pages/adf/process_services/formFields.js | 12 ++ .../attach_form_component.e2e.ts | 151 ++++++++++++++++++ 3 files changed, 239 insertions(+) create mode 100644 e2e/pages/adf/process_services/attachFormPage.ts create mode 100644 e2e/process-services/attach_form_component.e2e.ts diff --git a/e2e/pages/adf/process_services/attachFormPage.ts b/e2e/pages/adf/process_services/attachFormPage.ts new file mode 100644 index 0000000000..a0e34fbb8b --- /dev/null +++ b/e2e/pages/adf/process_services/attachFormPage.ts @@ -0,0 +1,76 @@ +/*! + * @license + * Copyright 2016 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 Util = require('../../../util/util'); +import TestConfig = require('../../../test.config'); + +export class AttachFormPage { + + noFormMessage = element(by.id('adf-no-form-message')); + attachFormButton = element(by.id('adf-no-form-attach-form-button')); + completeButton = element(by.id('adf-no-form-complete-button')); + formDropdown = element(by.id('form_id')); + cancelButton = element(by.id('adf-no-form-cancel-button')); + defaultTitle = element(by.css('mat-card-title[class="mat-card-title mat-card-title"]')); + attachFormDropdown = element(by.css("div[class='adf-attach-form-row']")); + + checkNoFormMessageIsDisplayed() { + return Util.waitUntilElementIsVisible(this.noFormMessage); + } + + checkAttachFormButtonIsDisplayed() { + return Util.waitUntilElementIsVisible(this.attachFormButton); + } + + checkCompleteButtonIsDisplayed() { + return Util.waitUntilElementIsVisible(this.completeButton); + } + + clickAttachFormButton() { + Util.waitUntilElementIsVisible(this.attachFormButton); + return this.attachFormButton.click(); + } + + checkDefaultFormTitleIsDisplayed(formTitle) { + this.defaultTitle.getText().then((result) => { + expect(result).toEqual(formTitle); + }); + } + + checkFormDropdownIsDisplayed() { + return Util.waitUntilElementIsVisible(this.formDropdown); + } + + checkCancelButtonIsDisplayed() { + return Util.waitUntilElementIsVisible(this.cancelButton); + } + + clickAttachFormDropdown() { + Util.waitUntilElementIsClickable(this.attachFormDropdown); + return this.attachFormDropdown.click(); + } + + selectAttachFormOption(option) { + Util.waitUntilElementIsClickable(element(by.cssContainingText("mat-option[role='option']", option))); + return element(by.cssContainingText("mat-option[role='option']", option)).click(); + } + + clickCancelButton() { + Util.waitUntilElementIsVisible(this.cancelButton); + return this.cancelButton.click(); + } +} diff --git a/e2e/pages/adf/process_services/formFields.js b/e2e/pages/adf/process_services/formFields.js index d58f3b1990..0df1bfbbb0 100644 --- a/e2e/pages/adf/process_services/formFields.js +++ b/e2e/pages/adf/process_services/formFields.js @@ -29,6 +29,7 @@ var FormFields = function () { var attachFormButton = element(by.id("adf-no-form-attach-form-button")); var selectFormDropDownArrow = element(by.css("adf-attach-form div[class*='mat-select-arrow']")); var selectFormContent = element(by.css("div[class*='mat-select-content']")); + var completeButton = element(by.id('adf-form-complete')); this.setFieldValue = function (By, field, value) { var fieldElement = element(By(field)); @@ -117,6 +118,17 @@ var FormFields = function () { formNameElement.click(); }; + this.checkWidgetIsReadOnlyMode = function (fieldId) { + var widget = element(by.css("form-field div[id='field-" + fieldId + "-container']")); + var widgetReadOnly = widget.element(by.css('div[class*="adf-readonly"]')); + Util.waitUntilElementIsVisible(widgetReadOnly); + return widgetReadOnly; + }; + + this.completeForm = function () { + Util.waitUntilElementIsVisible(completeButton); + return completeButton.click(); + }; }; module.exports = FormFields; diff --git a/e2e/process-services/attach_form_component.e2e.ts b/e2e/process-services/attach_form_component.e2e.ts new file mode 100644 index 0000000000..717595c320 --- /dev/null +++ b/e2e/process-services/attach_form_component.e2e.ts @@ -0,0 +1,151 @@ +/*! + * @license + * Copyright 2016 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 LoginPage = require('../pages/adf/loginPage'); +import ProcessServicesPage = require('../pages/adf/process_services/processServicesPage'); +import TasksPage = require('../pages/adf/process_services/tasksPage'); +import { AttachFormPage } from '../pages/adf/process_services/attachFormPage'; +import FormFields = require('../pages/adf/process_services/formFields'); + +import CONSTANTS = require('../util/constants'); + +import TestConfig = require('../test.config'); +import resources = require('../util/resources'); +import Util = require('../util/util.js'); + +import AlfrescoApi = require('alfresco-js-api-node'); +import { UsersActions } from '../actions/users.actions'; +import { AppsActions } from '../actions/APS/apps.actions'; + +describe('Attach Form Component', () => { + + let loginPage = new LoginPage(); + let processServicesPage = new ProcessServicesPage(); + let taskPage = new TasksPage(); + let attachFormPage = new AttachFormPage(); + let formFields = new FormFields(); + + let app = resources.Files.SIMPLE_APP_WITH_USER_FORM; + let formTextField = app.form_fields.form_fieldId; + let user, tenantId, appId; + + let testNames = { + taskName: 'Test Task', + formTitle: 'Select Form To Attach', + formName: 'Simple form', + widgetTitle: 'textfield', + formFieldValue: 'Test value' + }; + + beforeAll(async(done) => { + + this.alfrescoJsApi = new AlfrescoApi({ + provider: 'BPM', + hostBpm: TestConfig.adf.url + }); + + done(); + }); + + beforeEach(async(done) => { + + let users = new UsersActions(); + let appsActions = new AppsActions(); + + await this.alfrescoJsApi.login(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword); + + user = await users.createTenantAndUser(this.alfrescoJsApi); + + tenantId = user.tenantId; + + await this.alfrescoJsApi.login(user.email, user.password); + + let appModel = await appsActions.importPublishDeployApp(this.alfrescoJsApi, app.file_location); + + appId = appModel.id; + + await this.alfrescoJsApi.activiti.taskApi.createNewTask({name: testNames.taskName}); + + await loginPage.loginToProcessServicesUsingUserModel(user); + + done(); + }); + + afterEach(async(done) => { + + await this.alfrescoJsApi.activiti.modelsApi.deleteModel(appId); + + await this.alfrescoJsApi.login(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword); + + await this.alfrescoJsApi.activiti.adminTenantsApi.deleteTenant(tenantId); + + done(); + }); + + it('[C280047] Should be able to view the attach-form component after creating a standalone task', () => { + + processServicesPage.goToProcessServices().goToTaskApp().clickTasksButton(); + + taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.MY_TASKS); + taskPage.usingTasksListPage().selectTaskFromTasksList(testNames.taskName); + + attachFormPage.checkNoFormMessageIsDisplayed(); + attachFormPage.checkAttachFormButtonIsDisplayed(); + attachFormPage.checkCompleteButtonIsDisplayed(); + }); + + it('[C280048] Should be able to view the attach-form component after clicking cancel button', () => { + + processServicesPage.goToProcessServices().goToTaskApp().clickTasksButton(); + + taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.MY_TASKS); + taskPage.usingTasksListPage().selectTaskFromTasksList(testNames.taskName); + + attachFormPage.clickAttachFormButton(); + attachFormPage.checkDefaultFormTitleIsDisplayed(testNames.formTitle); + attachFormPage.checkFormDropdownIsDisplayed(); + attachFormPage.checkCancelButtonIsDisplayed(); + attachFormPage.clickAttachFormDropdown(); + attachFormPage.selectAttachFormOption(testNames.formName); + + formFields.checkWidgetIsReadOnlyMode(testNames.widgetTitle); + + attachFormPage.clickCancelButton(); + attachFormPage.checkAttachFormButtonIsDisplayed(); + }); + + it('[C280017] Should be able to attach a form on a standalone task and complete', () => { + + processServicesPage.goToProcessServices().goToTaskApp().clickTasksButton(); + + taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.MY_TASKS); + taskPage.usingTasksListPage().selectTaskFromTasksList(testNames.taskName); + + attachFormPage.clickAttachFormButton(); + attachFormPage.clickAttachFormDropdown(); + attachFormPage.selectAttachFormOption(testNames.formName); + attachFormPage.clickAttachFormButton(); + + formFields.setFieldValue(by.id, formTextField, testNames.formFieldValue); + formFields.completeForm(); + + taskPage.usingFiltersPage().goToFilter(CONSTANTS.TASKFILTERS.COMPL_TASKS); + taskPage.usingTasksListPage().selectTaskFromTasksList(testNames.taskName); + + expect(formFields.getFieldValue(formTextField)).toEqual(testNames.formFieldValue); + }); +});