Skip to content

Commit 9c6bc06

Browse files
committed
test: add validation test for flow with various node functions and settings
1 parent 5bcb841 commit 9c6bc06

2 files changed

Lines changed: 151 additions & 1 deletion

File tree

src/utils.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,15 @@ export function generateFlowSourceCode(
238238
.map(n => generateNodeCode(n!.id!))
239239
.join('\n');
240240

241-
return `${typeDefs}\n${flowTypeDeclaration}\n${funcDeclarations}\n\n// --- Flow ---\n${flowCode}\n${executionCode}`;
241+
return `
242+
${typeDefs}\n
243+
${flowTypeDeclaration}\n
244+
${funcDeclarations}\n
245+
(() =>
246+
${flowCode}
247+
${executionCode}
248+
)();
249+
`;
242250
}
243251

244252
export interface InferredTypes {

test/flowValidation.test.ts

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,4 +537,146 @@ describe('getFlowValidation - Integrationstest', () => {
537537
})
538538
});
539539

540+
it('8', () => {
541+
542+
const flow: Flow = {
543+
"__typename": "Flow",
544+
"id": "gid://sagittarius/Flow/1",
545+
"createdAt": "2026-04-12T13:46:13Z",
546+
"name": "Test",
547+
"signature": "(httpURL: HTTP_URL, httpMethod: HTTP_METHOD): { body: { test: TEXT } }",
548+
"nodes": {
549+
"__typename": "NodeFunctionConnection",
550+
"nodes": [
551+
{
552+
"__typename": "NodeFunction",
553+
"id": "gid://sagittarius/NodeFunction/1",
554+
"functionDefinition": {
555+
"__typename": "FunctionDefinition",
556+
"id": "gid://sagittarius/FunctionDefinition/9",
557+
"identifier": "std::boolean::from_number"
558+
},
559+
"parameters": {
560+
"__typename": "NodeParameterConnection",
561+
"nodes": [
562+
{
563+
"__typename": "NodeParameter",
564+
"parameterDefinition": {
565+
"__typename": "ParameterDefinition",
566+
"id": "gid://sagittarius/ParameterDefinition/11",
567+
"identifier": "value"
568+
},
569+
"value": {
570+
"__typename": "LiteralValue",
571+
"value": 1
572+
}
573+
}
574+
]
575+
},
576+
"nextNodeId": "gid://sagittarius/NodeFunction/2"
577+
},
578+
{
579+
"__typename": "NodeFunction",
580+
"id": "gid://sagittarius/NodeFunction/2",
581+
"functionDefinition": {
582+
"__typename": "FunctionDefinition",
583+
"id": "gid://sagittarius/FunctionDefinition/4",
584+
"identifier": "std::control::return"
585+
},
586+
"parameters": {
587+
"__typename": "NodeParameterConnection",
588+
"nodes": [
589+
{
590+
"__typename": "NodeParameter",
591+
"parameterDefinition": {
592+
"__typename": "ParameterDefinition",
593+
"id": "gid://sagittarius/ParameterDefinition/4",
594+
"identifier": "value"
595+
},
596+
"value": null
597+
}
598+
]
599+
},
600+
"nextNodeId": "gid://sagittarius/NodeFunction/3"
601+
},
602+
{
603+
"__typename": "NodeFunction",
604+
"id": "gid://sagittarius/NodeFunction/3",
605+
"functionDefinition": {
606+
"__typename": "FunctionDefinition",
607+
"id": "gid://sagittarius/FunctionDefinition/12",
608+
"identifier": "std::boolean::as_text"
609+
},
610+
"parameters": {
611+
"__typename": "NodeParameterConnection",
612+
"nodes": [
613+
{
614+
"__typename": "NodeParameter",
615+
"parameterDefinition": {
616+
"__typename": "ParameterDefinition",
617+
"id": "gid://sagittarius/ParameterDefinition/15",
618+
"identifier": "value"
619+
},
620+
"value": {
621+
"__typename": "LiteralValue",
622+
"value": false
623+
}
624+
}
625+
]
626+
}
627+
}
628+
]
629+
},
630+
"project": {
631+
"__typename": "NamespaceProject",
632+
"id": "gid://sagittarius/NamespaceProject/1"
633+
},
634+
"settings": {
635+
"__typename": "FlowSettingConnection",
636+
"count": 2,
637+
"nodes": [
638+
{
639+
"__typename": "FlowSetting",
640+
"id": "gid://sagittarius/FlowSetting/1",
641+
"createdAt": "2026-04-12T13:47:31Z",
642+
"updatedAt": "2026-04-12T13:47:31Z",
643+
"flowSettingIdentifier": "httpURL",
644+
"value": "/test"
645+
},
646+
{
647+
"__typename": "FlowSetting",
648+
"id": "gid://sagittarius/FlowSetting/2",
649+
"createdAt": "2026-04-12T13:47:31Z",
650+
"updatedAt": "2026-04-12T13:47:31Z",
651+
"flowSettingIdentifier": "httpMethod",
652+
"value": "GET"
653+
}
654+
],
655+
"pageInfo": {
656+
"__typename": "PageInfo",
657+
"endCursor": "Mg",
658+
"hasNextPage": false
659+
}
660+
},
661+
"startingNodeId": "gid://sagittarius/NodeFunction/1",
662+
"type": {
663+
"__typename": "FlowType",
664+
"id": "gid://sagittarius/FlowType/1"
665+
},
666+
"disabledReason": null,
667+
"updatedAt": "2026-04-13T00:07:31Z",
668+
"userAbilities": {
669+
"__typename": "FlowUserAbilities",
670+
"deleteFlow": true
671+
}
672+
};
673+
674+
const result = getFlowValidation(flow, FUNCTION_SIGNATURES, DATA_TYPES);
675+
676+
expect(result.isValid).toBe(true);
677+
result.diagnostics.forEach((error) => {
678+
expect(error.parameterIndex).toBeDefined()
679+
})
680+
});
681+
540682
});

0 commit comments

Comments
 (0)