Skip to content

Commit 7ee92bc

Browse files
author
nicosammito
committed
feat: enhance flow validation tests to ensure diagnostics contain nodeId and parameterIndex
1 parent 482e3af commit 7ee92bc

1 file changed

Lines changed: 271 additions & 3 deletions

File tree

test/flowValidation.test.ts

Lines changed: 271 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ describe('getFlowValidation - Integrationstest', () => {
6868

6969
expect(result.isValid).toBe(true);
7070
expect(result.diagnostics).toHaveLength(0);
71+
result.diagnostics.forEach((error) => {
72+
expect(error.nodeId).toBeDefined()
73+
expect(error.parameterIndex).toBeDefined()
74+
})
7175
});
7276

7377
it('2', () => {
@@ -110,6 +114,10 @@ describe('getFlowValidation - Integrationstest', () => {
110114
const result = getFlowValidation(flow, FUNCTION_SIGNATURES, DATA_TYPES);
111115

112116
expect(result.isValid).toBe(false);
117+
result.diagnostics.forEach((error) => {
118+
expect(error.nodeId).toBeDefined()
119+
expect(error.parameterIndex).toBeDefined()
120+
})
113121
});
114122

115123
it('3', () => {
@@ -133,9 +141,10 @@ describe('getFlowValidation - Integrationstest', () => {
133141
const result = getFlowValidation(flow, FUNCTION_SIGNATURES, DATA_TYPES);
134142

135143
expect(result.isValid).toBe(false);
136-
const diagnostic = result.diagnostics.find(d => d.nodeId === "gid://sagittarius/NodeFunction/1" && d.parameterIndex === 0);
137-
expect(diagnostic).toBeDefined();
138-
expect(diagnostic?.message).toContain("number");
144+
result.diagnostics.forEach((error) => {
145+
expect(error.nodeId).toBeDefined()
146+
expect(error.parameterIndex).toBeDefined()
147+
})
139148
});
140149

141150
it('4', () => {
@@ -182,6 +191,10 @@ describe('getFlowValidation - Integrationstest', () => {
182191

183192
expect(result.isValid).toBe(true);
184193
expect(result.diagnostics).toHaveLength(0);
194+
result.diagnostics.forEach((error) => {
195+
expect(error.nodeId).toBeDefined()
196+
expect(error.parameterIndex).toBeDefined()
197+
})
185198
});
186199

187200
it('5', () => {
@@ -235,6 +248,261 @@ describe('getFlowValidation - Integrationstest', () => {
235248

236249
expect(result.isValid).toBe(true);
237250
expect(result.diagnostics).toHaveLength(0);
251+
result.diagnostics.forEach((error) => {
252+
expect(error.nodeId).toBeDefined()
253+
expect(error.parameterIndex).toBeDefined()
254+
})
255+
});
256+
257+
it('6', () => {
258+
259+
const flow: Flow = {
260+
"__typename": "Flow",
261+
"id": "gid://sagittarius/Flow/1",
262+
"createdAt": "2026-03-17T14:02:31Z",
263+
"name": "Test",
264+
"inputType": "REST_ADAPTER_INPUT",
265+
"returnType": "HTTP_RESPONSE",
266+
"nodes": {
267+
"__typename": "NodeFunctionConnection",
268+
"nodes": [
269+
{
270+
"__typename": "NodeFunction",
271+
"id": "gid://sagittarius/NodeFunction/1",
272+
"functionDefinition": {
273+
"__typename": "FunctionDefinition",
274+
"id": "gid://sagittarius/FunctionDefinition/77",
275+
"identifier": "std::boolean::as_number"
276+
},
277+
"parameters": {
278+
"__typename": "NodeParameterConnection",
279+
"nodes": [
280+
{
281+
"__typename": "NodeParameter",
282+
"parameterDefinition": {
283+
"__typename": "ParameterDefinition",
284+
"id": "gid://sagittarius/ParameterDefinition/117",
285+
"identifier": "value"
286+
},
287+
"value": {
288+
"id": "gid://sagittarius/NodeFunction/2",
289+
"__typename": "NodeFunctionIdWrapper"
290+
}
291+
}
292+
]
293+
}
294+
},
295+
{
296+
"__typename": "NodeFunction",
297+
"id": "gid://sagittarius/NodeFunction/2",
298+
"functionDefinition": {
299+
"__typename": "FunctionDefinition",
300+
"id": "gid://sagittarius/FunctionDefinition/74",
301+
"identifier": "std::boolean::from_number"
302+
},
303+
"parameters": {
304+
"__typename": "NodeParameterConnection",
305+
"nodes": [
306+
{
307+
"__typename": "NodeParameter",
308+
"parameterDefinition": {
309+
"__typename": "ParameterDefinition",
310+
"id": "gid://sagittarius/ParameterDefinition/113",
311+
"identifier": "value"
312+
},
313+
"value": null
314+
}
315+
]
316+
}
317+
}
318+
]
319+
},
320+
"project": {
321+
"__typename": "NamespaceProject",
322+
"id": "gid://sagittarius/NamespaceProject/1"
323+
},
324+
"settings": {
325+
"__typename": "FlowSettingConnection",
326+
"count": 2,
327+
"nodes": [
328+
{
329+
"__typename": "FlowSetting",
330+
"id": "gid://sagittarius/FlowSetting/1",
331+
"createdAt": "2026-03-17T14:17:48Z",
332+
"updatedAt": "2026-03-17T14:17:48Z",
333+
"flowSettingIdentifier": "HTTP_METHOD",
334+
"value": ""
335+
},
336+
{
337+
"__typename": "FlowSetting",
338+
"id": "gid://sagittarius/FlowSetting/2",
339+
"createdAt": "2026-03-17T14:17:48Z",
340+
"updatedAt": "2026-03-17T14:17:48Z",
341+
"flowSettingIdentifier": "HTTP_URL",
342+
"value": ""
343+
}
344+
],
345+
"pageInfo": {
346+
"__typename": "PageInfo",
347+
"endCursor": "Mg",
348+
"hasNextPage": false
349+
}
350+
},
351+
"startingNodeId": "gid://sagittarius/NodeFunction/1",
352+
"type": {
353+
"__typename": "FlowType",
354+
"id": "gid://sagittarius/FlowType/1"
355+
},
356+
"updatedAt": "2026-03-17T17:21:45Z",
357+
"userAbilities": {
358+
"__typename": "FlowUserAbilities",
359+
"deleteFlow": true
360+
}
361+
};
362+
363+
const result = getFlowValidation(flow, FUNCTION_SIGNATURES, DATA_TYPES);
364+
365+
expect(result.isValid).toBe(false);
366+
result.diagnostics.forEach((error) => {
367+
expect(error.nodeId).toBeDefined()
368+
expect(error.parameterIndex).toBeDefined()
369+
})
370+
});
371+
372+
it('7', () => {
373+
374+
const flow: Flow = {
375+
"__typename": "Flow",
376+
"id": "gid://sagittarius/Flow/1",
377+
"createdAt": "2026-03-17T14:02:31Z",
378+
"name": "Test",
379+
"inputType": "REST_ADAPTER_INPUT",
380+
"returnType": "HTTP_RESPONSE",
381+
"nodes": {
382+
"__typename": "NodeFunctionConnection",
383+
"nodes": [{
384+
"__typename": "NodeFunction",
385+
"id": "gid://sagittarius/NodeFunction/2",
386+
"nextNodeId": null,
387+
"createdAt": "2026-03-17T14:04:15Z",
388+
"updatedAt": "2026-03-17T19:13:40Z",
389+
"parameters": {
390+
"__typename": "NodeParameterConnection",
391+
"count": 1,
392+
"nodes": [{
393+
"__typename": "NodeParameter",
394+
"id": "gid://sagittarius/NodeParameter/63",
395+
"updatedAt": "2026-03-17T19:13:40Z",
396+
"createdAt": "2026-03-17T18:35:16Z",
397+
"parameterDefinition": {
398+
"__typename": "ParameterDefinition",
399+
"id": "gid://sagittarius/ParameterDefinition/113",
400+
"identifier": "value",
401+
"createdAt": "2026-03-17T14:01:55Z",
402+
"updatedAt": "2026-03-17T14:01:55Z"
403+
},
404+
"value": null
405+
}],
406+
"pageInfo": {"__typename": "PageInfo", "endCursor": "NjM", "hasNextPage": false}
407+
},
408+
"functionDefinition": {
409+
"__typename": "FunctionDefinition",
410+
"id": "gid://sagittarius/FunctionDefinition/74",
411+
"identifier": "std::boolean::from_number"
412+
}
413+
}, {
414+
"__typename": "NodeFunction",
415+
"id": "gid://sagittarius/NodeFunction/3",
416+
"functionDefinition": {
417+
"__typename": "FunctionDefinition",
418+
"id": "gid://sagittarius/FunctionDefinition/7",
419+
"identifier": "std::list::for_each"
420+
},
421+
"parameters": {
422+
"__typename": "NodeParameterConnection",
423+
"nodes": [{
424+
"__typename": "NodeParameter",
425+
"parameterDefinition": {
426+
"__typename": "ParameterDefinition",
427+
"id": "gid://sagittarius/ParameterDefinition/10",
428+
"identifier": "list"
429+
},
430+
"value": null
431+
}, {
432+
"__typename": "NodeParameter",
433+
"parameterDefinition": {
434+
"__typename": "ParameterDefinition",
435+
"id": "gid://sagittarius/ParameterDefinition/11",
436+
"identifier": "consumer"
437+
},
438+
"value": {"id": "gid://sagittarius/NodeFunction/4", "__typename": "NodeFunctionIdWrapper"}
439+
}]
440+
}
441+
}, {
442+
"__typename": "NodeFunction",
443+
"id": "gid://sagittarius/NodeFunction/4",
444+
"functionDefinition": {
445+
"__typename": "FunctionDefinition",
446+
"id": "gid://sagittarius/FunctionDefinition/23",
447+
"identifier": "std::list::join"
448+
},
449+
"parameters": {
450+
"__typename": "NodeParameterConnection",
451+
"nodes": [{
452+
"__typename": "NodeParameter",
453+
"parameterDefinition": {
454+
"__typename": "ParameterDefinition",
455+
"id": "gid://sagittarius/ParameterDefinition/35",
456+
"identifier": "list"
457+
},
458+
"value": null
459+
}, {
460+
"__typename": "NodeParameter",
461+
"parameterDefinition": {
462+
"__typename": "ParameterDefinition",
463+
"id": "gid://sagittarius/ParameterDefinition/36",
464+
"identifier": "join_text"
465+
},
466+
"value": null
467+
}]
468+
}
469+
}]
470+
},
471+
"project": {"__typename": "NamespaceProject", "id": "gid://sagittarius/NamespaceProject/1"},
472+
"settings": {
473+
"__typename": "FlowSettingConnection",
474+
"count": 2,
475+
"nodes": [{
476+
"__typename": "FlowSetting",
477+
"id": "gid://sagittarius/FlowSetting/1",
478+
"createdAt": "2026-03-17T14:17:48Z",
479+
"updatedAt": "2026-03-17T14:17:48Z",
480+
"flowSettingIdentifier": "HTTP_METHOD",
481+
"value": ""
482+
}, {
483+
"__typename": "FlowSetting",
484+
"id": "gid://sagittarius/FlowSetting/2",
485+
"createdAt": "2026-03-17T14:17:48Z",
486+
"updatedAt": "2026-03-17T14:17:48Z",
487+
"flowSettingIdentifier": "HTTP_URL",
488+
"value": ""
489+
}],
490+
"pageInfo": {"__typename": "PageInfo", "endCursor": "Mg", "hasNextPage": false}
491+
},
492+
"startingNodeId": "gid://sagittarius/NodeFunction/3",
493+
"type": {"__typename": "FlowType", "id": "gid://sagittarius/FlowType/1"},
494+
"updatedAt": "2026-03-17T19:18:43Z",
495+
"userAbilities": {"__typename": "FlowUserAbilities", "deleteFlow": true},
496+
};
497+
498+
const result = getFlowValidation(flow, FUNCTION_SIGNATURES, DATA_TYPES);
499+
500+
expect(result.isValid).toBe(false);
501+
result.diagnostics.forEach((error) => {
502+
503+
expect(error.nodeId).toBeDefined()
504+
expect(error.parameterIndex).toBeDefined()
505+
})
238506
});
239507

240508
});

0 commit comments

Comments
 (0)