Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating dependencies #332

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .husky/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions .husky/pre-commit

This file was deleted.

15 changes: 4 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# node-red-contrib-zeebe
# node-red-contrib-zeebe-2 (fork of node-red-contrib-zeebe, updated to zeebe-node 8.2.x)
### (Work in progress)

[![](https://img.shields.io/badge/Community%20Extension-An%20open%20source%20community%20maintained%20project-FF4700)](https://github.com/camunda-community-hub/community)
![Compatible with: Camunda Platform 8.2+](https://img.shields.io/badge/Compatible%20with-Camunda%20Platform%208-0072Ce)

[![](https://img.shields.io/badge/Lifecycle-Incubating-blue)](https://github.com/Camunda-Community-Hub/community/blob/main/extension-lifecycle.md#incubating-)

![Compatible with: Camunda Platform 8](https://img.shields.io/badge/Compatible%20with-Camunda%20Platform%208-0072Ce)

![npm](https://img.shields.io/npm/v/node-red-contrib-zeebe)
![npm](https://img.shields.io/npm/v/node-red-contrib-zeebe-2)

This module leverages the [zeebe-node](https://creditsenseau.github.io/zeebe-client-node-js/index.html) client library to bring Zeebe awesomeness to Node-RED!

Expand Down Expand Up @@ -99,7 +96,3 @@ And then run them manually:
```bash
npm run test:integration
```

## Contributions

Contributions are always welcome! There are some [open issues](https://github.com/camunda-community-hub/node-red-contrib-zeebe/issues).
25 changes: 11 additions & 14 deletions __mocks__/zeebe-node.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
const mockJob = { key: '111', variables: {} };
const mockComplete = {
success: jest.fn(),
failure: jest.fn(),
const mockJob = { key: '111', variables: {} ,
complete: jest.fn(),
fail: jest.fn(),
error: jest.fn(),
forward: jest.fn(),
};

exports.ZBClient = jest.fn().mockImplementation(() => {
return {
createWorker: (
workerName,
createWorker: ({
taskType,
handler,
workerOptions,
onConnectionError
) => {
taskHandler,
...workerOptions
}) => {
// call the handler asynchronously right after ZBClient has been created
setTimeout(() => handler(mockJob, mockComplete));
setTimeout(() => taskHandler(mockJob));
},
publishMessage: jest.fn(),
publishStartMessage: jest.fn(),
deployWorkflow: jest.fn().mockResolvedValue({
workflows: [{ bpmnProcessId: 'my-process' }],
}),
deployResource: jest.fn().mockResolvedValue({ bpmnProcessId: 'my-process' }),

createProcessInstance: jest.fn(),
close: () => {},
};
Expand Down
49 changes: 26 additions & 23 deletions __tests__/complete-task_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ const completeTaskNode = require('../src/nodes/complete-task.js');

helper.init(require.resolve('node-red'));

const completeMock = {
success: jest.fn(),
failure: jest.fn(),
const jobMock = {
complete: jest.fn(),
fail: jest.fn(),
error: jest.fn(),
variables: { workflowId: 123 }
};

describe('complete-task node', () => {
beforeEach((done) => {
helper.startServer(done);
helper.startServer(done);
jest.resetAllMocks();
});

Expand All @@ -20,9 +21,7 @@ describe('complete-task node', () => {
helper.stopServer(done);
});

it('should call complete.success with variables', (done) => {
const variables = { workflowId: 123 };

it('should call job.complete with variables', (done) => {
var flow = [
{
id: 'n1',
Expand All @@ -33,17 +32,17 @@ describe('complete-task node', () => {

helper.load([completeTaskNode], flow, () => {
const n1 = helper.getNode('n1');

completeMock.success.mockImplementation(() => {
expect(completeMock.success).toHaveBeenCalledTimes(1);
expect(completeMock.success).toHaveBeenCalledWith(variables);
jobMock.complete.mockImplementation(() => {
expect(jobMock.complete).toHaveBeenCalledTimes(1);
expect(jobMock.complete).toHaveBeenCalledWith(jobMock.variables);
done();
});

n1.receive({
payload: {
complete: completeMock,
variables,
job: jobMock,
variables: jobMock.variables,

},
});
});
Expand All @@ -63,17 +62,17 @@ describe('complete-task node', () => {

const n1 = helper.getNode('n1');

completeMock.failure.mockImplementation(() => {
expect(completeMock.failure).toHaveBeenCalledTimes(1);
expect(completeMock.failure).toHaveBeenCalledWith(
jobMock.fail.mockImplementation(() => {
expect(jobMock.fail).toHaveBeenCalledTimes(1);
expect(jobMock.fail).toHaveBeenCalledWith(
failureMessage
);
done();
});

n1.receive({
payload: {
complete: completeMock,
job: jobMock,
type: 'failure',
failureMessage,
},
Expand All @@ -96,21 +95,25 @@ describe('complete-task node', () => {

const n1 = helper.getNode('n1');

completeMock.error.mockImplementation(() => {
expect(completeMock.error).toHaveBeenCalledTimes(1);
expect(completeMock.error).toHaveBeenCalledWith(
errorCode,
errorMessage
jobMock.error.mockImplementation(() => {
expect(jobMock.error).toHaveBeenCalledTimes(1);
expect(jobMock.error).toHaveBeenCalledWith(
{
errorCode,
errorMessage,
variables: jobMock.variables,
}
);
done();
});

n1.receive({
payload: {
complete: completeMock,
job: jobMock,
type: 'error',
errorCode,
errorMessage,
variables: jobMock.variables,
},
});
});
Expand Down
13 changes: 6 additions & 7 deletions __tests__/deploy_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('deploy node', () => {
helper.stopServer(done);
});

it('should call zbc.deployWorkflow', (done) => {
it('should call zbc.deployResource', (done) => {
var flow = [
{
id: 'n1',
Expand All @@ -42,22 +42,21 @@ describe('deploy node', () => {

n3.on('input', (msg) => {
Promise.resolve().then(() => {
expect(n1.zbc.deployWorkflow).toHaveBeenCalledTimes(1);
expect(n1.zbc.deployWorkflow).toHaveBeenCalledWith(
expect(n1.zbc.deployResource).toHaveBeenCalledTimes(1);
expect(n1.zbc.deployResource).toHaveBeenCalledWith(
expect.objectContaining({
name: expect.stringMatching(/^test.bpmn$/),
definition: expect.any(Buffer),
process: expect.any(Buffer),
})
);
expect(msg.payload).toEqual({
workflows: [{ bpmnProcessId: 'my-process' }],
});
expect(msg.payload.bpmnProcessId).toEqual('my-process' )
done();
});
});

n2.receive({
payload: {
resourceType: 'process',
definition: '<xml />',
resourceName: 'test.bpmn',
},
Expand Down
10 changes: 5 additions & 5 deletions __tests__/task-worker_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const zeebeNode = require('../src/nodes/zeebe');

helper.init(require.resolve('node-red'));

describe('task-worder node', () => {
describe('task-worker node', () => {
beforeEach((done) => {
helper.startServer(done);
});
Expand All @@ -14,7 +14,7 @@ describe('task-worder node', () => {
helper.stopServer(done);
});

it('should ouput response from zebee-node', (done) => {
it('should output response from zeebe-node', (done) => {
var flow = [
{
id: 'n1',
Expand All @@ -37,9 +37,9 @@ describe('task-worder node', () => {

n3.on('input', (msg) => {
Promise.resolve().then(() => {
expect(msg.payload.complete.success).toBeDefined();
expect(msg.payload.complete.failure).toBeDefined();
expect(msg.payload.job).toBeDefined();
expect(msg.payload.job.complete).toBeDefined();
expect(msg.payload.job.fail).toBeDefined();
expect(msg.payload.job.error).toBeDefined();
done();
});
});
Expand Down
Loading