mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
migrate js-api tests from Jest to Node.js native test runner (#12104)
This commit is contained in:
@@ -16,8 +16,10 @@
|
||||
*/
|
||||
|
||||
import assert from 'assert';
|
||||
import { resetGlobalMockAgent } from '../mockObjects/base.mock';
|
||||
import { AlfrescoApi, ModelsApi } from '../../src';
|
||||
import { BpmAuthMock, ModelsMock } from '../mockObjects';
|
||||
import { describe, it, beforeEach, afterEach } from 'node:test';
|
||||
|
||||
describe('Activiti Models Api', () => {
|
||||
let authResponseBpmMock: BpmAuthMock;
|
||||
@@ -42,6 +44,10 @@ describe('Activiti Models Api', () => {
|
||||
await alfrescoJsApi.login('admin', 'admin');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
resetGlobalMockAgent();
|
||||
});
|
||||
|
||||
it('get activiti model', async () => {
|
||||
modelsMock.get200getModels();
|
||||
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
*/
|
||||
|
||||
import assert from 'assert';
|
||||
import { resetGlobalMockAgent } from '../mockObjects/base.mock';
|
||||
import { AlfrescoApi, ModelJsonBpmnApi } from '../../src';
|
||||
import { BpmAuthMock, ModelJsonBpmMock } from '../mockObjects';
|
||||
import { describe, it, beforeEach, afterEach } from 'node:test';
|
||||
|
||||
describe('Activiti Model JsonBpmn Api', () => {
|
||||
let authResponseBpmMock: BpmAuthMock;
|
||||
@@ -42,6 +44,10 @@ describe('Activiti Model JsonBpmn Api', () => {
|
||||
await alfrescoJsApi.login('admin', 'admin');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
resetGlobalMockAgent();
|
||||
});
|
||||
|
||||
it('get Model JsonBpmn', async () => {
|
||||
modelJsonBpmMock.get200EditorDisplayJsonClient();
|
||||
const data = await modelJsonBpmnApi.getEditorDisplayJsonClient(1);
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
*/
|
||||
|
||||
import assert from 'assert';
|
||||
import { resetGlobalMockAgent } from '../mockObjects/base.mock';
|
||||
import { BpmAuthMock, ProcessMock } from '../mockObjects';
|
||||
import { AlfrescoApi, ProcessDefinitionsApi, ProcessInstanceQueryRepresentation, ProcessInstancesApi } from '../../src';
|
||||
import { describe, it, beforeEach, afterEach } from 'node:test';
|
||||
|
||||
describe('Activiti Process Api', () => {
|
||||
let authResponseBpmMock: BpmAuthMock;
|
||||
@@ -45,7 +47,11 @@ describe('Activiti Process Api', () => {
|
||||
await alfrescoJsApi.login('admin', 'admin');
|
||||
});
|
||||
|
||||
it('get activiti Process list filtered', (done) => {
|
||||
afterEach(() => {
|
||||
resetGlobalMockAgent();
|
||||
});
|
||||
|
||||
it('get activiti Process list filtered', async () => {
|
||||
processMock.get200Response();
|
||||
|
||||
const requestNode: ProcessInstanceQueryRepresentation = {
|
||||
@@ -54,31 +60,25 @@ describe('Activiti Process Api', () => {
|
||||
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();
|
||||
});
|
||||
const data = await processInstancesApi.getProcessInstances(requestNode);
|
||||
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);
|
||||
});
|
||||
|
||||
it('get activiti Process list', (done) => {
|
||||
it('get activiti Process list', async () => {
|
||||
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();
|
||||
});
|
||||
const data = await processInstancesApi.getProcessInstances({});
|
||||
assert.equal(data.data[0].name, 'Process Test Api - July 26th 2016');
|
||||
assert.equal(data.data[1].name, 'Process Test Api - July 26th 2016');
|
||||
});
|
||||
|
||||
it('get process definition startForm', (done) => {
|
||||
it('get process definition startForm', async () => {
|
||||
processMock.get200getProcessDefinitionStartForm();
|
||||
const processDefinitionId = 'testProcess:1:7504';
|
||||
|
||||
processDefinitionsApi.getProcessDefinitionStartForm(processDefinitionId).then((data) => {
|
||||
assert.equal(data.processDefinitionId, 'testProcess:1:7504');
|
||||
done();
|
||||
});
|
||||
const data = await processDefinitionsApi.getProcessDefinitionStartForm(processDefinitionId);
|
||||
assert.equal(data.processDefinitionId, 'testProcess:1:7504');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
*/
|
||||
|
||||
import assert from 'assert';
|
||||
import { resetGlobalMockAgent } from '../mockObjects/base.mock';
|
||||
import { BpmAuthMock, ProcessInstanceVariablesMock } from '../mockObjects';
|
||||
import { ProcessInstanceVariablesApi, AlfrescoApi } from '../../src';
|
||||
import { describe, it, beforeEach, afterEach } from 'node:test';
|
||||
|
||||
describe('Activiti Process Instance Variables Api', () => {
|
||||
let authResponseBpmMock: BpmAuthMock;
|
||||
@@ -25,10 +27,6 @@ describe('Activiti Process Instance Variables Api', () => {
|
||||
let alfrescoJsApi: AlfrescoApi;
|
||||
let processInstanceVariablesApi: ProcessInstanceVariablesApi;
|
||||
|
||||
const NOOP = () => {
|
||||
/* empty */
|
||||
};
|
||||
|
||||
beforeEach(async () => {
|
||||
const BPM_HOST = 'https://127.0.0.1:9999';
|
||||
|
||||
@@ -47,128 +45,129 @@ describe('Activiti Process Instance Variables Api', () => {
|
||||
await alfrescoJsApi.login('admin', 'admin');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
resetGlobalMockAgent();
|
||||
});
|
||||
|
||||
describe('get variables', () => {
|
||||
it('should return all variables for a process instance', (done) => {
|
||||
it('should return all variables for a process instance', async () => {
|
||||
const processInstanceId = '111';
|
||||
variablesMock.addListProcessInstanceVariables200Response(processInstanceId);
|
||||
|
||||
processInstanceVariablesApi.getProcessInstanceVariables(processInstanceId).then((data) => {
|
||||
assert.equal(data.length, 2);
|
||||
done();
|
||||
});
|
||||
const data = await processInstanceVariablesApi.getProcessInstanceVariables(processInstanceId);
|
||||
assert.equal(data.length, 2);
|
||||
});
|
||||
|
||||
it('should emit an error when API returns an error response', (done) => {
|
||||
it('should emit an error when API returns an error response', async () => {
|
||||
const processInstanceId = '111';
|
||||
variablesMock.addListProcessInstanceVariables500Response(processInstanceId);
|
||||
|
||||
processInstanceVariablesApi.getProcessInstanceVariables(processInstanceId).then(NOOP, (error) => {
|
||||
try {
|
||||
await processInstanceVariablesApi.getProcessInstanceVariables(processInstanceId);
|
||||
assert.fail('Expected getProcessInstanceVariables to throw error on 500 response');
|
||||
} catch (error: any) {
|
||||
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) => {
|
||||
it('should return all variables for a process instance', async () => {
|
||||
const processInstanceId = '111';
|
||||
variablesMock.addPutProcessInstanceVariables200Response(processInstanceId);
|
||||
|
||||
processInstanceVariablesApi.createOrUpdateProcessInstanceVariables(processInstanceId, []).then((data) => {
|
||||
assert.equal(data.length, 2);
|
||||
done();
|
||||
});
|
||||
const data = await processInstanceVariablesApi.createOrUpdateProcessInstanceVariables(processInstanceId, []);
|
||||
assert.equal(data.length, 2);
|
||||
});
|
||||
|
||||
it('should emit an error when API returns an error response', (done) => {
|
||||
it('should emit an error when API returns an error response', async () => {
|
||||
const processInstanceId = '111';
|
||||
variablesMock.addPutProcessInstanceVariables500Response(processInstanceId);
|
||||
|
||||
processInstanceVariablesApi.createOrUpdateProcessInstanceVariables(processInstanceId, []).then(NOOP, (error) => {
|
||||
try {
|
||||
await processInstanceVariablesApi.createOrUpdateProcessInstanceVariables(processInstanceId, []);
|
||||
assert.fail('Expected createOrUpdateProcessInstanceVariables to throw error on 500 response');
|
||||
} catch (error: any) {
|
||||
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) => {
|
||||
it('should call API to get variable', async () => {
|
||||
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();
|
||||
}
|
||||
);
|
||||
const data = await processInstanceVariablesApi.getProcessInstanceVariable(processInstanceId, variableName);
|
||||
assert.equal(data.name, 'variable1');
|
||||
assert.equal(data.value, 'Value 123');
|
||||
});
|
||||
|
||||
it('should emit an error when API returns an error response', (done) => {
|
||||
it('should emit an error when API returns an error response', async () => {
|
||||
const processInstanceId = '111';
|
||||
const variableName = 'var1';
|
||||
variablesMock.addGetProcessInstanceVariable500Response(processInstanceId, variableName);
|
||||
|
||||
processInstanceVariablesApi.getProcessInstanceVariable(processInstanceId, variableName).then(NOOP, (error) => {
|
||||
try {
|
||||
await processInstanceVariablesApi.getProcessInstanceVariable(processInstanceId, variableName);
|
||||
assert.fail('Expected getProcessInstanceVariable to throw error on 500 response');
|
||||
} catch (error: any) {
|
||||
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) => {
|
||||
it('should call API to update variable', async () => {
|
||||
const processInstanceId = '111';
|
||||
const variableName = 'var1';
|
||||
variablesMock.addUpdateProcessInstanceVariable200Response(processInstanceId, variableName);
|
||||
|
||||
processInstanceVariablesApi.updateProcessInstanceVariable(processInstanceId, variableName, {}).then(() => {
|
||||
done();
|
||||
});
|
||||
const result = await processInstanceVariablesApi.updateProcessInstanceVariable(processInstanceId, variableName, {});
|
||||
assert.ok(result !== undefined, 'updateProcessInstanceVariable should complete successfully');
|
||||
});
|
||||
|
||||
it('should emit an error when API returns an error response', (done) => {
|
||||
it('should emit an error when API returns an error response', async () => {
|
||||
const processInstanceId = '111';
|
||||
const variableName = 'var1';
|
||||
variablesMock.addUpdateProcessInstanceVariable500Response(processInstanceId, variableName);
|
||||
|
||||
processInstanceVariablesApi.updateProcessInstanceVariable(processInstanceId, variableName, {}).then(NOOP, (error) => {
|
||||
try {
|
||||
await processInstanceVariablesApi.updateProcessInstanceVariable(processInstanceId, variableName, {});
|
||||
assert.fail('Expected updateProcessInstanceVariable to throw error on 500 response');
|
||||
} catch (error: any) {
|
||||
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) => {
|
||||
it('should call API to delete variables', async () => {
|
||||
const processInstanceId = '111';
|
||||
const variableName = 'var1';
|
||||
variablesMock.addDeleteProcessInstanceVariable200Response(processInstanceId, variableName);
|
||||
|
||||
processInstanceVariablesApi.deleteProcessInstanceVariable(processInstanceId, variableName).then(() => {
|
||||
done();
|
||||
});
|
||||
const result = await processInstanceVariablesApi.deleteProcessInstanceVariable(processInstanceId, variableName);
|
||||
assert.ok(result !== undefined, 'deleteProcessInstanceVariable should complete successfully');
|
||||
});
|
||||
|
||||
it('should emit an error when API returns an error response', (done) => {
|
||||
it('should emit an error when API returns an error response', async () => {
|
||||
const processInstanceId = '111';
|
||||
const variableName = 'var1';
|
||||
variablesMock.addDeleteProcessInstanceVariable500Response(processInstanceId, variableName);
|
||||
|
||||
processInstanceVariablesApi.deleteProcessInstanceVariable(processInstanceId, variableName).then(NOOP, (error) => {
|
||||
try {
|
||||
await processInstanceVariablesApi.deleteProcessInstanceVariable(processInstanceId, variableName);
|
||||
assert.fail('Expected deleteProcessInstanceVariable to throw error on 500 response');
|
||||
} catch (error: any) {
|
||||
assert.equal(error.status, 500);
|
||||
assert.equal(error.message, '{"messageKey":"UNKNOWN","message":"Unknown error"}');
|
||||
done();
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
*/
|
||||
|
||||
import assert from 'assert';
|
||||
import { resetGlobalMockAgent } from '../mockObjects/base.mock';
|
||||
import { AlfrescoApi, UserProfileApi } from '../../src';
|
||||
import { BpmAuthMock, ProfileMock } from '../mockObjects';
|
||||
import { describe, it, beforeEach, afterEach } from 'node:test';
|
||||
|
||||
describe('Activiti Profile Api', () => {
|
||||
let profileApi: UserProfileApi;
|
||||
@@ -43,6 +45,10 @@ describe('Activiti Profile Api', () => {
|
||||
await alfrescoApi.login('admin', 'admin');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
resetGlobalMockAgent();
|
||||
});
|
||||
|
||||
it('get Profile Picture', async () => {
|
||||
profileMock.get200getProfilePicture();
|
||||
await profileApi.getProfilePicture();
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
*/
|
||||
|
||||
import assert from 'assert';
|
||||
import { resetGlobalMockAgent } from '../mockObjects/base.mock';
|
||||
import { BpmAuthMock, ReportsMock } from '../mockObjects';
|
||||
import { ReportApi, AlfrescoApi } from '../../src';
|
||||
import { describe, it, beforeEach, afterEach } from 'node:test';
|
||||
|
||||
describe('Activiti Report Api', () => {
|
||||
let authResponseBpmMock: BpmAuthMock;
|
||||
@@ -43,6 +45,10 @@ describe('Activiti Report Api', () => {
|
||||
await alfrescoJsApi.login('admin', 'admin');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
resetGlobalMockAgent();
|
||||
});
|
||||
|
||||
it('should create the default reports', async () => {
|
||||
reportsMock.get200ResponseCreateDefaultReport();
|
||||
await reportApi.createDefaultReports();
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
*/
|
||||
|
||||
import assert from 'assert';
|
||||
import { describe, it, beforeEach, afterEach } from 'node:test';
|
||||
import { resetGlobalMockAgent } from '../mockObjects/base.mock';
|
||||
import {
|
||||
AlfrescoApi,
|
||||
TaskFilterRequestRepresentation,
|
||||
@@ -35,10 +37,6 @@ describe('Activiti Task Api', () => {
|
||||
let taskFormsApi: TaskFormsApi;
|
||||
let taskActionsApi: TaskActionsApi;
|
||||
|
||||
const NOOP = () => {
|
||||
/* empty */
|
||||
};
|
||||
|
||||
beforeEach(async () => {
|
||||
const BPM_HOST = 'https://127.0.0.1:9999';
|
||||
|
||||
@@ -59,6 +57,10 @@ describe('Activiti Task Api', () => {
|
||||
await alfrescoJsApi.login('admin', 'admin');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
resetGlobalMockAgent();
|
||||
});
|
||||
|
||||
it('get Task list', async () => {
|
||||
tasksMock.get200Response();
|
||||
|
||||
@@ -77,14 +79,17 @@ describe('Activiti Task Api', () => {
|
||||
assert.equal(data.name, 'Upload Document');
|
||||
});
|
||||
|
||||
it('bad filter Tasks', (done) => {
|
||||
it('bad filter Tasks', async () => {
|
||||
tasksMock.get400TaskFilter();
|
||||
|
||||
const requestNode = new TaskFilterRequestRepresentation();
|
||||
|
||||
tasksApi.filterTasks(requestNode).then(NOOP, () => {
|
||||
done();
|
||||
});
|
||||
try {
|
||||
await tasksApi.filterTasks(requestNode);
|
||||
assert.fail('Expected filterTasks to throw error on 400 response');
|
||||
} catch (error: any) {
|
||||
assert.equal(error.status, 400);
|
||||
}
|
||||
});
|
||||
|
||||
it('filter Tasks', async () => {
|
||||
@@ -98,13 +103,16 @@ describe('Activiti Task Api', () => {
|
||||
assert.equal(data.data[0].id, '7506');
|
||||
});
|
||||
|
||||
it('complete Task not found', (done) => {
|
||||
it('complete Task not found', async () => {
|
||||
const taskId = '200';
|
||||
tasksMock.get404CompleteTask(taskId);
|
||||
|
||||
taskActionsApi.completeTask(taskId).then(NOOP, () => {
|
||||
done();
|
||||
});
|
||||
try {
|
||||
await taskActionsApi.completeTask(taskId);
|
||||
assert.fail('Expected completeTask to throw error on 404 response');
|
||||
} catch (error: any) {
|
||||
assert.equal(error.status, 404);
|
||||
}
|
||||
});
|
||||
|
||||
it('complete Task ', async () => {
|
||||
@@ -112,7 +120,8 @@ describe('Activiti Task Api', () => {
|
||||
|
||||
tasksMock.put200GenericResponse('/activiti-app/api/enterprise/tasks/5006/action/complete');
|
||||
|
||||
await taskActionsApi.completeTask(taskId);
|
||||
const result = await taskActionsApi.completeTask(taskId);
|
||||
assert.ok(result !== undefined, 'completeTask should complete successfully');
|
||||
});
|
||||
|
||||
it('Create a Task', async () => {
|
||||
@@ -123,7 +132,8 @@ describe('Activiti Task Api', () => {
|
||||
const taskRepresentation = new TaskRepresentation();
|
||||
taskRepresentation.name = taskName;
|
||||
|
||||
await tasksApi.createNewTask(taskRepresentation);
|
||||
const result = await tasksApi.createNewTask(taskRepresentation);
|
||||
assert.ok(result, 'createNewTask should return a result');
|
||||
});
|
||||
|
||||
it('Get task form', async () => {
|
||||
@@ -155,7 +165,8 @@ describe('Activiti Task Api', () => {
|
||||
const field = 'label';
|
||||
const column = 'user';
|
||||
|
||||
await taskFormsApi.getRestFieldColumnValues(taskId, field, column);
|
||||
const result = await taskFormsApi.getRestFieldColumnValues(taskId, field, column);
|
||||
assert.ok(result !== undefined, 'getRestFieldColumnValues should return a result');
|
||||
});
|
||||
|
||||
it('get form field values that are populated through a REST backend Specific case to retrieve information on a specific column', async () => {
|
||||
@@ -164,6 +175,7 @@ describe('Activiti Task Api', () => {
|
||||
const taskId = '2';
|
||||
const field = 'label';
|
||||
|
||||
await taskFormsApi.getRestFieldValues(taskId, field);
|
||||
const result = await taskFormsApi.getRestFieldValues(taskId, field);
|
||||
assert.ok(result !== undefined, 'getRestFieldValues should return a result');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
*/
|
||||
|
||||
import assert from 'assert';
|
||||
import { resetGlobalMockAgent } from '../mockObjects/base.mock';
|
||||
import { TaskFormsApi, AlfrescoApi } from '../../src';
|
||||
import { BpmAuthMock, TaskFormMock } from '../mockObjects';
|
||||
import { describe, it, beforeEach, afterEach } from 'node:test';
|
||||
|
||||
describe('Activiti Task Api', () => {
|
||||
let authResponseBpmMock: BpmAuthMock;
|
||||
@@ -43,6 +45,10 @@ describe('Activiti Task Api', () => {
|
||||
await alfrescoJsApi.login('admin', 'admin');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
resetGlobalMockAgent();
|
||||
});
|
||||
|
||||
it('get Task Form variables list', async () => {
|
||||
taskFormMock.get200getTaskFormVariables();
|
||||
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
*/
|
||||
|
||||
import assert from 'assert';
|
||||
import { resetGlobalMockAgent } from '../mockObjects/base.mock';
|
||||
import { AlfrescoApi, UserFiltersApi } from '../../src';
|
||||
import { BpmAuthMock, UserFiltersMock } from '../mockObjects';
|
||||
import { describe, it, beforeEach, afterEach } from 'node:test';
|
||||
|
||||
describe('Activiti User Filter Api', () => {
|
||||
const hostBpm = 'https://127.0.0.1:9999';
|
||||
@@ -41,6 +43,10 @@ describe('Activiti User Filter Api', () => {
|
||||
await alfrescoJsApi.login('admin', 'admin');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
resetGlobalMockAgent();
|
||||
});
|
||||
|
||||
it('get filter user', async () => {
|
||||
filtersMock.get200getUserTaskFilters();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user