Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Commit

Permalink
fixes onReady and onConnectionError #215
Browse files Browse the repository at this point in the history
  • Loading branch information
jwulf committed Oct 24, 2023
1 parent 0d8e82a commit 613f80b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 25 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ _New shiny stuff._

- Camunda Platform 8.3.0 introduces multi-tenancy. To support this, the Node.js client adds an optional `tenantId` parameter to `DeployResource`, `DeployProcess`, `CreateProcessInstance`, `CreateProcessInstanceWithResult`, and `PublishMessage`. You can also specify a `tenantId` in the ZBClient constructor or via the environment variable `ZEEBE_TENANT_ID`. In the case that you specify it via the environment or constructor, it will be transparently added to all method invocations. See [#330](https://github.com/camunda-community-hub/zeebe-client-node-js/issues/330) for more details.

_Things that were broken and are now fixed._

- The `onReady` and `onConnection` event tests now pass, so these events should be usable. See [#215](https://github.com/camunda-community-hub/zeebe-client-node-js/issues/215) for more details.

## Fixes

_Things that were broken and are now fixed._
Expand Down
37 changes: 18 additions & 19 deletions src/__tests__/integration/Worker-onReady.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,6 @@ import { ZBClient } from '../..'
jest.setTimeout(40000)
process.env.ZEEBE_NODE_LOG_LEVEL = process.env.ZEEBE_NODE_LOG_LEVEL || 'NONE'

// Currently broken. See #215
xtest(`Worker calls the onReady handler once if there is a broker`, done => {
let called = 0
const zbc2 = new ZBClient()
zbc2.createWorker({
onReady: () => {
called++
},
taskHandler: job => job.complete(),
taskType: 'nonsense-task',
})
setTimeout(async () => {
expect(called).toBe(1)
await zbc2.close()
done()
}, 12000)
})

test(`Worker emits the ready event once if there is a broker`, done => {
let called = 0
const zbc2 = new ZBClient()
Expand Down Expand Up @@ -74,7 +56,7 @@ test(`Does not call the onReady handler if there is no broker`, done => {
}, 5000)
})

xtest(`Does not emit the ready event if there is no broker`, done => {
test(`Does not emit the ready event if there is no broker`, done => {
let called = 0
const zbc2 = new ZBClient('nobroker')
zbc2.createWorker({
Expand All @@ -90,3 +72,20 @@ xtest(`Does not emit the ready event if there is no broker`, done => {
done()
}, 5000)
})

test(`Worker calls the onReady handler once if there is a broker`, done => {
let called = 0
const zbc2 = new ZBClient()
zbc2.createWorker({
onReady: () => {
called++
},
taskHandler: job => job.complete(),
taskType: 'nonsense-task',
})
setTimeout(async () => {
expect(called).toBe(1)
await zbc2.close()
done()
}, 12000)
})
9 changes: 3 additions & 6 deletions src/__tests__/local-integration/OnConnectionError.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ test(`Calls the onConnectionError handler if there is no broker and eagerConnect
}, 5000)
}))

// Currently broken. See #215
xtest(`Does not call the onConnectionError handler if there is a broker`, () =>
test(`Does not call the onConnectionError handler if there is a broker`, () =>
new Promise(done => {
let calledB = 0
const zbc2 = new ZBClient({
Expand All @@ -44,8 +43,7 @@ xtest(`Does not call the onConnectionError handler if there is a broker`, () =>
}, 5000)
}))

// Currently broken. See #215
xtest(`Calls ZBClient onConnectionError once when there is no broker, eagerConnection:true, and workers with no handler`, () =>
test(`Calls ZBClient onConnectionError once when there is no broker, eagerConnection:true, and workers with no handler`, () =>
new Promise(done => {
let calledC = 0
const zbc2 = new ZBClient('localtoast:234532534', {
Expand Down Expand Up @@ -125,8 +123,7 @@ test(`Trailing parameter worker onConnectionError handler API works`, () =>
}, 10000)
}))

// Currently broken. See #215
xtest(`Does not call the onConnectionError handler if there is a business error`, () =>
test(`Does not call the onConnectionError handler if there is a business error`, () =>
new Promise(async done => {
let calledF = 0
let wf = 'arstsrasrateiuhrastulyharsntharsie'
Expand Down

0 comments on commit 613f80b

Please sign in to comment.