[PRODENG-211] integrate JS-API with monorepo (part 1) (#9081)

* integrate JS-API with monorepo

* [ci:force] fix token issue

[ci:force] migrate docs folder

[ci:force] clean personal tokens

* [ci:force] gha workflow support

* [ci:force] npm publish target

* fix js-api test linting

* [ci:force] fix test linting, mocks, https scheme

* [ci:force] fix https scheme

* [ci:force] typescript mappings

* [ci:force] update scripts

* lint fixes

* linting fixes

* fix linting

* [ci:force] linting fixes

* linting fixes

* [ci:force] remove js-api upstream and corresponding scripts

* [ci:force] jsdoc fixes

* fix jsdoc linting

* [ci:force] jsdoc fixes

* [ci:force] jsdoc fixes

* jsdoc fixes

* jsdoc fixes

* jsdoc fixes

* [ci:force] fix jsdoc

* [ci:force] reduce code duplication

* replace 'chai' expect with node.js assert

* replace 'chai' expect with node.js assert

* [ci:force] remove chai and chai-spies for js-api testing

* [ci:force] cleanup and fix imports

* [ci:force] fix linting

* [ci:force] fix unit test

* [ci:force] fix sonar linting findings

* [ci:force] switch activiti api models to interfaces (-2.5% reduction of bundle)

* [ci:force] switch activiti api models to interfaces

* [ci:force] switch AGS api models to interfaces

* [ci:force] switch AGS api models to interfaces

* [ci:force] switch search api models to interfaces

* [ci:force] switch content api models to interfaces where applicable
This commit is contained in:
Denys Vuika
2023-11-21 10:27:51 +00:00
committed by GitHub
parent 804fa2ffd4
commit ea2c0ce229
1334 changed files with 82605 additions and 1068 deletions

View File

@@ -0,0 +1,56 @@
/*!
* @license
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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 assert from 'assert';
import { AlfrescoApi, ModelsApi } from '../../src';
import { BpmAuthMock, ModelsMock } from '../mockObjects';
describe('Activiti Models Api', () => {
let authResponseBpmMock: BpmAuthMock;
let modelsMock: ModelsMock;
let modelsApi: ModelsApi;
beforeEach(async () => {
const hostBpm = 'https://127.0.0.1:9999';
authResponseBpmMock = new BpmAuthMock(hostBpm);
authResponseBpmMock.get200Response();
modelsMock = new ModelsMock(hostBpm);
const alfrescoJsApi = new AlfrescoApi({
hostBpm,
provider: 'BPM'
});
modelsApi = new ModelsApi(alfrescoJsApi);
await alfrescoJsApi.login('admin', 'admin');
});
it('get activiti model', async () => {
modelsMock.get200getModels();
const opts = {
filter: 'myReusableForms',
modelType: 2
};
const data = await modelsApi.getModels(opts);
assert.equal(data.data[0].name, 'Metadata');
});
});

View File

@@ -0,0 +1,56 @@
/*!
* @license
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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 assert from 'assert';
import { AlfrescoApi, ModelJsonBpmnApi } from '../../src';
import { BpmAuthMock, ModelJsonBpmMock } from '../mockObjects';
describe('Activiti Model JsonBpmn Api', () => {
let authResponseBpmMock: BpmAuthMock;
let modelJsonBpmMock: ModelJsonBpmMock;
let modelJsonBpmnApi: ModelJsonBpmnApi;
beforeEach(async () => {
const hostBpm = 'https://127.0.0.1:9999';
authResponseBpmMock = new BpmAuthMock(hostBpm);
authResponseBpmMock.get200Response();
modelJsonBpmMock = new ModelJsonBpmMock(hostBpm);
const alfrescoJsApi = new AlfrescoApi({
hostBpm,
provider: 'BPM'
});
modelJsonBpmnApi = new ModelJsonBpmnApi(alfrescoJsApi);
await alfrescoJsApi.login('admin', 'admin');
});
it('get Model JsonBpmn', async () => {
modelJsonBpmMock.get200EditorDisplayJsonClient();
const data = await modelJsonBpmnApi.getEditorDisplayJsonClient(1);
assert.notEqual(data, null);
});
it('get Model JsonBpmn history', async () => {
modelJsonBpmMock.get200HistoricEditorDisplayJsonClient();
const data = await modelJsonBpmnApi.getHistoricEditorDisplayJsonClient(1, 1);
assert.notEqual(data, null);
});
});

View File

@@ -0,0 +1,84 @@
/*!
* @license
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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 assert from 'assert';
import { BpmAuthMock, ProcessMock } from '../mockObjects';
import { AlfrescoApi, ProcessDefinitionsApi, ProcessInstanceQueryRepresentation, ProcessInstancesApi } from '../../src';
describe('Activiti Process Api', () => {
let authResponseBpmMock: BpmAuthMock;
let processMock: ProcessMock;
let alfrescoJsApi: AlfrescoApi;
let processInstancesApi: ProcessInstancesApi;
let processDefinitionsApi: ProcessDefinitionsApi;
beforeEach(async () => {
const BPM_HOST = 'https://127.0.0.1:9999';
authResponseBpmMock = new BpmAuthMock(BPM_HOST);
processMock = new ProcessMock(BPM_HOST);
authResponseBpmMock.get200Response();
alfrescoJsApi = new AlfrescoApi({
hostBpm: BPM_HOST,
provider: 'BPM'
});
processInstancesApi = new ProcessInstancesApi(alfrescoJsApi);
processDefinitionsApi = new ProcessDefinitionsApi(alfrescoJsApi);
await alfrescoJsApi.login('admin', 'admin');
});
it('get activiti Process list filtered', (done) => {
processMock.get200Response();
const requestNode: ProcessInstanceQueryRepresentation = {
page: 0,
sort: 'created-desc',
state: 'completed'
};
processInstancesApi.getProcessInstances(requestNode).then((data) => {
assert.equal(data.data[0].name, 'Process Test Api - July 26th 2016');
assert.equal(data.data[1].name, 'Process Test Api - July 26th 2016');
assert.equal(data.size, 2);
done();
});
});
it('get activiti Process list', (done) => {
processMock.get200Response();
processInstancesApi.getProcessInstances({}).then((data) => {
assert.equal(data.data[0].name, 'Process Test Api - July 26th 2016');
assert.equal(data.data[1].name, 'Process Test Api - July 26th 2016');
done();
});
});
it('get process definition startForm', (done) => {
processMock.get200getProcessDefinitionStartForm();
const processDefinitionId = 'testProcess:1:7504';
processDefinitionsApi.getProcessDefinitionStartForm(processDefinitionId).then((data) => {
assert.equal(data.processDefinitionId, 'testProcess:1:7504');
done();
});
});
});

View File

@@ -0,0 +1,174 @@
/*!
* @license
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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 assert from 'assert';
import { BpmAuthMock, ProcessInstanceVariablesMock } from '../mockObjects';
import { ProcessInstanceVariablesApi, AlfrescoApi } from '../../src';
describe('Activiti Process Instance Variables Api', () => {
let authResponseBpmMock: BpmAuthMock;
let variablesMock: ProcessInstanceVariablesMock;
let alfrescoJsApi: AlfrescoApi;
let processInstanceVariablesApi: ProcessInstanceVariablesApi;
const NOOP = () => {
/* empty */
};
beforeEach(async () => {
const BPM_HOST = 'https://127.0.0.1:9999';
authResponseBpmMock = new BpmAuthMock(BPM_HOST);
variablesMock = new ProcessInstanceVariablesMock(BPM_HOST);
authResponseBpmMock.get200Response();
alfrescoJsApi = new AlfrescoApi({
hostBpm: BPM_HOST,
provider: 'BPM'
});
processInstanceVariablesApi = new ProcessInstanceVariablesApi(alfrescoJsApi);
await alfrescoJsApi.login('admin', 'admin');
});
describe('get variables', () => {
it('should return all variables for a process instance', (done) => {
const processInstanceId = '111';
variablesMock.addListProcessInstanceVariables200Response(processInstanceId);
processInstanceVariablesApi.getProcessInstanceVariables(processInstanceId).then((data) => {
assert.equal(data.length, 2);
done();
});
});
it('should emit an error when API returns an error response', (done) => {
const processInstanceId = '111';
variablesMock.addListProcessInstanceVariables500Response(processInstanceId);
processInstanceVariablesApi.getProcessInstanceVariables(processInstanceId).then(NOOP, (error) => {
assert.equal(error.status, 500);
assert.equal(error.message, '{"messageKey":"UNKNOWN","message":"Unknown error"}');
done();
});
});
});
describe('create or update variables', () => {
it('should return all variables for a process instance', (done) => {
const processInstanceId = '111';
variablesMock.addPutProcessInstanceVariables200Response(processInstanceId);
processInstanceVariablesApi.createOrUpdateProcessInstanceVariables(processInstanceId, []).then((data) => {
assert.equal(data.length, 2);
done();
});
});
it('should emit an error when API returns an error response', (done) => {
const processInstanceId = '111';
variablesMock.addPutProcessInstanceVariables500Response(processInstanceId);
processInstanceVariablesApi.createOrUpdateProcessInstanceVariables(processInstanceId, []).then(NOOP, (error) => {
assert.equal(error.status, 500);
assert.equal(error.message, '{"messageKey":"UNKNOWN","message":"Unknown error"}');
done();
});
});
});
describe('get variable', () => {
it('should call API to get variable', (done) => {
const processInstanceId = '111';
const variableName = 'var1';
variablesMock.addGetProcessInstanceVariable200Response(processInstanceId, variableName);
processInstanceVariablesApi.getProcessInstanceVariable(processInstanceId, variableName).then(
(data) => {
assert.equal(data.name, 'variable1');
assert.equal(data.value, 'Value 123');
done();
},
() => {
done();
}
);
});
it('should emit an error when API returns an error response', (done) => {
const processInstanceId = '111';
const variableName = 'var1';
variablesMock.addGetProcessInstanceVariable500Response(processInstanceId, variableName);
processInstanceVariablesApi.getProcessInstanceVariable(processInstanceId, variableName).then(NOOP, (error) => {
assert.equal(error.status, 500);
assert.equal(error.message, '{"messageKey":"UNKNOWN","message":"Unknown error"}');
done();
});
});
});
describe('update variable', () => {
it('should call API to update variable', (done) => {
const processInstanceId = '111';
const variableName = 'var1';
variablesMock.addUpdateProcessInstanceVariable200Response(processInstanceId, variableName);
processInstanceVariablesApi.updateProcessInstanceVariable(processInstanceId, variableName, {}).then(() => {
done();
});
});
it('should emit an error when API returns an error response', (done) => {
const processInstanceId = '111';
const variableName = 'var1';
variablesMock.addUpdateProcessInstanceVariable500Response(processInstanceId, variableName);
processInstanceVariablesApi.updateProcessInstanceVariable(processInstanceId, variableName, {}).then(NOOP, (error) => {
assert.equal(error.status, 500);
assert.equal(error.message, '{"messageKey":"UNKNOWN","message":"Unknown error"}');
done();
});
});
});
describe('delete variable', () => {
it('should call API to delete variables', (done) => {
const processInstanceId = '111';
const variableName = 'var1';
variablesMock.addDeleteProcessInstanceVariable200Response(processInstanceId, variableName);
processInstanceVariablesApi.deleteProcessInstanceVariable(processInstanceId, variableName).then(() => {
done();
});
});
it('should emit an error when API returns an error response', (done) => {
const processInstanceId = '111';
const variableName = 'var1';
variablesMock.addDeleteProcessInstanceVariable500Response(processInstanceId, variableName);
processInstanceVariablesApi.deleteProcessInstanceVariable(processInstanceId, variableName).then(NOOP, (error) => {
assert.equal(error.status, 500);
assert.equal(error.message, '{"messageKey":"UNKNOWN","message":"Unknown error"}');
done();
});
});
});
});

