@justworkflowit/cdk-constructs 0.0.189 → 0.0.190
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.
|
@@ -199,4 +199,141 @@ describe('Workflow Engine Integration Tests', () => {
|
|
|
199
199
|
expect(stateAfterStep1.executionHistory[0].stepName).toBe(step1Name);
|
|
200
200
|
expect(stateAfterStep1.executionHistory[0]?.output?.status).toBe('success');
|
|
201
201
|
});
|
|
202
|
+
test('should reject invalid workflow definition with malformed JSON', () => {
|
|
203
|
+
const invalidJson = '{ "workflowName": "invalid", "steps": [';
|
|
204
|
+
expect(() => {
|
|
205
|
+
new engine_1.JustWorkflowItEngine({
|
|
206
|
+
workflowDefinition: invalidJson,
|
|
207
|
+
stepExecutors,
|
|
208
|
+
});
|
|
209
|
+
}).toThrow();
|
|
210
|
+
});
|
|
211
|
+
test('should reject workflow definition with missing required fields', () => {
|
|
212
|
+
const workflowMissingSteps = {
|
|
213
|
+
workflowName: 'missingSteps',
|
|
214
|
+
// steps field is missing
|
|
215
|
+
};
|
|
216
|
+
expect(() => {
|
|
217
|
+
new engine_1.JustWorkflowItEngine({
|
|
218
|
+
workflowDefinition: JSON.stringify(workflowMissingSteps),
|
|
219
|
+
stepExecutors,
|
|
220
|
+
});
|
|
221
|
+
}).toThrow();
|
|
222
|
+
});
|
|
223
|
+
test('should reject workflow definition with invalid step structure', () => {
|
|
224
|
+
const workflowWithInvalidStep = {
|
|
225
|
+
workflowName: 'invalidStep',
|
|
226
|
+
steps: [
|
|
227
|
+
{
|
|
228
|
+
// Missing required 'name' field
|
|
229
|
+
retries: 2,
|
|
230
|
+
timeoutSeconds: 1000,
|
|
231
|
+
transitionToStep: null,
|
|
232
|
+
integrationDetails: {
|
|
233
|
+
type: simpleIntegration,
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
],
|
|
237
|
+
definitions: {},
|
|
238
|
+
};
|
|
239
|
+
expect(() => {
|
|
240
|
+
new engine_1.JustWorkflowItEngine({
|
|
241
|
+
workflowDefinition: JSON.stringify(workflowWithInvalidStep),
|
|
242
|
+
stepExecutors,
|
|
243
|
+
});
|
|
244
|
+
}).toThrow();
|
|
245
|
+
});
|
|
246
|
+
test('should reject workflow definition with non-existent step executor type', () => {
|
|
247
|
+
const workflowWithBadExecutorType = {
|
|
248
|
+
workflowName: 'badExecutorType',
|
|
249
|
+
steps: [
|
|
250
|
+
{
|
|
251
|
+
name: 'testStep',
|
|
252
|
+
retries: 2,
|
|
253
|
+
timeoutSeconds: 1000,
|
|
254
|
+
transitionToStep: null,
|
|
255
|
+
integrationDetails: {
|
|
256
|
+
type: 'nonExistentExecutorType',
|
|
257
|
+
inputDefinition: {
|
|
258
|
+
$ref: '#/definitions/testInput',
|
|
259
|
+
},
|
|
260
|
+
outputDefinition: {
|
|
261
|
+
$ref: '#/definitions/testOutput',
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
},
|
|
265
|
+
],
|
|
266
|
+
definitions: {
|
|
267
|
+
testInput: {
|
|
268
|
+
type: 'object',
|
|
269
|
+
properties: {},
|
|
270
|
+
additionalProperties: false,
|
|
271
|
+
},
|
|
272
|
+
testOutput: {
|
|
273
|
+
type: 'object',
|
|
274
|
+
properties: {},
|
|
275
|
+
additionalProperties: false,
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
|
+
};
|
|
279
|
+
expect(() => {
|
|
280
|
+
new engine_1.JustWorkflowItEngine({
|
|
281
|
+
workflowDefinition: JSON.stringify(workflowWithBadExecutorType),
|
|
282
|
+
stepExecutors,
|
|
283
|
+
});
|
|
284
|
+
}).toThrow();
|
|
285
|
+
});
|
|
286
|
+
test('should reject workflow definition with invalid reference in input transformer', () => {
|
|
287
|
+
const workflowWithInvalidTransformer = {
|
|
288
|
+
workflowName: 'invalidTransformer',
|
|
289
|
+
steps: [
|
|
290
|
+
{
|
|
291
|
+
name: 'testStep',
|
|
292
|
+
retries: 2,
|
|
293
|
+
timeoutSeconds: 1000,
|
|
294
|
+
transitionToStep: null,
|
|
295
|
+
integrationDetails: {
|
|
296
|
+
type: simpleIntegration,
|
|
297
|
+
inputDefinition: {
|
|
298
|
+
$ref: '#/definitions/testInput',
|
|
299
|
+
},
|
|
300
|
+
outputDefinition: {
|
|
301
|
+
$ref: '#/definitions/testOutput',
|
|
302
|
+
},
|
|
303
|
+
inputTransformer: {
|
|
304
|
+
fieldset: [
|
|
305
|
+
{
|
|
306
|
+
from: 'nonExistentStep.someProperty',
|
|
307
|
+
to: 'outputProperty',
|
|
308
|
+
},
|
|
309
|
+
],
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
],
|
|
314
|
+
definitions: {
|
|
315
|
+
testInput: {
|
|
316
|
+
type: 'object',
|
|
317
|
+
properties: {
|
|
318
|
+
outputProperty: {
|
|
319
|
+
type: 'string',
|
|
320
|
+
},
|
|
321
|
+
},
|
|
322
|
+
required: ['outputProperty'],
|
|
323
|
+
additionalProperties: false,
|
|
324
|
+
},
|
|
325
|
+
testOutput: {
|
|
326
|
+
type: 'object',
|
|
327
|
+
properties: {},
|
|
328
|
+
additionalProperties: false,
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
};
|
|
332
|
+
expect(() => {
|
|
333
|
+
new engine_1.JustWorkflowItEngine({
|
|
334
|
+
workflowDefinition: JSON.stringify(workflowWithInvalidTransformer),
|
|
335
|
+
stepExecutors,
|
|
336
|
+
});
|
|
337
|
+
}).toThrow();
|
|
338
|
+
});
|
|
202
339
|
});
|