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:
@@ -1,7 +1,7 @@
|
|||||||
<adf-toolbar>
|
<adf-toolbar>
|
||||||
<adf-toolbar-title>
|
<adf-toolbar-title>
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<mat-select [(ngModel)]="selectedSource">
|
<mat-select [(ngModel)]="selectedSource" data-automation-id="custom-sources-select">
|
||||||
<mat-option *ngFor="let source of sources" [value]="source.value">
|
<mat-option *ngFor="let source of sources" [value]="source.value">
|
||||||
{{ source.title }}
|
{{ source.title }}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
import { LoginPage, BrowserActions, StringUtil } from '@alfresco/adf-testing';
|
import { LoginPage, BrowserActions, StringUtil } from '@alfresco/adf-testing';
|
||||||
import { ContentServicesPage } from '../../pages/adf/content-services.page';
|
import { ContentServicesPage } from '../../pages/adf/content-services.page';
|
||||||
import { CreateLibraryDialogPage } from '../../pages/adf/dialog/create-library-dialog.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 { AcsUserModel } from '../../models/ACS/acs-user.model';
|
||||||
import { browser } from 'protractor';
|
import { browser } from 'protractor';
|
||||||
import { AlfrescoApiCompatibility as AlfrescoApi } from '@alfresco/js-api';
|
import { AlfrescoApiCompatibility as AlfrescoApi } from '@alfresco/js-api';
|
||||||
@@ -29,7 +29,7 @@ describe('Create library directive', () => {
|
|||||||
const loginPage = new LoginPage();
|
const loginPage = new LoginPage();
|
||||||
const contentServicesPage = new ContentServicesPage();
|
const contentServicesPage = new ContentServicesPage();
|
||||||
const createLibraryDialog = new CreateLibraryDialogPage();
|
const createLibraryDialog = new CreateLibraryDialogPage();
|
||||||
const customSourcesPage = new CustomSources();
|
const customSourcesPage = new CustomSourcesPage();
|
||||||
const navigationBarPage = new NavigationBarPage();
|
const navigationBarPage = new NavigationBarPage();
|
||||||
|
|
||||||
const visibility = {
|
const visibility = {
|
||||||
|
@@ -23,7 +23,7 @@ import { AlfrescoApiCompatibility as AlfrescoApi } from '@alfresco/js-api';
|
|||||||
import { browser } from 'protractor';
|
import { browser } from 'protractor';
|
||||||
import { FileModel } from '../../models/ACS/file.model';
|
import { FileModel } from '../../models/ACS/file.model';
|
||||||
import { NavigationBarPage } from '../../pages/adf/navigation-bar.page';
|
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';
|
import { TrashcanPage } from '../../pages/adf/trashcan.page';
|
||||||
|
|
||||||
describe('Favorite directive', () => {
|
describe('Favorite directive', () => {
|
||||||
@@ -32,7 +32,7 @@ describe('Favorite directive', () => {
|
|||||||
const contentServicesPage = new ContentServicesPage();
|
const contentServicesPage = new ContentServicesPage();
|
||||||
const navigationBarPage = new NavigationBarPage();
|
const navigationBarPage = new NavigationBarPage();
|
||||||
const acsUser = new AcsUserModel();
|
const acsUser = new AcsUserModel();
|
||||||
const customSourcesPage = new CustomSources();
|
const customSourcesPage = new CustomSourcesPage();
|
||||||
const trashcanPage = new TrashcanPage();
|
const trashcanPage = new TrashcanPage();
|
||||||
const contentListPage = contentServicesPage.getDocumentList();
|
const contentListPage = contentServicesPage.getDocumentList();
|
||||||
const contentNodeSelector = new ContentNodeSelectorDialogPage();
|
const contentNodeSelector = new ContentNodeSelectorDialogPage();
|
||||||
|
@@ -21,7 +21,7 @@ import {
|
|||||||
LocalStorageUtil,
|
LocalStorageUtil,
|
||||||
NotificationHistoryPage,
|
NotificationHistoryPage,
|
||||||
UploadActions,
|
UploadActions,
|
||||||
ViewerPage
|
ViewerPage, ApiUtil
|
||||||
} from '@alfresco/adf-testing';
|
} from '@alfresco/adf-testing';
|
||||||
import { ContentServicesPage } from '../../pages/adf/content-services.page';
|
import { ContentServicesPage } from '../../pages/adf/content-services.page';
|
||||||
import { NavigationBarPage } from '../../pages/adf/navigation-bar.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 { AcsUserModel } from '../../models/ACS/acs-user.model';
|
||||||
import { FileModel } from '../../models/ACS/file.model';
|
import { FileModel } from '../../models/ACS/file.model';
|
||||||
import { browser } from 'protractor';
|
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', () => {
|
describe('Share file', () => {
|
||||||
|
|
||||||
@@ -42,6 +43,7 @@ describe('Share file', () => {
|
|||||||
const contentListPage = contentServicesPage.getDocumentList();
|
const contentListPage = contentServicesPage.getDocumentList();
|
||||||
const shareDialog = new ShareDialogPage();
|
const shareDialog = new ShareDialogPage();
|
||||||
const navigationBarPage = new NavigationBarPage();
|
const navigationBarPage = new NavigationBarPage();
|
||||||
|
const customSourcesPage = new CustomSourcesPage();
|
||||||
const viewerPage = new ViewerPage();
|
const viewerPage = new ViewerPage();
|
||||||
const notificationHistoryPage = new NotificationHistoryPage();
|
const notificationHistoryPage = new NotificationHistoryPage();
|
||||||
const acsUser = new AcsUserModel();
|
const acsUser = new AcsUserModel();
|
||||||
@@ -53,6 +55,23 @@ describe('Share file', () => {
|
|||||||
|
|
||||||
let nodeId;
|
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 () => {
|
beforeAll(async () => {
|
||||||
await this.alfrescoJsApi.login(browser.params.testConfig.adf.adminEmail, browser.params.testConfig.adf.adminPassword);
|
await this.alfrescoJsApi.login(browser.params.testConfig.adf.adminEmail, browser.params.testConfig.adf.adminPassword);
|
||||||
await this.alfrescoJsApi.core.peopleApi.addPerson(acsUser);
|
await this.alfrescoJsApi.core.peopleApi.addPerson(acsUser);
|
||||||
@@ -199,5 +218,20 @@ describe('Share file', () => {
|
|||||||
await BrowserActions.getUrl(sharedLink);
|
await BrowserActions.getUrl(sharedLink);
|
||||||
await viewerPage.checkFileNameIsDisplayed(pngFileModel.name);
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -612,7 +612,7 @@ export class ContentServicesPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async selectGridSortingFromDropdown(sortingOption): Promise<void> {
|
async selectGridSortingFromDropdown(sortingOption): Promise<void> {
|
||||||
await this.sortingDropdown.clickDropdownWithOption(sortingOption);
|
await this.sortingDropdown.selectDropdownOption(sortingOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
async checkRowIsDisplayed(rowName): Promise<void> {
|
async checkRowIsDisplayed(rowName): Promise<void> {
|
||||||
@@ -630,7 +630,7 @@ export class ContentServicesPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async selectSite(siteName: string): Promise<void> {
|
async selectSite(siteName: string): Promise<void> {
|
||||||
await this.siteListDropdown.clickDropdownWithOption(siteName);
|
await this.siteListDropdown.selectDropdownOption(siteName);
|
||||||
}
|
}
|
||||||
|
|
||||||
async clickDownloadButton(): Promise<void> {
|
async clickDownloadButton(): Promise<void> {
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* limitations under the License.
|
* 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 { by, element, ElementFinder } from 'protractor';
|
||||||
import { NavigationBarPage } from '../navigation-bar.page';
|
import { NavigationBarPage } from '../navigation-bar.page';
|
||||||
|
|
||||||
@@ -35,17 +35,12 @@ const column = {
|
|||||||
status: 'Status'
|
status: 'Status'
|
||||||
};
|
};
|
||||||
|
|
||||||
export class CustomSources {
|
export class CustomSourcesPage {
|
||||||
|
|
||||||
dataTable: DataTableComponentPage = new DataTableComponentPage();
|
dataTable: DataTableComponentPage = new DataTableComponentPage();
|
||||||
navigationBarPage: NavigationBarPage = new NavigationBarPage();
|
navigationBarPage: NavigationBarPage = new NavigationBarPage();
|
||||||
|
|
||||||
toolbar: ElementFinder = element(by.css('app-custom-sources .adf-toolbar-title'));
|
toolbar: ElementFinder = element(by.css('app-custom-sources .adf-toolbar-title'));
|
||||||
sourceTypeDropdown: ElementFinder = element(by.css('div[class*="select-arrow"]>div'));
|
selectModeDropdown = new DropdownPage(element(by.css('mat-select[data-automation-id="custom-sources-select"]')));
|
||||||
|
|
||||||
getSourceType(option): ElementFinder {
|
|
||||||
return element(by.cssContainingText('.cdk-overlay-pane span', `${option}`));
|
|
||||||
}
|
|
||||||
|
|
||||||
async waitForToolbarToBeVisible(): Promise<void> {
|
async waitForToolbarToBeVisible(): Promise<void> {
|
||||||
await BrowserVisibility.waitUntilElementIsVisible(this.toolbar);
|
await BrowserVisibility.waitUntilElementIsVisible(this.toolbar);
|
||||||
@@ -56,18 +51,16 @@ export class CustomSources {
|
|||||||
await this.waitForToolbarToBeVisible();
|
await this.waitForToolbarToBeVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
async clickOnSourceType(): Promise<void> {
|
|
||||||
await BrowserActions.click(this.sourceTypeDropdown);
|
|
||||||
}
|
|
||||||
|
|
||||||
async selectMySitesSourceType(): Promise<void> {
|
async selectMySitesSourceType(): Promise<void> {
|
||||||
await this.clickOnSourceType();
|
await this.selectModeDropdown.selectDropdownOption(source.mySites);
|
||||||
await BrowserActions.click(this.getSourceType(source.mySites));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async selectFavoritesSourceType(): Promise<void> {
|
async selectFavoritesSourceType(): Promise<void> {
|
||||||
await this.clickOnSourceType();
|
await this.selectModeDropdown.selectDropdownOption(source.favorites);
|
||||||
await BrowserActions.click(this.getSourceType(source.favorites));
|
}
|
||||||
|
|
||||||
|
async selectSharedLinksSourceType(): Promise<void> {
|
||||||
|
await this.selectModeDropdown.selectDropdownOption(source.sharedLinks);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkRowIsDisplayed(rowName): Promise<void> {
|
checkRowIsDisplayed(rowName): Promise<void> {
|
||||||
|
@@ -129,7 +129,7 @@ export class DataTablePage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async selectSelectionMode(selectionMode): Promise<void> {
|
async selectSelectionMode(selectionMode): Promise<void> {
|
||||||
await this.selectModeDropdown.clickDropdownWithOption(selectionMode);
|
await this.selectModeDropdown.selectDropdownOption(selectionMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
getRowCheckbox(rowNumber: string): ElementFinder {
|
getRowCheckbox(rowNumber: string): ElementFinder {
|
||||||
|
@@ -36,11 +36,11 @@ export class ProcessListDemoPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async selectSorting(sortingOption: string): Promise<void> {
|
async selectSorting(sortingOption: string): Promise<void> {
|
||||||
await this.sortDropdown.clickDropdownWithOption(sortingOption);
|
await this.sortDropdown.selectDropdownOption(sortingOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
async selectStateFilter(stateOption: string): Promise<void> {
|
async selectStateFilter(stateOption: string): Promise<void> {
|
||||||
await this.stateDropdown.clickDropdownWithOption(stateOption);
|
await this.stateDropdown.selectDropdownOption(stateOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
async addAppId(appId): Promise<void> {
|
async addAppId(appId): Promise<void> {
|
||||||
|
@@ -139,7 +139,7 @@ export class TaskListDemoPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async selectState(state): Promise<void> {
|
async selectState(state): Promise<void> {
|
||||||
await this.stateDropdown.clickDropdownWithOption(state);
|
await this.stateDropdown.selectDropdownOption(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAllProcessDefinitionIds(): Promise<any> {
|
getAllProcessDefinitionIds(): Promise<any> {
|
||||||
|
@@ -66,15 +66,15 @@ export class NotificationPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async selectHorizontalPosition(selectItem): Promise<void> {
|
async selectHorizontalPosition(selectItem): Promise<void> {
|
||||||
await this.horizontalPositionDropdown.clickDropdownWithOption(selectItem);
|
await this.horizontalPositionDropdown.selectDropdownOption(selectItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
async selectVerticalPosition(selectItem): Promise<void> {
|
async selectVerticalPosition(selectItem): Promise<void> {
|
||||||
await this.verticalPositionDropdown.clickDropdownWithOption(selectItem);
|
await this.verticalPositionDropdown.selectDropdownOption(selectItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
async selectDirection(selectItem): Promise<void> {
|
async selectDirection(selectItem): Promise<void> {
|
||||||
await this.directionDropdown.clickDropdownWithOption(selectItem);
|
await this.directionDropdown.selectDropdownOption(selectItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
async clickNotificationButton(): Promise<void> {
|
async clickNotificationButton(): Promise<void> {
|
||||||
|
@@ -58,7 +58,7 @@ export class AttachFormPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async selectAttachFormOption(option): Promise<void> {
|
async selectAttachFormOption(option): Promise<void> {
|
||||||
await this.attachFormDropdown.clickDropdownWithOption(option);
|
await this.attachFormDropdown.selectDropdownOption(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
async clickCancelButton(): Promise<void> {
|
async clickCancelButton(): Promise<void> {
|
||||||
|
@@ -63,7 +63,7 @@ export class StartTaskDialogPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async selectForm(form): Promise<void> {
|
async selectForm(form): Promise<void> {
|
||||||
await this.selectFormDropdown.clickDropdownWithOption(form);
|
await this.selectFormDropdown.selectDropdownOption(form);
|
||||||
}
|
}
|
||||||
|
|
||||||
async clickStartButton(): Promise<void> {
|
async clickStartButton(): Promise<void> {
|
||||||
|
@@ -113,7 +113,7 @@ export class TaskDetailsPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async selectAttachFormOption(option): Promise<void> {
|
async selectAttachFormOption(option): Promise<void> {
|
||||||
await this.attachFormDropdown.clickDropdownWithOption(option);
|
await this.attachFormDropdown.selectDropdownOption(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
async checkCancelAttachFormIsDisplayed(): Promise<void> {
|
async checkCancelAttachFormIsDisplayed(): Promise<void> {
|
||||||
|
@@ -125,7 +125,7 @@ export class FormFields {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async selectForm(formName): Promise<void> {
|
async selectForm(formName): Promise<void> {
|
||||||
await this.selectFormDropdown.clickDropdownWithOption(formName);
|
await this.selectFormDropdown.selectDropdownOption(formName);
|
||||||
}
|
}
|
||||||
|
|
||||||
async selectFormFromDropDown(formName): Promise<void> {
|
async selectFormFromDropDown(formName): Promise<void> {
|
||||||
|
@@ -47,7 +47,7 @@ export class SettingsPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setProvider(option): Promise<void> {
|
async setProvider(option): Promise<void> {
|
||||||
await this.providerDropdown.clickDropdownWithOption(option);
|
await this.providerDropdown.selectDropdownOption(option);
|
||||||
await this.providerDropdown.checkOptionIsSelected(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 { browser } from 'protractor';
|
||||||
import { ModelingAPI } from './modeling-api';
|
import { ModelingAPI } from './modeling-api';
|
||||||
import { NodeEntry, ResultSetPaging } from '@alfresco/js-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 { E2eRequestApiHelper, E2eRequestApiHelperOptions } from './e2e-request-api.helper';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import { StringUtil } from '../utils/string.util';
|
import { StringUtil } from '../utils/string.util';
|
||||||
@@ -123,7 +123,7 @@ export class Project {
|
|||||||
};
|
};
|
||||||
const apiCall = () => this.searchProjects();
|
const apiCall = () => this.searchProjects();
|
||||||
|
|
||||||
return UtilApi.waitForApi(apiCall, predicate);
|
return ApiUtil.waitForApi(apiCall, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private getRandomName(): string {
|
private getRandomName(): string {
|
||||||
|
@@ -16,6 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export * from './api';
|
export * from './api';
|
||||||
export * from './utilapi';
|
export * from './api.util';
|
||||||
export * from './deployment-api';
|
export * from './deployment-api';
|
||||||
export * from './modeling-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 {
|
static generatePasswordString(length: number = 8): string {
|
||||||
let text = '';
|
let text = '';
|
||||||
const possibleUpperCase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
||||||
const possibleLowerCase = 'abcdefghijklmnopqrstuvwxyz';
|
|
||||||
const lowerCaseLimit = Math.floor(length / 2);
|
const lowerCaseLimit = Math.floor(length / 2);
|
||||||
|
text += StringUtil.generateRandomCharset(lowerCaseLimit, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
|
||||||
for (let i = 0; i < lowerCaseLimit; i++) {
|
text += StringUtil.generateRandomCharset(length - lowerCaseLimit, 'abcdefghijklmnopqrstuvwxyz');
|
||||||
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));
|
|
||||||
}
|
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
@@ -38,17 +30,9 @@ export class StringUtil {
|
|||||||
* Generates a random string.
|
* Generates a random string.
|
||||||
*
|
*
|
||||||
* @param length If this parameter is not provided the length is set to 8 by default.
|
* @param length If this parameter is not provided the length is set to 8 by default.
|
||||||
* @method generateRandomString
|
|
||||||
*/
|
*/
|
||||||
static generateRandomString(length: number = 8): string {
|
static generateRandomString(length: number = 8): string {
|
||||||
let text = '';
|
return StringUtil.generateRandomCharset(length, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789');
|
||||||
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
||||||
|
|
||||||
for (let i = 0; i < length; i++) {
|
|
||||||
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
|
||||||
}
|
|
||||||
|
|
||||||
return text;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,16 +40,9 @@ export class StringUtil {
|
|||||||
*
|
*
|
||||||
* @param domain
|
* @param domain
|
||||||
* @param length
|
* @param length
|
||||||
* @method generateRandomEmail
|
|
||||||
*/
|
*/
|
||||||
static generateRandomEmail(domain: string, length: number = 5): string {
|
static generateRandomEmail(domain: string, length: number = 5): string {
|
||||||
let email = '';
|
let email = StringUtil.generateRandomCharset(length, 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789');
|
||||||
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
||||||
|
|
||||||
for (let i = 0; i < length; i++) {
|
|
||||||
email += possible.charAt(Math.floor(Math.random() * possible.length));
|
|
||||||
}
|
|
||||||
|
|
||||||
email += domain;
|
email += domain;
|
||||||
return email.toLowerCase();
|
return email.toLowerCase();
|
||||||
}
|
}
|
||||||
@@ -74,33 +51,34 @@ export class StringUtil {
|
|||||||
* Generates a random string - digits only.
|
* Generates a random string - digits only.
|
||||||
*
|
*
|
||||||
* @param length {int} If this parameter is not provided the length is set to 8 by default.
|
* @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 {
|
static generateRandomStringDigits(length: number = 8): string {
|
||||||
let text = '';
|
return StringUtil.generateRandomCharset(length, '0123456789');
|
||||||
const possible = '0123456789';
|
|
||||||
|
|
||||||
for (let i = 0; i < length; i++) {
|
|
||||||
text += possible.charAt(Math.floor(Math.random() * possible.length));
|
|
||||||
}
|
|
||||||
|
|
||||||
return text;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a random string - non-latin characters only.
|
* 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.
|
* @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 {
|
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 = '';
|
let text = '';
|
||||||
const possible = '密码你好𠮷';
|
|
||||||
|
|
||||||
for (let i = 0; i < length; i++) {
|
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;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -80,7 +80,7 @@ export class DropdownPage {
|
|||||||
await BrowserVisibility.waitUntilElementIsNotVisible(element(by.cssContainingText('mat-option span.mat-option-text', option)));
|
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.clickDropdown();
|
||||||
await this.selectOption(option);
|
await this.selectOption(option);
|
||||||
}
|
}
|
||||||
|
@@ -61,7 +61,7 @@ export class EditProcessFilterCloudComponentPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setStatusFilterDropDown(option: string): Promise<void> {
|
async setStatusFilterDropDown(option: string): Promise<void> {
|
||||||
await this.statusDropdown.clickDropdownWithOption(option);
|
await this.statusDropdown.selectDropdownOption(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getStateFilterDropDownValue(): Promise<string> {
|
async getStateFilterDropDownValue(): Promise<string> {
|
||||||
@@ -69,7 +69,7 @@ export class EditProcessFilterCloudComponentPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setSortFilterDropDown(option): Promise<void> {
|
async setSortFilterDropDown(option): Promise<void> {
|
||||||
await this.sortDropdown.clickDropdownWithOption(option);
|
await this.sortDropdown.selectDropdownOption(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSortFilterDropDownValue(): Promise<string> {
|
async getSortFilterDropDownValue(): Promise<string> {
|
||||||
@@ -78,7 +78,7 @@ export class EditProcessFilterCloudComponentPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setOrderFilterDropDown(option): Promise<void> {
|
async setOrderFilterDropDown(option): Promise<void> {
|
||||||
await this.orderDropdown.clickDropdownWithOption(option);
|
await this.orderDropdown.selectDropdownOption(option);
|
||||||
await browser.sleep(1500);
|
await browser.sleep(1500);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ export class EditProcessFilterCloudComponentPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setAppNameDropDown(option: string): Promise<void> {
|
async setAppNameDropDown(option: string): Promise<void> {
|
||||||
await this.appNameDropdown.clickDropdownWithOption(option);
|
await this.appNameDropdown.selectDropdownOption(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getApplicationSelected(): Promise<string> {
|
async getApplicationSelected(): Promise<string> {
|
||||||
|
@@ -65,7 +65,7 @@ export class EditTaskFilterCloudComponentPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setStatusFilterDropDown(option: string): Promise<void> {
|
async setStatusFilterDropDown(option: string): Promise<void> {
|
||||||
await this.statusDropdown.clickDropdownWithOption(option);
|
await this.statusDropdown.selectDropdownOption(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getStatusFilterDropDownValue(): Promise<string> {
|
async getStatusFilterDropDownValue(): Promise<string> {
|
||||||
@@ -73,7 +73,7 @@ export class EditTaskFilterCloudComponentPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setSortFilterDropDown(option: string): Promise<void> {
|
async setSortFilterDropDown(option: string): Promise<void> {
|
||||||
await this.sortDropdown.clickDropdownWithOption(option);
|
await this.sortDropdown.selectDropdownOption(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSortFilterDropDownValue(): Promise<string> {
|
async getSortFilterDropDownValue(): Promise<string> {
|
||||||
@@ -81,7 +81,7 @@ export class EditTaskFilterCloudComponentPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setOrderFilterDropDown(option: string): Promise<void> {
|
async setOrderFilterDropDown(option: string): Promise<void> {
|
||||||
await this.orderDropdown.clickDropdownWithOption(option);
|
await this.orderDropdown.selectDropdownOption(option);
|
||||||
await browser.sleep(1500);
|
await browser.sleep(1500);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,7 +193,7 @@ export class EditTaskFilterCloudComponentPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async setAppNameDropDown(option: string): Promise<void> {
|
async setAppNameDropDown(option: string): Promise<void> {
|
||||||
await this.appNameDropdown.clickDropdownWithOption(option);
|
await this.appNameDropdown.selectDropdownOption(option);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAppNameDropDownValue(): Promise<string> {
|
async getAppNameDropDownValue(): Promise<string> {
|
||||||
|
Reference in New Issue
Block a user