diff --git a/src/__tests__/lib/GetCustomCertificateBuffer.unit.spec.ts b/src/__tests__/lib/GetCustomCertificateBuffer.unit.spec.ts
index 84eaf0ee..481d5b67 100644
--- a/src/__tests__/lib/GetCustomCertificateBuffer.unit.spec.ts
+++ b/src/__tests__/lib/GetCustomCertificateBuffer.unit.spec.ts
@@ -53,11 +53,11 @@ test('Can use a custom root certificate to connect to a REST API', async () => {
CAMUNDA_OPERATE_BASE_URL: 'https://localhost:3012',
},
})
- console.log('Trying to get process instance with certificate')
+ // console.log('Trying to get process instance with certificate')
const res = await c.getProcessInstance('1')
- console.log(
- `Got response from self-signed secured server: ${res.bpmnProcessId}`
- )
+ // console.log(
+ // `Got response from self-signed secured server: ${res.bpmnProcessId}`
+ // )
expect(res.bpmnProcessId).toBe('test')
const c1 = new OperateApiClient({
config: {
@@ -68,7 +68,7 @@ test('Can use a custom root certificate to connect to a REST API', async () => {
let threw = false
try {
- console.log('Trying to get process instance without certificate')
+ // console.log('Trying to get process instance without certificate')
await c1.getProcessInstance('1')
} catch (e) {
threw = true
diff --git a/src/__tests__/tasklist/tasklist.integration.spec.ts b/src/__tests__/tasklist/tasklist.integration.spec.ts
index 82205487..d7d53a08 100644
--- a/src/__tests__/tasklist/tasklist.integration.spec.ts
+++ b/src/__tests__/tasklist/tasklist.integration.spec.ts
@@ -107,11 +107,7 @@ describe('TasklistApiClient', () => {
const tasklist = new TasklistApiClient()
expect(p).toBeTruthy()
const operate = new OperateApiClient()
- const res = await operate
- .getProcessInstance(p!.processInstanceKey)
- .catch((e) => {
- console.log('Error getting process instance', e)
- })
+ const res = await operate.getProcessInstance(p!.processInstanceKey)
expect(res).toBeTruthy()
const tasks = await tasklist.searchTasks({ state: 'CREATED' })
const taskid = tasks[0].id
diff --git a/src/__tests__/testdata/zeebe-user-task.bpmn b/src/__tests__/testdata/zeebe-user-task.bpmn
new file mode 100644
index 00000000..bfdb8338
--- /dev/null
+++ b/src/__tests__/testdata/zeebe-user-task.bpmn
@@ -0,0 +1,48 @@
+
+
+
+
+ Flow_0k05u9v
+
+
+
+ Flow_1sm7z6x
+
+
+
+
+
+
+ Flow_0k05u9v
+ Flow_1sm7z6x
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/__tests__/zeebe/integration-rest/Topology.spec.ts b/src/__tests__/zeebe/integration-rest/Topology-rest.spec.ts
similarity index 100%
rename from src/__tests__/zeebe/integration-rest/Topology.spec.ts
rename to src/__tests__/zeebe/integration-rest/Topology-rest.spec.ts
diff --git a/src/__tests__/zeebe/integration-rest/UserTask-rest.spec.ts b/src/__tests__/zeebe/integration-rest/UserTask-rest.spec.ts
new file mode 100644
index 00000000..e3f7827e
--- /dev/null
+++ b/src/__tests__/zeebe/integration-rest/UserTask-rest.spec.ts
@@ -0,0 +1,33 @@
+import { TasklistApiClient } from '../../../tasklist'
+import { ZeebeGrpcClient, ZeebeRestClient } from '../../../zeebe'
+
+jest.setTimeout(30000)
+test('can update a task', async () => {
+ const grpc = new ZeebeGrpcClient()
+
+ await grpc.deployResource({
+ processFilename: './src/__tests__/testdata/zeebe-user-task.bpmn',
+ })
+ await grpc.createProcessInstance({
+ bpmnProcessId: 'zeebe-user-task-test',
+ variables: {},
+ })
+ const tasklist = new TasklistApiClient()
+ await new Promise((resolve) => setTimeout(resolve, 10000))
+ const tasks = await tasklist.searchTasks({
+ state: 'CREATED',
+ })
+ const zbc = new ZeebeRestClient()
+ const res = await zbc.completeUserTask({
+ userTaskKey: tasks[0].id,
+ })
+ expect(res.statusCode).toBe(204)
+ const res2 = await zbc
+ .completeUserTask({
+ userTaskKey: '2251799814261421',
+ })
+ .catch((e) => {
+ return e
+ })
+ expect(res2.statusCode).toBe(404)
+})
diff --git a/src/__tests__/zeebe/local-integration/OnConnectionError.spec.ts b/src/__tests__/zeebe/local-integration/OnConnectionError.spec.ts
index 990b7d99..0f50094c 100644
--- a/src/__tests__/zeebe/local-integration/OnConnectionError.spec.ts
+++ b/src/__tests__/zeebe/local-integration/OnConnectionError.spec.ts
@@ -133,10 +133,10 @@ xtest('Does not call the onConnectionError handler if there is a business error'
const zbc2 = new ZeebeGrpcClient()
zbc2.on('connectionError', () => {
// tslint:disable-next-line: no-console
- console.log('OnConnectionError!!!! Incrementing calledF') // @DEBUG
- const e = new Error()
+ // console.log('OnConnectionError!!!! Incrementing calledF') // @DEBUG
+ // const e = new Error()
// tslint:disable-next-line: no-console
- console.log(e.stack) // @DEBUG
+ // console.log(e.stack) // @DEBUG
calledF++
})
diff --git a/src/__tests__/zeebe/multitenancy/createProcessInstance-mt.spec.ts b/src/__tests__/zeebe/multitenancy/createProcessInstance-mt.spec.ts
index f3802eeb..5cc3cdfb 100644
--- a/src/__tests__/zeebe/multitenancy/createProcessInstance-mt.spec.ts
+++ b/src/__tests__/zeebe/multitenancy/createProcessInstance-mt.spec.ts
@@ -37,7 +37,7 @@ test('Will not throw an error if tenantId is provided when starting a process in
await client.cancelProcessInstance(p.processInstanceKey)
} catch (e) {
threwError = true
- console.log(e)
+ // console.log(e)
}
expect(threwError).toBe(false)
diff --git a/src/zeebe/zb/ZeebeRESTClient.ts b/src/zeebe/zb/ZeebeRESTClient.ts
index 2141aef2..a0e41e84 100644
--- a/src/zeebe/zb/ZeebeRESTClient.ts
+++ b/src/zeebe/zb/ZeebeRESTClient.ts
@@ -26,13 +26,13 @@ const ZEEBE_REST_API_VERSION = 'v1'
*/
interface TaskChangeSet {
/* The due date of the task. Reset by providing an empty String. */
- dueDate: Date | string
+ dueDate?: Date | string
/* The follow-up date of the task. Reset by providing an empty String. */
- followUpDate: Date | string
+ followUpDate?: Date | string
/* The list of candidate users of the task. Reset by providing an empty list. */
- candidateUsers: string[]
+ candidateUsers?: string[]
/* The list of candidate groups of the task. Reset by providing an empty list. */
- candidateGroups: string[]
+ candidateGroups?: string[]
}
export class ZeebeRestClient {
@@ -110,28 +110,31 @@ export class ZeebeRestClient {
) as Promise
}
- /* Completes a user task with the given key. */
- public completeUserTask({
+ /* Completes a user task with the given key. The method either completes the task or throws 400, 404, or 409.
+ Documentation: https://docs.camunda.io/docs/apis-tools/zeebe-api-rest/specifications/complete-a-user-task/ */
+ public async completeUserTask({
userTaskKey,
- variables,
+ variables = {},
action = 'complete',
}: {
userTaskKey: string
- variables: Record
- action: string
+ variables?: Record
+ action?: string
}) {
+ const headers = await this.getHeaders()
return this.rest.then((rest) =>
rest.post(`user-tasks/${userTaskKey}/completion`, {
body: JSON.stringify({
variables,
action,
}),
+ headers,
})
)
}
/* Assigns a user task with the given key to the given assignee. */
- public assignTask({
+ public async assignTask({
userTaskKey,
assignee,
allowOverride = true,
@@ -142,6 +145,8 @@ export class ZeebeRestClient {
allowOverride?: boolean
action: string
}) {
+ const headers = await this.getHeaders()
+
return this.rest.then((rest) =>
rest.post(`user-tasks/${userTaskKey}/assignment`, {
body: JSON.stringify({
@@ -149,28 +154,34 @@ export class ZeebeRestClient {
action,
assignee,
}),
+ headers,
})
)
}
/** Update a user task with the given key. */
- public updateTask({
+ public async updateTask({
userTaskKey,
changeset,
}: {
userTaskKey: string
changeset: TaskChangeSet
}) {
+ const headers = await this.getHeaders()
+
return this.rest.then((rest) =>
rest.post(`user-tasks/${userTaskKey}/update`, {
body: JSON.stringify(changeset),
+ headers,
})
)
}
/* Removes the assignee of a task with the given key. */
- public removeAssignee({ userTaskKey }: { userTaskKey: string }) {
+ public async removeAssignee({ userTaskKey }: { userTaskKey: string }) {
+ const headers = await this.getHeaders()
+
return this.rest.then((rest) =>
- rest.delete(`user-tasks/${userTaskKey}/assignee`)
+ rest.delete(`user-tasks/${userTaskKey}/assignee`, { headers })
)
}
}