Optimize tests and upgrade Nx workspace (#5884)

* fix issue with async await, use interface over class

* upgrade nx workspace

* remove useless async

* code fixes
This commit is contained in:
Denys Vuika 2020-07-16 22:34:50 +01:00 committed by GitHub
parent b9dc285d2b
commit b69fdb9370
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 396 additions and 400 deletions

View File

@ -18,9 +18,7 @@
"tsConfig": "tsconfig.dev.json",
"polyfills": "demo-shell/src/polyfills.ts",
"stylePreprocessorOptions": {
"includePaths": [
"lib"
]
"includePaths": ["lib"]
},
"assets": [
"demo-shell/src/assets",
@ -288,13 +286,8 @@
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"tsconfig.dev.json"
],
"exclude": [
"**/node_modules/**/*",
"package.json"
]
"tsConfig": ["tsconfig.dev.json"],
"exclude": ["**/node_modules/**/*", "package.json"]
}
}
}
@ -327,12 +320,8 @@
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"./e2e/tsconfig.e2e.json"
],
"exclude": [
"**/node_modules/**/*"
]
"tsConfig": ["./e2e/tsconfig.e2e.json"],
"exclude": ["**/node_modules/**/*"]
}
}
}
@ -373,9 +362,7 @@
"lib/core/tsconfig.lib.json",
"lib/core/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
"exclude": ["**/node_modules/**"]
}
}
}
@ -416,9 +403,7 @@
"lib/content-services/tsconfig.lib.json",
"lib/content-services/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
"exclude": ["**/node_modules/**"]
}
}
}
@ -459,9 +444,7 @@
"lib/process-services/tsconfig.lib.json",
"lib/process-services/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
"exclude": ["**/node_modules/**"]
}
}
}
@ -502,9 +485,7 @@
"lib/process-services-cloud/tsconfig.lib.json",
"lib/process-services-cloud/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
"exclude": ["**/node_modules/**"]
}
}
}
@ -545,9 +526,7 @@
"lib/insights/tsconfig.lib.json",
"lib/insights/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
"exclude": ["**/node_modules/**"]
}
}
}
@ -587,9 +566,7 @@
"lib/extensions/tsconfig.lib.json",
"lib/extensions/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
"exclude": ["**/node_modules/**"]
}
}
}
@ -619,9 +596,7 @@
"lib/testing/tsconfig.lib.json",
"lib/testing/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
"exclude": ["**/node_modules/**"]
}
}
}

95
decorate-angular-cli.js Normal file
View File

@ -0,0 +1,95 @@
/**
* This file decorates the Angular CLI with the Nx CLI to enable features such as computation caching
* and faster execution of tasks.
*
* It does this by:
*
* - Patching the Angular CLI to warn you in case you accidentally use the undecorated ng command.
* - Symlinking the ng to nx command, so all commands run through the Nx CLI
* - Updating the package.json postinstall script to give you control over this script
*
* The Nx CLI decorates the Angular CLI, so the Nx CLI is fully compatible with it.
* Every command you run should work the same when using the Nx CLI, except faster.
*
* Because of symlinking you can still type `ng build/test/lint` in the terminal. The ng command, in this case,
* will point to nx, which will perform optimizations before invoking ng. So the Angular CLI is always invoked.
* The Nx CLI simply does some optimizations before invoking the Angular CLI.
*
* To opt out of this patch:
* - Replace occurrences of nx with ng in your package.json
* - Remove the script from your postinstall script in your package.json
* - Delete and reinstall your node_modules
*/
const fs = require("fs");
const os = require("os");
const cp = require("child_process");
const isWindows = os.platform() === "win32";
const { output } = require("@nrwl/workspace");
/**
* Paths to files being patched
*/
const angularCLIInitPath = "node_modules/@angular/cli/lib/cli/index.js";
/**
* Patch index.js to warn you if you invoke the undecorated Angular CLI.
*/
function patchAngularCLI(initPath) {
const angularCLIInit = fs.readFileSync(initPath, "utf-8").toString();
if (!angularCLIInit.includes("NX_CLI_SET")) {
fs.writeFileSync(
initPath,
`
if (!process.env['NX_CLI_SET']) {
const { output } = require('@nrwl/workspace');
output.warn({ title: 'The Angular CLI was invoked instead of the Nx CLI. Use "npx ng [command]" or "nx [command]" instead.' });
}
${angularCLIInit}
`
);
}
}
/**
* Symlink of ng to nx, so you can keep using `ng build/test/lint` and still
* invoke the Nx CLI and get the benefits of computation caching.
*/
function symlinkNgCLItoNxCLI() {
try {
const ngPath = "./node_modules/.bin/ng";
const nxPath = "./node_modules/.bin/nx";
if (isWindows) {
/**
* This is the most reliable way to create symlink-like behavior on Windows.
* Such that it works in all shells and works with npx.
*/
["", ".cmd", ".ps1"].forEach(ext => {
fs.writeFileSync(ngPath + ext, fs.readFileSync(nxPath + ext));
});
} else {
// If unix-based, symlink
cp.execSync(`ln -sf ./nx ${ngPath}`);
}
} catch (e) {
output.error({
title:
"Unable to create a symlink from the Angular CLI to the Nx CLI:" +
e.message
});
throw e;
}
}
try {
symlinkNgCLItoNxCLI();
patchAngularCLI(angularCLIInitPath);
output.log({
title: "Angular CLI has been decorated to enable computation caching."
});
} catch (e) {
output.error({
title: "Decoration of the Angular CLI did not complete successfully"
});
}

