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.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { AlfrescoApi } from '@alfresco/js-api';
|
|
||||||
import { browser } from 'protractor';
|
import { browser } from 'protractor';
|
||||||
|
import { ApiService } from './api.service';
|
||||||
|
|
||||||
export abstract class Api {
|
export abstract class Api {
|
||||||
public api: AlfrescoApi;
|
|
||||||
|
|
||||||
constructor(root: string) {
|
public api: ApiService;
|
||||||
this.api = this.configureApi(root);
|
|
||||||
|
constructor() {
|
||||||
|
this.api = this.configureApi();
|
||||||
}
|
}
|
||||||
|
|
||||||
private configureApi(root: string): AlfrescoApi {
|
private configureApi(): ApiService {
|
||||||
const config = browser.params.adminapp.apiConfig;
|
const config = browser.params.adminapp.apiConfig;
|
||||||
|
|
||||||
return new AlfrescoApi({
|
return new ApiService({
|
||||||
provider: 'BPM',
|
provider: 'BPM',
|
||||||
authType: config.authType,
|
authType: config.authType,
|
||||||
oauth2: config.oauth2,
|
oauth2: config.oauth2,
|
||||||
hostBpm: config.bpmHost + '/' + root
|
hostBpm: config.bpmHost
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,3 +16,4 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export * from './user.model';
|
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 { BrowserVisibility } from '../utils/browser-visibility';
|
||||||
import { Logger } from './logger';
|
import { Logger } from './logger';
|
||||||
|
|
||||||
|
import * as path from 'path';
|
||||||
|
import * as fs from 'fs';
|
||||||
|
|
||||||
export class BrowserActions {
|
export class BrowserActions {
|
||||||
|
|
||||||
static async click(elementFinder: ElementFinder): Promise<void> {
|
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
|
// if the opened menu has only disabled items, pressing escape to close it won't work
|
||||||
await browser.actions().sendKeys(protractor.Key.ENTER).perform();
|
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 { E2eRequestApiHelper } from '../../core/actions/e2e-request-api.helper';
|
||||||
import { Api } from '../../core/actions/api';
|
|
||||||
import { Logger } from '../../core/utils/logger';
|
import { Logger } from '../../core/utils/logger';
|
||||||
import { ResultSetPaging } from '@alfresco/js-api';
|
import { ResultSetPaging } from '@alfresco/js-api';
|
||||||
import { ApiService } from '../../core/actions/api.service';
|
import { ApiService } from '../../core/actions/api.service';
|
||||||
@ -26,7 +25,7 @@ export class Application {
|
|||||||
requestApiHelper: E2eRequestApiHelper;
|
requestApiHelper: E2eRequestApiHelper;
|
||||||
endPoint = `/deployment-service/v1/applications/`;
|
endPoint = `/deployment-service/v1/applications/`;
|
||||||
|
|
||||||
constructor(api: Api | ApiService) {
|
constructor(api: ApiService) {
|
||||||
this.requestApiHelper = new E2eRequestApiHelper(api);
|
this.requestApiHelper = new E2eRequestApiHelper(api);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,16 +17,17 @@
|
|||||||
|
|
||||||
import { NodeEntry } from '@alfresco/js-api';
|
import { NodeEntry } from '@alfresco/js-api';
|
||||||
import { E2eRequestApiHelper } from '../../core/actions/e2e-request-api.helper';
|
import { E2eRequestApiHelper } from '../../core/actions/e2e-request-api.helper';
|
||||||
import { Api } from '../../core/actions/api';
|
|
||||||
import { ApplicationRepresentation } from '../../core/models/application-model';
|
import { ApplicationRepresentation } from '../../core/models/application-model';
|
||||||
import { Logger } from '../../core/utils/logger';
|
import { Logger } from '../../core/utils/logger';
|
||||||
import { ApiUtil } from '../../core/actions/api.util';
|
import { ApiUtil } from '../../core/actions/api.util';
|
||||||
|
import { ApiService } from '../../core/actions/api.service';
|
||||||
|
|
||||||
export class Descriptor {
|
export class Descriptor {
|
||||||
requestApiHelper: E2eRequestApiHelper;
|
|
||||||
endPoint = `/v1/descriptors/`;
|
|
||||||
|
|
||||||
constructor(api: Api) {
|
requestApiHelper: E2eRequestApiHelper;
|
||||||
|
endPoint = `deployment-service/v1/descriptors/`;
|
||||||
|
|
||||||
|
constructor(api: ApiService) {
|
||||||
this.requestApiHelper = new E2eRequestApiHelper(api);
|
this.requestApiHelper = new E2eRequestApiHelper(api);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,18 +24,18 @@ import { NodeEntry, ResultSetPaging } from '@alfresco/js-api';
|
|||||||
export class ModelingAPI extends Api {
|
export class ModelingAPI extends Api {
|
||||||
public project: Project;
|
public project: Project;
|
||||||
|
|
||||||
constructor(ROOT: string = 'modeling-service') {
|
constructor() {
|
||||||
super(ROOT);
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
async setUp(): Promise<ModelingAPI> {
|
async setUp(): Promise<ModelingAPI> {
|
||||||
await this.login();
|
await this.login();
|
||||||
this.project = new Project(this);
|
this.project = new Project(this.api);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
async tearDown(): Promise<void> {
|
async tearDown(): Promise<void> {
|
||||||
await this.api.logout();
|
await this.api.apiService.logout();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async login(): Promise<void> {
|
private async login(): Promise<void> {
|
||||||
@ -74,5 +74,4 @@ export class ModelingAPI extends Api {
|
|||||||
const projects = await this.project.searchProjects();
|
const projects = await this.project.searchProjects();
|
||||||
return projects;
|
return projects;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,26 +16,25 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { browser } from 'protractor';
|
import { browser } from 'protractor';
|
||||||
import { ModelingAPI } from './modeling-api';
|
|
||||||
import { NodeEntry, ResultSetPaging } from '@alfresco/js-api';
|
import { NodeEntry, ResultSetPaging } from '@alfresco/js-api';
|
||||||
import { ApiUtil } from '../../core/actions/api.util';
|
import { ApiUtil } from '../../core/actions/api.util';
|
||||||
import { E2eRequestApiHelper, E2eRequestApiHelperOptions } from '../../core/actions/e2e-request-api.helper';
|
import { E2eRequestApiHelper, E2eRequestApiHelperOptions } from '../../core/actions/e2e-request-api.helper';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import { StringUtil } from '../../core/utils/string.util';
|
import { StringUtil } from '../../core/utils/string.util';
|
||||||
import { Logger } from '../../core/utils/logger';
|
import { Logger } from '../../core/utils/logger';
|
||||||
|
import { ApiService } from '../../core/actions/api.service';
|
||||||
|
|
||||||
export class Project {
|
export class Project {
|
||||||
requestApiHelper: E2eRequestApiHelper;
|
requestApiHelper: E2eRequestApiHelper;
|
||||||
endPoint = '/v1/projects/';
|
endPoint = 'modeling-service/v1/projects/';
|
||||||
namePrefix: string = browser.params.namePrefix;
|
namePrefix: string = browser.params.namePrefix;
|
||||||
|
|
||||||
constructor(api: ModelingAPI) {
|
constructor(api: ApiService) {
|
||||||
this.requestApiHelper = new E2eRequestApiHelper(api);
|
this.requestApiHelper = new E2eRequestApiHelper(api);
|
||||||
}
|
}
|
||||||
|
|
||||||
async create(modelName: string = this.getRandomName()): Promise<NodeEntry> {
|
async create(modelName: string = this.getRandomName()): Promise<NodeEntry> {
|
||||||
const project = await this.requestApiHelper
|
const project = await this.requestApiHelper.post<NodeEntry>(this.endPoint, {bodyParam: { name: modelName }});
|
||||||
.post<NodeEntry>(this.endPoint, {bodyParam: { name: modelName }});
|
|
||||||
|
|
||||||
Logger.info(
|
Logger.info(
|
||||||
`[Project] Project created with name: ${project.entry.name} and id: ${
|
`[Project] Project created with name: ${project.entry.name} and id: ${
|
||||||
@ -57,11 +56,11 @@ export class Project {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async get(projectId: string): Promise<NodeEntry> {
|
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> {
|
async delete(projectId: string): Promise<void> {
|
||||||
await this.requestApiHelper.delete(`/v1/projects/${projectId}`);
|
await this.requestApiHelper.delete(`${this.endPoint}${projectId}`);
|
||||||
Logger.info(
|
Logger.info(
|
||||||
`[Project] Project '${projectId}' was deleted successfully.`
|
`[Project] Project '${projectId}' was deleted successfully.`
|
||||||
);
|
);
|
||||||
@ -70,7 +69,7 @@ export class Project {
|
|||||||
async release(projectId: string): Promise<any> {
|
async release(projectId: string): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const release = await this.requestApiHelper
|
const release = await this.requestApiHelper
|
||||||
.post(`/v1/projects/${projectId}/releases`);
|
.post(`${this.endPoint}${projectId}/releases`);
|
||||||
Logger.info(`[Project] Project '${projectId}' was released.`);
|
Logger.info(`[Project] Project '${projectId}' was released.`);
|
||||||
return release;
|
return release;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -82,7 +81,7 @@ export class Project {
|
|||||||
async getProjectRelease(projectId: string): Promise<any> {
|
async getProjectRelease(projectId: string): Promise<any> {
|
||||||
try {
|
try {
|
||||||
return await this.requestApiHelper
|
return await this.requestApiHelper
|
||||||
.get<ResultSetPaging>(`/v1/projects/${projectId}/releases`);
|
.get<ResultSetPaging>(`${this.endPoint}${projectId}/releases`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
Logger.error(`[Project] Not able to fetch project release!`);
|
Logger.error(`[Project] Not able to fetch project release!`);
|
||||||
throw error;
|
throw error;
|
||||||
@ -97,7 +96,7 @@ export class Project {
|
|||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
const project = await this.requestApiHelper
|
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}'.`);
|
Logger.info(`[Project] Project imported with name '${project.entry.name}' and id '${project.entry.id}'.`);
|
||||||
return project;
|
return project;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user