@camunda/task-testing 2.1.0 → 3.0.0-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -20
- package/README.md +118 -49
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/ElementConfig.d.ts +35 -0
- package/dist/types/ElementVariables.d.ts +8 -0
- package/dist/types/ExecutionLog.d.ts +196 -0
- package/dist/types/TaskExecution.d.ts +133 -0
- package/dist/types/components/Input/Input.d.ts +8 -0
- package/dist/types/components/Input/InputEditor.d.ts +10 -0
- package/dist/types/components/Output/ExecutionLog.d.ts +24 -0
- package/dist/types/components/Output/Output.d.ts +43 -0
- package/dist/types/components/Output/OutputEditor.d.ts +3 -0
- package/dist/types/components/TaskTesting/TaskTesting.d.ts +58 -0
- package/dist/types/components/shared/CodeMirrorTheme.d.ts +5 -0
- package/dist/types/components/shared/Tooltip.d.ts +24 -0
- package/dist/types/components/shared/plugins.d.ts +4 -0
- package/dist/types/hooks/useSelectedElement.d.ts +13 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/types.d.ts +236 -0
- package/dist/types/utils/autocompletion.d.ts +12 -0
- package/dist/types/utils/element.d.ts +20 -0
- package/dist/types/utils/getOperateUrl.d.ts +9 -0
- package/dist/types/utils/getTasklistUrl.d.ts +9 -0
- package/dist/types/utils/trimTrailingSlashes.d.ts +12 -0
- package/dist/types/utils/variables.d.ts +28 -0
- package/package.json +101 -95
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022-present Camunda Services GmbH
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022-present Camunda Services GmbH
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,50 +1,119 @@
|
|
|
1
|
-
# @camunda/task-testing
|
|
2
|
-
|
|
3
|
-
[](https://github.com/camunda/task-testing/actions/workflows/CI.yml)
|
|
4
|
-
|
|
5
|
-
Run and test a single building block of your BPMN diagram.
|
|
6
|
-
|
|
7
|
-
## Usage
|
|
8
|
-
|
|
9
|
-
```js
|
|
10
|
-
import TaskTesting from '@camunda/task-testing';
|
|
11
|
-
|
|
12
|
-
function App() {
|
|
13
|
-
...
|
|
14
|
-
|
|
15
|
-
<TaskTesting
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
1
|
+
# @camunda/task-testing
|
|
2
|
+
|
|
3
|
+
[](https://github.com/camunda/task-testing/actions/workflows/CI.yml)
|
|
4
|
+
|
|
5
|
+
Run and test a single building block of your BPMN diagram.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import TaskTesting from '@camunda/task-testing';
|
|
11
|
+
|
|
12
|
+
function App() {
|
|
13
|
+
...
|
|
14
|
+
|
|
15
|
+
<TaskTesting
|
|
16
|
+
{ ...props }
|
|
17
|
+
>
|
|
18
|
+
<TaskTesting.Tab label="My dynamic tab" render={ ({ output }) => <div>...</div> } />
|
|
19
|
+
<TaskTesting.Tab label="My static tab">My static content</TaskTesting.Tab>
|
|
20
|
+
<TaskTesting.Link href="https://example.com" render={ ({ output }) => <div>...</div> } />
|
|
21
|
+
<TaskTesting.Link href="https://example.com">My static link</TaskTesting.Link>
|
|
22
|
+
</TaskTesting>
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Props
|
|
27
|
+
|
|
28
|
+
| Prop | Type | Required | Description |
|
|
29
|
+
|------|------|----------|-------------|
|
|
30
|
+
| `injector` | `Object` | yes | The [didi](https://github.com/nikku/didi) injector from the bpmn-js modeler |
|
|
31
|
+
| `api` | `TaskExecutionApi` | yes | API object with methods for deploying, starting instances, and polling |
|
|
32
|
+
| `isConnectionConfigured` | `boolean` | yes | Whether a Camunda 8 connection is configured |
|
|
33
|
+
| `config` | `Config` | no | Input/output configuration for elements |
|
|
34
|
+
| `onConfigChanged` | `(config: Config) => void` | no | Called when the configuration changes |
|
|
35
|
+
| `configureConnectionBannerTitle` | `string` | no | Title for the connection banner (default: `'Connection required'`) |
|
|
36
|
+
| `configureConnectionBannerDescription` | `string` | no | Description for the connection banner (default: `'Configure a connection to start testing.'`) |
|
|
37
|
+
| `configureConnectionLabel` | `string` | no | Label for the configure connection button (default: `'Configure'`) |
|
|
38
|
+
| `onConfigureConnection` | `Function` | no | Called when the user clicks the configure connection button |
|
|
39
|
+
| `onTestTask` | `() => boolean \| Promise<boolean>` | no | Called when the user clicks _Test task_. Return `true` to proceed, `false` to abort |
|
|
40
|
+
| `operateBaseUrl` | `string` | no | Base URL for Operate links |
|
|
41
|
+
| `tasklistBaseUrl` | `string` | no | Base URL for Tasklist links |
|
|
42
|
+
| `documentationUrl` | `string` | no | URL for the documentation link |
|
|
43
|
+
| `onTaskExecutionStarted` | `(element) => void` | no | Called when task execution starts |
|
|
44
|
+
| `onTaskExecutionFinished` | `(element, result) => void` | no | Called when task execution ends |
|
|
45
|
+
|
|
46
|
+
#### `TaskExecutionApi`
|
|
47
|
+
|
|
48
|
+
The `api` prop must implement the following methods. Each method should return a `{ success: true, response }` or `{ success: false, error }` object.
|
|
49
|
+
|
|
50
|
+
| Method | Description |
|
|
51
|
+
|--------|-------------|
|
|
52
|
+
| `deploy()` | Deploy the process definition |
|
|
53
|
+
| `startInstance(processDefinitionKey, elementId, variables)` | Start a process instance |
|
|
54
|
+
| `getProcessInstance(processInstanceKey)` | Search for a process instance |
|
|
55
|
+
| `getProcessInstanceElementInstances(processInstanceKey)` | Search element instances |
|
|
56
|
+
| `getProcessInstanceIncident(processInstanceKey)` | Search incidents |
|
|
57
|
+
| `getProcessInstanceJobs(processInstanceKey, elementId)` | Search jobs |
|
|
58
|
+
| `getProcessInstanceMessageSubscriptions(processInstanceKey, elementId)` | Search message subscriptions |
|
|
59
|
+
| `getProcessInstanceUserTasks(processInstanceKey, elementId)` | Search user tasks |
|
|
60
|
+
| `getProcessInstanceVariables(processInstanceKey)` | Search variables |
|
|
61
|
+
|
|
62
|
+
#### `onTaskExecutionFinished` result
|
|
63
|
+
|
|
64
|
+
The `result` parameter is a discriminated union:
|
|
65
|
+
|
|
66
|
+
- **`success: true`** — Task completed successfully. Contains `lastPolledResult` and `processInstanceKey`.
|
|
67
|
+
- **`success: false`** — Task did not complete successfully. Contains `reason`:
|
|
68
|
+
- `'incident'` — An incident occurred (includes `incident` details)
|
|
69
|
+
- `'terminated'` — Process instance was terminated
|
|
70
|
+
- `'user.cancel'` — User clicked cancel
|
|
71
|
+
- `'user.selectionChanged'` — User selected a different element
|
|
72
|
+
- `'error'` — Deployment or start failed (includes `error` with `message`)
|
|
73
|
+
|
|
74
|
+
#### Plugins
|
|
75
|
+
|
|
76
|
+
Custom tabs and links can be added as children:
|
|
77
|
+
|
|
78
|
+
- **`<TaskTesting.Tab>`** — Adds a tab to the output panel
|
|
79
|
+
- `label` (string, required) — Tab label
|
|
80
|
+
- `render` (function) — Render function receiving `{ output }`, for dynamic content
|
|
81
|
+
- `children` (ReactNode) — Static content (alternative to `render`)
|
|
82
|
+
- `priority` (number, default `1000`) — Higher priority tabs appear first
|
|
83
|
+
|
|
84
|
+
- **`<TaskTesting.Link>`** — Adds a link to the output header
|
|
85
|
+
- `href` (string, required) — Link URL
|
|
86
|
+
- `target` (string) — Link target (e.g. `'_blank'`)
|
|
87
|
+
- `render` (function) — Render function receiving `{ output }`, for dynamic content
|
|
88
|
+
- `children` (ReactNode) — Static content (alternative to `render`)
|
|
89
|
+
- `priority` (number, default `1000`) — Higher priority links appear first
|
|
90
|
+
|
|
91
|
+
[See demo](https://github.com/camunda/task-testing/tree/main/demo)
|
|
92
|
+
|
|
93
|
+
## Development
|
|
94
|
+
|
|
95
|
+
Install the dependencies and spin up a local server at [http://localhost:3000](http://localhost:3000):
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
npm install
|
|
99
|
+
|
|
100
|
+
npm start
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
It requires a Camunda 8 instance to run.
|
|
104
|
+
|
|
105
|
+
We recommend using [Camunda 8 Run](https://docs.camunda.io/docs/self-managed/quickstart/developer-quickstart/c8run/) for development.
|
|
106
|
+
|
|
107
|
+
You can configure your Camunda 8 environment in the `demo/.env` file.
|
|
108
|
+
|
|
109
|
+
## Build
|
|
110
|
+
|
|
111
|
+
Run all tests and build the library:
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
npm run all
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## License
|
|
118
|
+
|
|
50
119
|
MIT
|