Exporting base login page (#4483)

* Exporting base login page for e2e tests

* fixed exporting and renamed pages as per standards

* Added base login page to testing package

* Fixed wrong import for the setting page

* Removed old pages and using the one in the adf-testing package

* fix after merge conflict

* fix base url param
This commit is contained in:
Vito
2019-04-02 23:44:36 +01:00
committed by Eugenio Romano
parent 1b65555e18
commit 3f2af4cc03
135 changed files with 182 additions and 195 deletions

View File

@@ -0,0 +1,42 @@
/*!
* @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 { by } from 'protractor';
import { BrowserVisibility } from '../browser-visibility';
export class FormControllersPage {
enableToggle(toggle) {
BrowserVisibility.waitUntilElementIsVisible(toggle);
toggle.getAttribute('class').then((check) => {
if (check.indexOf('mat-checked') < 0) {
BrowserVisibility.waitUntilElementIsClickable(toggle.all(by.css('div')).first());
toggle.all(by.css('div')).first().click();
}
});
}
disableToggle(toggle) {
BrowserVisibility.waitUntilElementIsVisible(toggle);
toggle.getAttribute('class').then((check) => {
if (check.indexOf('mat-checked') >= 0) {
BrowserVisibility.waitUntilElementIsClickable(toggle.all(by.css('div')).first());
toggle.all(by.css('div')).first().click();
}
});
}
}

View File

@@ -0,0 +1,283 @@
/*!
* @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 { FormControllersPage } from './form-controller.page';
import { browser, by, element, protractor } from 'protractor';
import { BrowserVisibility } from '../browser-visibility';
import { SettingsPage } from './settings.page';
export class LoginPage {
formControllersPage = new FormControllersPage();
txtUsername = element(by.css('input[id="username"]'));
txtPassword = element(by.css('input[id="password"]'));
logoImg = element(by.css('img[id="adf-login-img-logo"]'));
successRouteTxt = element(
by.css('input[data-automation-id="adf-success-route"]')
);
logoTxt = element(by.css('input[data-automation-id="adf-url-logo"]'));
usernameTooltip = element(
by.css('span[data-automation-id="username-error"]')
);
passwordTooltip = element(
by.css('span[data-automation-id="password-required"]')
);
loginTooltip = element(by.css('span[class="adf-login-error-message"]'));
usernameInactive = element(
by.css('input[id="username"][aria-invalid="false"]')
);
passwordInactive = element(
by.css('input[id="password"][aria-invalid="false"]')
);
adfLogo = element(by.css('img[class="adf-img-logo ng-star-inserted"]'));
usernameHighlighted = element(
by.css('input[id="username"][aria-invalid="true"]')
);
passwordHighlighted = element(
by.css('input[id="password"][aria-invalid="true"]')
);
signInButton = element(by.id('login-button'));
showPasswordElement = element(
by.css('mat-icon[data-automation-id="show_password"]')
);
hidePasswordElement = element(
by.css('mat-icon[data-automation-id="hide_password"]')
);
rememberMe = element(by.css('mat-checkbox[id="adf-login-remember"]'));
needHelp = element(by.css('div[id="adf-login-action-left"]'));
register = element(by.css('div[id="adf-login-action-right"]'));
footerSwitch = element(by.id('switch4'));
rememberMeSwitch = element(by.id('adf-toggle-show-rememberme'));
successRouteSwitch = element(by.id('adf-toggle-show-successRoute'));
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() {
BrowserVisibility.waitUntilElementIsVisible(this.txtUsername);
BrowserVisibility.waitUntilElementIsVisible(this.txtPassword);
return this;
}
enterUsername(username) {
BrowserVisibility.waitUntilElementIsVisible(this.txtUsername);
this.txtUsername.sendKeys('');
this.txtUsername.clear();
return this.txtUsername.sendKeys(username);
}
enterPassword(password) {
BrowserVisibility.waitUntilElementIsVisible(this.txtPassword);
this.txtPassword.clear();
return this.txtPassword.sendKeys(password);
}
clearUsername() {
BrowserVisibility.waitUntilElementIsVisible(this.txtUsername);
this.txtUsername.click();
this.txtUsername.getAttribute('value').then((value) => {
for (let i = value.length; i >= 0; i--) {
this.txtUsername.sendKeys(protractor.Key.BACK_SPACE);
}
});
return this;
}
clearPassword() {
BrowserVisibility.waitUntilElementIsVisible(this.txtPassword);
this.txtPassword.getAttribute('value').then((value) => {
for (let i = value.length; i >= 0; i--) {
this.txtPassword.sendKeys(protractor.Key.BACK_SPACE);
}
});
}
getUsernameTooltip() {
BrowserVisibility.waitUntilElementIsVisible(this.usernameTooltip);
return this.usernameTooltip.getText();
}
getPasswordTooltip() {
BrowserVisibility.waitUntilElementIsVisible(this.passwordTooltip);
return this.passwordTooltip.getText();
}
getLoginError() {
BrowserVisibility.waitUntilElementIsVisible(this.loginTooltip);
return this.loginTooltip.getText();
}
checkLoginImgURL() {
BrowserVisibility.waitUntilElementIsVisible(this.logoImg);
return this.logoImg.getAttribute('src');
}
checkUsernameInactive() {
BrowserVisibility.waitUntilElementIsVisible(this.usernameInactive);
}
checkPasswordInactive() {
BrowserVisibility.waitUntilElementIsVisible(this.passwordInactive);
}
checkUsernameHighlighted() {
this.adfLogo.click();
BrowserVisibility.waitUntilElementIsVisible(this.usernameHighlighted);
}
checkPasswordHighlighted() {
this.adfLogo.click();
BrowserVisibility.waitUntilElementIsVisible(this.passwordHighlighted);
}
checkUsernameTooltipIsNotVisible() {
BrowserVisibility.waitUntilElementIsNotVisible(this.usernameTooltip);
}
checkPasswordTooltipIsNotVisible() {
BrowserVisibility.waitUntilElementIsNotVisible(this.passwordTooltip);
}
getSignInButtonIsEnabled() {
BrowserVisibility.waitUntilElementIsVisible(this.signInButton);
return this.signInButton.isEnabled();
}
loginToProcessServicesUsingUserModel(userModel) {
this.settingsPage.setProviderBpm();
this.waitForElements();
this.login(userModel.email, userModel.password);
}
loginToContentServicesUsingUserModel(userModel) {
this.settingsPage.setProviderEcm();
this.waitForElements();
this.login(userModel.getId(), userModel.getPassword());
}
loginToContentServices(username, password) {
this.settingsPage.setProviderEcm();
this.waitForElements();
this.login(username, password);
}
goToLoginPage() {
browser.waitForAngularEnabled(true);
browser.driver.get(browser.baseUrl + '/login');
this.waitForElements();
}
clickSignInButton() {
BrowserVisibility.waitUntilElementIsVisible(this.signInButton);
this.signInButton.click();
}
clickSettingsIcon() {
BrowserVisibility.waitUntilElementIsVisible(this.settingsIcon);
this.settingsIcon.click();
}
showPassword() {
BrowserVisibility.waitUntilElementIsVisible(this.showPasswordElement);
this.showPasswordElement.click();
}
hidePassword() {
BrowserVisibility.waitUntilElementIsVisible(this.hidePasswordElement);
this.hidePasswordElement.click();
}
getShownPassword() {
return this.txtPassword.getAttribute('value');
}
checkPasswordIsHidden() {
BrowserVisibility.waitUntilElementIsVisible(this.txtPassword);
}
checkRememberIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.rememberMe);
}
checkRememberIsNotDisplayed() {
BrowserVisibility.waitUntilElementIsNotVisible(this.rememberMe);
}
checkNeedHelpIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.needHelp);
}
checkNeedHelpIsNotDisplayed() {
BrowserVisibility.waitUntilElementIsNotVisible(this.needHelp);
}
checkRegisterDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.register);
}
checkRegisterIsNotDisplayed() {
BrowserVisibility.waitUntilElementIsNotVisible(this.register);
}
enableFooter() {
this.formControllersPage.enableToggle(this.footerSwitch);
}
disableFooter() {
this.formControllersPage.disableToggle(this.footerSwitch);
}
disableRememberMe() {
this.formControllersPage.disableToggle(this.rememberMeSwitch);
}
enableSuccessRouteSwitch() {
this.formControllersPage.enableToggle(this.successRouteSwitch);
}
enableLogoSwitch() {
this.formControllersPage.enableToggle(this.logoSwitch);
}
enterSuccessRoute(route) {
BrowserVisibility.waitUntilElementIsVisible(this.successRouteTxt);
this.successRouteTxt.sendKeys('');
this.successRouteTxt.clear();
return this.successRouteTxt.sendKeys(route);
}
enterLogo(logo) {
BrowserVisibility.waitUntilElementIsVisible(this.logoTxt);
this.logoTxt.sendKeys('');
this.logoTxt.clear();
return this.logoTxt.sendKeys(logo);
}
login(username, password) {
this.waitForElements();
this.enterUsername(username);
this.enterPassword(password);
this.clickSignInButton();
return BrowserVisibility.waitUntilElementIsVisible(this.header);
}
}

View File

@@ -17,5 +17,8 @@
export * from './header.page';
export * from './user-info.page';
export * from './login.page';
export * from './settings.page';
export * from './form-controller.page';
export * from './login-sso.page';
export * from './data-table-component.page';

View File

@@ -0,0 +1,301 @@
/*!
* @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 { browser, by, element, protractor } from 'protractor';
import { BrowserVisibility } from '../browser-visibility';
export class SettingsPage {
settingsURL = browser.baseUrl + '/settings';
providerDropdown = element(by.css('mat-select[id="adf-provider-selector"] div[class="mat-select-arrow-wrapper"]'));
ecmAndBpm = {
option: element(by.xpath('//SPAN[@class="mat-option-text"][contains(text(),"ALL")]')),
text: 'ALL'
};
bpm = {
option: element(by.xpath('//SPAN[@class="mat-option-text"][contains(text(),"BPM") and not (contains(text(),"and"))]')),
text: 'BPM'
};
ecm = {
option: element(by.xpath('//SPAN[@class="mat-option-text"][contains(text(),"ECM") and not (contains(text(),"and"))]')),
text: 'ECM'
};
oauth = {
option: element(by.xpath('//SPAN[@class="mat-option-text"][contains(text(),"OAUTH")]')),
text: 'OAUTH'
};
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"]'));
clientIdText = element(by.css('input[id="clientId"]'));
authHostText = element(by.css('input[id="oauthHost"]'));
logoutUrlText = element(by.css('input[id="logout-url"]'));
basicAuthRadioButton = element(by.cssContainingText('mat-radio-button[id*="mat-radio"]', 'Basic Authentication'));
identityHostText = element(by.css('input[id="identityHost"]'));
ssoRadioButton = element(by.cssContainingText('[id*="mat-radio"]', 'SSO'));
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);
browser.driver.get(this.settingsURL);
BrowserVisibility.waitUntilElementIsVisible(this.providerDropdown);
return this;
}
setProvider(option, selected) {
BrowserVisibility.waitUntilElementIsVisible(this.providerDropdown);
this.providerDropdown.click();
BrowserVisibility.waitUntilElementIsVisible(option);
option.click();
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);
BrowserVisibility.waitUntilElementIsVisible(this.bpmText);
BrowserVisibility.waitUntilElementIsVisible(this.ecmText);
this.clickApply();
return this;
}
setProviderBpm() {
this.goToSettingsPage();
this.setProvider(this.bpm.option, this.bpm.text);
BrowserVisibility.waitUntilElementIsVisible(this.bpmText);
this.clickApply();
return this;
}
setProviderEcm() {
this.goToSettingsPage();
this.setProvider(this.ecm.option, this.ecm.text);
BrowserVisibility.waitUntilElementIsVisible(this.ecmText);
expect(this.bpmText.isPresent()).toBeFalsy();
this.clickApply();
return this;
}
setProviderOauth() {
this.goToSettingsPage();
this.setProvider(this.oauth.option, this.oauth.text);
BrowserVisibility.waitUntilElementIsVisible(this.bpmText);
BrowserVisibility.waitUntilElementIsVisible(this.ecmText);
expect(this.authHostText.isPresent()).toBeTruthy();
this.clickApply();
return this;
}
async clickBackButton() {
BrowserVisibility.waitUntilElementIsVisible(this.backButton);
await this.backButton.click();
}
async clickSsoRadioButton() {
BrowserVisibility.waitUntilElementIsVisible(this.ssoRadioButton);
await this.ssoRadioButton.click();
}
async setProviderEcmSso(contentServiceURL, authHost, identityHost, silentLogin = true, implicitFlow = true, clientId?: string, logoutUr: string = '/logout') {
this.goToSettingsPage();
this.setProvider(this.ecm.option, this.ecm.text);
BrowserVisibility.waitUntilElementIsNotOnPage(this.bpmText);
BrowserVisibility.waitUntilElementIsVisible(this.ecmText);
await this.clickSsoRadioButton();
await this.setClientId(clientId);
await this.setContentServicesURL(contentServiceURL);
await this.setAuthHost(authHost);
await this.setIdentityHost(identityHost);
await this.setSilentLogin(silentLogin);
await this.setImplicitFlow(implicitFlow);
await this.setLogoutUrl(logoutUr);
await this.clickApply();
}
async setProviderBpmSso(processServiceURL, authHost, identityHost, silentLogin = true, implicitFlow = true) {
this.goToSettingsPage();
this.setProvider(this.bpm.option, this.bpm.text);
BrowserVisibility.waitUntilElementIsVisible(this.bpmText);
BrowserVisibility.waitUntilElementIsNotOnPage(this.ecmText);
await this.clickSsoRadioButton();
await this.setClientId();
await this.setProcessServicesURL(processServiceURL);
await this.setAuthHost(authHost);
await this.setIdentityHost(identityHost);
await this.setSilentLogin(silentLogin);
await this.setImplicitFlow(implicitFlow);
await this.clickApply();
}
async setLogoutUrl(logoutUrl) {
BrowserVisibility.waitUntilElementIsPresent(this.logoutUrlText);
this.logoutUrlText.clear();
this.logoutUrlText.sendKeys(logoutUrl);
}
async setProcessServicesURL(processServiceURL) {
BrowserVisibility.waitUntilElementIsVisible(this.bpmText);
this.bpmText.clear();
this.bpmText.sendKeys(processServiceURL);
}
async setClientId(clientId: string = browser.params.config.oauth2.clientId) {
BrowserVisibility.waitUntilElementIsVisible(this.clientIdText);
this.clientIdText.clear();
this.clientIdText.sendKeys(clientId);
}
async setContentServicesURL(contentServiceURL) {
BrowserVisibility.waitUntilElementIsClickable(this.ecmText);
this.ecmText.clear();
this.ecmText.sendKeys(contentServiceURL);
}
clearContentServicesURL() {
BrowserVisibility.waitUntilElementIsVisible(this.ecmText);
this.ecmText.clear();
this.ecmText.sendKeys('a');
this.ecmText.sendKeys(protractor.Key.BACK_SPACE);
}
clearProcessServicesURL() {
BrowserVisibility.waitUntilElementIsVisible(this.bpmText);
this.bpmText.clear();
this.bpmText.sendKeys('a');
this.bpmText.sendKeys(protractor.Key.BACK_SPACE);
}
async setAuthHost(authHostURL) {
BrowserVisibility.waitUntilElementIsVisible(this.authHostText);
await this.authHostText.clear();
await this.authHostText.sendKeys(authHostURL);
}
async setIdentityHost(identityHost) {
BrowserVisibility.waitUntilElementIsVisible(this.identityHostText);
await this.identityHostText.clear();
await this.identityHostText.sendKeys(identityHost);
}
async clickApply() {
BrowserVisibility.waitUntilElementIsVisible(this.applyButton);
await this.applyButton.click();
}
async setSilentLogin(enableToggle) {
await BrowserVisibility.waitUntilElementIsVisible(this.silentLoginToggleElement);
const isChecked = (await this.silentLoginToggleElement.getAttribute('class')).includes('mat-checked');
if (isChecked && !enableToggle || !isChecked && enableToggle) {
return this.silentLoginToggleLabel.click();
}
return Promise.resolve();
}
async setImplicitFlow(enableToggle) {
await BrowserVisibility.waitUntilElementIsVisible(this.implicitFlowElement);
const isChecked = (await this.implicitFlowElement.getAttribute('class')).includes('mat-checked');
if (isChecked && !enableToggle || !isChecked && enableToggle) {
return this.implicitFlowLabel.click();
}
return Promise.resolve();
}
checkApplyButtonIsDisabled() {
BrowserVisibility.waitUntilElementIsVisible(this.applyButton.getAttribute('disabled'));
return this;
}
checkProviderDropdownIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.providerDropdown);
}
checkValidationMessageIsDisplayed() {
BrowserVisibility.waitUntilElementIsVisible(this.validationMessage);
}
checkProviderOptions() {
BrowserVisibility.waitUntilElementIsVisible(this.providerDropdown);
this.providerDropdown.click();
BrowserVisibility.waitUntilElementIsVisible(this.ecmAndBpm.option);
BrowserVisibility.waitUntilElementIsVisible(this.ecm.option);
BrowserVisibility.waitUntilElementIsVisible(this.bpm.option);
}
getBasicAuthRadioButton() {
BrowserVisibility.waitUntilElementIsVisible(this.basicAuthRadioButton);
return this.basicAuthRadioButton;
}
getSsoRadioButton() {
BrowserVisibility.waitUntilElementIsVisible(this.ssoRadioButton);
return this.ssoRadioButton;
}
getBackButton() {
BrowserVisibility.waitUntilElementIsVisible(this.backButton);
return this.backButton;
}
getApplyButton() {
BrowserVisibility.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');
}
}