From 66543a48b0d9b486fba1f5f1a0fed58635ae55dd Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Tue, 21 Oct 2025 15:37:10 +0200 Subject: [PATCH] Add integration tests for WorkflowDefinitionActivity scenarios (#6999) * Add unit tests for `FlowFork` activity and enhance test utilities - Introduce `FlowForkTests` to validate activity behavior with various branch configurations. - Extend `ActivityExecutionContextExtensions` with methods to retrieve and check outcomes. - Modify `ActivityTestFixture` to ensure activities transition to `Running` status before execution. * Add unit tests for `FlowSwitch` activity and extend test utilities - Implement `FlowSwitchTests` to verify behavior based on switch cases, modes, and literal expressions. - Enhance `ActivityExecutionContextExtensions` with methods to retrieve and check outcomes in execution context. * Update test guidelines to include examples for checking activity outcomes - Add unit test examples for validating multiple and default outcomes. - Extend documentation to describe new `ActivityExecutionContextExtensions` methods: `GetOutcomes` and `HasOutcome`. * Apply suggestion from @Copilot Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Simplify `GetOutcomes` method in `ActivityExecutionContextExtensions`. * Add unit tests for `FlowSendHttpRequest` activity and refactor helper utilities - Introduce `FlowSendHttpRequestTests` to validate activity behavior across various scenarios. - Add utility methods in `SendHttpRequestTestHelpers` for creating mock responses and exceptions. - Refactor `Helpers` namespace to `Http.Helpers` for better organization. - Update project file to reflect namespace adjustments. * Update test/unit/Elsa.Activities.UnitTests/Elsa.Activities.UnitTests.csproj Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Add integration tests for WorkflowDefinitionActivity scenarios - Introduce integration tests covering inputs, outputs, version fallback, and outcome handling. - Add JSON workflow definitions to validate parent-child workflow execution. - Update project files to include new test scenarios. - Enhance error handling in `RunWorkflowExtensions` for missing workflow definitions. - Adjust JavaScript expression handler to support PascalCase activity names. * Refactor WorkflowDefinitionActivity tests to use Theory with dynamic test cases - Consolidate multiple Fact-based tests into a single parameterized Theory. - Introduce `WorkflowDefinitionActivityTestCases` for reusable test scenarios. - Simplify assertions and improve test structure for better maintainability. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../RunWorkflowExtensions.cs | 6 +- ...ineWithVariablesAndInputOutputAccessors.cs | 2 +- .../Elsa.Workflows.IntegrationTests.csproj | 27 ++++ .../Scenarios/DependencyWorkflows/Tests.cs | 5 +- .../WorkflowDefinitionActivities/Tests.cs | 41 +++++ .../Workflows/child-published-version.json | 23 +++ .../Workflows/child-with-input.json | 79 ++++++++++ .../Workflows/child-with-outcomes.json | 72 +++++++++ .../Workflows/child-with-output.json | 84 ++++++++++ .../Workflows/parent-version-fallback.json | 23 +++ .../Workflows/parent-with-input.json | 74 +++++++++ .../Workflows/parent-with-io.json | 23 +++ .../Workflows/parent-with-outcomes.json | 147 ++++++++++++++++++ .../Workflows/parent-with-output.json | 107 +++++++++++++ 14 files changed, 709 insertions(+), 4 deletions(-) create mode 100644 test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Tests.cs create mode 100644 test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/child-published-version.json create mode 100644 test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/child-with-input.json create mode 100644 test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/child-with-outcomes.json create mode 100644 test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/child-with-output.json create mode 100644 test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/parent-version-fallback.json create mode 100644 test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/parent-with-input.json create mode 100644 test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/parent-with-io.json create mode 100644 test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/parent-with-outcomes.json create mode 100644 test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/parent-with-output.json diff --git a/src/common/Elsa.Testing.Shared.Integration/RunWorkflowExtensions.cs b/src/common/Elsa.Testing.Shared.Integration/RunWorkflowExtensions.cs index 25e8b3ce8..429ce6f99 100644 --- a/src/common/Elsa.Testing.Shared.Integration/RunWorkflowExtensions.cs +++ b/src/common/Elsa.Testing.Shared.Integration/RunWorkflowExtensions.cs @@ -35,11 +35,15 @@ public static class RunWorkflowExtensions { var workflowDefinitionService = services.GetRequiredService(); var workflowGraph = await workflowDefinitionService.FindWorkflowGraphAsync(workflowDefinitionId, versionOptions ?? VersionOptions.Published); + + if (workflowGraph == null) + throw new InvalidOperationException($"Workflow definition with ID '{workflowDefinitionId}' not found."); + var workflowRuntime = services.GetRequiredService(); var workflowClient = await workflowRuntime.CreateClientAsync(); var response = await workflowClient.CreateAndRunInstanceAsync(new() { - WorkflowDefinitionHandle = WorkflowDefinitionHandle.ByDefinitionVersionId(workflowGraph!.Workflow.Identity.Id), + WorkflowDefinitionHandle = WorkflowDefinitionHandle.ByDefinitionVersionId(workflowGraph.Workflow.Identity.Id), Input = input }); diff --git a/src/modules/Elsa.Expressions.JavaScript/Handlers/ConfigureEngineWithVariablesAndInputOutputAccessors.cs b/src/modules/Elsa.Expressions.JavaScript/Handlers/ConfigureEngineWithVariablesAndInputOutputAccessors.cs index 6a443629d..c1f38f9ae 100644 --- a/src/modules/Elsa.Expressions.JavaScript/Handlers/ConfigureEngineWithVariablesAndInputOutputAccessors.cs +++ b/src/modules/Elsa.Expressions.JavaScript/Handlers/ConfigureEngineWithVariablesAndInputOutputAccessors.cs @@ -75,6 +75,6 @@ public class ConfigureEngineWithVariablesAndInputOutputAccessors(IOptions)(() => context.GetOutput(activityOutput.ActivityId, outputName))); + engine.SetValue($"get{outputName}From{activityOutput.ActivityName.Pascalize()}", (Func)(() => context.GetOutput(activityOutput.ActivityId, outputName))); } } \ No newline at end of file diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Elsa.Workflows.IntegrationTests.csproj b/test/integration/Elsa.Workflows.IntegrationTests/Elsa.Workflows.IntegrationTests.csproj index f3487fa1f..08c0420f9 100644 --- a/test/integration/Elsa.Workflows.IntegrationTests/Elsa.Workflows.IntegrationTests.csproj +++ b/test/integration/Elsa.Workflows.IntegrationTests/Elsa.Workflows.IntegrationTests.csproj @@ -35,5 +35,32 @@ Always + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + + + Always + diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/DependencyWorkflows/Tests.cs b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/DependencyWorkflows/Tests.cs index 45b4a0dca..f90bd7c9f 100644 --- a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/DependencyWorkflows/Tests.cs +++ b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/DependencyWorkflows/Tests.cs @@ -17,12 +17,13 @@ public class Tests } [Fact(DisplayName = "Workflows provided from JSON files that depend on other workflows are executed correctly.")] - public async Task Test1() + public async Task Should_Execute_Multi_Level_Nested_Workflow_Definitions() { // Populate registries. await _services.PopulateRegistriesAsync(); - // Run the "matter" workflow. + // Run the "matter" workflow which contains MoleculeActivity, which contains AtomActivity. + // Matter -> 3x Molecule -> each Molecule contains 3x Atom = 9 "Atom" outputs total await _services.RunWorkflowUntilEndAsync("matter-workflow"); // Assert. diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Tests.cs b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Tests.cs new file mode 100644 index 000000000..453054974 --- /dev/null +++ b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Tests.cs @@ -0,0 +1,41 @@ +using Elsa.Testing.Shared; +using Xunit.Abstractions; + +namespace Elsa.Workflows.IntegrationTests.Scenarios.WorkflowDefinitionActivities; + +public class Tests +{ + private readonly CapturingTextWriter _capturingTextWriter = new(); + private readonly IServiceProvider _services; + + public Tests(ITestOutputHelper testOutputHelper) + { + _services = new TestApplicationBuilder(testOutputHelper) + .WithCapturingTextWriter(_capturingTextWriter) + .WithWorkflowsFromDirectory("Scenarios", "WorkflowDefinitionActivities", "Workflows") + .Build(); + } + + [Theory] + [MemberData(nameof(WorkflowDefinitionActivityTestCases))] + public async Task Should_Execute_WorkflowDefinitionActivity_Scenarios(string workflowDefinitionId, string expectedOutput) + { + // Populate registries. + await _services.PopulateRegistriesAsync(); + + // Run the workflow. + await _services.RunWorkflowUntilEndAsync(workflowDefinitionId); + + // Assert - verify expected output appears. + var lines = _capturingTextWriter.Lines.ToList(); + Assert.Contains(expectedOutput, lines); + } + + public static IEnumerable WorkflowDefinitionActivityTestCases() + { + yield return ["parent-with-input", "Hello from parent!"]; + yield return ["parent-with-output", "Received from child: Child output value"]; + yield return ["parent-with-outcomes", "Success path taken"]; + yield return ["parent-version-fallback", "Published version executed"]; + } +} diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/child-published-version.json b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/child-published-version.json new file mode 100644 index 000000000..23cf02e78 --- /dev/null +++ b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/child-published-version.json @@ -0,0 +1,23 @@ +{ + "id": "child-published-v1", + "definitionId": "child-published", + "name": "ChildPublished", + "version": 1, + "isLatest": true, + "isPublished": true, + "usableAsActivity": true, + "inputs": [], + "outputs": [], + "root": { + "type": "Elsa.WriteLine", + "version": 1, + "id": "WriteLine1", + "text": { + "typeName": "String", + "expression": { + "type": "Literal", + "value": "Published version executed" + } + } + } +} diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/child-with-input.json b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/child-with-input.json new file mode 100644 index 000000000..3b85bc4bf --- /dev/null +++ b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/child-with-input.json @@ -0,0 +1,79 @@ +{ + "$schema": "https://elsaworkflows.io/schemas/workflow-definition/v3.0.0/schema.json", + "id": "e694d38a6d17f6ab", + "definitionId": "d0ae88e4c15eacc0", + "name": "ChildWithInput", + "createdAt": "2025-10-21T12:06:12.52497\u002B00:00", + "version": 1, + "toolVersion": "3.6.0.0", + "variables": [], + "inputs": [ + { + "uiHint": "singleline", + "storageDriverType": "Elsa.Workflows.WorkflowInstanceStorageDriver, Elsa.Workflows.Core", + "type": "String", + "name": "Message", + "displayName": "Message", + "description": "The message to write", + "category": "Primitives" + } + ], + "outputs": [], + "outcomes": [], + "customProperties": {}, + "isReadonly": false, + "isSystem": false, + "isLatest": true, + "isPublished": true, + "options": { + "usableAsActivity": true, + "autoUpdateConsumingWorkflows": true + }, + "root": { + "id": "855226c76e9ad551", + "nodeId": "Workflow1:855226c76e9ad551", + "name": "Flowchart1", + "type": "Elsa.Flowchart", + "version": 1, + "customProperties": { + "notFoundConnections": [], + "canStartWorkflow": false, + "runAsynchronously": false + }, + "metadata": {}, + "activities": [ + { + "text": { + "typeName": "String", + "expression": { + "type": "JavaScript", + "value": "getMessage()" + } + }, + "id": "eff084a902159510", + "nodeId": "Workflow1:855226c76e9ad551:eff084a902159510", + "name": "WriteLine1", + "type": "Elsa.WriteLine", + "version": 1, + "customProperties": { + "canStartWorkflow": false, + "runAsynchronously": false + }, + "metadata": { + "designer": { + "position": { + "x": -278.5, + "y": -178.5 + }, + "size": { + "width": 159.6171875, + "height": 67.9765625 + } + } + } + } + ], + "variables": [], + "connections": [] + } +} \ No newline at end of file diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/child-with-outcomes.json b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/child-with-outcomes.json new file mode 100644 index 000000000..6a4aeeba8 --- /dev/null +++ b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/child-with-outcomes.json @@ -0,0 +1,72 @@ +{ + "$schema": "https://elsaworkflows.io/schemas/workflow-definition/v3.0.0/schema.json", + "id": "85761829037332b7", + "definitionId": "7ee5c04453217e3f", + "name": "ChildWithOutcomes", + "createdAt": "2025-10-21T13:11:59.899105\u002B00:00", + "version": 2, + "toolVersion": "3.6.0.0", + "variables": [], + "inputs": [], + "outputs": [], + "outcomes": [ + "Success", + "Failed" + ], + "customProperties": {}, + "isReadonly": false, + "isSystem": false, + "isLatest": true, + "isPublished": true, + "options": { + "usableAsActivity": true, + "autoUpdateConsumingWorkflows": true + }, + "root": { + "id": "3519519e32e50f38", + "nodeId": "Workflow1:3519519e32e50f38", + "name": "Flowchart1", + "type": "Elsa.Flowchart", + "version": 1, + "customProperties": { + "notFoundConnections": [], + "canStartWorkflow": false, + "runAsynchronously": false + }, + "metadata": {}, + "activities": [ + { + "outcomes": { + "typeName": "Object", + "expression": { + "type": "Literal", + "value": "Success" + } + }, + "id": "a093b294de68dc32", + "nodeId": "Workflow1:3519519e32e50f38:a093b294de68dc32", + "name": "Complete1", + "type": "Elsa.Complete", + "version": 1, + "customProperties": { + "canStartWorkflow": false, + "runAsynchronously": false + }, + "metadata": { + "designer": { + "position": { + "x": -160.5, + "y": -143.5 + }, + "size": { + "width": 157.15625, + "height": 67.9765625 + } + } + } + } + ], + "variables": [], + "connections": [] + } +} \ No newline at end of file diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/child-with-output.json b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/child-with-output.json new file mode 100644 index 000000000..fab43afa4 --- /dev/null +++ b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/child-with-output.json @@ -0,0 +1,84 @@ +{ + "$schema": "https://elsaworkflows.io/schemas/workflow-definition/v3.0.0/schema.json", + "id": "4da8180d0c9f7e3f", + "definitionId": "5781ed56ea4b160", + "name": "ChildWithOutput", + "createdAt": "2025-10-21T12:15:08.404102\u002B00:00", + "version": 4, + "toolVersion": "3.6.0.0", + "variables": [], + "inputs": [], + "outputs": [ + { + "type": "String", + "name": "Output", + "displayName": "Output", + "description": "The result value", + "category": "Primitives" + } + ], + "outcomes": [], + "customProperties": {}, + "isReadonly": false, + "isSystem": false, + "isLatest": true, + "isPublished": true, + "options": { + "usableAsActivity": true, + "autoUpdateConsumingWorkflows": true + }, + "root": { + "id": "14493561a73301af", + "nodeId": "Workflow1:14493561a73301af", + "name": "Flowchart1", + "type": "Elsa.Flowchart", + "version": 1, + "customProperties": { + "notFoundConnections": [], + "canStartWorkflow": false, + "runAsynchronously": false + }, + "metadata": {}, + "activities": [ + { + "outputName": { + "typeName": "String", + "expression": { + "type": "Literal", + "value": "Output" + } + }, + "outputValue": { + "typeName": "Object", + "expression": { + "type": "Literal", + "value": "Child output value" + } + }, + "id": "461b5cebad79475c", + "nodeId": "Workflow1:14493561a73301af:461b5cebad79475c", + "name": "SetOutput1", + "type": "Elsa.SetOutput", + "version": 1, + "customProperties": { + "canStartWorkflow": false, + "runAsynchronously": false + }, + "metadata": { + "designer": { + "position": { + "x": -353.5, + "y": -235.5 + }, + "size": { + "width": 132.3203125, + "height": 67.9765625 + } + } + } + } + ], + "variables": [], + "connections": [] + } +} \ No newline at end of file diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/parent-version-fallback.json b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/parent-version-fallback.json new file mode 100644 index 000000000..b750cb617 --- /dev/null +++ b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/parent-version-fallback.json @@ -0,0 +1,23 @@ +{ + "id": "parent-version-fallback-v1", + "definitionId": "parent-version-fallback", + "name": "ParentVersionFallback", + "version": 1, + "isLatest": true, + "isPublished": true, + "root": { + "type": "Elsa.Flowchart", + "version": 1, + "id": "Flowchart1", + "start": "ChildActivity1", + "activities": [ + { + "type": "ChildPublished", + "version": 1, + "id": "ChildActivity1", + "workflowDefinitionId": "child-published", + "workflowDefinitionVersionId": "non-existent-version-id" + } + ] + } +} diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/parent-with-input.json b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/parent-with-input.json new file mode 100644 index 000000000..2293ba19f --- /dev/null +++ b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/parent-with-input.json @@ -0,0 +1,74 @@ +{ + "$schema": "https://elsaworkflows.io/schemas/workflow-definition/v3.0.0/schema.json", + "id": "70a093d85f846d05", + "definitionId": "parent-with-input", + "name": "ParentWithInput", + "createdAt": "2025-10-21T12:08:40.940992\u002B00:00", + "version": 4, + "toolVersion": "3.6.0.0", + "variables": [], + "inputs": [], + "outputs": [], + "outcomes": [], + "customProperties": {}, + "isReadonly": false, + "isSystem": false, + "isLatest": true, + "isPublished": true, + "options": { + "autoUpdateConsumingWorkflows": false + }, + "root": { + "id": "Flowchart1", + "nodeId": "Workflow2:Flowchart1", + "type": "Elsa.Flowchart", + "version": 1, + "customProperties": { + "notFoundConnections": [], + "canStartWorkflow": false, + "runAsynchronously": false + }, + "metadata": {}, + "activities": [ + { + "workflowDefinitionId": "d0ae88e4c15eacc0", + "workflowDefinitionVersionId": "e694d38a6d17f6ab", + "latestAvailablePublishedVersion": 1, + "latestAvailablePublishedVersionId": "e694d38a6d17f6ab", + "id": "ChildActivity1", + "nodeId": "Workflow2:Flowchart1:ChildActivity1", + "name": null, + "type": "ChildWithInput", + "version": 1, + "customProperties": { + "canStartWorkflow": false, + "runAsynchronously": false + }, + "metadata": { + "designer": { + "position": { + "x": -80, + "y": -40 + }, + "size": { + "width": 161.8515625, + "height": 67.9765625 + } + } + }, + "message": { + "typeName": "String", + "expression": { + "type": "Literal", + "value": "Hello from parent!" + }, + "memoryReference": { + "id": "ChildActivity1:input-message" + } + } + } + ], + "variables": [], + "connections": [] + } +} \ No newline at end of file diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/parent-with-io.json b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/parent-with-io.json new file mode 100644 index 000000000..526e7396b --- /dev/null +++ b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/parent-with-io.json @@ -0,0 +1,23 @@ +{ + "id": "parent-with-io-v1", + "definitionId": "parent-with-io", + "name": "ParentWithIO", + "version": 1, + "toolVersion": "3.6.0.0", + "isLatest": true, + "isPublished": true, + "root": { + "type": "ChildWithInput", + "version": 1, + "id": "ChildActivity1", + "workflowDefinitionId": "child-with-input", + "workflowDefinitionVersionId": "child-with-input-v1", + "message": { + "typeName": "String", + "expression": { + "type": "Literal", + "value": "Test message" + } + } + } +} diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/parent-with-outcomes.json b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/parent-with-outcomes.json new file mode 100644 index 000000000..887f6f04e --- /dev/null +++ b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/parent-with-outcomes.json @@ -0,0 +1,147 @@ +{ + "$schema": "https://elsaworkflows.io/schemas/workflow-definition/v3.0.0/schema.json", + "id": "a09fb3bdfd316332", + "definitionId": "parent-with-outcomes", + "name": "ParentWithOutcomes", + "createdAt": "2025-10-21T13:11:28.283567\u002B00:00", + "version": 2, + "toolVersion": "3.6.0.0", + "variables": [], + "inputs": [], + "outputs": [], + "outcomes": [], + "customProperties": {}, + "isReadonly": false, + "isSystem": false, + "isLatest": true, + "isPublished": true, + "options": { + "autoUpdateConsumingWorkflows": false + }, + "root": { + "id": "Flowchart1", + "nodeId": "Workflow2:Flowchart1", + "type": "Elsa.Flowchart", + "version": 1, + "customProperties": { + "notFoundConnections": [], + "canStartWorkflow": false, + "runAsynchronously": false + }, + "metadata": {}, + "activities": [ + { + "workflowDefinitionId": "7ee5c04453217e3f", + "workflowDefinitionVersionId": "85761829037332b7", + "latestAvailablePublishedVersion": 2, + "latestAvailablePublishedVersionId": "85761829037332b7", + "id": "ChildActivity1", + "nodeId": "Workflow2:Flowchart1:ChildActivity1", + "name": null, + "type": "ChildWithOutcomes", + "version": 2, + "customProperties": { + "canStartWorkflow": false, + "runAsynchronously": false + }, + "metadata": { + "designer": { + "position": { + "x": -140, + "y": 0 + }, + "size": { + "width": 198.7421875, + "height": 67.9765625 + } + } + } + }, + { + "text": { + "typeName": "String", + "expression": { + "type": "Literal", + "value": "Failed path taken" + } + }, + "id": "WriteLineFailed", + "nodeId": "Workflow2:Flowchart1:WriteLineFailed", + "name": null, + "type": "Elsa.WriteLine", + "version": 1, + "customProperties": { + "canStartWorkflow": false, + "runAsynchronously": false + }, + "metadata": { + "designer": { + "position": { + "x": 140, + "y": 80 + }, + "size": { + "width": 159.6171875, + "height": 67.9765625 + } + } + } + }, + { + "text": { + "typeName": "String", + "expression": { + "type": "Literal", + "value": "Success path taken" + } + }, + "id": "WriteLineSuccess", + "nodeId": "Workflow2:Flowchart1:WriteLineSuccess", + "name": null, + "type": "Elsa.WriteLine", + "version": 1, + "customProperties": { + "canStartWorkflow": false, + "runAsynchronously": false + }, + "metadata": { + "designer": { + "position": { + "x": 180, + "y": -220 + }, + "size": { + "width": 159.6171875, + "height": 67.9765625 + } + } + } + } + ], + "variables": [], + "connections": [ + { + "source": { + "activity": "ChildActivity1", + "port": "Success" + }, + "target": { + "activity": "WriteLineSuccess", + "port": "In" + }, + "vertices": [] + }, + { + "source": { + "activity": "ChildActivity1", + "port": "Failed" + }, + "target": { + "activity": "WriteLineFailed", + "port": "In" + }, + "vertices": [] + } + ] + } +} \ No newline at end of file diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/parent-with-output.json b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/parent-with-output.json new file mode 100644 index 000000000..e1c7dd555 --- /dev/null +++ b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/WorkflowDefinitionActivities/Workflows/parent-with-output.json @@ -0,0 +1,107 @@ +{ + "$schema": "https://elsaworkflows.io/schemas/workflow-definition/v3.0.0/schema.json", + "id": "b1f4fc14b3c6b51", + "definitionId": "parent-with-output", + "name": "ParentWithOutput", + "createdAt": "2025-10-21T12:27:50.918094\u002B00:00", + "version": 1, + "toolVersion": "3.6.0.0", + "variables": [], + "inputs": [], + "outputs": [], + "outcomes": [], + "customProperties": {}, + "isReadonly": false, + "isSystem": false, + "isLatest": true, + "isPublished": true, + "options": { + "autoUpdateConsumingWorkflows": false + }, + "root": { + "id": "bcbe1e9e5a9c9b0e", + "nodeId": "Workflow2:bcbe1e9e5a9c9b0e", + "name": "Flowchart1", + "type": "Elsa.Flowchart", + "version": 1, + "customProperties": { + "notFoundConnections": [], + "canStartWorkflow": false, + "runAsynchronously": false + }, + "metadata": {}, + "activities": [ + { + "workflowDefinitionId": "5781ed56ea4b160", + "workflowDefinitionVersionId": "4da8180d0c9f7e3f", + "latestAvailablePublishedVersion": 4, + "latestAvailablePublishedVersionId": "4da8180d0c9f7e3f", + "id": "c98383464dab2047", + "nodeId": "Workflow2:bcbe1e9e5a9c9b0e:c98383464dab2047", + "name": "ChildWithOutput1", + "type": "ChildWithOutput", + "version": 4, + "customProperties": { + "canStartWorkflow": false, + "runAsynchronously": false + }, + "metadata": { + "designer": { + "position": { + "x": -323.5, + "y": -85.5 + }, + "size": { + "width": 174.1640625, + "height": 67.9765625 + } + } + } + }, + { + "text": { + "typeName": "String", + "expression": { + "type": "JavaScript", + "value": "\u0060Received from child: ${getOutputFromChildWithOutput1()}\u0060" + } + }, + "id": "b4f314dce11c7135", + "nodeId": "Workflow2:bcbe1e9e5a9c9b0e:b4f314dce11c7135", + "name": "WriteLine1", + "type": "Elsa.WriteLine", + "version": 1, + "customProperties": { + "canStartWorkflow": false, + "runAsynchronously": false + }, + "metadata": { + "designer": { + "position": { + "x": -27.5, + "y": -85.5 + }, + "size": { + "width": 159.6171875, + "height": 67.9765625 + } + } + } + } + ], + "variables": [], + "connections": [ + { + "source": { + "activity": "c98383464dab2047", + "port": "Done" + }, + "target": { + "activity": "b4f314dce11c7135", + "port": "In" + }, + "vertices": [] + } + ] + } +} \ No newline at end of file