adf-testing - Cloud - Move user info e2e to adf-testing (#4369)

* Move user info e2e to adf-testing

* Create testing wrapper for the api sevice
This commit is contained in:
Maurizio Vitale
2019-03-01 16:18:53 +00:00
committed by Eugenio Romano
parent 3adc569b0a
commit 249d688820
10 changed files with 302 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
/*
* Public API Surface of testing
*/
export * from './testing-alfresco-api.service';
export * from './testing-app-config.service';

View File

@@ -0,0 +1,52 @@
/*!
* @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 { AlfrescoApiCompatibility, AlfrescoApiConfig } from '@alfresco/js-api';
import { AlfrescoApiService, AppConfigValues, AppConfigService } from '@alfresco/adf-core';
export class TestingAlfrescoApiService extends AlfrescoApiService {
protected alfrescoApi: AlfrescoApiCompatibility;
config = {
};
constructor(public appConfig: AppConfigService) {
super(null, null);
let oauth = Object.assign({}, this.appConfig.get<any>(AppConfigValues.OAUTHCONFIG, null));
this.config = new AlfrescoApiConfig({
provider: this.appConfig.get<string>(AppConfigValues.PROVIDERS),
hostEcm: this.appConfig.get<string>(AppConfigValues.ECMHOST),
hostBpm: this.appConfig.get<string>(AppConfigValues.BPMHOST),
authType: this.appConfig.get<string>(AppConfigValues.AUTHTYPE, 'BASIC'),
contextRootBpm: this.appConfig.get<string>(AppConfigValues.CONTEXTROOTBPM),
contextRoot: this.appConfig.get<string>(AppConfigValues.CONTEXTROOTECM),
disableCsrf: this.appConfig.get<boolean>(AppConfigValues.DISABLECSRF),
withCredentials: this.appConfig.get<boolean>(AppConfigValues.AUTH_WITH_CREDENTIALS, false),
oauth2: oauth
});
}
getInstance(): AlfrescoApiCompatibility {
if (this.alfrescoApi) {
this.alfrescoApi.configureJsApi(this.config);
} else {
this.alfrescoApi = new AlfrescoApiCompatibility(this.config);
}
return this.alfrescoApi;
}
}

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 { AppConfigService } from '@alfresco/adf-core';
export class TestingAppConfigService extends AppConfigService {
config = {
};
constructor(config?) {
super(null);
this.config = config;
}
getLocationHostname(): string {
return '';
}
getLocationPort(prefix: string = ''): string {
return '';
}
getLocationProtocol(): string {
return '';
}
}

View File

@@ -0,0 +1,45 @@
/*!
* @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 { element, by } from 'protractor';
import { BrowserVisibility } from '../../core/browser-visibility';
export class AppListCloudPage {
apsAppsContainer = element(by.css('adf-cloud-app-list'));
checkApsContainer() {
BrowserVisibility.waitUntilElementIsVisible(this.apsAppsContainer);
}
goToApp(applicationName) {
let app = element(by.css('mat-card[title="' + applicationName + '"]'));
BrowserVisibility.waitUntilElementIsVisible(app);
app.click();
}
checkAppIsNotDisplayed(applicationName) {
let app = element(by.css('mat-card[title="' + applicationName + '"]'));
return BrowserVisibility.waitUntilElementIsNotOnPage(app);
}
checkAppIsDisplayed(applicationName) {
let app = element(by.css('mat-card[title="' + applicationName + '"]'));
return BrowserVisibility.waitUntilElementIsVisible(app);
}
}

View File

@@ -0,0 +1,59 @@
/*!
* @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 { element, by, browser, protractor } from 'protractor';
import { BrowserVisibility } from '../../core/browser-visibility';
export class LoginSSOPage {
ssoButton = element(by.css(`[data-automation-id="login-button-sso"]`));
usernameField = element(by.id('username'));
passwordField = element(by.id('password'));
loginButton = element(by.css('input[class="submit"]'));
header = element(by.id('adf-header'));
loginAPS(username, password) {
BrowserVisibility.waitUntilElementIsVisible(this.usernameField);
this.enterUsername(username);
this.enterPassword(password);
this.clickLoginButton();
browser.actions().sendKeys(protractor.Key.ENTER).perform();
return BrowserVisibility.waitUntilElementIsVisible(this.header);
}
clickOnSSOButton() {
BrowserVisibility.waitUntilElementIsVisible(this.ssoButton);
this.ssoButton.click();
}
enterUsername(username) {
BrowserVisibility.waitUntilElementIsVisible(this.usernameField);
this.usernameField.clear();
this.usernameField.sendKeys(username);
}
enterPassword(password) {
BrowserVisibility.waitUntilElementIsVisible(this.passwordField);
this.passwordField.clear();
this.passwordField.sendKeys(password);
}
clickLoginButton() {
BrowserVisibility.waitUntilElementIsVisible(this.loginButton);
return this.loginButton.click();
}
}

View File

@@ -0,0 +1,36 @@
/*!
* @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, element } from 'protractor';
import { BrowserVisibility } from '../../core/browser-visibility';
import { AppListCloudPage } from './app-list-cloud.page';
export class NavigationBarPage {
processServicesCloudButton = element(by.css('a[data-automation-id="Process Cloud"]'));
userProfileButton = element(by.css('button[data-automation-id="adf-user-profile"]'));
navigateToProcessServicesCloudPage() {
BrowserVisibility.waitUntilElementIsVisible(this.processServicesCloudButton);
this.processServicesCloudButton.click();
return new AppListCloudPage();
}
clickUserProfile() {
BrowserVisibility.waitUntilElementIsVisible(this.userProfileButton);
this.userProfileButton.click();
}
}

View File

@@ -0,0 +1,8 @@
/*
* Public API Surface of testing
*/
export * from './app-list-cloud.page';
export * from './navigation-bar.page';
export * from './login-sso.page';
export * from './user-info-dialog.page';

View File

@@ -0,0 +1,47 @@
/*!
* @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 { element, by, browser, protractor } from 'protractor';
import { BrowserVisibility } from '../../core/browser-visibility';
export class UserInfoDialogPage {
dialog = element.all(by.css('mat-card[class*="adf-userinfo-card"]')).first();
userInfoSsoHeaderTitle = this.dialog.element(by.css('div[id="identity-username"]'));
userInfoSsoTitle = element(by.css('.adf-userinfo__detail-title'));
ssoEmail = element(by.id('identity-email'));
getSsoHeaderTitle () {
BrowserVisibility.waitUntilElementIsVisible(this.userInfoSsoHeaderTitle);
return this.userInfoSsoHeaderTitle.getText();
}
getSsoTitle() {
BrowserVisibility.waitUntilElementIsVisible(this.userInfoSsoTitle);
return this.userInfoSsoTitle.getText();
}
getSsoEmail() {
BrowserVisibility.waitUntilElementIsVisible(this.ssoEmail);
return this.ssoEmail.getText();
}
closeUserProfile() {
BrowserVisibility.waitUntilElementIsVisible(this.dialog);
browser.actions().sendKeys(protractor.Key.ESCAPE).perform();
}
}

View File

@@ -0,0 +1,6 @@
/*
* Public API Surface of testing
*/
export * from './pages/public-api';
export * from './actions/public-api';

View File

@@ -5,4 +5,5 @@
export * from './lib/core/public-api';
export * from './lib/content-services/public-api';
export * from './lib/process-services/public-api';
export * from './lib/process-services-cloud/public-api';
export * from './lib/testing.module';