mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-26 17:24:56 +00:00
parent
0257cf5748
commit
8e241a9e8f
@ -15,24 +15,25 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { AlfrescoApi } from '@alfresco/js-api';
|
||||
import { browser } from 'protractor';
|
||||
import { ApiService } from './api.service';
|
||||
|
||||
export abstract class Api {
|
||||
public api: AlfrescoApi;
|
||||
|
||||
constructor(root: string) {
|
||||
this.api = this.configureApi(root);
|
||||
public api: ApiService;
|
||||
|
||||
constructor() {
|
||||
this.api = this.configureApi();
|
||||
}
|
||||
|
||||
private configureApi(root: string): AlfrescoApi {
|
||||
private configureApi(): ApiService {
|
||||
const config = browser.params.adminapp.apiConfig;
|
||||
|
||||
return new AlfrescoApi({
|
||||
return new ApiService({
|
||||
provider: 'BPM',
|
||||
authType: config.authType,
|
||||
oauth2: config.oauth2,
|
||||
hostBpm: config.bpmHost + '/' + root
|
||||
hostBpm: config.bpmHost
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -16,3 +16,4 @@
|
||||
*/
|
||||
|
||||
export * from './user.model';
|
||||
export * from './application-model';
|
||||
|
@ -19,6 +19,9 @@ import { browser, by, element, ElementArrayFinder, ElementFinder, protractor } f
|
||||
import { BrowserVisibility } from '../utils/browser-visibility';
|
||||
import { Logger } from './logger';
|
||||
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
|
||||
export class BrowserActions {
|
||||
|
||||
static async click(elementFinder: ElementFinder): Promise<void> {
|
||||
@ -124,4 +127,16 @@ export class BrowserActions {
|
||||
// if the opened menu has only disabled items, pressing escape to close it won't work
|
||||
await browser.actions().sendKeys(protractor.Key.ENTER).perform();
|
||||
}
|
||||
|
||||
static async takeScreenshot(screenshotFilePath: string, fileName: string) {
|
||||
const pngData = await browser.takeScreenshot();
|
||||
const filenameWithExt = `${fileName}.png`;
|
||||
Logger.info('Taking screenshot: ', filenameWithExt);
|
||||
|
||||
const fileWithPath = path.join(screenshotFilePath, filenameWithExt);
|
||||
const stream = fs.createWriteStream(fileWithPath);
|
||||
stream.write(new Buffer(pngData, 'base64'));
|
||||
stream.end();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,7 +16,6 @@
|
||||
*/
|
||||
|
||||
import { E2eRequestApiHelper } from '../../core/actions/e2e-request-api.helper';
|
||||
import { Api } from '../../core/actions/api';
|
||||
import { Logger } from '../../core/utils/logger';
|
||||
import { ResultSetPaging } from '@alfresco/js-api';
|
||||
import { ApiService } from '../../core/actions/api.service';
|
||||
@ -26,7 +25,7 @@ export class Application {
|
||||
requestApiHelper: E2eRequestApiHelper;
|
||||
endPoint = `/deployment-service/v1/applications/`;
|
||||
|
||||
constructor(api: Api | ApiService) {
|
||||
constructor(api: ApiService) {
|
||||
this.requestApiHelper = new E2eRequestApiHelper(api);
|
||||
}
|
||||
|
||||
|
@ -17,56 +17,57 @@
|
||||
|
||||
import { NodeEntry } from '@alfresco/js-api';
|
||||
import { E2eRequestApiHelper } from '../../core/actions/e2e-request-api.helper';
|
||||
import { Api } from '../../core/actions/api';
|
||||
import { ApplicationRepresentation } from '../../core/models/application-model';
|
||||
import { Logger } from '../../core/utils/logger';
|
||||
import { ApiUtil } from '../../core/actions/api.util';
|
||||
import { ApiService } from '../../core/actions/api.service';
|
||||
|
||||
export class Descriptor {
|
||||
requestApiHelper: E2eRequestApiHelper;
|
||||
endPoint = `/v1/descriptors/`;
|
||||
|
||||
constructor(api: Api) {
|
||||
this.requestApiHelper = new E2eRequestApiHelper(api);
|
||||
}
|
||||
requestApiHelper: E2eRequestApiHelper;
|
||||
endPoint = `deployment-service/v1/descriptors/`;
|
||||
|
||||
async create(model: ApplicationRepresentation): Promise<void> {
|
||||
try {
|
||||
await this.requestApiHelper.post<NodeEntry>(this.endPoint, {
|
||||
bodyParam: model
|
||||
});
|
||||
Logger.info(`[Descriptor] Descriptor has been created with name: ${model.name}.`);
|
||||
} catch (error) {
|
||||
Logger.error(`[Descriptor] Create descriptor ${model.name} failed with message: ${error.message}`);
|
||||
throw error;
|
||||
constructor(api: ApiService) {
|
||||
this.requestApiHelper = new E2eRequestApiHelper(api);
|
||||
}
|
||||
}
|
||||
|
||||
async delete(name: string): Promise<void> {
|
||||
try {
|
||||
await this.retryUntilDescriptorIsInStatus(name, `DescriptorCreated`);
|
||||
await this.requestApiHelper.delete(`${this.endPoint}${name}`);
|
||||
Logger.info(`[Descriptor] Descriptor '${name}' was deleted successfully.`);
|
||||
} catch (error) {
|
||||
Logger.error(`[Descriptor] Delete descriptor ${name} failed with message: ${error.message}`);
|
||||
async create(model: ApplicationRepresentation): Promise<void> {
|
||||
try {
|
||||
await this.requestApiHelper.post<NodeEntry>(this.endPoint, {
|
||||
bodyParam: model
|
||||
});
|
||||
Logger.info(`[Descriptor] Descriptor has been created with name: ${model.name}.`);
|
||||
} catch (error) {
|
||||
Logger.error(`[Descriptor] Create descriptor ${model.name} failed with message: ${error.message}`);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async get(name: string): Promise<any> {
|
||||
Logger.info(`[Descriptor] Get descriptor ${name} details.`);
|
||||
try {
|
||||
return this.requestApiHelper.get<any>(`${this.endPoint}${name}`);
|
||||
} catch (error) {
|
||||
Logger.error(`[Descriptor] Get descriptor ${name} details failed with message: ${error.message}`);
|
||||
async delete(name: string): Promise<void> {
|
||||
try {
|
||||
await this.retryUntilDescriptorIsInStatus(name, `DescriptorCreated`);
|
||||
await this.requestApiHelper.delete(`${this.endPoint}${name}`);
|
||||
Logger.info(`[Descriptor] Descriptor '${name}' was deleted successfully.`);
|
||||
} catch (error) {
|
||||
Logger.error(`[Descriptor] Delete descriptor ${name} failed with message: ${error.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async retryUntilDescriptorIsInStatus(name: string, expectedStatus: string): Promise<any> {
|
||||
const predicate = (result: { status: string }) => {
|
||||
return result.status === expectedStatus;
|
||||
};
|
||||
const apiCall = async () => this.get(name);
|
||||
async get(name: string): Promise<any> {
|
||||
Logger.info(`[Descriptor] Get descriptor ${name} details.`);
|
||||
try {
|
||||
return this.requestApiHelper.get<any>(`${this.endPoint}${name}`);
|
||||
} catch (error) {
|
||||
Logger.error(`[Descriptor] Get descriptor ${name} details failed with message: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
return ApiUtil.waitForApi(apiCall, predicate);
|
||||
}
|
||||
async retryUntilDescriptorIsInStatus(name: string, expectedStatus: string): Promise<any> {
|
||||
const predicate = (result: { status: string }) => {
|
||||
return result.status === expectedStatus;
|
||||
};
|
||||
const apiCall = async () => this.get(name);
|
||||
|
||||
return ApiUtil.waitForApi(apiCall, predicate);
|
||||
}
|
||||
}
|
||||
|
@ -24,18 +24,18 @@ import { NodeEntry, ResultSetPaging } from '@alfresco/js-api';
|
||||
export class ModelingAPI extends Api {
|
||||
public project: Project;
|
||||
|
||||
constructor(ROOT: string = 'modeling-service') {
|
||||
super(ROOT);
|
||||
constructor() {
|
||||
super();
|
||||
}
|
||||
|
||||
async setUp(): Promise<ModelingAPI> {
|
||||
await this.login();
|
||||
this.project = new Project(this);
|
||||
this.project = new Project(this.api);
|
||||
return this;
|
||||
}
|
||||
|
||||
async tearDown(): Promise<void> {
|
||||
await this.api.logout();
|
||||
await this.api.apiService.logout();
|
||||
}
|
||||
|
||||
private async login(): Promise<void> {
|
||||
@ -74,5 +74,4 @@ export class ModelingAPI extends Api {
|
||||
const projects = await this.project.searchProjects();
|
||||
return projects;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,26 +16,25 @@
|
||||
*/
|
||||
|
||||
import { browser } from 'protractor';
|
||||
import { ModelingAPI } from './modeling-api';
|
||||
import { NodeEntry, ResultSetPaging } from '@alfresco/js-api';
|
||||
import { ApiUtil } from '../../core/actions/api.util';
|
||||
import { E2eRequestApiHelper, E2eRequestApiHelperOptions } from '../../core/actions/e2e-request-api.helper';
|
||||
import * as fs from 'fs';
|
||||
import { StringUtil } from '../../core/utils/string.util';
|
||||
import { Logger } from '../../core/utils/logger';
|
||||
import { ApiService } from '../../core/actions/api.service';
|
||||
|
||||
export class Project {
|
||||
requestApiHelper: E2eRequestApiHelper;
|
||||
endPoint = '/v1/projects/';
|
||||
endPoint = 'modeling-service/v1/projects/';
|
||||
namePrefix: string = browser.params.namePrefix;
|
||||
|
||||
constructor(api: ModelingAPI) {
|
||||
constructor(api: ApiService) {
|
||||
this.requestApiHelper = new E2eRequestApiHelper(api);
|
||||
}
|
||||
|
||||
async create(modelName: string = this.getRandomName()): Promise<NodeEntry> {
|
||||
const project = await this.requestApiHelper
|
||||
.post<NodeEntry>(this.endPoint, {bodyParam: { name: modelName }});
|
||||
const project = await this.requestApiHelper.post<NodeEntry>(this.endPoint, {bodyParam: { name: modelName }});
|
||||
|
||||
Logger.info(
|
||||
`[Project] Project created with name: ${project.entry.name} and id: ${
|
||||
@ -57,11 +56,11 @@ export class Project {
|
||||
}
|
||||
|
||||
async get(projectId: string): Promise<NodeEntry> {
|
||||
return this.requestApiHelper.get<NodeEntry>(`/v1/projects/${projectId}`);
|
||||
return this.requestApiHelper.get<NodeEntry>(`${this.endPoint}${projectId}`);
|
||||
}
|
||||
|
||||
async delete(projectId: string): Promise<void> {
|
||||
await this.requestApiHelper.delete(`/v1/projects/${projectId}`);
|
||||
await this.requestApiHelper.delete(`${this.endPoint}${projectId}`);
|
||||
Logger.info(
|
||||
`[Project] Project '${projectId}' was deleted successfully.`
|
||||
);
|
||||
@ -70,7 +69,7 @@ export class Project {
|
||||
async release(projectId: string): Promise<any> {
|
||||
try {
|
||||
const release = await this.requestApiHelper
|
||||
.post(`/v1/projects/${projectId}/releases`);
|
||||
.post(`${this.endPoint}${projectId}/releases`);
|
||||
Logger.info(`[Project] Project '${projectId}' was released.`);
|
||||
return release;
|
||||
} catch (error) {
|
||||
@ -82,7 +81,7 @@ export class Project {
|
||||
async getProjectRelease(projectId: string): Promise<any> {
|
||||
try {
|
||||
return await this.requestApiHelper
|
||||
.get<ResultSetPaging>(`/v1/projects/${projectId}/releases`);
|
||||
.get<ResultSetPaging>(`${this.endPoint}${projectId}/releases`);
|
||||
} catch (error) {
|
||||
Logger.error(`[Project] Not able to fetch project release!`);
|
||||
throw error;
|
||||
@ -97,7 +96,7 @@ export class Project {
|
||||
};
|
||||
try {
|
||||
const project = await this.requestApiHelper
|
||||
.post<NodeEntry>(`/v1/projects/import`, requestOptions);
|
||||
.post<NodeEntry>(`${this.endPoint}import`, requestOptions);
|
||||
Logger.info(`[Project] Project imported with name '${project.entry.name}' and id '${project.entry.id}'.`);
|
||||
return project;
|
||||
} catch (error) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user