diff --git a/e2e/core/settings-component.e2e.ts b/e2e/core/settings-component.e2e.ts new file mode 100644 index 0000000000..cae576d2ae --- /dev/null +++ b/e2e/core/settings-component.e2e.ts @@ -0,0 +1,238 @@ +/*! + * @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 { SettingsPage } from '../pages/adf/settingsPage'; +import { browser, protractor } from 'protractor'; +import { AcsUserModel } from '../models/ACS/acsUserModel'; +import { NavigationBarPage } from '../pages/adf/navigationBarPage'; +import { ProcessServicesPage } from '../pages/adf/process-services/processServicesPage'; +import { ContentServicesPage } from '../pages/adf/contentServicesPage'; +import TestConfig = require('../test.config'); + +describe('Settings component', () => { + + const loginPage = new LoginPage(); + const settingsPage = new SettingsPage(); + const navigationBarPage = new NavigationBarPage(); + const processServicesPage = new ProcessServicesPage(); + const contentServicesPage = new ContentServicesPage(); + const loginError = 'Request has been terminated ' + + 'Possible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.'; + + let adminUserModel = new AcsUserModel({ + 'id': TestConfig.adf.adminUser, + 'password': TestConfig.adf.adminPassword + }); + + describe('Should be able to change Urls in the Settings', () => { + beforeEach( (done) => { + settingsPage.goToSettingsPage(); + done(); + }); + + it('[C245641] Should navigate User from Settings page to Login screen', () => { + settingsPage.clickBackButton(); + loginPage.waitForElements(); + }); + + it('[C291946] Should not save BPM Settings changes when User clicks Back button', () => { + settingsPage.setProvider(settingsPage.getBpmOption(), 'BPM'); + settingsPage.setProcessServicesURL('http://adfdev.envalfresco1.com'); + settingsPage.clickBackButton(); + loginPage.waitForElements(); + settingsPage.goToSettingsPage(); + expect(settingsPage.getSelectedOptionText()).not.toEqual('BPM', 'The Settings changes are saved'); + expect(settingsPage.getBpmHostUrl()).not.toEqual('http://adfdev.envalfresco1.com', 'The Settings changes are saved'); + + }); + + it('[C291947] Should not save ECM Settings changes when User clicks Back button', () => { + settingsPage.setProvider(settingsPage.getEcmOption(), 'ECM'); + settingsPage.setContentServicesURL('http://adfdev.envalfresco1.com'); + settingsPage.clickBackButton(); + loginPage.waitForElements(); + settingsPage.goToSettingsPage(); + expect(settingsPage.getSelectedOptionText()).not.toEqual('ECM', 'The Settings changes are saved'); + expect(settingsPage.getBpmHostUrl()).not.toEqual('http://adfdev.envalfresco1.com', 'The Settings changes are saved'); + + }); + + it('[C291948] Should save ALL Settings changes when User clicks Apply button', () => { + settingsPage.setProviderEcmBpm(); + loginPage.waitForElements(); + settingsPage.goToSettingsPage(); + expect(settingsPage.getSelectedOptionText()).toEqual('ALL', 'The Settings changes are not saved'); + expect(settingsPage.getBpmHostUrl()).toEqual(TestConfig.adf.url, 'The BPM Settings changes are not saved'); + expect(settingsPage.getEcmHostUrl()).toEqual(TestConfig.adf.url, 'The ECM Settings changes are not saved'); + + }); + + it('[C291949] Should have field validation for Content Services Url', () => { + settingsPage.setProvider(settingsPage.getEcmAndBpmOption(), 'ALL'); + settingsPage.clearContentServicesURL(); + settingsPage.ecmText.sendKeys(protractor.Key.TAB); + settingsPage.checkValidationMessageIsDisplayed(); + settingsPage.checkApplyButtonIsDisabled(); + }); + + it('[C291950] Should have field validation for Process Services Url', () => { + settingsPage.setProvider(settingsPage.getEcmAndBpmOption(), 'ALL'); + settingsPage.clearProcessServicesURL(); + settingsPage.bpmText.sendKeys(protractor.Key.TAB); + settingsPage.checkValidationMessageIsDisplayed(); + settingsPage.checkApplyButtonIsDisabled(); + }); + + it('[C291951] Should not be able to sign in with invalid Content Services Url', () => { + settingsPage.setProvider(settingsPage.getEcmOption(), 'ECM'); + settingsPage.setContentServicesURL('http://localhost:7070'); + settingsPage.clickApply(); + loginPage.waitForElements(); + loginPage.enterUsername(adminUserModel.id); + loginPage.enterPassword(adminUserModel.password); + loginPage.clickSignInButton(); + expect(loginPage.getLoginError()).toMatch(loginError); + }); + + it('[C291952] Should not be able to sign in with invalid Process Services Url', () => { + settingsPage.setProvider(settingsPage.getBpmOption(), 'BPM'); + settingsPage.setProcessServicesURL('http://localhost:7070'); + settingsPage.clickApply(); + loginPage.waitForElements(); + loginPage.enterUsername(adminUserModel.id); + loginPage.enterPassword(adminUserModel.password); + loginPage.clickSignInButton(); + expect(loginPage.getLoginError()).toMatch(loginError); + }); + }); + + describe('Settings Component - Basic Authentication', () => { + beforeAll( (done) => { + settingsPage.goToSettingsPage(); + settingsPage.setProvider(settingsPage.getEcmAndBpmOption(), 'ALL'); + settingsPage.setContentServicesURL(TestConfig.adf.url); + settingsPage.setProcessServicesURL(TestConfig.adf.url); + settingsPage.clickApply(); + done(); + }); + + beforeEach( (done) => { + loginPage.goToLoginPage(); + loginPage.clickSettingsIcon(); + settingsPage.checkProviderDropdownIsDisplayed(); + done(); + }); + + it('[C277751] Should allow the User to login to Process Services using the BPM selection on Settings page', () => { + settingsPage.checkProviderOptions(); + settingsPage.checkBasicAuthRadioIsSelected(); + settingsPage.checkSsoRadioIsNotSelected(); + expect(settingsPage.getEcmHostUrl()).toBe(TestConfig.adf.url); + expect(settingsPage.getBpmHostUrl()).toBe(TestConfig.adf.url); + expect(settingsPage.getBackButton().isEnabled()).toBe(true); + expect(settingsPage.getApplyButton().isEnabled()).toBe(true); + loginPage.goToLoginPage(); + loginPage.clickSettingsIcon(); + settingsPage.checkProviderDropdownIsDisplayed(); + settingsPage.setProvider(settingsPage.getBpmOption(), 'BPM'); + settingsPage.clickBackButton(); + loginPage.waitForElements(); + loginPage.clickSettingsIcon(); + settingsPage.checkProviderDropdownIsDisplayed(); + settingsPage.setProviderBpm(); + loginPage.waitForElements(); + loginPage.enterUsername(adminUserModel.id); + loginPage.enterPassword(adminUserModel.password); + loginPage.clickSignInButton(); + navigationBarPage.navigateToProcessServicesPage(); + processServicesPage.checkApsContainer(); + processServicesPage.checkAppIsDisplayed('Task App'); + navigationBarPage.navigateToSettingsPage(); + expect(settingsPage.getSelectedOptionText()).toBe('BPM'); + settingsPage.checkBasicAuthRadioIsSelected(); + settingsPage.checkSsoRadioIsNotSelected(); + expect(settingsPage.getBpmHostUrl()).toBe(TestConfig.adf.url); + expect(settingsPage.getBackButton().isEnabled()).toBe(true); + expect(settingsPage.getApplyButton().isEnabled()).toBe(true); + settingsPage.clickBackButton(); + loginPage.waitForElements(); + browser.get(TestConfig.adf.url + '/activiti'); + processServicesPage.checkApsContainer(); + processServicesPage.checkAppIsDisplayed('Task App'); + }); + + it('[C277752] Should allow the User to login to Content Services using the ECM selection on Settings page', () => { + settingsPage.setProvider(settingsPage.getEcmOption(), 'ECM'); + settingsPage.clickBackButton(); + loginPage.waitForElements(); + loginPage.clickSettingsIcon(); + settingsPage.checkProviderDropdownIsDisplayed(); + settingsPage.setProviderEcm(); + loginPage.waitForElements(); + loginPage.enterUsername(adminUserModel.id); + loginPage.enterPassword(adminUserModel.password); + loginPage.clickSignInButton(); + navigationBarPage.clickContentServicesButton(); + contentServicesPage.checkAcsContainer(); + navigationBarPage.navigateToSettingsPage(); + expect(settingsPage.getSelectedOptionText()).toBe('ECM'); + settingsPage.checkBasicAuthRadioIsSelected(); + settingsPage.checkSsoRadioIsNotSelected(); + expect(settingsPage.getEcmHostUrl()).toBe(TestConfig.adf.url); + expect(settingsPage.getBackButton().isEnabled()).toBe(true); + expect(settingsPage.getApplyButton().isEnabled()).toBe(true); + settingsPage.clickBackButton(); + loginPage.waitForElements(); + browser.get(TestConfig.adf.url + '/files'); + contentServicesPage.checkAcsContainer(); + }); + + it('[C277753] Should allow the User to login to both Process Services and Content Services using the ALL selection on Settings Page', () => { + settingsPage.setProvider(settingsPage.getEcmAndBpmOption(), 'ALL'); + settingsPage.clickBackButton(); + loginPage.waitForElements(); + loginPage.clickSettingsIcon(); + settingsPage.checkProviderDropdownIsDisplayed(); + settingsPage.setProviderEcmBpm(); + loginPage.waitForElements(); + loginPage.enterUsername(adminUserModel.id); + loginPage.enterPassword(adminUserModel.password); + loginPage.clickSignInButton(); + navigationBarPage.clickContentServicesButton(); + contentServicesPage.checkAcsContainer(); + navigationBarPage.navigateToProcessServicesPage(); + processServicesPage.checkApsContainer(); + processServicesPage.checkAppIsDisplayed('Task App'); + navigationBarPage.navigateToSettingsPage(); + expect(settingsPage.getSelectedOptionText()).toBe('ALL'); + settingsPage.checkBasicAuthRadioIsSelected(); + settingsPage.checkSsoRadioIsNotSelected(); + expect(settingsPage.getEcmHostUrl()).toBe(TestConfig.adf.url); + expect(settingsPage.getBpmHostUrl()).toBe(TestConfig.adf.url); + expect(settingsPage.getBackButton().isEnabled()).toBe(true); + expect(settingsPage.getApplyButton().isEnabled()).toBe(true); + settingsPage.clickBackButton(); + loginPage.waitForElements(); + browser.get(TestConfig.adf.url + '/files'); + contentServicesPage.checkAcsContainer(); + browser.get(TestConfig.adf.url + '/activiti'); + processServicesPage.checkApsContainer(); + processServicesPage.checkAppIsDisplayed('Task App'); + }); + }); +}); diff --git a/e2e/pages/adf/loginPage.ts b/e2e/pages/adf/loginPage.ts index 39a3a2cae4..44e806fe90 100644 --- a/e2e/pages/adf/loginPage.ts +++ b/e2e/pages/adf/loginPage.ts @@ -18,9 +18,9 @@ import { FormControllersPage } from './material/formControllersPage'; import { Util } from '../../util/util'; -import TestConfig = require('../../test.config'); import { SettingsPage } from './settingsPage'; -import { element, by, protractor, browser } from 'protractor'; +import { browser, by, element, protractor } from 'protractor'; +import TestConfig = require('../../test.config'); export class LoginPage { @@ -50,6 +50,7 @@ export class LoginPage { logoSwitch = element(by.id('adf-toggle-logo')); header = element(by.id('adf-header')); settingsPage = new SettingsPage(); + settingsIcon = element(by.cssContainingText('a[data-automation-id="settings"] mat-icon', 'settings')); waitForElements() { Util.waitUntilElementIsVisible(this.txtUsername); @@ -171,6 +172,11 @@ export class LoginPage { this.signInButton.click(); } + clickSettingsIcon() { + Util.waitUntilElementIsVisible(this.settingsIcon); + this.settingsIcon.click(); + } + showPassword() { Util.waitUntilElementIsVisible(this.showPasswordElement); this.showPasswordElement.click(); diff --git a/e2e/pages/adf/navigationBarPage.ts b/e2e/pages/adf/navigationBarPage.ts index d025d7939d..b3b3454156 100644 --- a/e2e/pages/adf/navigationBarPage.ts +++ b/e2e/pages/adf/navigationBarPage.ts @@ -16,10 +16,10 @@ */ import { Util } from '../../util/util'; -import TestConfig = require('../../test.config'); -import { element, by, browser } from 'protractor'; +import { browser, by, element } from 'protractor'; import { ProcessServicesPage } from './process-services/processServicesPage'; import { AppListCloudComponent } from './process-cloud/appListCloudComponent'; +import TestConfig = require('../../test.config'); export class NavigationBarPage { @@ -45,6 +45,7 @@ export class NavigationBarPage { treeViewButton = element(by.css('a[data-automation-id="Tree View"]')); iconsButton = element(by.css('a[data-automation-id="Icons"]')); customSourcesButton = element(by.css('a[data-automation-id="Custom Sources"]')); + settingsButton = element(by.css('a[data-automation-id="Settings"]')); navigateToDatatable() { Util.waitUntilElementIsVisible(this.dataTableButton); @@ -78,6 +79,12 @@ export class NavigationBarPage { return new AppListCloudComponent(); } + navigateToSettingsPage() { + Util.waitUntilElementIsVisible(this.settingsButton); + this.settingsButton.click(); + return new AppListCloudComponent(); + } + clickLoginButton() { Util.waitUntilElementIsVisible(this.loginButton); this.loginButton.click(); diff --git a/e2e/pages/adf/settingsPage.ts b/e2e/pages/adf/settingsPage.ts index 80ff995bc5..3d489e10d9 100644 --- a/e2e/pages/adf/settingsPage.ts +++ b/e2e/pages/adf/settingsPage.ts @@ -17,7 +17,7 @@ import TestConfig = require('../../test.config'); import { Util } from '../../util/util'; -import { element, by, browser } from 'protractor'; +import { browser, by, element, protractor } from 'protractor'; export class SettingsPage { @@ -39,16 +39,19 @@ export class SettingsPage { option: element(by.xpath('//SPAN[@class="mat-option-text"][contains(text(),"OAUTH")]')), text: 'OAUTH' }; - selectedOption = element.all(by.css('span[class*="ng-star-inserted"]')).first(); + selectedOption = element(by.css('span[class*="mat-select-value-text"]')); ecmText = element(by.css('input[data-automation-id*="ecmHost"]')); bpmText = element(by.css('input[data-automation-id*="bpmHost"]')); authHostText = element(by.css('input[id="oauthHost"]')); - ssoRadioButton = element(by.cssContainingText('[id*="mat-radio"]', 'SSO')); + ssoRadioButton = element(by.cssContainingText('mat-radio-button[id*="mat-radio"]', 'SSO')); + basicAuthRadioButton = element(by.cssContainingText('mat-radio-button[id*="mat-radio"]', 'Basic Authentication')); silentLoginToggleLabel = element(by.css('mat-slide-toggle[name="silentLogin"] label')); silentLoginToggleElement = element(by.css('mat-slide-toggle[name="silentLogin"]')); implicitFlowLabel = element(by.css('mat-slide-toggle[name="implicitFlow"] label')); implicitFlowElement = element(by.css('mat-slide-toggle[name="implicitFlow"]')); applyButton = element(by.css('button[data-automation-id*="host-button"]')); + backButton = element(by.cssContainingText('button span[class="mat-button-wrapper"]', 'Back')); + validationMessage = element(by.cssContainingText('mat-error', 'This field is required')); goToSettingsPage() { browser.waitForAngularEnabled(true); @@ -65,6 +68,30 @@ export class SettingsPage { return expect(this.selectedOption.getText()).toEqual(selected); } + getSelectedOptionText() { + return this.selectedOption.getText(); + } + + getBpmHostUrl() { + return this.bpmText.getAttribute('value'); + } + + getEcmHostUrl() { + return this.ecmText.getAttribute('value'); + } + + getBpmOption() { + return this.bpm.option; + } + + getEcmOption() { + return this.ecm.option; + } + + getEcmAndBpmOption() { + return this.ecmAndBpm.option; + } + setProviderEcmBpm() { this.goToSettingsPage(); this.setProvider(this.ecmAndBpm.option, this.ecmAndBpm.text); @@ -101,6 +128,11 @@ export class SettingsPage { return this; } + async clickBackButton() { + Util.waitUntilElementIsVisible(this.backButton); + await this.backButton.click(); + } + async clickSsoRadioButton () { Util.waitUntilElementIsVisible(this.ssoRadioButton); await this.ssoRadioButton.click(); @@ -121,8 +153,28 @@ export class SettingsPage { async setProcessServicesURL (processServiceURL) { Util.waitUntilElementIsVisible(this.bpmText); - await this.bpmText.clear(); - await this.bpmText.sendKeys(processServiceURL); + this.bpmText.clear(); + this.bpmText.sendKeys(processServiceURL); + } + + async setContentServicesURL (contentServiceURL) { + Util.waitUntilElementIsClickable(this.ecmText); + this.ecmText.clear(); + this.ecmText.sendKeys(contentServiceURL); + } + + clearContentServicesURL () { + Util.waitUntilElementIsVisible(this.ecmText); + this.ecmText.clear(); + this.ecmText.sendKeys('a'); + this.ecmText.sendKeys(protractor.Key.BACK_SPACE); + } + + clearProcessServicesURL () { + Util.waitUntilElementIsVisible(this.bpmText); + this.bpmText.clear(); + this.bpmText.sendKeys('a'); + this.bpmText.sendKeys(protractor.Key.BACK_SPACE); } async setAuthHost (authHostURL) { @@ -160,7 +212,52 @@ export class SettingsPage { return Promise.resolve(); } + checkApplyButtonIsDisabled() { + Util.waitUntilElementIsVisible(this.applyButton.getAttribute('disabled')); + return this; + } + checkProviderDropdownIsDisplayed() { Util.waitUntilElementIsVisible(this.providerDropdown); } + + checkValidationMessageIsDisplayed() { + Util.waitUntilElementIsVisible(this.validationMessage); + } + + checkProviderOptions() { + Util.waitUntilElementIsVisible(this.providerDropdown); + this.providerDropdown.click(); + Util.waitUntilElementIsVisible(this.ecmAndBpm.option); + Util.waitUntilElementIsVisible(this.ecm.option); + Util.waitUntilElementIsVisible(this.bpm.option); + } + + getBasicAuthRadioButton() { + Util.waitUntilElementIsVisible(this.basicAuthRadioButton); + return this.basicAuthRadioButton; + } + + getSsoRadioButton() { + Util.waitUntilElementIsVisible(this.ssoRadioButton); + return this.ssoRadioButton; + } + + getBackButton() { + Util.waitUntilElementIsVisible(this.backButton); + return this.backButton; + } + + getApplyButton() { + Util.waitUntilElementIsVisible(this.applyButton); + return this.applyButton; + } + + checkBasicAuthRadioIsSelected() { + expect(this.getBasicAuthRadioButton().getAttribute('class')).toContain('mat-radio-checked'); + } + + checkSsoRadioIsNotSelected() { + expect(this.getSsoRadioButton().getAttribute('class')).not.toContain('mat-radio-checked'); + } }