This repository has been archived by the owner on Apr 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Proposed Changes Refactor tests to use Operate
- Loading branch information
Showing
17 changed files
with
297 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { OperateApiClient } from 'operate-api-client' | ||
|
||
const operate = new OperateApiClient() | ||
|
||
export async function cancelProcesses(processDefinitionKey: string) { | ||
const processes = await operate.searchProcessInstances({ | ||
filter: { | ||
processDefinitionKey: +processDefinitionKey | ||
} | ||
}) | ||
await Promise.all(processes.items.map(item => | ||
operate.deleteProcessInstance(+item.bpmnProcessId) | ||
)) | ||
} | ||
|
||
|
||
function createClient() { | ||
try { | ||
return new OperateApiClient() | ||
} catch (e) { | ||
console.log(e.message) | ||
console.log(`Running without access to Operate`) | ||
return null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,10 @@ | ||
import { ZBClient } from '../../index' | ||
import { createUniqueTaskType } from '../../lib/createUniqueTaskType' | ||
process.env.ZEEBE_NODE_LOG_LEVEL = process.env.ZEEBE_NODE_LOG_LEVEL || 'NONE' | ||
jest.setTimeout(20000) | ||
|
||
test('deploys a process', async () => { | ||
const zbc = new ZBClient() | ||
const { bpmn, processId } = createUniqueTaskType({ | ||
bpmnFilePath: `./src/__tests__/testdata/Client-DeployWorkflow.bpmn`, | ||
messages: [], | ||
taskTypes: [], | ||
}) | ||
const result = await zbc.deployProcess({ | ||
definition: bpmn, | ||
name: `Client-DeployProcess-${processId}.bpmn`, | ||
}) | ||
const result = await zbc.deployProcess(`./src/__tests__/testdata/Client-DeployWorkflow.bpmn`) | ||
await zbc.close() | ||
expect(result.processes[0].bpmnProcessId).toBe(processId) | ||
expect(result.processes[0].bpmnProcessId).toBeTruthy() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
import { ZBClient } from '../../index' | ||
import { createUniqueTaskType } from '../../lib/createUniqueTaskType' | ||
import { cancelProcesses } from '../ lib/cancelProcesses' | ||
import { ZBClient, BpmnParser } from '../../index' | ||
import fs from 'fs' | ||
process.env.ZEEBE_NODE_LOG_LEVEL = process.env.ZEEBE_NODE_LOG_LEVEL || 'NONE' | ||
jest.setTimeout(20000) | ||
|
||
const zbc = new ZBClient() | ||
const bpmnString = fs.readFileSync(`./src/__tests__/testdata/Client-DeployWorkflow.bpmn`, 'utf8') | ||
const expectedPid = BpmnParser.getProcessId(bpmnString) | ||
|
||
beforeAll(async () => | ||
await cancelProcesses(expectedPid) | ||
) | ||
|
||
afterAll(async () => | ||
await zbc.close() | ||
) | ||
|
||
test('deploys a process', async () => { | ||
const zbc = new ZBClient() | ||
const { bpmn, processId } = createUniqueTaskType({ | ||
bpmnFilePath: `./src/__tests__/testdata/Client-DeployWorkflow.bpmn`, | ||
messages: [], | ||
taskTypes: [], | ||
}) | ||
const result = await zbc.deployResource({ | ||
process: bpmn, | ||
name: `Client-DeployProcess-${processId}.bpmn`, | ||
process: Buffer.from(bpmnString), | ||
name: `Client-DeployWorkflow.bpmn`, | ||
}) | ||
await zbc.close() | ||
expect(result.deployments[0].process.bpmnProcessId).toBe(processId) | ||
expect(result.deployments[0].process.bpmnProcessId).toBe(expectedPid) | ||
}) | ||
test('deploys a process from a file', async () => { | ||
const zbc = new ZBClient() | ||
const result = await zbc.deployResource({ | ||
processFilename: `./src/__tests__/testdata/Client-DeployWorkflow.bpmn`, | ||
}) | ||
await zbc.close() | ||
expect(result.deployments[0].process.version).toBeGreaterThanOrEqual(1) | ||
}) | ||
test('deploys a DMN table from a filename', async () => { | ||
const zbc = new ZBClient() | ||
const result = await zbc.deployResource({ | ||
decisionFilename: './src/__tests__/testdata/quarantine-duration.dmn', | ||
}) | ||
await zbc.close() | ||
expect(result.deployments[0].decision.decisionKey).not.toBeNull() | ||
}) | ||
test('deploys a DMN table', async () => { | ||
const zbc = new ZBClient() | ||
const decision = fs.readFileSync( | ||
'./src/__tests__/testdata/quarantine-duration.dmn' | ||
) | ||
const result = await zbc.deployResource({ | ||
decision, | ||
name: 'quarantine-duration.dmn', | ||
}) | ||
await zbc.close() | ||
expect(result.deployments[0].decision.decisionKey).not.toBeNull() | ||
}) |
Oops, something went wrong.