From 7a2af38699d10bdcd4b7829d715d6cdf395129dd Mon Sep 17 00:00:00 2001 From: Eugenio Romano Date: Mon, 2 Mar 2020 10:28:38 +0000 Subject: [PATCH] [AAE-1884] e2e shared file and refactor custom sources (#5506) * fix lint e2e shared file and refactor custom sources additional tests for search chip list (#5523) * modify wait startegy * fix metadata problem * improve method retry * login before to execute call * login before to execute call --- .../files/custom-sources.component.html | 2 +- .../create-library-directive.e2e.ts | 4 +- .../directives/favorite-directive.e2e.ts | 4 +- .../share-file/share-file.e2e.ts | 38 ++++++++++++- e2e/pages/adf/content-services.page.ts | 4 +- .../adf/demo-shell/custom-sources.page.ts | 25 +++------ e2e/pages/adf/demo-shell/data-table.page.ts | 2 +- .../process-list-demo.page.ts | 4 +- .../process-services/task-list-demo.page.ts | 2 +- e2e/pages/adf/notification.page.ts | 6 +- .../adf/process-services/attach-form.page.ts | 2 +- .../dialog/start-task-dialog.page.ts | 2 +- .../adf/process-services/task-details.page.ts | 2 +- .../src/lib/core/pages/form/form-fields.ts | 2 +- .../src/lib/core/pages/settings.page.ts | 2 +- .../src/lib/core/structure/api.util.ts | 52 +++++++++++++++++ lib/testing/src/lib/core/structure/project.ts | 4 +- .../src/lib/core/structure/public-api.ts | 2 +- lib/testing/src/lib/core/structure/utilapi.ts | 44 --------------- lib/testing/src/lib/core/utils/string.util.ts | 56 ++++++------------- .../src/lib/material/pages/dropdown.page.ts | 2 +- ...dit-process-filter-cloud-component.page.ts | 8 +-- .../edit-task-filter-cloud-component.page.ts | 8 +-- 23 files changed, 145 insertions(+), 132 deletions(-) create mode 100644 lib/testing/src/lib/core/structure/api.util.ts delete mode 100644 lib/testing/src/lib/core/structure/utilapi.ts diff --git a/demo-shell/src/app/components/files/custom-sources.component.html b/demo-shell/src/app/components/files/custom-sources.component.html index 96196a8f2b..b580d9ec68 100644 --- a/demo-shell/src/app/components/files/custom-sources.component.html +++ b/demo-shell/src/app/components/files/custom-sources.component.html @@ -1,7 +1,7 @@ - + {{ source.title }} diff --git a/e2e/content-services/directives/create-library-directive.e2e.ts b/e2e/content-services/directives/create-library-directive.e2e.ts index 015cc8fc15..ee6fc83927 100644 --- a/e2e/content-services/directives/create-library-directive.e2e.ts +++ b/e2e/content-services/directives/create-library-directive.e2e.ts @@ -18,7 +18,7 @@ import { LoginPage, BrowserActions, StringUtil } from '@alfresco/adf-testing'; import { ContentServicesPage } from '../../pages/adf/content-services.page'; import { CreateLibraryDialogPage } from '../../pages/adf/dialog/create-library-dialog.page'; -import { CustomSources } from '../../pages/adf/demo-shell/custom-sources.page'; +import { CustomSourcesPage } from '../../pages/adf/demo-shell/custom-sources.page'; import { AcsUserModel } from '../../models/ACS/acs-user.model'; import { browser } from 'protractor'; import { AlfrescoApiCompatibility as AlfrescoApi } from '@alfresco/js-api'; @@ -29,7 +29,7 @@ describe('Create library directive', () => { const loginPage = new LoginPage(); const contentServicesPage = new ContentServicesPage(); const createLibraryDialog = new CreateLibraryDialogPage(); - const customSourcesPage = new CustomSources(); + const customSourcesPage = new CustomSourcesPage(); const navigationBarPage = new NavigationBarPage(); const visibility = { diff --git a/e2e/content-services/directives/favorite-directive.e2e.ts b/e2e/content-services/directives/favorite-directive.e2e.ts index 8d537dc3d9..ec6be0e37c 100644 --- a/e2e/content-services/directives/favorite-directive.e2e.ts +++ b/e2e/content-services/directives/favorite-directive.e2e.ts @@ -23,7 +23,7 @@ import { AlfrescoApiCompatibility as AlfrescoApi } from '@alfresco/js-api'; import { browser } from 'protractor'; import { FileModel } from '../../models/ACS/file.model'; import { NavigationBarPage } from '../../pages/adf/navigation-bar.page'; -import { CustomSources } from '../../pages/adf/demo-shell/custom-sources.page'; +import { CustomSourcesPage } from '../../pages/adf/demo-shell/custom-sources.page'; import { TrashcanPage } from '../../pages/adf/trashcan.page'; describe('Favorite directive', () => { @@ -32,7 +32,7 @@ describe('Favorite directive', () => { const contentServicesPage = new ContentServicesPage(); const navigationBarPage = new NavigationBarPage(); const acsUser = new AcsUserModel(); - const customSourcesPage = new CustomSources(); + const customSourcesPage = new CustomSourcesPage(); const trashcanPage = new TrashcanPage(); const contentListPage = contentServicesPage.getDocumentList(); const contentNodeSelector = new ContentNodeSelectorDialogPage(); diff --git a/e2e/content-services/share-file/share-file.e2e.ts b/e2e/content-services/share-file/share-file.e2e.ts index e167ba890c..f54c2868d6 100644 --- a/e2e/content-services/share-file/share-file.e2e.ts +++ b/e2e/content-services/share-file/share-file.e2e.ts @@ -21,7 +21,7 @@ import { LocalStorageUtil, NotificationHistoryPage, UploadActions, - ViewerPage + ViewerPage, ApiUtil } from '@alfresco/adf-testing'; import { ContentServicesPage } from '../../pages/adf/content-services.page'; import { NavigationBarPage } from '../../pages/adf/navigation-bar.page'; @@ -29,7 +29,8 @@ import { ShareDialogPage } from '../../pages/adf/dialog/share-dialog.page'; import { AcsUserModel } from '../../models/ACS/acs-user.model'; import { FileModel } from '../../models/ACS/file.model'; import { browser } from 'protractor'; -import { AlfrescoApiCompatibility as AlfrescoApi } from '@alfresco/js-api'; +import { AlfrescoApiCompatibility as AlfrescoApi, SharedLinkEntry, SharedLinkPaging } from '@alfresco/js-api'; +import { CustomSourcesPage } from '../../pages/adf/demo-shell/custom-sources.page'; describe('Share file', () => { @@ -42,6 +43,7 @@ describe('Share file', () => { const contentListPage = contentServicesPage.getDocumentList(); const shareDialog = new ShareDialogPage(); const navigationBarPage = new NavigationBarPage(); + const customSourcesPage = new CustomSourcesPage(); const viewerPage = new ViewerPage(); const notificationHistoryPage = new NotificationHistoryPage(); const acsUser = new AcsUserModel(); @@ -53,6 +55,23 @@ describe('Share file', () => { let nodeId; + const waitForShareLink = async (nodeIdSharedFile: string) => { + const predicate = (sharedLinkPaging: SharedLinkPaging) => { + const sharedLink = sharedLinkPaging.list.entries.find((sharedLinkEntry: SharedLinkEntry) => { + return sharedLinkEntry.entry.nodeId === nodeIdSharedFile; + }); + + return sharedLink !== null; + }; + + const apiCall = async () => { + await this.alfrescoJsApi.login(acsUser.id, acsUser.password); + return this.alfrescoJsApi.core.sharedlinksApi.findSharedLinks(); + }; + + return ApiUtil.waitForApi(apiCall, predicate, 10, 2000); + }; + beforeAll(async () => { await this.alfrescoJsApi.login(browser.params.testConfig.adf.adminEmail, browser.params.testConfig.adf.adminPassword); await this.alfrescoJsApi.core.peopleApi.addPerson(acsUser); @@ -199,5 +218,20 @@ describe('Share file', () => { await BrowserActions.getUrl(sharedLink); await viewerPage.checkFileNameIsDisplayed(pngFileModel.name); }); + + it('[C260153] Should shared files listed in share files custom resources', async () => { + await contentListPage.selectRow(pngFileModel.name); + await contentServicesPage.clickShareButton(); + await shareDialog.checkDialogIsDisplayed(); + await shareDialog.clickShareLinkButton(); + + await BrowserActions.closeMenuAndDialogs(); + + await waitForShareLink(nodeId); + + await customSourcesPage.navigateToCustomSources(); + await customSourcesPage.selectSharedLinksSourceType(); + await customSourcesPage.checkRowIsDisplayed(pngFileModel.name); + }); }); }); diff --git a/e2e/pages/adf/content-services.page.ts b/e2e/pages/adf/content-services.page.ts index 6877484f64..fdf6597ad3 100644 --- a/e2e/pages/adf/content-services.page.ts +++ b/e2e/pages/adf/content-services.page.ts @@ -612,7 +612,7 @@ export class ContentServicesPage { } async selectGridSortingFromDropdown(sortingOption): Promise { - await this.sortingDropdown.clickDropdownWithOption(sortingOption); + await this.sortingDropdown.selectDropdownOption(sortingOption); } async checkRowIsDisplayed(rowName): Promise { @@ -630,7 +630,7 @@ export class ContentServicesPage { } async selectSite(siteName: string): Promise { - await this.siteListDropdown.clickDropdownWithOption(siteName); + await this.siteListDropdown.selectDropdownOption(siteName); } async clickDownloadButton(): Promise { diff --git a/e2e/pages/adf/demo-shell/custom-sources.page.ts b/e2e/pages/adf/demo-shell/custom-sources.page.ts index b16f81364c..16312e82d4 100644 --- a/e2e/pages/adf/demo-shell/custom-sources.page.ts +++ b/e2e/pages/adf/demo-shell/custom-sources.page.ts @@ -15,7 +15,7 @@ * limitations under the License. */ -import { BrowserActions, BrowserVisibility, DataTableComponentPage } from '@alfresco/adf-testing'; +import { BrowserActions, BrowserVisibility, DataTableComponentPage, DropdownPage } from '@alfresco/adf-testing'; import { by, element, ElementFinder } from 'protractor'; import { NavigationBarPage } from '../navigation-bar.page'; @@ -35,17 +35,12 @@ const column = { status: 'Status' }; -export class CustomSources { - +export class CustomSourcesPage { dataTable: DataTableComponentPage = new DataTableComponentPage(); navigationBarPage: NavigationBarPage = new NavigationBarPage(); toolbar: ElementFinder = element(by.css('app-custom-sources .adf-toolbar-title')); - sourceTypeDropdown: ElementFinder = element(by.css('div[class*="select-arrow"]>div')); - - getSourceType(option): ElementFinder { - return element(by.cssContainingText('.cdk-overlay-pane span', `${option}`)); - } + selectModeDropdown = new DropdownPage(element(by.css('mat-select[data-automation-id="custom-sources-select"]'))); async waitForToolbarToBeVisible(): Promise { await BrowserVisibility.waitUntilElementIsVisible(this.toolbar); @@ -56,18 +51,16 @@ export class CustomSources { await this.waitForToolbarToBeVisible(); } - async clickOnSourceType(): Promise { - await BrowserActions.click(this.sourceTypeDropdown); - } - async selectMySitesSourceType(): Promise { - await this.clickOnSourceType(); - await BrowserActions.click(this.getSourceType(source.mySites)); + await this.selectModeDropdown.selectDropdownOption(source.mySites); } async selectFavoritesSourceType(): Promise { - await this.clickOnSourceType(); - await BrowserActions.click(this.getSourceType(source.favorites)); + await this.selectModeDropdown.selectDropdownOption(source.favorites); + } + + async selectSharedLinksSourceType(): Promise { + await this.selectModeDropdown.selectDropdownOption(source.sharedLinks); } checkRowIsDisplayed(rowName): Promise { diff --git a/e2e/pages/adf/demo-shell/data-table.page.ts b/e2e/pages/adf/demo-shell/data-table.page.ts index eb8e612711..4139645b03 100644 --- a/e2e/pages/adf/demo-shell/data-table.page.ts +++ b/e2e/pages/adf/demo-shell/data-table.page.ts @@ -129,7 +129,7 @@ export class DataTablePage { } async selectSelectionMode(selectionMode): Promise { - await this.selectModeDropdown.clickDropdownWithOption(selectionMode); + await this.selectModeDropdown.selectDropdownOption(selectionMode); } getRowCheckbox(rowNumber: string): ElementFinder { diff --git a/e2e/pages/adf/demo-shell/process-services/process-list-demo.page.ts b/e2e/pages/adf/demo-shell/process-services/process-list-demo.page.ts index a529a075dc..ef3d7765b8 100644 --- a/e2e/pages/adf/demo-shell/process-services/process-list-demo.page.ts +++ b/e2e/pages/adf/demo-shell/process-services/process-list-demo.page.ts @@ -36,11 +36,11 @@ export class ProcessListDemoPage { } async selectSorting(sortingOption: string): Promise { - await this.sortDropdown.clickDropdownWithOption(sortingOption); + await this.sortDropdown.selectDropdownOption(sortingOption); } async selectStateFilter(stateOption: string): Promise { - await this.stateDropdown.clickDropdownWithOption(stateOption); + await this.stateDropdown.selectDropdownOption(stateOption); } async addAppId(appId): Promise { diff --git a/e2e/pages/adf/demo-shell/process-services/task-list-demo.page.ts b/e2e/pages/adf/demo-shell/process-services/task-list-demo.page.ts index fe356faf7d..09e400402a 100644 --- a/e2e/pages/adf/demo-shell/process-services/task-list-demo.page.ts +++ b/e2e/pages/adf/demo-shell/process-services/task-list-demo.page.ts @@ -139,7 +139,7 @@ export class TaskListDemoPage { } async selectState(state): Promise { - await this.stateDropdown.clickDropdownWithOption(state); + await this.stateDropdown.selectDropdownOption(state); } getAllProcessDefinitionIds(): Promise { diff --git a/e2e/pages/adf/notification.page.ts b/e2e/pages/adf/notification.page.ts index 5ae843eff4..68e400a92f 100644 --- a/e2e/pages/adf/notification.page.ts +++ b/e2e/pages/adf/notification.page.ts @@ -66,15 +66,15 @@ export class NotificationPage { } async selectHorizontalPosition(selectItem): Promise { - await this.horizontalPositionDropdown.clickDropdownWithOption(selectItem); + await this.horizontalPositionDropdown.selectDropdownOption(selectItem); } async selectVerticalPosition(selectItem): Promise { - await this.verticalPositionDropdown.clickDropdownWithOption(selectItem); + await this.verticalPositionDropdown.selectDropdownOption(selectItem); } async selectDirection(selectItem): Promise { - await this.directionDropdown.clickDropdownWithOption(selectItem); + await this.directionDropdown.selectDropdownOption(selectItem); } async clickNotificationButton(): Promise { diff --git a/e2e/pages/adf/process-services/attach-form.page.ts b/e2e/pages/adf/process-services/attach-form.page.ts index 8b54eb33f6..03caff5a82 100644 --- a/e2e/pages/adf/process-services/attach-form.page.ts +++ b/e2e/pages/adf/process-services/attach-form.page.ts @@ -58,7 +58,7 @@ export class AttachFormPage { } async selectAttachFormOption(option): Promise { - await this.attachFormDropdown.clickDropdownWithOption(option); + await this.attachFormDropdown.selectDropdownOption(option); } async clickCancelButton(): Promise { diff --git a/e2e/pages/adf/process-services/dialog/start-task-dialog.page.ts b/e2e/pages/adf/process-services/dialog/start-task-dialog.page.ts index 93eb38393d..0cdd53966a 100644 --- a/e2e/pages/adf/process-services/dialog/start-task-dialog.page.ts +++ b/e2e/pages/adf/process-services/dialog/start-task-dialog.page.ts @@ -63,7 +63,7 @@ export class StartTaskDialogPage { } async selectForm(form): Promise { - await this.selectFormDropdown.clickDropdownWithOption(form); + await this.selectFormDropdown.selectDropdownOption(form); } async clickStartButton(): Promise { diff --git a/e2e/pages/adf/process-services/task-details.page.ts b/e2e/pages/adf/process-services/task-details.page.ts index 0df6888b58..623154ba95 100644 --- a/e2e/pages/adf/process-services/task-details.page.ts +++ b/e2e/pages/adf/process-services/task-details.page.ts @@ -113,7 +113,7 @@ export class TaskDetailsPage { } async selectAttachFormOption(option): Promise { - await this.attachFormDropdown.clickDropdownWithOption(option); + await this.attachFormDropdown.selectDropdownOption(option); } async checkCancelAttachFormIsDisplayed(): Promise { diff --git a/lib/testing/src/lib/core/pages/form/form-fields.ts b/lib/testing/src/lib/core/pages/form/form-fields.ts index 7db45637d8..3b808d67c7 100644 --- a/lib/testing/src/lib/core/pages/form/form-fields.ts +++ b/lib/testing/src/lib/core/pages/form/form-fields.ts @@ -125,7 +125,7 @@ export class FormFields { } async selectForm(formName): Promise { - await this.selectFormDropdown.clickDropdownWithOption(formName); + await this.selectFormDropdown.selectDropdownOption(formName); } async selectFormFromDropDown(formName): Promise { diff --git a/lib/testing/src/lib/core/pages/settings.page.ts b/lib/testing/src/lib/core/pages/settings.page.ts index e9c27563a6..a14ddc525a 100644 --- a/lib/testing/src/lib/core/pages/settings.page.ts +++ b/lib/testing/src/lib/core/pages/settings.page.ts @@ -47,7 +47,7 @@ export class SettingsPage { } async setProvider(option): Promise { - await this.providerDropdown.clickDropdownWithOption(option); + await this.providerDropdown.selectDropdownOption(option); await this.providerDropdown.checkOptionIsSelected(option); } diff --git a/lib/testing/src/lib/core/structure/api.util.ts b/lib/testing/src/lib/core/structure/api.util.ts new file mode 100644 index 0000000000..8c4edae9db --- /dev/null +++ b/lib/testing/src/lib/core/structure/api.util.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. + */ + +/* + * Copyright 2005-2019 Alfresco Software, Ltd. All rights reserved. + * + * License rights for this program may be obtained from Alfresco Software, Ltd. + * pursuant to a written agreement and any use of this program without such an + * agreement is prohibited. + */ + +export type ApiResultPredicate = (result: T) => boolean; +export type ApiCall = () => Promise; + +export class ApiUtil { + static async waitForApi(apiCall: ApiCall, predicate: ApiResultPredicate, retry: number = 30, delay: number = 1000) { + const apiCallWithPredicateChecking = async () => { + const apiCallResult = await apiCall(); + if (predicate(apiCallResult)) { + return Promise.resolve(apiCallResult); + } else { + return Promise.reject(apiCallResult); + } + }; + + return ApiUtil.retryCall(apiCallWithPredicateChecking, retry, delay); + } + + static retryCall(fn: () => Promise, retry: number = 30, delay: number = 1000): Promise { + const pause = duration => new Promise(res => setTimeout(res, duration)); + + const run = retries => { + return fn().catch(err => (retries > 1 ? pause(delay).then(() => run(retries - 1)) : Promise.reject(err))); + }; + + return run(retry); + } +} diff --git a/lib/testing/src/lib/core/structure/project.ts b/lib/testing/src/lib/core/structure/project.ts index 4c93cae7ac..1b5b56bc7f 100644 --- a/lib/testing/src/lib/core/structure/project.ts +++ b/lib/testing/src/lib/core/structure/project.ts @@ -18,7 +18,7 @@ import { browser } from 'protractor'; import { ModelingAPI } from './modeling-api'; import { NodeEntry, ResultSetPaging } from '@alfresco/js-api'; -import { UtilApi } from './utilapi'; +import { ApiUtil } from './api.util'; import { E2eRequestApiHelper, E2eRequestApiHelperOptions } from './e2e-request-api.helper'; import * as fs from 'fs'; import { StringUtil } from '../utils/string.util'; @@ -123,7 +123,7 @@ export class Project { }; const apiCall = () => this.searchProjects(); - return UtilApi.waitForApi(apiCall, predicate); + return ApiUtil.waitForApi(apiCall, predicate); } private getRandomName(): string { diff --git a/lib/testing/src/lib/core/structure/public-api.ts b/lib/testing/src/lib/core/structure/public-api.ts index 2971e105b0..aa5e9f1846 100644 --- a/lib/testing/src/lib/core/structure/public-api.ts +++ b/lib/testing/src/lib/core/structure/public-api.ts @@ -16,6 +16,6 @@ */ export * from './api'; -export * from './utilapi'; +export * from './api.util'; export * from './deployment-api'; export * from './modeling-api'; diff --git a/lib/testing/src/lib/core/structure/utilapi.ts b/lib/testing/src/lib/core/structure/utilapi.ts deleted file mode 100644 index 161451a525..0000000000 --- a/lib/testing/src/lib/core/structure/utilapi.ts +++ /dev/null @@ -1,44 +0,0 @@ -/*! - * @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. - */ - -export type ApiResultPredicate = (result: T) => boolean; -export type ApiCall = () => Promise; - -export class UtilApi { - static async waitForApi(apiCall: ApiCall, predicate: ApiResultPredicate) { - const apiCallWithPredicateChecking = async () => { - const apiCallResult = await apiCall(); - if (predicate(apiCallResult)) { - return Promise.resolve(apiCallResult); - } else { - return Promise.reject(apiCallResult); - } - }; - - return UtilApi.retryCall(apiCallWithPredicateChecking); - } - - static retryCall(fn: () => Promise, retry: number = 30, delay: number = 1000): Promise { - const pause = (duration: number) => new Promise((res) => setTimeout(res, duration)); - - const run = (retries: number) => { - return fn().catch((err) => (retries > 1 ? pause(delay).then(() => run(retries - 1)) : Promise.reject(err))); - }; - - return run(retry); - } -} diff --git a/lib/testing/src/lib/core/utils/string.util.ts b/lib/testing/src/lib/core/utils/string.util.ts index 6ce0c5b50d..2c7abdcab7 100644 --- a/lib/testing/src/lib/core/utils/string.util.ts +++ b/lib/testing/src/lib/core/utils/string.util.ts @@ -19,17 +19,9 @@ export class StringUtil { static generatePasswordString(length: number = 8): string { let text = ''; - const possibleUpperCase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; - const possibleLowerCase = 'abcdefghijklmnopqrstuvwxyz'; const lowerCaseLimit = Math.floor(length / 2); - - for (let i = 0; i < lowerCaseLimit; i++) { - text += possibleLowerCase.charAt(Math.floor(Math.random() * possibleLowerCase.length)); - } - - for (let i = 0; i < length - lowerCaseLimit; i++) { - text += possibleUpperCase.charAt(Math.floor(Math.random() * possibleUpperCase.length)); - } + text += StringUtil.generateRandomCharset(lowerCaseLimit, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'); + text += StringUtil.generateRandomCharset(length - lowerCaseLimit, 'abcdefghijklmnopqrstuvwxyz'); return text; } @@ -38,17 +30,9 @@ export class StringUtil { * Generates a random string. * * @param length If this parameter is not provided the length is set to 8 by default. - * @method generateRandomString */ static generateRandomString(length: number = 8): string { - let text = ''; - const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - - for (let i = 0; i < length; i++) { - text += possible.charAt(Math.floor(Math.random() * possible.length)); - } - - return text; + return StringUtil.generateRandomCharset(length, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'); } /** @@ -56,16 +40,9 @@ export class StringUtil { * * @param domain * @param length - * @method generateRandomEmail */ static generateRandomEmail(domain: string, length: number = 5): string { - let email = ''; - const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; - - for (let i = 0; i < length; i++) { - email += possible.charAt(Math.floor(Math.random() * possible.length)); - } - + let email = StringUtil.generateRandomCharset(length, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'); email += domain; return email.toLowerCase(); } @@ -74,33 +51,34 @@ export class StringUtil { * Generates a random string - digits only. * * @param length {int} If this parameter is not provided the length is set to 8 by default. - * @method generateRandomString */ static generateRandomStringDigits(length: number = 8): string { - let text = ''; - const possible = '0123456789'; - - for (let i = 0; i < length; i++) { - text += possible.charAt(Math.floor(Math.random() * possible.length)); - } - - return text; + return StringUtil.generateRandomCharset(length, '0123456789'); } /** * Generates a random string - non-latin characters only. * * @param length {int} If this parameter is not provided the length is set to 3 by default. - * @method generateRandomString */ static generateRandomStringNonLatin(length: number = 3): string { + return StringUtil.generateRandomCharset(length, '密码你好𠮷'); + } + + /** + * Generates a random string. + * + * @param length If this parameter is not provided the length is set to 8 by default. + * @param charSet to use + */ + static generateRandomCharset(length: number = 8, charSet: string): string { let text = ''; - const possible = '密码你好𠮷'; for (let i = 0; i < length; i++) { - text += possible.charAt(Math.floor(Math.random() * possible.length)); + text += charSet.charAt(Math.floor(Math.random() * charSet.length)); } return text; } + } diff --git a/lib/testing/src/lib/material/pages/dropdown.page.ts b/lib/testing/src/lib/material/pages/dropdown.page.ts index f3ffaad946..114972da50 100644 --- a/lib/testing/src/lib/material/pages/dropdown.page.ts +++ b/lib/testing/src/lib/material/pages/dropdown.page.ts @@ -80,7 +80,7 @@ export class DropdownPage { await BrowserVisibility.waitUntilElementIsNotVisible(element(by.cssContainingText('mat-option span.mat-option-text', option))); } - async clickDropdownWithOption(option: string): Promise { + async selectDropdownOption(option: string): Promise { await this.clickDropdown(); await this.selectOption(option); } diff --git a/lib/testing/src/lib/process-services-cloud/pages/edit-process-filter-cloud-component.page.ts b/lib/testing/src/lib/process-services-cloud/pages/edit-process-filter-cloud-component.page.ts index 8643050fd8..9c4e2d595d 100644 --- a/lib/testing/src/lib/process-services-cloud/pages/edit-process-filter-cloud-component.page.ts +++ b/lib/testing/src/lib/process-services-cloud/pages/edit-process-filter-cloud-component.page.ts @@ -61,7 +61,7 @@ export class EditProcessFilterCloudComponentPage { } async setStatusFilterDropDown(option: string): Promise { - await this.statusDropdown.clickDropdownWithOption(option); + await this.statusDropdown.selectDropdownOption(option); } async getStateFilterDropDownValue(): Promise { @@ -69,7 +69,7 @@ export class EditProcessFilterCloudComponentPage { } async setSortFilterDropDown(option): Promise { - await this.sortDropdown.clickDropdownWithOption(option); + await this.sortDropdown.selectDropdownOption(option); } async getSortFilterDropDownValue(): Promise { @@ -78,7 +78,7 @@ export class EditProcessFilterCloudComponentPage { } async setOrderFilterDropDown(option): Promise { - await this.orderDropdown.clickDropdownWithOption(option); + await this.orderDropdown.selectDropdownOption(option); await browser.sleep(1500); } @@ -87,7 +87,7 @@ export class EditProcessFilterCloudComponentPage { } async setAppNameDropDown(option: string): Promise { - await this.appNameDropdown.clickDropdownWithOption(option); + await this.appNameDropdown.selectDropdownOption(option); } async getApplicationSelected(): Promise { diff --git a/lib/testing/src/lib/process-services-cloud/pages/edit-task-filter-cloud-component.page.ts b/lib/testing/src/lib/process-services-cloud/pages/edit-task-filter-cloud-component.page.ts index b8aac8487d..ed0d8ff742 100644 --- a/lib/testing/src/lib/process-services-cloud/pages/edit-task-filter-cloud-component.page.ts +++ b/lib/testing/src/lib/process-services-cloud/pages/edit-task-filter-cloud-component.page.ts @@ -65,7 +65,7 @@ export class EditTaskFilterCloudComponentPage { } async setStatusFilterDropDown(option: string): Promise { - await this.statusDropdown.clickDropdownWithOption(option); + await this.statusDropdown.selectDropdownOption(option); } async getStatusFilterDropDownValue(): Promise { @@ -73,7 +73,7 @@ export class EditTaskFilterCloudComponentPage { } async setSortFilterDropDown(option: string): Promise { - await this.sortDropdown.clickDropdownWithOption(option); + await this.sortDropdown.selectDropdownOption(option); } async getSortFilterDropDownValue(): Promise { @@ -81,7 +81,7 @@ export class EditTaskFilterCloudComponentPage { } async setOrderFilterDropDown(option: string): Promise { - await this.orderDropdown.clickDropdownWithOption(option); + await this.orderDropdown.selectDropdownOption(option); await browser.sleep(1500); } @@ -193,7 +193,7 @@ export class EditTaskFilterCloudComponentPage { } async setAppNameDropDown(option: string): Promise { - await this.appNameDropdown.clickDropdownWithOption(option); + await this.appNameDropdown.selectDropdownOption(option); } async getAppNameDropDownValue(): Promise {