Add synthetic properties to JS engine for exclusion (#6178)
* Add synthetic properties to JS engine for exclusion This fixes an issue where inputs would be declared as new variables, causing a "miss" when trying to read the input. * Add InputOutput workflows and tests for data exchange Introduce new Consumer and Provider JSON workflows to facilitate testing of input and output functionalities, ensuring seamless data exchange between processes. Implement corresponding tests to verify the correct reception and transmission of input data within the Provider workflow back to the Consumer, validating the setup with an assertion for expected output. Update the project configuration to include these workflows in the build output.
This commit is contained in:
parent
97b59974d9
commit
75cb3a3de2
|
|
@ -87,6 +87,11 @@ public class ConfigureEngineWithVariables(IOptions<JintOptions> options) : INoti
|
|||
yield return inputDefinition.Name;
|
||||
}
|
||||
|
||||
foreach (var syntheticProperty in activityExecutionContext.Activity.SyntheticProperties)
|
||||
{
|
||||
yield return syntheticProperty.Key;
|
||||
}
|
||||
|
||||
activityExecutionContext = activityExecutionContext.ParentActivityExecutionContext;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,6 +82,12 @@
|
|||
<None Update="Scenarios\HttpWorkflows\Workflows\http-hello-world.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Scenarios\InputOutput\Workflows\consumer.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Scenarios\InputOutput\Workflows\provider.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
using Elsa.Workflows.ComponentTests.Abstractions;
|
||||
using Elsa.Workflows.ComponentTests.Fixtures;
|
||||
using Elsa.Workflows.Management;
|
||||
using Elsa.Workflows.Runtime;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Elsa.Workflows.ComponentTests.Scenarios.InputOutput;
|
||||
|
||||
public class InputOutputTests(App app) : AppComponentTest(app)
|
||||
{
|
||||
[Fact(DisplayName = "Input should be received by the Provider and should in turn be able to send it back to the Consumer.")]
|
||||
public async Task InputShouldBeOutput()
|
||||
{
|
||||
const string workflowDefinitionVersionId = "4e993ab1b3d4e4a1";
|
||||
var workflowDefinitionService = Scope.ServiceProvider.GetRequiredService<IWorkflowDefinitionService>();
|
||||
var workflowInvoker = Scope.ServiceProvider.GetRequiredService<IWorkflowInvoker>();
|
||||
var variableManager = Scope.ServiceProvider.GetRequiredService<IWorkflowInstanceVariableManager>();
|
||||
var workflowGraph = await workflowDefinitionService.FindWorkflowGraphAsync(workflowDefinitionVersionId);
|
||||
var result = await workflowInvoker.InvokeAsync(workflowGraph!);
|
||||
var variables = await variableManager.GetVariablesAsync(result.WorkflowState.Id);
|
||||
var variableValue = variables.First().Value;
|
||||
|
||||
Assert.Equal("Hello World!", variableValue);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
{
|
||||
"$schema": "https://elsaworkflows.io/schemas/workflow-definition/v3.0.0/schema.json",
|
||||
"id": "4e993ab1b3d4e4a1",
|
||||
"definitionId": "58dbd7bffa85a761",
|
||||
"name": "Consumer",
|
||||
"createdAt": "2024-12-04T16:49:20.593932\u002B00:00",
|
||||
"version": 1,
|
||||
"toolVersion": "3.3.0.0",
|
||||
"variables": [
|
||||
{
|
||||
"id": "67fcb9870af4c28e",
|
||||
"name": "Variable1",
|
||||
"typeName": "String",
|
||||
"isArray": false,
|
||||
"value": "",
|
||||
"storageDriverTypeName": "Elsa.Workflows.WorkflowInstanceStorageDriver, Elsa.Workflows.Core"
|
||||
}
|
||||
],
|
||||
"inputs": [],
|
||||
"outputs": [],
|
||||
"outcomes": [],
|
||||
"customProperties": {
|
||||
"logPersistenceConfig": {
|
||||
"default": {
|
||||
"evaluationMode": "Strategy",
|
||||
"strategyType": "Elsa.Workflows.LogPersistence.Strategies.Inherit, Elsa.Workflows.Core",
|
||||
"expression": null
|
||||
}
|
||||
}
|
||||
},
|
||||
"isReadonly": false,
|
||||
"isSystem": false,
|
||||
"isLatest": true,
|
||||
"isPublished": true,
|
||||
"options": {
|
||||
"autoUpdateConsumingWorkflows": false
|
||||
},
|
||||
"root": {
|
||||
"id": "938f2c91bb759a6a",
|
||||
"nodeId": "Workflow2:938f2c91bb759a6a",
|
||||
"name": "Flowchart1",
|
||||
"type": "Elsa.Flowchart",
|
||||
"version": 1,
|
||||
"customProperties": {
|
||||
"notFoundConnections": [],
|
||||
"canStartWorkflow": false,
|
||||
"runAsynchronously": false
|
||||
},
|
||||
"metadata": {},
|
||||
"activities": [
|
||||
{
|
||||
"workflowDefinitionId": "780fbf96f1bb1e7e",
|
||||
"workflowDefinitionVersionId": "640867552fc865d",
|
||||
"latestAvailablePublishedVersion": 3,
|
||||
"latestAvailablePublishedVersionId": "640867552fc865d",
|
||||
"id": "8c1127e1193cd6e8",
|
||||
"nodeId": "Workflow2:938f2c91bb759a6a:8c1127e1193cd6e8",
|
||||
"name": "Output1",
|
||||
"type": "Provider",
|
||||
"version": 1,
|
||||
"customProperties": {
|
||||
"canStartWorkflow": false,
|
||||
"runAsynchronously": false
|
||||
},
|
||||
"metadata": {
|
||||
"designer": {
|
||||
"position": {
|
||||
"x": -160,
|
||||
"y": -280
|
||||
},
|
||||
"size": {
|
||||
"width": 89.6953125,
|
||||
"height": 50
|
||||
}
|
||||
}
|
||||
},
|
||||
"input1": {
|
||||
"typeName": "Object",
|
||||
"expression": {
|
||||
"type": "Literal",
|
||||
"value": "Hello World!"
|
||||
},
|
||||
"memoryReference": {
|
||||
"id": "8c1127e1193cd6e8:input-input-1"
|
||||
}
|
||||
},
|
||||
"output1": {
|
||||
"typeName": "Object",
|
||||
"memoryReference": {
|
||||
"id": "67fcb9870af4c28e"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"variables": [],
|
||||
"connections": []
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,104 @@
|
|||
{
|
||||
"$schema": "https://elsaworkflows.io/schemas/workflow-definition/v3.0.0/schema.json",
|
||||
"id": "5ba5a7e36d60549b",
|
||||
"definitionId": "780fbf96f1bb1e7e",
|
||||
"name": "Provider",
|
||||
"createdAt": "2024-12-04T16:22:39.064075\u002B00:00",
|
||||
"version": 1,
|
||||
"toolVersion": "3.3.0.0",
|
||||
"variables": [],
|
||||
"inputs": [
|
||||
{
|
||||
"uiHint": "singleline",
|
||||
"storageDriverType": "Elsa.Workflows.WorkflowInstanceStorageDriver, Elsa.Workflows.Core",
|
||||
"type": "Object",
|
||||
"name": "Input1",
|
||||
"displayName": "Input 1",
|
||||
"description": "",
|
||||
"category": "Primitives",
|
||||
"isArray": false
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"type": "Object",
|
||||
"name": "Output1",
|
||||
"displayName": "Output 1",
|
||||
"description": "",
|
||||
"category": "Primitives",
|
||||
"isArray": false
|
||||
}
|
||||
],
|
||||
"outcomes": [],
|
||||
"customProperties": {
|
||||
"logPersistenceConfig": {
|
||||
"default": {
|
||||
"evaluationMode": "Strategy",
|
||||
"strategyType": "Elsa.Workflows.LogPersistence.Strategies.Inherit, Elsa.Workflows.Core",
|
||||
"expression": null
|
||||
}
|
||||
}
|
||||
},
|
||||
"isReadonly": false,
|
||||
"isSystem": false,
|
||||
"isLatest": true,
|
||||
"isPublished": false,
|
||||
"options": {
|
||||
"usableAsActivity": true,
|
||||
"autoUpdateConsumingWorkflows": true
|
||||
},
|
||||
"root": {
|
||||
"id": "85a5e1d9e487bfa4",
|
||||
"nodeId": "Workflow1:85a5e1d9e487bfa4",
|
||||
"name": "Flowchart1",
|
||||
"type": "Elsa.Flowchart",
|
||||
"version": 1,
|
||||
"customProperties": {
|
||||
"notFoundConnections": [],
|
||||
"canStartWorkflow": false,
|
||||
"runAsynchronously": false
|
||||
},
|
||||
"metadata": {},
|
||||
"activities": [
|
||||
{
|
||||
"outputName": {
|
||||
"typeName": "String",
|
||||
"expression": {
|
||||
"type": "Literal",
|
||||
"value": "Output1"
|
||||
}
|
||||
},
|
||||
"outputValue": {
|
||||
"typeName": "Object",
|
||||
"expression": {
|
||||
"type": "JavaScript",
|
||||
"value": "return getInput1()"
|
||||
}
|
||||
},
|
||||
"id": "985eb3bfb8d4dd3f",
|
||||
"nodeId": "Workflow1:85a5e1d9e487bfa4:985eb3bfb8d4dd3f",
|
||||
"name": "SetOutput1",
|
||||
"type": "Elsa.SetOutput",
|
||||
"version": 1,
|
||||
"customProperties": {
|
||||
"canStartWorkflow": false,
|
||||
"runAsynchronously": false
|
||||
},
|
||||
"metadata": {
|
||||
"designer": {
|
||||
"position": {
|
||||
"x": -380,
|
||||
"y": -220
|
||||
},
|
||||
"size": {
|
||||
"width": 107.3203125,
|
||||
"height": 50
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"variables": [],
|
||||
"connections": []
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue