From 249d68882037089d0f2b183decec14da0e6fef05 Mon Sep 17 00:00:00 2001 From: Maurizio Vitale Date: Fri, 1 Mar 2019 16:18:53 +0000 Subject: [PATCH] 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 --- .../actions/public-api.ts | 6 ++ .../actions/testing-alfresco-api.service.ts | 52 ++++++++++++++++ .../actions/testing-app-config.service.ts | 42 +++++++++++++ .../pages/app-list-cloud.page.ts | 45 ++++++++++++++ .../pages/login-sso.page.ts | 59 +++++++++++++++++++ .../pages/navigation-bar.page.ts | 36 +++++++++++ .../pages/public-api.ts | 8 +++ .../pages/user-info-dialog.page.ts | 47 +++++++++++++++ .../lib/process-services-cloud/public-api.ts | 6 ++ lib/testing/src/public-api.ts | 1 + 10 files changed, 302 insertions(+) create mode 100644 lib/testing/src/lib/process-services-cloud/actions/public-api.ts create mode 100644 lib/testing/src/lib/process-services-cloud/actions/testing-alfresco-api.service.ts create mode 100644 lib/testing/src/lib/process-services-cloud/actions/testing-app-config.service.ts create mode 100644 lib/testing/src/lib/process-services-cloud/pages/app-list-cloud.page.ts create mode 100644 lib/testing/src/lib/process-services-cloud/pages/login-sso.page.ts create mode 100644 lib/testing/src/lib/process-services-cloud/pages/navigation-bar.page.ts create mode 100644 lib/testing/src/lib/process-services-cloud/pages/public-api.ts create mode 100644 lib/testing/src/lib/process-services-cloud/pages/user-info-dialog.page.ts create mode 100644 lib/testing/src/lib/process-services-cloud/public-api.ts diff --git a/lib/testing/src/lib/process-services-cloud/actions/public-api.ts b/lib/testing/src/lib/process-services-cloud/actions/public-api.ts new file mode 100644 index 0000000000..b55db50921 --- /dev/null +++ b/lib/testing/src/lib/process-services-cloud/actions/public-api.ts @@ -0,0 +1,6 @@ +/* + * Public API Surface of testing + */ + +export * from './testing-alfresco-api.service'; +export * from './testing-app-config.service'; diff --git a/lib/testing/src/lib/process-services-cloud/actions/testing-alfresco-api.service.ts b/lib/testing/src/lib/process-services-cloud/actions/testing-alfresco-api.service.ts new file mode 100644 index 0000000000..62bf797a4d --- /dev/null +++ b/lib/testing/src/lib/process-services-cloud/actions/testing-alfresco-api.service.ts @@ -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(AppConfigValues.OAUTHCONFIG, null)); + this.config = new AlfrescoApiConfig({ + provider: this.appConfig.get(AppConfigValues.PROVIDERS), + hostEcm: this.appConfig.get(AppConfigValues.ECMHOST), + hostBpm: this.appConfig.get(AppConfigValues.BPMHOST), + authType: this.appConfig.get(AppConfigValues.AUTHTYPE, 'BASIC'), + contextRootBpm: this.appConfig.get(AppConfigValues.CONTEXTROOTBPM), + contextRoot: this.appConfig.get(AppConfigValues.CONTEXTROOTECM), + disableCsrf: this.appConfig.get(AppConfigValues.DISABLECSRF), + withCredentials: this.appConfig.get(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; + } +} diff --git a/lib/testing/src/lib/process-services-cloud/actions/testing-app-config.service.ts b/lib/testing/src/lib/process-services-cloud/actions/testing-app-config.service.ts new file mode 100644 index 0000000000..436af00168 --- /dev/null +++ b/lib/testing/src/lib/process-services-cloud/actions/testing-app-config.service.ts @@ -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 ''; + } + +} diff --git a/lib/testing/src/lib/process-services-cloud/pages/app-list-cloud.page.ts b/lib/testing/src/lib/process-services-cloud/pages/app-list-cloud.page.ts new file mode 100644 index 0000000000..41efdbbd92 --- /dev/null +++ b/lib/testing/src/lib/process-services-cloud/pages/app-list-cloud.page.ts @@ -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); + } + +} diff --git a/lib/testing/src/lib/process-services-cloud/pages/login-sso.page.ts b/lib/testing/src/lib/process-services-cloud/pages/login-sso.page.ts new file mode 100644 index 0000000000..f638b81d8f --- /dev/null +++ b/lib/testing/src/lib/process-services-cloud/pages/login-sso.page.ts @@ -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(); + } + +} diff --git a/lib/testing/src/lib/process-services-cloud/pages/navigation-bar.page.ts b/lib/testing/src/lib/process-services-cloud/pages/navigation-bar.page.ts new file mode 100644 index 0000000000..145209c20d --- /dev/null +++ b/lib/testing/src/lib/process-services-cloud/pages/navigation-bar.page.ts @@ -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(); + } +} diff --git a/lib/testing/src/lib/process-services-cloud/pages/public-api.ts b/lib/testing/src/lib/process-services-cloud/pages/public-api.ts new file mode 100644 index 0000000000..ef0c0640d4 --- /dev/null +++ b/lib/testing/src/lib/process-services-cloud/pages/public-api.ts @@ -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'; diff --git a/lib/testing/src/lib/process-services-cloud/pages/user-info-dialog.page.ts b/lib/testing/src/lib/process-services-cloud/pages/user-info-dialog.page.ts new file mode 100644 index 0000000000..7819a7d2e7 --- /dev/null +++ b/lib/testing/src/lib/process-services-cloud/pages/user-info-dialog.page.ts @@ -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(); + } +} diff --git a/lib/testing/src/lib/process-services-cloud/public-api.ts b/lib/testing/src/lib/process-services-cloud/public-api.ts new file mode 100644 index 0000000000..dcc70fb91a --- /dev/null +++ b/lib/testing/src/lib/process-services-cloud/public-api.ts @@ -0,0 +1,6 @@ +/* + * Public API Surface of testing + */ + +export * from './pages/public-api'; +export * from './actions/public-api'; diff --git a/lib/testing/src/public-api.ts b/lib/testing/src/public-api.ts index f064dd3d68..b3cc1140a0 100644 --- a/lib/testing/src/public-api.ts +++ b/lib/testing/src/public-api.ts @@ -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';