View File

@ -15,7 +15,7 @@
* limitations under the License.
*/
import { async, TestBed } from '@angular/core/testing';
import { TestBed } from '@angular/core/testing';
import { setupTestBed } from 'core';
import { CoreTestingModule } from 'core/testing/core.testing.module';
import { TranslateModule } from '@ngx-translate/core';
@ -35,7 +35,7 @@ describe('ProcessNameCloudPipe', () => {
const nameWithProcessDefinitionIdentifier = `${defaultName} - ${processDefinitionIdentifier}`;
const nameWithDatetimeIdentifier = `${defaultName} - ${datetimeIdentifier}`;
const nameWithAllIdentifiers = `${defaultName} ${processDefinitionIdentifier} - ${datetimeIdentifier}`;
const fakeProcessInstanceDetails = new ProcessInstanceCloud({ processDefinitionName: 'my-process-definition' });
const fakeProcessInstanceDetails: ProcessInstanceCloud = { processDefinitionName: 'my-process-definition' };
setupTestBed({
imports: [
@ -44,10 +44,10 @@ describe('ProcessNameCloudPipe', () => {
]
});
beforeEach(async(() => {
beforeEach(() => {
const localizedDatePipe = TestBed.inject(LocalizedDatePipe);
processNamePipe = new ProcessNameCloudPipe(localizedDatePipe);
}));
});
it('should not modify the name when there is no identifier', () => {
const transformResult = processNamePipe.transform(defaultName);

View File

@ -19,9 +19,12 @@ import { Component, ViewChild } from '@angular/core';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { IdentityUserService, setupTestBed } from '@alfresco/adf-core';
import { CancelProcessDirective } from './cancel-process.directive';
import { processDetailsMockRunning, processDetailsMockCompleted } from '../mock/process-details.mock';
import { ProcessServiceCloudTestingModule } from '../../testing/process-service-cloud.testing.module';
import { TranslateModule } from '@ngx-translate/core';
import { ProcessInstanceCloud } from '../start-process/models/process-instance-cloud.model';
const processDetailsMockRunning: ProcessInstanceCloud = { initiator: 'usermock', status: 'RUNNING' };
const processDetailsMockCompleted: ProcessInstanceCloud = { initiator: 'usermock', status: 'COMPLETED' };
describe('CancelProcessDirective', () => {

View File

@ -29,11 +29,11 @@ export class CancelProcessDirective implements OnInit, OnDestroy {
/** Emitted when the process is cancelled. */
@Output()
success: EventEmitter<any> = new EventEmitter<any>();
success = new EventEmitter<any>();
/** Emitted when the process cannot be cancelled. */
@Output()
error: EventEmitter<any> = new EventEmitter<any>();
error = new EventEmitter<any>();
processInstanceDetails: ProcessInstanceCloud;
@ -49,7 +49,7 @@ export class CancelProcessDirective implements OnInit, OnDestroy {
ngOnInit() {
this.processCloudService.dataChangesDetected
.pipe(takeUntil(this.onDestroy$))
.subscribe((processDetails: ProcessInstanceCloud) => {
.subscribe((processDetails) => {
this.processInstanceDetails = processDetails;
this.canCancelProcess = this.checkCanCancelProcess();
this.setElementVisibility();
@ -57,12 +57,8 @@ export class CancelProcessDirective implements OnInit, OnDestroy {
}
@HostListener('click')
async onClick() {
try {
await this.cancelProcess();
} catch (error) {
this.error.emit(error);
}
onClick() {
this.cancelProcess();
}
private setElementVisibility() {
@ -74,15 +70,13 @@ export class CancelProcessDirective implements OnInit, OnDestroy {
return this.processInstanceDetails.initiator === currentUser && this.processInstanceDetails.status === 'RUNNING';
}
async cancelProcess() {
cancelProcess() {
if (this.canCancelProcess) {
await this.processCloudService.cancelProcess(this.processInstanceDetails.appName, this.processInstanceDetails.id)
.pipe(takeUntil(this.onDestroy$))
.subscribe((response) => {
this.success.emit(response);
}, ((error) => {
this.error.emit(error);
}));
this.processCloudService.cancelProcess(this.processInstanceDetails.appName, this.processInstanceDetails.id)
.subscribe(
(response) => this.success.emit(response),
(error) => this.error.emit(error)
);
} else {
this.error.emit('Permission denied, only process initiator can cancel the process');
}

View File

@ -1,22 +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.
*/
import { ProcessInstanceCloud } from '../start-process/models/process-instance-cloud.model';
export let processDetailsMockRunning = new ProcessInstanceCloud({ initiator: 'usermock', status: 'RUNNING' });
export let processDetailsMockCompleted = new ProcessInstanceCloud({ initiator: 'usermock', status: 'COMPLETED' });

View File

@ -1,191 +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.
*/
import { ProcessFilterCloudModel } from '../models/process-filter-cloud.model';
export const fakeProcessCloudFilterEntries = {
list: {
entries: [
{
entry: {
key: 'process-filters-mock-appName-mock-username',
value: JSON.stringify([
{
name: 'MOCK_PROCESS_NAME_1',
id: '1',
key: 'all-mock-process',
icon: 'adjust',
appName: 'mock-appName',
sort: 'startDate',
status: 'MOCK_ALL',
order: 'DESC'
},
{
name: 'MOCK_PROCESS_NAME_2',
id: '2',
key: 'run-mock-process',
icon: 'adjust',
appName: 'mock-appName',
sort: 'startDate',
status: 'MOCK-RUNNING',
order: 'DESC'
},
{
name: 'MOCK_PROCESS_NAME_3',
id: '3',
key: 'complete-mock-process',
icon: 'adjust',
appName: 'mock-appName',
sort: 'startDate',
status: 'MOCK-COMPLETED',
order: 'DESC'
}
])
}
},
{
entry: {
key: 'mock-key-2',
value: {
name: 'MOCK_PROCESS_NAME_2',
id: '2',
key: 'run-mock-process',
icon: 'adjust',
appName: 'mock-appName',
sort: 'startDate',
status: 'MOCK-RUNNING',
order: 'DESC'
}
}
},
{
entry: {
key: 'mock-key-3',
value: {
name: 'MOCK_PROCESS_NAME_3',
id: '3',
key: 'complete-mock-process',
icon: 'adjust',
appName: 'mock-appName',
sort: 'startDate',
status: 'MOCK-COMPLETED',
order: 'DESC'
}
}
}
],
pagination: {
skipCount: 0,
maxItems: 100,
count: 3,
hasMoreItems: false,
totalItems: 3
}
}
};
export const fakeEmptyProcessCloudFilterEntries = {
list: {
entries: [],
pagination: {
skipCount: 0,
maxItems: 100,
count: 0,
hasMoreItems: false,
totalItems: 0
}
}
};
export const fakeProcessCloudFilterWithDifferentEntries = {
list: {
entries: [
{
entry: {
key: 'my-mock-key-1',
value: 'my-mock-value-2'
}
},
{
entry: {
key: 'my-mock-key-2',
value: 'my-mock-key-2'
}
}
],
pagination: {
skipCount: 0,
maxItems: 100,
count: 4,
hasMoreItems: false,
totalItems: 2
}
}
};
export const fakeProcessFilter: ProcessFilterCloudModel = {
name: 'MOCK_PROCESS_NAME_1',
id: '1',
key: 'all-mock-process',
icon: 'adjust',
appName: 'mock-appName',
sort: 'startDate',
status: 'MOCK_ALL',
order: 'DESC',
index: 2,
processName: 'process-name',
processInstanceId: 'processinstanceid',
initiator: 'mockuser',
processDefinitionId: 'processDefid',
processDefinitionKey: 'processDefKey',
lastModified: null,
lastModifiedTo: null,
lastModifiedFrom: null
};
export const fakeProcessCloudFilters = [
{
name: 'MOCK_PROCESS_NAME_1',
id: '1',
key: 'all-mock-process',
icon: 'adjust',
appName: 'mock-appName',
sort: 'startDate',
status: 'MOCK_ALL',
order: 'DESC'
},
{
name: 'MOCK_PROCESS_NAME_2',
id: '2',
key: 'run-mock-process',
icon: 'adjust',
appName: 'mock-appName',
sort: 'startDate',
status: 'MOCK-RUNNING',
order: 'DESC'
},
{
name: 'MOCK_PROCESS_NAME_3',
id: '3',
key: 'complete-mock-process',
icon: 'adjust',
appName: 'mock-appName',
sort: 'startDate',
status: 'MOCK-COMPLETED',
order: 'DESC'
}
];

View File

@ -19,17 +19,11 @@ import { async, TestBed } from '@angular/core/testing';
import { setupTestBed, IdentityUserService } from '@alfresco/adf-core';
import { of } from 'rxjs';
import { ProcessFilterCloudService } from './process-filter-cloud.service';
import {
fakeProcessCloudFilterEntries,
fakeProcessCloudFilters,
fakeEmptyProcessCloudFilterEntries,
fakeProcessCloudFilterWithDifferentEntries,
fakeProcessFilter
} from '../mock/process-filters.cloud.mock';
import { PROCESS_FILTERS_SERVICE_TOKEN } from '../../../services/cloud-token.service';
import { LocalPreferenceCloudService } from '../../../services/local-preference-cloud.service';
import { ProcessServiceCloudTestingModule } from '../../../testing/process-service-cloud.testing.module';
import { TranslateModule } from '@ngx-translate/core';
import { ProcessFilterCloudModel } from '../models/process-filter-cloud.model';
describe('ProcessFilterCloudService', () => {
let service: ProcessFilterCloudService;
@ -39,7 +33,185 @@ describe('ProcessFilterCloudService', () => {
let createPreferenceSpy: jasmine.Spy;
let getCurrentUserInfoSpy: jasmine.Spy;
const identityUserMock = { username: 'mock-username', firstName: 'fake-identity-first-name', lastName: 'fake-identity-last-name', email: 'fakeIdentity@email.com' };
const identityUserMock = {
username: 'mock-username',
firstName: 'fake-identity-first-name',
lastName: 'fake-identity-last-name',
email: 'fakeIdentity@email.com'
};
const fakeProcessFilter: ProcessFilterCloudModel = {
name: 'MOCK_PROCESS_NAME_1',
id: '1',
key: 'all-mock-process',
icon: 'adjust',
appName: 'mock-appName',
sort: 'startDate',
status: 'MOCK_ALL',
order: 'DESC',
index: 2,
processName: 'process-name',
processInstanceId: 'processinstanceid',
initiator: 'mockuser',
processDefinitionId: 'processDefid',
processDefinitionKey: 'processDefKey',
lastModified: null,
lastModifiedTo: null,
lastModifiedFrom: null
};
const fakeProcessCloudFilterEntries = {
list: {
entries: [
{
entry: {
key: 'process-filters-mock-appName-mock-username',
value: JSON.stringify([
{
name: 'MOCK_PROCESS_NAME_1',
id: '1',
key: 'all-mock-process',
icon: 'adjust',
appName: 'mock-appName',
sort: 'startDate',
status: 'MOCK_ALL',
order: 'DESC'
},
{
name: 'MOCK_PROCESS_NAME_2',
id: '2',
key: 'run-mock-process',
icon: 'adjust',
appName: 'mock-appName',
sort: 'startDate',
status: 'MOCK-RUNNING',
order: 'DESC'
},
{
name: 'MOCK_PROCESS_NAME_3',
id: '3',
key: 'complete-mock-process',
icon: 'adjust',
appName: 'mock-appName',
sort: 'startDate',
status: 'MOCK-COMPLETED',
order: 'DESC'
}
])
}
},
{
entry: {
key: 'mock-key-2',
value: {
name: 'MOCK_PROCESS_NAME_2',
id: '2',
key: 'run-mock-process',
icon: 'adjust',
appName: 'mock-appName',
sort: 'startDate',
status: 'MOCK-RUNNING',
order: 'DESC'
}
}
},
{
entry: {
key: 'mock-key-3',
value: {
name: 'MOCK_PROCESS_NAME_3',
id: '3',
key: 'complete-mock-process',
icon: 'adjust',
appName: 'mock-appName',
sort: 'startDate',
status: 'MOCK-COMPLETED',
order: 'DESC'
}
}
}
],
pagination: {
skipCount: 0,
maxItems: 100,
count: 3,
hasMoreItems: false,
totalItems: 3
}
}
};
const fakeEmptyProcessCloudFilterEntries = {
list: {
entries: [],
pagination: {
skipCount: 0,
maxItems: 100,
count: 0,
hasMoreItems: false,
totalItems: 0
}
}
};
const fakeProcessCloudFilterWithDifferentEntries = {
list: {
entries: [
{
entry: {
key: 'my-mock-key-1',
value: 'my-mock-value-2'
}
},
{
entry: {
key: 'my-mock-key-2',
value: 'my-mock-key-2'
}
}
],
pagination: {
skipCount: 0,
maxItems: 100,
count: 4,
hasMoreItems: false,
totalItems: 2
}
}
};
const fakeProcessCloudFilters = [
{
name: 'MOCK_PROCESS_NAME_1',
id: '1',
key: 'all-mock-process',
icon: 'adjust',
appName: 'mock-appName',
sort: 'startDate',
status: 'MOCK_ALL',
order: 'DESC'
},
{
name: 'MOCK_PROCESS_NAME_2',
id: '2',
key: 'run-mock-process',
icon: 'adjust',
appName: 'mock-appName',
sort: 'startDate',
status: 'MOCK-RUNNING',
order: 'DESC'
},
{
name: 'MOCK_PROCESS_NAME_3',
id: '3',
key: 'complete-mock-process',
icon: 'adjust',
appName: 'mock-appName',
sort: 'startDate',
status: 'MOCK-COMPLETED',
order: 'DESC'
}
];
setupTestBed({
imports: [

View File

@ -38,7 +38,7 @@ export class ProcessHeaderCloudComponent implements OnChanges, OnInit {
@Input()
processInstanceId: string;
processInstanceDetails: ProcessInstanceCloud = new ProcessInstanceCloud();
processInstanceDetails: ProcessInstanceCloud;
properties: CardViewItem[];
dateFormat: string;
dateLocale: string;
@ -56,7 +56,7 @@ export class ProcessHeaderCloudComponent implements OnChanges, OnInit {
ngOnInit() {
this.processCloudService.dataChangesDetected
.pipe(takeUntil(this.onDestroy$))
.subscribe((processDetails: ProcessInstanceCloud) => {
.subscribe((processDetails) => {
this.processInstanceDetails = processDetails;
this.refreshData();
});
@ -155,5 +155,4 @@ export class ProcessHeaderCloudComponent implements OnChanges, OnInit {
this.onDestroy$.next(true);
this.onDestroy$.complete();
}
}

View File

@ -45,10 +45,10 @@ export class ProcessCloudService extends BaseCloudService {
if (appName && processInstanceId) {
const url = `${this.getBasePath(appName)}/query/v1/process-instances/${processInstanceId}`;
return this.get(url).pipe(
map((res: any) => {
return this.get<{ entry: ProcessInstanceCloud }>(url).pipe(
map((res) => {
this.dataChangesDetected.next(res.entry);
return new ProcessInstanceCloud(res.entry);
return res.entry;
})
);
} else {
@ -69,7 +69,7 @@ export class ProcessCloudService extends BaseCloudService {
return this.delete(queryUrl).pipe(
map((res: any) => {
this.dataChangesDetected.next(res.entry);
return new ProcessInstanceCloud(res.entry);
return res.entry;
})
);
} else {

View File

@ -377,7 +377,7 @@ export class StartProcessCloudComponent implements OnChanges, OnInit, OnDestroy
processDefinitionSelectionChanged(processDefinition: ProcessDefinitionCloud) {
if (processDefinition) {
const processInstanceDetails = new ProcessInstanceCloud({ processDefinitionName: processDefinition.name });
const processInstanceDetails: ProcessInstanceCloud = { processDefinitionName: processDefinition.name };
const defaultProcessName = this.processNameCloudPipe.transform(this.name, processInstanceDetails);
this.processInstanceName.setValue(defaultProcessName);
this.processInstanceName.markAsDirty();

View File

@ -19,21 +19,19 @@ import { ProcessInstanceCloud } from '../models/process-instance-cloud.model';
import { ProcessPayloadCloud } from '../models/process-payload-cloud.model';
import { ProcessDefinitionCloud } from '../models/process-definition-cloud.model';
export let fakeProcessInstance = new ProcessInstanceCloud({
export const fakeProcessInstance: ProcessInstanceCloud = {
appName: 'simple-app',
appVersion: '',
id: 'd0b30377-dc5a-11e8-ae24-0a58646001fa',
name: 'My Process Name',
startDate: '2018-10-30T15:45:24.136+0000',
startDate: new Date('2018-10-30T15:45:24.136+0000'),
initiator: 'usermock',
status: 'RUNNING',
processDefinitionId: 'BasicProcess:1:d05062f1-c6fb-11e8-ae24-0a58646001fa',
processDefinitionKey: 'BasicProcess'
});
};
export let fakeCreatedProcessInstance = new ProcessInstanceCloud({
export const fakeCreatedProcessInstance: ProcessInstanceCloud = {
appName: 'simple-app',
appVersion: '',
id: 'd0b30377-dc5a-11e8-ae24-0a58646001fa',
name: 'My Process Name',
startDate: null,
@ -41,9 +39,9 @@ export let fakeCreatedProcessInstance = new ProcessInstanceCloud({
status: 'CREATED',
processDefinitionId: 'BasicProcess:1:d05062f1-c6fb-11e8-ae24-0a58646001fa',
processDefinitionKey: 'BasicProcess'
});
};
export let fakeProcessDefinitions: ProcessDefinitionCloud[] = [
export const fakeProcessDefinitions: ProcessDefinitionCloud[] = [
new ProcessDefinitionCloud({
appName: 'myApp',
appVersion: 0,
@ -100,7 +98,7 @@ export function fakeSingleProcessDefinitionWithoutForm(name: string): ProcessDef
];
}
export let fakeNoNameProcessDefinitions: ProcessDefinitionCloud[] = [
export const fakeNoNameProcessDefinitions: ProcessDefinitionCloud[] = [
new ProcessDefinitionCloud({
appName: 'myApp',
appVersion: 0,
@ -117,13 +115,13 @@ export let fakeNoNameProcessDefinitions: ProcessDefinitionCloud[] = [
})
];
export let fakeProcessPayload = new ProcessPayloadCloud({
export const fakeProcessPayload = new ProcessPayloadCloud({
processDefinitionKey: 'NewProcess:1',
name: 'NewProcess 1',
payloadType: 'string'
});
export let fakeStartForm = {
export const fakeStartForm = {
'formRepresentation': {
'id': 'form-de8895be-d0d7-4434-beef-559b15305d72',
'name': 'StartEventForm',
@ -187,7 +185,7 @@ export let fakeStartForm = {
}
};
export let fakeStartFormNotValid = {
export const fakeStartFormNotValid = {
'formRepresentation': {
'id': 'form-a5d50817-5183-4850-802d-17af54b2632f',
'name': 'simpleform',

View File

@ -15,32 +15,17 @@
* limitations under the License.
*/
export class ProcessInstanceCloud {
appName: string;
id: string;
name: string;
startDate: Date;
initiator: string;
status: string;
businessKey: string;
lastModified: Date;
parentId: string;
processDefinitionId: string;
processDefinitionKey: string;
processDefinitionName: string;
constructor(obj?: any) {
this.appName = obj && obj.appName || null;
this.id = obj && obj.id || null;
this.name = obj && obj.name || null;
this.startDate = obj && obj.startDate || null;
this.initiator = obj && obj.initiator || null;
this.status = obj && obj.status || null;
this.businessKey = obj && obj.businessKey || null;
this.lastModified = obj && obj.lastModified || null;
this.parentId = obj && obj.parentId || null;
this.processDefinitionId = obj && obj.processDefinitionId || null;
this.processDefinitionKey = obj && obj.processDefinitionKey || null;
this.processDefinitionName = obj && obj.processDefinitionName || null;
}
export interface ProcessInstanceCloud {
appName?: string;
id?: string;
name?: string;
startDate?: Date;
initiator?: string;
status?: string;
businessKey?: string;
lastModified?: Date;
parentId?: string;
processDefinitionId?: string;
processDefinitionKey?: string;
processDefinitionName?: string;
}

View File

@ -20,7 +20,6 @@ import { of, throwError } from 'rxjs';
import { setupTestBed, AlfrescoApiService } from '@alfresco/adf-core';
import { StartProcessCloudService } from './start-process-cloud.service';
import { fakeProcessPayload } from '../mock/start-process.component.mock';
import { ProcessInstanceCloud } from '../models/process-instance-cloud.model';
import { HttpErrorResponse, HttpClientModule } from '@angular/common/http';
import { ProcessDefinitionCloud } from '../models/process-definition-cloud.model';
@ -54,7 +53,7 @@ describe('StartProcessCloudService', () => {
spyOn(service, 'startProcess').and.returnValue(of({ id: 'fake-id', name: 'fake-name' }));
service.startProcess('appName1', fakeProcessPayload)
.subscribe(
(res: ProcessInstanceCloud) => {
(res) => {
expect(res).toBeDefined();
expect(res.id).toEqual('fake-id');
expect(res.name).toEqual('fake-name');
@ -119,7 +118,7 @@ describe('StartProcessCloudService', () => {
spyOn(service, 'createProcess').and.returnValue(of({ id: 'fake-id', name: 'fake-name', status: 'CREATED' }));
service.createProcess('appName1', fakeProcessPayload)
.subscribe(
(res: ProcessInstanceCloud) => {
(res) => {
expect(res).toBeDefined();
expect(res.id).toEqual('fake-id');
expect(res.name).toEqual('fake-name');
@ -133,7 +132,7 @@ describe('StartProcessCloudService', () => {
spyOn(service, 'startCreatedProcess').and.returnValue(of({ id: 'fake-id', name: 'fake-name', status: 'RUNNING' }));
service.startCreatedProcess('appName1', 'fake-id', fakeProcessPayload)
.subscribe(
(res: ProcessInstanceCloud) => {
(res) => {
expect(res).toBeDefined();
expect(res.id).toEqual('fake-id');
expect(res.name).toEqual('fake-name');
@ -147,7 +146,7 @@ describe('StartProcessCloudService', () => {
spyOn(alfrescoApiService, 'getInstance').and.returnValue(mock);
service.startCreatedProcess('appName1', 'fake-id', fakeProcessPayload)
.subscribe(
(res: ProcessInstanceCloud) => {
(res) => {
expect(res).toBeDefined();
expect(res.id).toEqual('fake-id');
expect(res.name).toEqual('fake-name');

View File

@ -66,8 +66,7 @@ export class StartProcessCloudService extends BaseCloudService {
payload.payloadType = 'CreateProcessInstancePayload';
return this.post(url, payload).pipe(
map((result: any) => result.entry),
map(processInstance => new ProcessInstanceCloud(processInstance))
map((result: any) => result.entry)
);
}
@ -80,8 +79,7 @@ export class StartProcessCloudService extends BaseCloudService {
const url = `${this.getBasePath(appName)}/rb/v1/process-instances/${createdProcessInstanceId}/start`;
return this.post(url, payload).pipe(
map((result: any) => result.entry),
map(processInstance => new ProcessInstanceCloud(processInstance))
map((result: any) => result.entry)
);
}
@ -95,9 +93,7 @@ export class StartProcessCloudService extends BaseCloudService {
const url = `${this.getBasePath(appName)}/rb/v1/process-instances`;
payload.payloadType = 'StartProcessPayload';
return this.post(url, payload).pipe(
map(processInstance => new ProcessInstanceCloud(processInstance))
);
return this.post(url, payload);
}
/**
@ -112,9 +108,7 @@ export class StartProcessCloudService extends BaseCloudService {
payload.payloadType = 'UpdateProcessPayload';
return this.put(url, payload).pipe(
map((processInstance: any) => {
return new ProcessInstanceCloud(processInstance.entry);
})
map((processInstance: any) => processInstance.entry)
);
}

99
package-lock.json generated
View File

@ -48,19 +48,19 @@
}
},
"@angular-devkit/architect": {
"version": "0.901.9",
"resolved": "https://registry.npmjs.org/@angular-devkit/architect/-/architect-0.901.9.tgz",
"integrity": "sha512-Xokyh7bv4qICHpb5Xui1jPTi6ZZvzR5tbTIxT0DFWqw16TEkFgkNubQsW6mFSR3g3CXdySMfOwWExfa/rE1ggA==",
"version": "0.901.11",
"resolved": "https://registry.npmjs.org/@angular-devkit/architect/-/architect-0.901.11.tgz",
"integrity": "sha512-RmYOq1VEJdQLzwMno+C56WtgscAtoR/7i4tX5b5VxRa2RmQKTxowllYWwgrF5445VGUqzap9H6zJFXvlY2FA0w==",
"dev": true,
"requires": {
"@angular-devkit/core": "9.1.9",
"@angular-devkit/core": "9.1.11",
"rxjs": "6.5.4"
},
"dependencies": {
"@angular-devkit/core": {
"version": "9.1.9",
"resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-9.1.9.tgz",
"integrity": "sha512-SWgBh4an/Vezjw2BZ5S+bKvuK5lH6gOtR8d5YjN9vxpJSZ0GimrGjfnLlWOkwWAsU8jfn4JzofECUHwX/7EW6Q==",
"version": "9.1.11",
"resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-9.1.11.tgz",
"integrity": "sha512-uiEkDvWfMgPHuO4jVgBEr9Kl/LuxHaWYGD2ZtKsOnnHYZyRGp61ot7UcDF+KNdXTiq01JJH84VTd3IttEewmhQ==",
"dev": true,
"requires": {
"ajv": "6.12.0",
@ -89,14 +89,6 @@
"dev": true,
"requires": {
"tslib": "^1.9.0"
},
"dependencies": {
"tslib": {
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz",
"integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==",
"dev": true
}
}
},
"source-map": {
@ -104,6 +96,12 @@
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz",
"integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==",
"dev": true
},
"tslib": {
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz",
"integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==",
"dev": true
}
}
},
@ -892,20 +890,20 @@
}
},
"@angular-devkit/schematics": {
"version": "9.1.9",
"resolved": "https://registry.npmjs.org/@angular-devkit/schematics/-/schematics-9.1.9.tgz",
"integrity": "sha512-aKuMmS3wshOTl9+01jiB50ml09fRN1WfOOtoNqwvKTEi87DrT6Mn3l0eVQo8PJK/bIq/FBmPgsIl2nsETiBSxg==",
"version": "9.1.11",
"resolved": "https://registry.npmjs.org/@angular-devkit/schematics/-/schematics-9.1.11.tgz",
"integrity": "sha512-1A3Oryhl8hpibJK2J5j2FYNzjfvBJcR4wuNRKzl27kBvVsdRXLQzMD3aAgqFvlMgUWhloQs4tZwuinu0E2VP1A==",
"dev": true,
"requires": {
"@angular-devkit/core": "9.1.9",
"@angular-devkit/core": "9.1.11",
"ora": "4.0.3",
"rxjs": "6.5.4"
},
"dependencies": {
"@angular-devkit/core": {
"version": "9.1.9",
"resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-9.1.9.tgz",
"integrity": "sha512-SWgBh4an/Vezjw2BZ5S+bKvuK5lH6gOtR8d5YjN9vxpJSZ0GimrGjfnLlWOkwWAsU8jfn4JzofECUHwX/7EW6Q==",
"version": "9.1.11",
"resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-9.1.11.tgz",
"integrity": "sha512-uiEkDvWfMgPHuO4jVgBEr9Kl/LuxHaWYGD2ZtKsOnnHYZyRGp61ot7UcDF+KNdXTiq01JJH84VTd3IttEewmhQ==",
"dev": true,
"requires": {
"ajv": "6.12.0",
@ -934,14 +932,6 @@
"dev": true,
"requires": {
"tslib": "^1.9.0"
},
"dependencies": {
"tslib": {
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz",
"integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==",
"dev": true
}
}
},
"source-map": {
@ -949,6 +939,12 @@
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz",
"integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==",
"dev": true
},
"tslib": {
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz",
"integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==",
"dev": true
}
}
},
@ -3871,17 +3867,18 @@
}
},
"@nrwl/workspace": {
"version": "9.3.0",
"resolved": "https://registry.npmjs.org/@nrwl/workspace/-/workspace-9.3.0.tgz",
"integrity": "sha512-IXIWnximAQDpFxifZzETFyF58ul5t4kIAojlwxoF/V9BGAnIwlMxodcsPmqXp1b25vX8w6ir5DeHN+Efz1YuGg==",
"version": "9.5.1",
"resolved": "https://registry.npmjs.org/@nrwl/workspace/-/workspace-9.5.1.tgz",
"integrity": "sha512-lUaK4U8qRJijWhgje71pjGHxI+aaXKlYh4ROgC2i/k6pJ1CEMEwdIIaK7Hl4u3Q/NJHmtXobZd/nBAqsNLB5vg==",
"dev": true,
"requires": {
"@angular-devkit/core": "~9.1.0",
"@angular-devkit/schematics": "~9.1.0",
"@nrwl/cli": "9.3.0",
"@nrwl/cli": "9.5.1",
"axios": "0.19.2",
"chalk": "2.4.2",
"cosmiconfig": "4.0.0",
"dotenv": "8.2.0",
"fs-extra": "6.0.0",
"hasha": "5.1.0",
"ignore": "5.0.4",
@ -3896,9 +3893,9 @@
},
"dependencies": {
"@angular-devkit/core": {
"version": "9.1.9",
"resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-9.1.9.tgz",
"integrity": "sha512-SWgBh4an/Vezjw2BZ5S+bKvuK5lH6gOtR8d5YjN9vxpJSZ0GimrGjfnLlWOkwWAsU8jfn4JzofECUHwX/7EW6Q==",
"version": "9.1.11",
"resolved": "https://registry.npmjs.org/@angular-devkit/core/-/core-9.1.11.tgz",
"integrity": "sha512-uiEkDvWfMgPHuO4jVgBEr9Kl/LuxHaWYGD2ZtKsOnnHYZyRGp61ot7UcDF+KNdXTiq01JJH84VTd3IttEewmhQ==",
"dev": true,
"requires": {
"ajv": "6.12.0",
@ -3915,25 +3912,17 @@
"dev": true,
"requires": {
"tslib": "^1.9.0"
},
"dependencies": {
"tslib": {
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz",
"integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==",
"dev": true
}
}
}
}
},
"@nrwl/cli": {
"version": "9.3.0",
"resolved": "https://registry.npmjs.org/@nrwl/cli/-/cli-9.3.0.tgz",
"integrity": "sha512-S3fZg9g/+sVovoEwW00i1MiRQ70BWu55rsHyl8PxN+cciNOnnWP88IjZFnRreoLUnRaNhOlOE8AEp7q2x0M38A==",
"version": "9.5.1",
"resolved": "https://registry.npmjs.org/@nrwl/cli/-/cli-9.5.1.tgz",
"integrity": "sha512-HldjuqLgeBZL6a0IheAiiIusZAvBrt61Fi+3lJh5lMm7GyDZ1D76ScQaMsPZ4+ezg/mHs+opxJ1GCLbSujzu/w==",
"dev": true,
"requires": {
"@nrwl/tao": "9.3.0",
"@nrwl/tao": "9.5.1",
"chalk": "2.4.2",
"tmp": "0.0.33",
"yargs": "^11.0.0",
@ -3941,9 +3930,9 @@
}
},
"@nrwl/tao": {
"version": "9.3.0",
"resolved": "https://registry.npmjs.org/@nrwl/tao/-/tao-9.3.0.tgz",
"integrity": "sha512-jD8dt3sMFKMK4Z8WXEwRTF2AJ12u1v19L0Dhdp+KOETelf0BlzvIhEmgJx2vfcsGMe+oVzTTEwMnWsouXm6cMg==",
"version": "9.5.1",
"resolved": "https://registry.npmjs.org/@nrwl/tao/-/tao-9.5.1.tgz",
"integrity": "sha512-fEGWZqBpfBM2buo0wQqPBI0jTJlL6msziSkjEv6/PGDEZTQsgII6WovTthqOHqLwO+i4B8bUYCZPdG6Iopl0Gg==",
"dev": true,
"requires": {
"@angular-devkit/architect": "~0.901.0",
@ -4147,6 +4136,12 @@
"integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==",
"dev": true
},
"tslib": {
"version": "1.13.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.13.0.tgz",
"integrity": "sha512-i/6DQjL8Xf3be4K/E6Wgpekn5Qasl1usyw++dAA35Ue5orEn65VIxOA+YvNNl9HV3qv70T7CNwjODHZrLwvd1Q==",
"dev": true
},
"wrap-ansi": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-2.1.0.tgz",

View File

@ -6,8 +6,8 @@
"author": "Alfresco Software, Ltd.",
"main": "./index.js",
"scripts": {
"postinstall": "ngcc",
"ng": "ng",
"postinstall": "ngcc && node ./decorate-angular-cli.js",
"ng": "nx",
"concurrently": "concurrently",
"ng-packagr": "node ./node_modules/ng-packagr/cli/main.js",
"webpack": "node ./node_modules/webpack/bin/webpack.js",
@ -112,7 +112,7 @@
"@angular/cli": "^10.0.3",
"@angular/compiler-cli": "^10.0.4",
"@nrwl/schematics": "8.12.11",
"@nrwl/workspace": "9.3.0",
"@nrwl/workspace": "9.5.1",
"@paperist/types-remark": "^0.1.3",
"@types/jasmine": "~2.8.3",
"@types/jasminewd2": "~2.0.2",