View File

@@ -0,0 +1,62 @@
/*!
* @license
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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 assert from 'assert';
import { AlfrescoApi, UserProfileApi } from '../../src';
import { BpmAuthMock, ProfileMock } from '../mockObjects';
describe('Activiti Profile Api', () => {
let profileApi: UserProfileApi;
let profileMock: ProfileMock;
let authResponseBpmMock: BpmAuthMock;
beforeEach(async () => {
const BPM_HOST = 'https://127.0.0.1:9999';
authResponseBpmMock = new BpmAuthMock(BPM_HOST);
profileMock = new ProfileMock(BPM_HOST);
authResponseBpmMock.get200Response();
const alfrescoApi = new AlfrescoApi({
hostBpm: BPM_HOST,
provider: 'BPM'
});
profileApi = new UserProfileApi(alfrescoApi);
await alfrescoApi.login('admin', 'admin');
});
it('get Profile Picture', async () => {
profileMock.get200getProfilePicture();
await profileApi.getProfilePicture();
});
it('get Profile url Picture', () => {
assert.equal(profileApi.getProfilePictureUrl(), 'https://127.0.0.1:9999/activiti-app/app/rest/admin/profile-picture');
});
it('get Profile', async () => {
profileMock.get200getProfile();
const data = await profileApi.getProfile();
assert.equal(data.lastName, 'Administrator');
assert.equal(data.groups[0].name, 'analytics-users');
assert.equal(data.tenantName, 'test');
});
});

View File

@@ -0,0 +1,203 @@
/*!
* @license
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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 assert from 'assert';
import { BpmAuthMock, ReportsMock } from '../mockObjects';
import { ReportApi, AlfrescoApi } from '../../src';
describe('Activiti Report Api', () => {
let authResponseBpmMock: BpmAuthMock;
let reportsMock: ReportsMock;
let alfrescoJsApi: AlfrescoApi;
let reportApi: ReportApi;
beforeEach(async () => {
const BPM_HOST = 'https://127.0.0.1:9999';
authResponseBpmMock = new BpmAuthMock(BPM_HOST);
reportsMock = new ReportsMock(BPM_HOST);
authResponseBpmMock.get200Response();
alfrescoJsApi = new AlfrescoApi({
hostBpm: BPM_HOST,
provider: 'BPM'
});
reportApi = new ReportApi(alfrescoJsApi);
await alfrescoJsApi.login('admin', 'admin');
});
it('should create the default reports', async () => {
reportsMock.get200ResponseCreateDefaultReport();
await reportApi.createDefaultReports();
});
it('should return the tasks referring to the process id', async () => {
const reportId = '11015';
const processDefinitionId = 'Process_sid-0FF10DA3-E2BD-4E6A-9013-6D66FC8A4716:1:30004';
reportsMock.get200ResponseTasksByProcessDefinitionId(reportId, processDefinitionId);
const data = await reportApi.getTasksByProcessDefinitionId(reportId, processDefinitionId);
assert.equal(data.length, 3);
assert.equal(data[0], 'Fake Task 1');
assert.equal(data[1], 'Fake Task 2');
assert.equal(data[2], 'Fake Task 3');
});
it('should return the chart reports', async () => {
const reportId = '11015';
const paramsQuery = { status: 'All' };
reportsMock.get200ResponseReportsByParams(reportId, paramsQuery);
const data = await reportApi.getReportsByParams(reportId, paramsQuery);
assert.equal(data.elements.length, 3);
assert.equal(data.elements[0].type, 'table');
assert.equal(data.elements[1].type, 'pieChart');
assert.equal(data.elements[1].titleKey, 'REPORTING.DEFAULT-REPORTS.PROCESS-DEFINITION-OVERVIEW.PROC-INST-CHART-TITLE');
assert.equal(data.elements[2].type, 'table');
assert.equal(data.elements[2].titleKey, 'REPORTING.DEFAULT-REPORTS.PROCESS-DEFINITION-OVERVIEW.DETAIL-TABLE');
});
it('should return the process definitions when the appId is not provided', async () => {
reportsMock.get200ResponseProcessDefinitions();
const res = await reportApi.getProcessDefinitions();
assert.equal(res.length, 4);
assert.equal(res[0].id, 'Process_sid-0FF10DA3-E2BD-4E6A-9013-6D66FC8A4716:1:30004');
assert.equal(res[0].name, 'Fake Process Name 1');
assert.equal(res[1].id, 'SecondProcess:1:15027');
assert.equal(res[1].name, 'Fake Process Name 2');
assert.equal(res[2].id, 'Simpleprocess:15:10004');
assert.equal(res[2].name, 'Fake Process Name 3');
assert.equal(res[3].id, 'fruitorderprocess:5:42530');
assert.equal(res[3].name, 'Fake Process Name 4');
});
it('should return the report list', async () => {
reportsMock.get200ResponseReportList();
const res = await reportApi.getReportList();
assert.equal(res.length, 5);
assert.equal(res[0].id, 11011);
assert.equal(res[0].name, 'Process definition heat map');
assert.equal(res[1].id, 11012);
assert.equal(res[1].name, 'Process definition overview');
assert.equal(res[2].id, 11013);
assert.equal(res[2].name, 'Process instances overview');
assert.equal(res[3].id, 11014);
assert.equal(res[3].name, 'Task overview');
assert.equal(res[4].id, 11015);
assert.equal(res[4].name, 'Task service level agreement');
});
it('should return the report parameters', async () => {
const reportId = '11013'; // String | reportId
reportsMock.get200ResponseReportParams(reportId);
const res = await reportApi.getReportParams(reportId);
const paramsDefinition = JSON.parse(res.definition);
assert.equal(res.id, 11013);
assert.equal(res.name, 'Process instances overview');
assert.equal(paramsDefinition.parameters.length, 4);
assert.equal(paramsDefinition.parameters[0].id, 'processDefinitionId');
assert.equal(paramsDefinition.parameters[0].nameKey, 'REPORTING.DEFAULT-REPORTS.PROCESS-INSTANCES-OVERVIEW.PROCESS-DEFINITION');
assert.equal(paramsDefinition.parameters[0].type, 'processDefinition');
assert.equal(paramsDefinition.parameters[1].id, 'dateRange');
assert.equal(paramsDefinition.parameters[1].nameKey, 'REPORTING.DEFAULT-REPORTS.PROCESS-INSTANCES-OVERVIEW.DATE-RANGE');
assert.equal(paramsDefinition.parameters[1].type, 'dateRange');
assert.equal(paramsDefinition.parameters[2].id, 'slowProcessInstanceInteger');
assert.equal(paramsDefinition.parameters[2].nameKey, 'REPORTING.DEFAULT-REPORTS.PROCESS-INSTANCES-OVERVIEW.SLOW-PROC-INST-NUMBER');
assert.equal(paramsDefinition.parameters[2].type, 'integer');
assert.equal(paramsDefinition.parameters[3].id, 'status');
assert.equal(paramsDefinition.parameters[3].nameKey, 'REPORTING.PROCESS-STATUS');
assert.equal(paramsDefinition.parameters[3].type, 'status');
});
it('should update the report', async () => {
const reportId = '11015';
const name = 'New Fake Name';
reportsMock.get200ResponseUpdateReport(reportId);
await reportApi.updateReport(reportId, name);
});
it('should export the report', async () => {
const reportId = '11015'; // String | reportId
const queryParams = {
processDefinitionId: 'TEST:99:999',
dateRange: {
startDate: '2017-01-01T00:00:00.000Z',
endDate: '2017-01-24T23:59:59.999Z',
rangeId: 'currentYear'
},
slowProcessInstanceInteger: 10,
status: 'All',
reportName: 'FAKE_REPORT_NAME'
};
reportsMock.get200ResponseExportReport(reportId);
const response = await reportApi.exportToCsv(reportId, queryParams);
assert.notEqual(response, null);
assert.notEqual(response, undefined);
});
it('should save the report', async () => {
const reportId = '11015'; // String | reportId
const queryParams = {
processDefinitionId: 'TEST:99:999',
dateRange: {
startDate: '2017-01-01T00:00:00.000Z',
endDate: '2017-01-24T23:59:59.999Z',
rangeId: 'currentYear'
},
slowProcessInstanceInteger: 10,
status: 'All',
reportName: 'FAKE_REPORT_NAME'
};
reportsMock.get200ResponseSaveReport(reportId);
await reportApi.saveReport(reportId, queryParams);
});
it('should delete a report', async () => {
const reportId = '11015';
reportsMock.get200ResponseDeleteReport(reportId);
await reportApi.deleteReport(reportId);
});
});

View File

@@ -0,0 +1,169 @@
/*!
* @license
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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 assert from 'assert';
import {
AlfrescoApi,
TaskFilterRequestRepresentation,
TaskRepresentation,
TaskFormsApi,
TaskActionsApi,
TasksApi,
TaskQueryRepresentation
} from '../../src';
import { BpmAuthMock, TasksMock } from '../mockObjects';
describe('Activiti Task Api', () => {
let authResponseBpmMock: BpmAuthMock;
let tasksMock: TasksMock;
let alfrescoJsApi: AlfrescoApi;
let tasksApi: TasksApi;
let taskFormsApi: TaskFormsApi;
let taskActionsApi: TaskActionsApi;
const NOOP = () => {
/* empty */
};
beforeEach(async () => {
const BPM_HOST = 'https://127.0.0.1:9999';
authResponseBpmMock = new BpmAuthMock(BPM_HOST);
tasksMock = new TasksMock(BPM_HOST);
authResponseBpmMock.get200Response();
alfrescoJsApi = new AlfrescoApi({
hostBpm: BPM_HOST,
provider: 'BPM'
});
tasksApi = new TasksApi(alfrescoJsApi);
taskFormsApi = new TaskFormsApi(alfrescoJsApi);
taskActionsApi = new TaskActionsApi(alfrescoJsApi);
await alfrescoJsApi.login('admin', 'admin');
});
it('get Task list', async () => {
tasksMock.get200Response();
const requestNode = new TaskQueryRepresentation();
const data = await tasksApi.listTasks(requestNode);
assert.equal(data.data[0].processDefinitionName, 'Process Test Api');
assert.equal(data.data[1].processDefinitionName, 'Process Test Api');
assert.equal(data.size, 2);
});
it('get Task', async () => {
tasksMock.get200ResponseGetTask('10');
const data = await tasksApi.getTask('10');
assert.equal(data.name, 'Upload Document');
});
it('bad filter Tasks', (done) => {
tasksMock.get400TaskFilter();
const requestNode = new TaskFilterRequestRepresentation();
tasksApi.filterTasks(requestNode).then(NOOP, () => {
done();
});
});
it('filter Tasks', async () => {
tasksMock.get200TaskFilter();
const requestNode = new TaskFilterRequestRepresentation();
requestNode.appDefinitionId = 1;
const data = await tasksApi.filterTasks(requestNode);
assert.equal(data.size, 2);
assert.equal(data.data[0].id, '7506');
});
it('complete Task not found', (done) => {
const taskId = '200';
tasksMock.get404CompleteTask(taskId);
taskActionsApi.completeTask(taskId).then(NOOP, () => {
done();
});
});
it('complete Task ', async () => {
const taskId = '5006';
tasksMock.put200GenericResponse('/activiti-app/api/enterprise/tasks/5006/action/complete');
await taskActionsApi.completeTask(taskId);
});
it('Create a Task', async () => {
const taskName = 'test-name';
tasksMock.get200CreateTask(taskName);
const taskRepresentation = new TaskRepresentation();
taskRepresentation.name = taskName;
await tasksApi.createNewTask(taskRepresentation);
});
it('Get task form', async () => {
tasksMock.get200getTaskForm();
const taskId = '2518';
const data = await taskFormsApi.getTaskForm(taskId);
assert.equal(data.name, 'Metadata');
assert.equal(data.fields[0].name, 'Label');
assert.equal(data.fields[0].fieldType, 'ContainerRepresentation');
});
it('Get getRestFieldValuesColumn ', async () => {
tasksMock.get200getTaskForm();
const taskId = '2518';
const data = await taskFormsApi.getTaskForm(taskId);
assert.equal(data.name, 'Metadata');
assert.equal(data.fields[0].name, 'Label');
assert.equal(data.fields[0].fieldType, 'ContainerRepresentation');
});
it('get form field values that are populated through a REST backend', async () => {
tasksMock.get200getRestFieldValuesColumn();
const taskId = '1';
const field = 'label';
const column = 'user';
await taskFormsApi.getRestFieldColumnValues(taskId, field, column);
});
it('get form field values that are populated through a REST backend Specific case to retrieve information on a specific column', async () => {
tasksMock.get200getRestFieldValues();
const taskId = '2';
const field = 'label';
await taskFormsApi.getRestFieldValues(taskId, field);
});
});

