Add project files.

This commit is contained in:
2025-08-18 17:11:43 +03:30
parent 807dc263be
commit e5eb10d604
3943 changed files with 223719 additions and 0 deletions
@@ -0,0 +1,109 @@
using Elsa.Api.Client.Resources.WorkflowDefinitions.Contracts;
using Elsa.Api.Client.Resources.WorkflowDefinitions.Responses;
using Elsa.Api.Client.Resources.WorkflowInstances.Models;
using Elsa.Common.Entities;
using Elsa.Testing.Shared.Extensions;
using Elsa.Workflows.Activities;
using Elsa.Workflows.ComponentTests.Abstractions;
using Elsa.Workflows.ComponentTests.Fixtures;
using Elsa.Workflows.Helpers;
using Elsa.Workflows.Runtime;
using Elsa.Workflows.Runtime.Entities;
using Elsa.Workflows.Runtime.Filters;
using Elsa.Workflows.Runtime.OrderDefinitions;
using Microsoft.Extensions.DependencyInjection;
using Open.Linq.AsyncExtensions;
namespace Elsa.Workflows.ComponentTests.Scenarios.LogPersistenceModes;
public class InputOutputLoggingTests(App app) : AppComponentTest(app)
{
[Theory]
[InlineData("input-output-logging-1", true, false, true, false)]
[InlineData("input-output-logging-2", true, false, true, false)]
public async Task Workflow_ShouldHonorSettings_WhenExecuting(string workflowDefinitionId, params bool[] shouldBeIncludedArray)
{
var workflowState = await ExecuteWorkflowAsync(workflowDefinitionId);
var workflowInstanceId = workflowState.Id;
var writeLineActivityTypeName = ActivityTypeNameHelper.GenerateTypeName<WriteLine>();
var activityExecutionRecords = await GetActivityExecutionRecordsAsync(workflowInstanceId, x => x.ActivityType == writeLineActivityTypeName).ToList();
for (var i = 0; i < shouldBeIncludedArray.Length; i++)
{
var activityExecutionRecord = activityExecutionRecords[i];
var shouldBeIncluded = shouldBeIncludedArray[i];
var isIncluded = activityExecutionRecord.ActivityState?.ContainsKey(nameof(WriteLine.Text)) == true;
Assert.Equal(shouldBeIncluded, isIncluded);
}
}
[Fact]
public async Task WorkflowAsActivity_ShouldHonorSettings_WhenExecuting()
{
await ExecuteWorkflowAsync("input-output-logging-3");
var activityExecutionRecord = await GetRecordByActivityNameAsync("InputOutputLogging3-Child1");
var output1IsIncluded = activityExecutionRecord.Outputs!.ContainsKey("Output1");
var output2IsIncluded = activityExecutionRecord.Outputs!.ContainsKey("Output2");
Assert.True(output1IsIncluded);
Assert.True(output2IsIncluded);
}
[Fact(Skip = "Although this functionality works in practice, the component test fails from time to time for no clear reason (yet).")]
public async Task WorkflowAsActivityInternal_ShouldHonorSettings_WhenExecuting()
{
await ExecuteWorkflowAsync("input-output-logging-3");
var setOutput1Record = await GetRecordByActivityNameAsync("SetOutput1");
var setOutput2Record = await GetRecordByActivityNameAsync("SetOutput2");
var output1IsIncluded = setOutput1Record.ActivityState?.ContainsKey("OutputName") == true;
var output2IsIncluded = setOutput2Record.ActivityState?.ContainsKey("OutputName") == true;
Assert.False(output1IsIncluded);
Assert.True(output2IsIncluded);
}
private async Task<WorkflowState> ExecuteWorkflowAsync(string workflowDefinitionId)
{
var client = WorkflowServer.CreateApiClient<IExecuteWorkflowApi>();
using var response = await client.ExecuteAsync(workflowDefinitionId);
var model = await response.ReadAsJsonAsync<ExecuteWorkflowDefinitionResponse>(WorkflowServer.Services);
return model.WorkflowState;
}
private Task<IEnumerable<ActivityExecutionRecord>> GetActivityExecutionRecordsAsync(string workflowInstanceId, Func<ActivityExecutionRecord, bool> predicate)
{
var activityExecutionRecordFilter = new ActivityExecutionRecordFilter
{
WorkflowInstanceId = workflowInstanceId,
};
return GetActivityExecutionRecordsAsync(activityExecutionRecordFilter, predicate);
}
private Task<ActivityExecutionRecord> GetRecordByActivityNameAsync(string name)
{
var filter = new ActivityExecutionRecordFilter
{
Name = name
};
return GetActivityExecutionRecordAsync(filter);
}
private async Task<IEnumerable<ActivityExecutionRecord>> GetActivityExecutionRecordsAsync(ActivityExecutionRecordFilter filter, Func<ActivityExecutionRecord, bool>? predicate = null)
{
var activityExecutionStore = Scope.ServiceProvider.GetRequiredService<IActivityExecutionStore>();
var orderBy = new ActivityExecutionRecordOrder<DateTimeOffset>(x => x.StartedAt, OrderDirection.Ascending);
var activityExecutionRecords = await activityExecutionStore.FindManyAsync(filter, orderBy);
return predicate == null ? activityExecutionRecords : activityExecutionRecords.Where(predicate);
}
private async Task<ActivityExecutionRecord> GetActivityExecutionRecordAsync(ActivityExecutionRecordFilter filter)
{
var activityExecutionStore = Scope.ServiceProvider.GetRequiredService<IActivityExecutionStore>();
var result = await activityExecutionStore.FindAsync(filter);
if(result == null)
throw new InvalidOperationException($"Activity execution record not found.");
return result;
}
}
@@ -0,0 +1,210 @@
{
"id": "94f11e583299383b",
"definitionId": "input-output-logging-1",
"name": "Input Output Logging 1",
"createdAt": "2024-04-21T11:34:17.423214+00:00",
"version": 1,
"toolVersion": "3.2.0.0",
"variables": [],
"inputs": [],
"outputs": [],
"outcomes": [],
"customProperties": {
"Elsa:WorkflowContextProviderTypes": []
},
"isReadonly": false,
"isSystem": false,
"isLatest": true,
"isPublished": true,
"options": {
"autoUpdateConsumingWorkflows": false
},
"root": {
"type": "Elsa.Flowchart",
"version": 1,
"id": "482993d55270a5e7",
"nodeId": "Workflow1:482993d55270a5e7",
"metadata": {},
"customProperties": {
"source": "FlowchartJsonConverter.cs:45",
"notFoundConnections": [],
"canStartWorkflow": false,
"runAsynchronously": false
},
"activities": [
{
"text": {
"typeName": "String",
"expression": {
"type": "Literal",
"value": "This input should be stored"
}
},
"id": "ea21b3863867ebb3",
"nodeId": "Workflow1:482993d55270a5e7:ea21b3863867ebb3",
"name": "WriteLine1",
"type": "Elsa.WriteLine",
"version": 1,
"customProperties": {
"canStartWorkflow": false,
"runAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": -440,
"y": -140
},
"size": {
"width": 139.296875,
"height": 50
}
}
}
},
{
"text": {
"typeName": "String",
"expression": {
"type": "Literal",
"value": "This input should not be stored"
}
},
"id": "4726389b3d516c40",
"nodeId": "Workflow1:482993d55270a5e7:4726389b3d516c40",
"name": "WriteLine2",
"type": "Elsa.WriteLine",
"version": 1,
"customProperties": {
"logPersistenceMode": {
"default": "Exclude",
"inputs": {
"text": "Inherit"
},
"outputs": {}
},
"canStartWorkflow": false,
"runAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": -220,
"y": -140
},
"size": {
"width": 139.296875,
"height": 50
}
}
}
},
{
"text": {
"typeName": "String",
"expression": {
"type": "Literal",
"value": "This input should be stored"
}
},
"id": "e13b09839d4244b9",
"nodeId": "Workflow1:482993d55270a5e7:e13b09839d4244b9",
"name": "WriteLine3",
"type": "Elsa.WriteLine",
"version": 1,
"customProperties": {
"logPersistenceMode": {
"default": "Exclude",
"inputs": {
"text": "Include"
},
"outputs": {}
},
"canStartWorkflow": false,
"runAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": -16,
"y": -140
},
"size": {
"width": 139.296875,
"height": 50
}
}
}
},
{
"text": {
"typeName": "String",
"expression": {
"type": "Literal",
"value": "This input should not be stored"
}
},
"id": "1ba2922db9052ce9",
"nodeId": "Workflow1:482993d55270a5e7:1ba2922db9052ce9",
"name": "WriteLine4",
"type": "Elsa.WriteLine",
"version": 1,
"customProperties": {
"logPersistenceMode": {
"default": "Include",
"inputs": {
"text": "Exclude"
},
"outputs": {}
},
"canStartWorkflow": false,
"runAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": 188,
"y": -140
},
"size": {
"width": 139.296875,
"height": 50
}
}
}
}
],
"connections": [
{
"source": {
"activity": "ea21b3863867ebb3",
"port": "Done"
},
"target": {
"activity": "4726389b3d516c40",
"port": "In"
}
},
{
"source": {
"activity": "4726389b3d516c40",
"port": "Done"
},
"target": {
"activity": "e13b09839d4244b9",
"port": "In"
}
},
{
"source": {
"activity": "e13b09839d4244b9",
"port": "Done"
},
"target": {
"activity": "1ba2922db9052ce9",
"port": "In"
}
}
]
}
}
@@ -0,0 +1,213 @@
{
"id": "a7499c4c7888fafb",
"definitionId": "input-output-logging-2",
"name": "Input Output Logging 2",
"createdAt": "2024-04-21T11:39:57.182662+00:00",
"version": 2,
"toolVersion": "3.2.0.0",
"variables": [],
"inputs": [],
"outputs": [],
"outcomes": [],
"customProperties": {
"Elsa:WorkflowContextProviderTypes": [],
"logPersistenceMode": {
"default": "Exclude"
}
},
"isReadonly": false,
"isSystem": false,
"isLatest": true,
"isPublished": true,
"options": {
"autoUpdateConsumingWorkflows": false
},
"root": {
"type": "Elsa.Flowchart",
"version": 1,
"id": "4dce3806d9c7af92",
"nodeId": "Workflow1:4dce3806d9c7af92",
"metadata": {},
"customProperties": {
"source": "FlowchartJsonConverter.cs:45",
"notFoundConnections": [],
"canStartWorkflow": false,
"runAsynchronously": false
},
"activities": [
{
"text": {
"typeName": "String",
"expression": {
"type": "Literal",
"value": "This should be logged"
}
},
"id": "30d32d634c1ddbfa",
"nodeId": "Workflow1:4dce3806d9c7af92:30d32d634c1ddbfa",
"name": "WriteLine1",
"type": "Elsa.WriteLine",
"version": 1,
"customProperties": {
"logPersistenceMode": {
"default": "Include",
"inputs": {
"text": "Inherit"
},
"outputs": {}
},
"canStartWorkflow": false,
"runAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": -380,
"y": -120
},
"size": {
"width": 139.296875,
"height": 50
}
}
}
},
{
"text": {
"typeName": "String",
"expression": {
"type": "Literal",
"value": "This should not be logged"
}
},
"id": "50fcb804a7ace442",
"nodeId": "Workflow1:4dce3806d9c7af92:50fcb804a7ace442",
"name": "WriteLine2",
"type": "Elsa.WriteLine",
"version": 1,
"customProperties": {
"canStartWorkflow": false,
"runAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": -156,
"y": -120
},
"size": {
"width": 139.296875,
"height": 50
}
}
}
},
{
"text": {
"typeName": "String",
"expression": {
"type": "Literal",
"value": "This should be logged"
}
},
"id": "3f00f1de3ec2862b",
"nodeId": "Workflow1:4dce3806d9c7af92:3f00f1de3ec2862b",
"name": "WriteLine3",
"type": "Elsa.WriteLine",
"version": 1,
"customProperties": {
"logPersistenceMode": {
"default": "Inherit",
"inputs": {
"text": "Include"
},
"outputs": {}
},
"canStartWorkflow": false,
"runAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": 60,
"y": -120
},
"size": {
"width": 139.296875,
"height": 50
}
}
}
},
{
"text": {
"typeName": "String",
"expression": {
"type": "Literal",
"value": "This should not be logged"
}
},
"id": "3dcff307781b3707",
"nodeId": "Workflow1:4dce3806d9c7af92:3dcff307781b3707",
"name": "WriteLine4",
"type": "Elsa.WriteLine",
"version": 1,
"customProperties": {
"logPersistenceMode": {
"default": "Inherit",
"inputs": {
"text": "Exclude"
},
"outputs": {}
},
"canStartWorkflow": false,
"runAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": 264,
"y": -120
},
"size": {
"width": 139.296875,
"height": 50
}
}
}
}
],
"connections": [
{
"source": {
"activity": "3f00f1de3ec2862b",
"port": "Done"
},
"target": {
"activity": "3dcff307781b3707",
"port": "In"
}
},
{
"source": {
"activity": "30d32d634c1ddbfa",
"port": "Done"
},
"target": {
"activity": "50fcb804a7ace442",
"port": "In"
}
},
{
"source": {
"activity": "50fcb804a7ace442",
"port": "Done"
},
"target": {
"activity": "3f00f1de3ec2862b",
"port": "In"
}
}
]
}
}
@@ -0,0 +1,158 @@
{
"id": "4cf7c10c7a2901d6",
"definitionId": "input-output-logging-3-child",
"name": "Input Output Logging 3 - Child",
"createdAt": "2024-04-22T13:11:07.146222+00:00",
"version": 4,
"toolVersion": "3.2.0.0",
"variables": [],
"inputs": [],
"outputs": [
{
"type": "Object",
"name": "Output1",
"displayName": "Output 1",
"category": "Primitives",
"isArray": false
},
{
"type": "Object",
"name": "Output2",
"displayName": "Output 2",
"category": "Primitives",
"isArray": false
}
],
"outcomes": [],
"customProperties": {
"logPersistenceMode": {
"default": "Exclude"
},
"Elsa:WorkflowContextProviderTypes": []
},
"isReadonly": false,
"isSystem": false,
"isLatest": true,
"isPublished": true,
"options": {
"usableAsActivity": true,
"autoUpdateConsumingWorkflows": true
},
"root": {
"type": "Elsa.Flowchart",
"version": 1,
"id": "5f72efc9043753fa",
"nodeId": "Workflow1:5f72efc9043753fa",
"metadata": {},
"customProperties": {
"source": "FlowchartJsonConverter.cs:45",
"notFoundConnections": [],
"canStartWorkflow": false,
"runAsynchronously": false
},
"activities": [
{
"outputName": {
"typeName": "String",
"expression": {
"type": "Literal",
"value": "Output1"
}
},
"outputValue": {
"typeName": "Object",
"expression": {
"type": "Literal",
"value": "Output value 1"
}
},
"id": "402076f12c1220a9",
"nodeId": "Workflow1:5f72efc9043753fa:402076f12c1220a9",
"name": "SetOutput1",
"type": "Elsa.SetOutput",
"version": 1,
"customProperties": {
"canStartWorkflow": false,
"runAsynchronously": false,
"logPersistenceMode": {
"default": "Inherit",
"inputs": {
"outputName": "Inherit",
"outputValue": "Inherit"
},
"outputs": {}
}
},
"metadata": {
"designer": {
"position": {
"x": -221.4757080078125,
"y": 264.861083984375
},
"size": {
"width": 107.734375,
"height": 50.2256965637207
}
}
}
},
{
"outputName": {
"typeName": "String",
"expression": {
"type": "Literal",
"value": "Output2"
}
},
"outputValue": {
"typeName": "Object",
"expression": {
"type": "Literal",
"value": "Output value 2"
}
},
"id": "db1d1c02cbfac590",
"nodeId": "Workflow1:5f72efc9043753fa:db1d1c02cbfac590",
"name": "SetOutput2",
"type": "Elsa.SetOutput",
"version": 1,
"customProperties": {
"canStartWorkflow": false,
"runAsynchronously": false,
"logPersistenceMode": {
"default": "Inherit",
"inputs": {
"outputName": "Include",
"outputValue": "Include"
},
"outputs": {}
}
},
"metadata": {
"designer": {
"position": {
"x": 58.5242919921875,
"y": 264.861083984375
},
"size": {
"width": 107.734375,
"height": 50.2256965637207
}
}
}
}
],
"connections": [
{
"source": {
"activity": "402076f12c1220a9",
"port": "Done"
},
"target": {
"activity": "db1d1c02cbfac590",
"port": "In"
}
}
]
}
}
@@ -0,0 +1,65 @@
{
"id": "6da18530316aee2e",
"definitionId": "input-output-logging-3",
"name": "Input Output Logging 3",
"createdAt": "2024-04-21T20:08:17.495551+00:00",
"version": 1,
"toolVersion": "3.2.0.0",
"variables": [],
"inputs": [],
"outputs": [],
"outcomes": [],
"customProperties": {
"Elsa:WorkflowContextProviderTypes": []
},
"isReadonly": false,
"isSystem": false,
"isLatest": true,
"isPublished": true,
"options": {
"autoUpdateConsumingWorkflows": false
},
"root": {
"type": "Elsa.Flowchart",
"version": 1,
"id": "9aec3fea5a39cccd",
"nodeId": "Workflow2:9aec3fea5a39cccd",
"metadata": {},
"customProperties": {
"source": "FlowchartJsonConverter.cs:45",
"notFoundConnections": [],
"canStartWorkflow": false,
"runAsynchronously": false
},
"activities": [
{
"workflowDefinitionId": "input-output-logging-3-child",
"workflowDefinitionVersionId": "4cf7c10c7a2901d6",
"latestAvailablePublishedVersion": 4,
"latestAvailablePublishedVersionId": "4cf7c10c7a2901d6",
"id": "6bf4016d6074831f",
"nodeId": "Workflow2:9aec3fea5a39cccd:6bf4016d6074831f",
"name": "InputOutputLogging3-Child1",
"type": "InputOutputLogging3-Child",
"version": 4,
"customProperties": {
"canStartWorkflow": false,
"runAsynchronously": false
},
"metadata": {
"designer": {
"position": {
"x": -360,
"y": -320
},
"size": {
"width": 246.375,
"height": 50
}
}
}
}
],
"connections": []
}
}