mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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
This commit is contained in:
@@ -125,7 +125,7 @@ export class FormFields {
|
||||
}
|
||||
|
||||
async selectForm(formName): Promise<void> {
|
||||
await this.selectFormDropdown.clickDropdownWithOption(formName);
|
||||
await this.selectFormDropdown.selectDropdownOption(formName);
|
||||
}
|
||||
|
||||
async selectFormFromDropDown(formName): Promise<void> {
|
||||
|
@@ -47,7 +47,7 @@ export class SettingsPage {
|
||||
}
|
||||
|
||||
async setProvider(option): Promise<void> {
|
||||
await this.providerDropdown.clickDropdownWithOption(option);
|
||||
await this.providerDropdown.selectDropdownOption(option);
|
||||
await this.providerDropdown.checkOptionIsSelected(option);
|
||||
}
|
||||
|
||||
|
52
lib/testing/src/lib/core/structure/api.util.ts
Normal file
52
lib/testing/src/lib/core/structure/api.util.ts
Normal 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* 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<T> = (result: T) => boolean;
|
||||
export type ApiCall<T> = () => Promise<T>;
|
||||
|
||||
export class ApiUtil {
|
||||
static async waitForApi<T>(apiCall: ApiCall<T>, predicate: ApiResultPredicate<T>, 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<any>, retry: number = 30, delay: number = 1000): Promise<any> {
|
||||
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);
|
||||
}
|
||||
}
|
@@ -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 {
|
||||
|
@@ -16,6 +16,6 @@
|
||||
*/
|
||||
|
||||
export * from './api';
|
||||
export * from './utilapi';
|
||||
export * from './api.util';
|
||||
export * from './deployment-api';
|
||||
export * from './modeling-api';
|
||||
|
@@ -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<T> = (result: T) => boolean;
|
||||
export type ApiCall<T> = () => Promise<T>;
|
||||
|
||||
export class UtilApi {
|
||||
static async waitForApi<T>(apiCall: ApiCall<T>, predicate: ApiResultPredicate<T>) {
|
||||
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<any>, retry: number = 30, delay: number = 1000): Promise<any> {
|
||||
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);
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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<void> {
|
||||
async selectDropdownOption(option: string): Promise<void> {
|
||||
await this.clickDropdown();
|
||||
await this.selectOption(option);
|
||||
}
|
||||
|
@@ -61,7 +61,7 @@ export class EditProcessFilterCloudComponentPage {
|
||||
}
|
||||
|
||||
async setStatusFilterDropDown(option: string): Promise<void> {
|
||||
await this.statusDropdown.clickDropdownWithOption(option);
|
||||
await this.statusDropdown.selectDropdownOption(option);
|
||||
}
|
||||
|
||||
async getStateFilterDropDownValue(): Promise<string> {
|
||||
@@ -69,7 +69,7 @@ export class EditProcessFilterCloudComponentPage {
|
||||
}
|
||||
|
||||
async setSortFilterDropDown(option): Promise<void> {
|
||||
await this.sortDropdown.clickDropdownWithOption(option);
|
||||
await this.sortDropdown.selectDropdownOption(option);
|
||||
}
|
||||
|
||||
async getSortFilterDropDownValue(): Promise<string> {
|
||||
@@ -78,7 +78,7 @@ export class EditProcessFilterCloudComponentPage {
|
||||
}
|
||||
|
||||
async setOrderFilterDropDown(option): Promise<void> {
|
||||
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<void> {
|
||||
await this.appNameDropdown.clickDropdownWithOption(option);
|
||||
await this.appNameDropdown.selectDropdownOption(option);
|
||||
}
|
||||
|
||||
async getApplicationSelected(): Promise<string> {
|
||||
|
@@ -65,7 +65,7 @@ export class EditTaskFilterCloudComponentPage {
|
||||
}
|
||||
|
||||
async setStatusFilterDropDown(option: string): Promise<void> {
|
||||
await this.statusDropdown.clickDropdownWithOption(option);
|
||||
await this.statusDropdown.selectDropdownOption(option);
|
||||
}
|
||||
|
||||
async getStatusFilterDropDownValue(): Promise<string> {
|
||||
@@ -73,7 +73,7 @@ export class EditTaskFilterCloudComponentPage {
|
||||
}
|
||||
|
||||
async setSortFilterDropDown(option: string): Promise<void> {
|
||||
await this.sortDropdown.clickDropdownWithOption(option);
|
||||
await this.sortDropdown.selectDropdownOption(option);
|
||||
}
|
||||
|
||||
async getSortFilterDropDownValue(): Promise<string> {
|
||||
@@ -81,7 +81,7 @@ export class EditTaskFilterCloudComponentPage {
|
||||
}
|
||||
|
||||
async setOrderFilterDropDown(option: string): Promise<void> {
|
||||
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<void> {
|
||||
await this.appNameDropdown.clickDropdownWithOption(option);
|
||||
await this.appNameDropdown.selectDropdownOption(option);
|
||||
}
|
||||
|
||||
async getAppNameDropDownValue(): Promise<string> {
|
||||
|
Reference in New Issue
Block a user