View File

@@ -0,0 +1,65 @@
/*!
* @license
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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 assert from 'assert';
import { TaskFormsApi, AlfrescoApi } from '../../src';
import { BpmAuthMock, TaskFormMock } from '../mockObjects';
describe('Activiti Task Api', () => {
let authResponseBpmMock: BpmAuthMock;
let taskFormMock: TaskFormMock;
let alfrescoJsApi: AlfrescoApi;
let taskFormsApi: TaskFormsApi;
beforeEach(async () => {
const BPM_HOST = 'https://127.0.0.1:9999';
authResponseBpmMock = new BpmAuthMock(BPM_HOST);
taskFormMock = new TaskFormMock(BPM_HOST);
authResponseBpmMock.get200Response();
alfrescoJsApi = new AlfrescoApi({
hostBpm: BPM_HOST,
provider: 'BPM'
});
taskFormsApi = new TaskFormsApi(alfrescoJsApi);
await alfrescoJsApi.login('admin', 'admin');
});
it('get Task Form variables list', async () => {
taskFormMock.get200getTaskFormVariables();
const taskId = '5028';
const data = await taskFormsApi.getTaskFormVariables(taskId);
assert.equal(data[0].id, 'initiator');
});
it('Check cookie settings', async () => {
taskFormMock.get200getTaskFormVariables();
const taskId = '5028';
await taskFormsApi.getTaskFormVariables(taskId);
assert.equal(
(taskFormsApi.apiClient as any).authentications.cookie,
'ACTIVITI_REMEMBER_ME=NjdOdGwvcUtFTkVEczQyMGh4WFp5QT09OmpUL1UwdFVBTC94QTJMTFFUVFgvdFE9PQ'
);
});
});

View File

@@ -0,0 +1,54 @@
/*!
* @license
* Copyright © 2005-2023 Hyland Software, Inc. and its affiliates. All rights reserved.
*
* 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 assert from 'assert';
import { AlfrescoApi, UserFiltersApi } from '../../src';
import { BpmAuthMock, UserFiltersMock } from '../mockObjects';
describe('Activiti User Filter Api', () => {
const hostBpm = 'https://127.0.0.1:9999';
let authResponseBpmMock: BpmAuthMock;
let filtersMock: UserFiltersMock;
let userFiltersApi: UserFiltersApi;
beforeEach(async () => {
authResponseBpmMock = new BpmAuthMock(hostBpm);
filtersMock = new UserFiltersMock(hostBpm);
authResponseBpmMock.get200Response();
const alfrescoJsApi = new AlfrescoApi({
hostBpm,
provider: 'BPM'
});
userFiltersApi = new UserFiltersApi(alfrescoJsApi);
await alfrescoJsApi.login('admin', 'admin');
});
it('get filter user', async () => {
filtersMock.get200getUserTaskFilters();
const opts = {
appId: 1 // Integer | appId
};
const data = await userFiltersApi.getUserTaskFilters(opts);
assert.equal(data.data[0].name, 'Involved Tasks');
});
});