From 9179b0ccbb93eca36e1d5193d1d9eb16c32f88b2 Mon Sep 17 00:00:00 2001 From: jdosti Date: Thu, 11 Oct 2018 22:25:33 +0100 Subject: [PATCH] [ADF-3597] Create automated test to cover Error Log on Form component (#3831) * [ADF-3597] Create automated test to cover Error Log on Form component * Removing double quotes * Removing console log * Changing capital letter * Creating pages for each widget * Minor changes on spaces and namings * fix rebase --- e2e/pages/adf/navigationBarPage.ts | 6 + e2e/pages/adf/process_services/formPage.ts | 39 +++++++ .../adf/process_services/widgets/Amount.ts | 46 ++++++++ .../adf/process_services/widgets/Date.ts | 46 ++++++++ .../adf/process_services/widgets/Number.ts | 46 ++++++++ e2e/process-services/form_component.e2e.ts | 105 ++++++++++++++++++ 6 files changed, 288 insertions(+) create mode 100644 e2e/pages/adf/process_services/formPage.ts create mode 100644 e2e/pages/adf/process_services/widgets/Amount.ts create mode 100644 e2e/pages/adf/process_services/widgets/Date.ts create mode 100644 e2e/pages/adf/process_services/widgets/Number.ts create mode 100644 e2e/process-services/form_component.e2e.ts diff --git a/e2e/pages/adf/navigationBarPage.ts b/e2e/pages/adf/navigationBarPage.ts index 5510764ba6..63bc188e02 100644 --- a/e2e/pages/adf/navigationBarPage.ts +++ b/e2e/pages/adf/navigationBarPage.ts @@ -34,6 +34,7 @@ export class NavigationBarPage { appTitle = element(by.css('.adf-app-title')); headerDataButton = element(by.css('a[data-automation-id="Header Data"]')); menuButton = element(by.css('button[data-automation-id="adf-menu-icon"]')); + formButton = element(by.css('a[data-automation-id="Form"]')); clickContentServicesButton() { Util.waitUntilElementIsVisible(this.contentServicesButton); @@ -134,6 +135,11 @@ export class NavigationBarPage { this.appTitle.click(); } + clickFormButton = function () { + Util.waitUntilElementIsVisible(this.formButton); + return this.formButton.click(); + }; + checkLogoTooltip(logoTooltip) { let logoTooltip = element(by.css('a[title="' + logoTooltip + '"]')); Util.waitUntilElementIsVisible(logoTooltip); diff --git a/e2e/pages/adf/process_services/formPage.ts b/e2e/pages/adf/process_services/formPage.ts new file mode 100644 index 0000000000..ee9acda3bb --- /dev/null +++ b/e2e/pages/adf/process_services/formPage.ts @@ -0,0 +1,39 @@ +/*! + * @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 { element, by } from 'protractor'; +import Util = require('../../../util/util'); + +export class FormPage { + + errorLog = element(by.css('div[class*="console"]')); + + checkErrorMessageForWidgetIsDisplayed(errorMessage) { + return Util.waitUntilElementIsVisible(element(by.cssContainingText('.adf-error-text', errorMessage))); + } + + checkErrorLogMessage(errorMessage) { + Util.waitUntilElementIsVisible(this.errorLog); + return Util.waitUntilElementIsVisible(element(by.cssContainingText('div[class*="console"] p', errorMessage))); + } + + checkErrorMessageIsNotDisplayed(errorMessage) { + Util.waitUntilElementIsVisible(this.errorLog); + return Util.waitUntilElementIsNotVisible(element(by.cssContainingText('div[class*="console"] p', errorMessage))); + } + +} diff --git a/e2e/pages/adf/process_services/widgets/Amount.ts b/e2e/pages/adf/process_services/widgets/Amount.ts new file mode 100644 index 0000000000..0ede82684b --- /dev/null +++ b/e2e/pages/adf/process_services/widgets/Amount.ts @@ -0,0 +1,46 @@ +/*! + * @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 { element, by, protractor } from 'protractor'; +import Util = require('../../../../util/util'); + +export class Amount { + + amountWidgetLabel11 = element(by.id('field-label11-container')); + amountWidgetInput = element(by.css('div[id="field-label11-container"] input[id="label11"]')); + + checkLabel11IsDisplayed() { + return Util.waitUntilElementIsVisible(this.amountWidgetLabel11); + } + + addIntoAmountWidget(input) { + Util.waitUntilElementIsVisible(this.amountWidgetLabel11); + this.amountWidgetInput.click(); + this.amountWidgetInput.sendKeys(input); + return this.amountWidgetInput.sendKeys(protractor.Key.ENTER); + } + + removeFromAmountWidget() { + Util.waitUntilElementIsVisible(this.amountWidgetLabel11); + + this.amountWidgetInput.getAttribute('value').then((result) => { + for (let i = result.length; i >= 0; i--) { + this.amountWidgetInput.sendKeys(protractor.Key.BACK_SPACE); + } + }); + } +} diff --git a/e2e/pages/adf/process_services/widgets/Date.ts b/e2e/pages/adf/process_services/widgets/Date.ts new file mode 100644 index 0000000000..9afc42c046 --- /dev/null +++ b/e2e/pages/adf/process_services/widgets/Date.ts @@ -0,0 +1,46 @@ +/*! + * @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 { element, by, protractor } from 'protractor'; +import Util = require('../../../../util/util'); + +export class Date { + + dateWidgetLabel7 = element(by.id('field-label7-container')); + dateWidgetInput = element(by.css('div[id="field-label7-container"] input[id="label7"]')); + + checkLabel7IsDisplayed() { + return Util.waitUntilElementIsVisible(this.dateWidgetLabel7); + } + + addIntoDateWidget(input) { + Util.waitUntilElementIsVisible(this.dateWidgetLabel7); + this.dateWidgetInput.click(); + this.dateWidgetInput.sendKeys(input); + return this.dateWidgetInput.sendKeys(protractor.Key.ENTER); + } + + removeFromDateWidget() { + Util.waitUntilElementIsVisible(this.dateWidgetLabel7); + + this.dateWidgetInput.getAttribute('value').then((result) => { + for (let i = result.length; i >= 0; i--) { + this.dateWidgetInput.sendKeys(protractor.Key.BACK_SPACE); + } + }); + } +} diff --git a/e2e/pages/adf/process_services/widgets/Number.ts b/e2e/pages/adf/process_services/widgets/Number.ts new file mode 100644 index 0000000000..84fe041052 --- /dev/null +++ b/e2e/pages/adf/process_services/widgets/Number.ts @@ -0,0 +1,46 @@ +/*! + * @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 { element, by, protractor } from 'protractor'; +import Util = require('../../../../util/util'); + +export class NumberWidget { + + numberWidgetLabel4 = element(by.id('field-label4-container')); + numberWidgetInput = element(by.css('div[id="field-label4-container"] input[id="label4"]')); + + checkLabel4IsDisplayed() { + return Util.waitUntilElementIsVisible(this.numberWidgetLabel4); + } + + addIntoNumberWidget(input) { + Util.waitUntilElementIsVisible(this.numberWidgetLabel4); + this.numberWidgetInput.click(); + this.numberWidgetInput.sendKeys(input); + return this.numberWidgetInput.sendKeys(protractor.Key.ENTER); + } + + removeFromNumberWidget() { + Util.waitUntilElementIsVisible(this.numberWidgetLabel4); + + this.numberWidgetInput.getAttribute('value').then((result) => { + for (let i = result.length; i >= 0; i--) { + this.numberWidgetInput.sendKeys(protractor.Key.BACK_SPACE); + } + }); + } +} diff --git a/e2e/process-services/form_component.e2e.ts b/e2e/process-services/form_component.e2e.ts new file mode 100644 index 0000000000..ce2b1846eb --- /dev/null +++ b/e2e/process-services/form_component.e2e.ts @@ -0,0 +1,105 @@ +/*! + * @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 } from '../pages/adf/loginPage'; +import { NavigationBarPage } from '../pages/adf/navigationBarPage'; +import { FormPage } from '../pages/adf/process_services/formPage'; +import { Date } from '../pages/adf/process_services/widgets/Date'; +import { Amount } from '../pages/adf/process_services/widgets/Amount'; +import { NumberWidget } from '../pages/adf/process_services/widgets/Number'; +import TestConfig = require('../test.config'); + +import AlfrescoApi = require('alfresco-js-api-node'); +import { UsersActions } from '../actions/users.actions'; + +describe('Form Component', () => { + + const loginPage = new LoginPage(); + const navigationBarPage = new NavigationBarPage(); + const formPage = new FormPage(); + const dateWidget = new Date(); + const amountWidget = new Amount(); + const numberWidget = new NumberWidget(); + + let tenantId, user; + + let message = { + test: 'Text Test', + warningNumberAndAmount: 'Use a different number format', + warningDate: 'D-M-YYYY', + errorLogNumber: 'Error Label4 Use a different number format', + errorLogDate: 'Error Label7 D-M-YYYY', + errorLogAmount: 'Error Label11 Use a different number format', + errorLabel: 'Error Label4' + }; + + beforeAll(async (done) => { + this.alfrescoJsApi = new AlfrescoApi({ + provider: 'BPM', + hostBpm: TestConfig.adf.url + }); + + let users = new UsersActions(); + + 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); + + await loginPage.loginToProcessServicesUsingUserModel(user); + + navigationBarPage.clickFormButton(); + + done(); + }); + + afterAll(async (done) => { + await this.alfrescoJsApi.login(TestConfig.adf.adminEmail, TestConfig.adf.adminPassword); + + await this.alfrescoJsApi.activiti.adminTenantsApi.deleteTenant(tenantId); + + done(); + }); + + it('[C286505] Should be able to display errors under the Error Log section', () => { + numberWidget.checkLabel4IsDisplayed(); + numberWidget.addIntoNumberWidget(message.test); + formPage.checkErrorMessageForWidgetIsDisplayed(message.warningNumberAndAmount); + formPage.checkErrorLogMessage(message.errorLogNumber); + + dateWidget.checkLabel7IsDisplayed(); + dateWidget.addIntoDateWidget(message.test); + formPage.checkErrorMessageForWidgetIsDisplayed(message.warningDate); + formPage.checkErrorLogMessage(message.errorLogDate); + + amountWidget.checkLabel11IsDisplayed(); + amountWidget.addIntoAmountWidget(message.test); + formPage.checkErrorMessageForWidgetIsDisplayed(message.warningNumberAndAmount); + formPage.checkErrorLogMessage(message.errorLogAmount); + + amountWidget.removeFromAmountWidget(); + formPage.checkErrorMessageIsNotDisplayed(message.errorLogAmount); + + dateWidget.removeFromDateWidget(); + numberWidget.removeFromNumberWidget(); + formPage.checkErrorMessageIsNotDisplayed(message.errorLogDate); + formPage.checkErrorLogMessage(message.errorLabel); + }); +});