Commit graph

184 commits

Author SHA1 Message Date
lukhipolito-nexxbiz 90af851962
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/Workflows/FileUploadWorkflow.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-03 16:15:39 +01:00
lukhipolito-nexxbiz 859a14ede2
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/Workflows/BlockedFileExtensionWorkflow.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-03 16:14:52 +01:00
lukhipolito-nexxbiz 2f9d6c1ec3
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/Workflows/BasicHttpEndpointWorkflow.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-03 16:14:39 +01:00
lukhipolito-nexxbiz f023e1f994
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/README.md
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-03 16:14:03 +01:00
lukhipolito-nexxbiz c791843860
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/HttpEndpointRouteParametersTests.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-03 16:13:49 +01:00
lukhipolito-nexxbiz d8b929a5bd
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/Workflows/QueryStringAndHeadersWorkflow.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-03 16:13:38 +01:00
lukhipolito-nexxbiz 1f0aa37780
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/Workflows/MultipleHttpMethodsWorkflow.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-03 16:13:28 +01:00
lukhipolito-nexxbiz 9f0220e088
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/Workflows/FormDataWorkflow.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-03 16:13:17 +01:00
lucas.hipolito 0074061990 fixing build after merge 2025-12-03 15:31:33 +01:00
lucas.hipolito 2f93f498b4 Merge remote-tracking branch 'origin/feat/tests-http-endpoint' into feat/tests-http-endpoint 2025-12-03 15:30:20 +01:00
lucas.hipolito 7184336f8e PR comments 2025-12-03 15:30:17 +01:00
lukhipolito-nexxbiz fc14e99ed4
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/HttpEndpointTests.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-03 15:30:00 +01:00
lukhipolito-nexxbiz 536e908898
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/HttpEndpointTests.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-03 14:33:14 +01:00
lukhipolito-nexxbiz eaac09dfd6
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/README.md
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-03 14:08:21 +01:00
lucas.hipolito 570b0d4678 Removed unnecessary tests, small refactors for readability +organization 2025-12-03 11:48:53 +01:00
lucas.hipolito 9e7b04b48d Merge remote-tracking branch 'origin/feat/tests-http-endpoint' into feat/tests-http-endpoint 2025-12-03 11:25:10 +01:00
lukhipolito-nexxbiz c4f1fcdef4
Merge pull request #7126 from elsa-workflows/copilot/sub-pr-7125
Remove test that validates web server behavior rather than Elsa functionality
2025-12-03 11:24:36 +01:00
lucas.hipolito bbf9378d83 Merge remote-tracking branch 'origin/feat/tests-http-endpoint' into feat/tests-http-endpoint 2025-12-03 11:22:06 +01:00
lucas.hipolito ad9bc2ef70 Removing ambiguous assertions 2025-12-03 11:20:51 +01:00
lukhipolito-nexxbiz e3149ea3c2
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/HttpEndpointTests.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-03 11:19:57 +01:00
lukhipolito-nexxbiz a87cbe34a2
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/HttpEndpointSecurityAndEdgeCasesTests.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-03 11:18:21 +01:00
lukhipolito-nexxbiz 46004b33c4
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/HttpEndpointSecurityAndEdgeCasesTests.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-03 11:18:06 +01:00
lukhipolito-nexxbiz 4712782e6d
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/HttpEndpointQueryStringAndHeadersTests.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-03 11:17:21 +01:00
lukhipolito-nexxbiz 466f62f016
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/Workflows/FormDataWorkflow.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-03 11:06:34 +01:00
lukhipolito-nexxbiz b0ee28008e
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/Workflows/RouteParametersWorkflow.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-03 08:20:27 +01:00
copilot-swe-agent[bot] 0a337fe251 Remove HttpEndpoint_ExtremelyLongPath_HandlesGracefully test per reviewer feedback
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
2025-12-02 17:23:04 +00:00
lucas.hipolito eb05233f36 small QoL improvements 2025-12-02 17:19:25 +01:00
lukhipolito-nexxbiz bacca3f890
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/HttpEndpointSecurityAndEdgeCasesTests.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-02 16:51:43 +01:00
lukhipolito-nexxbiz e281ff229a
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/HttpEndpointQueryStringAndHeadersTests.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-02 16:50:42 +01:00
lucas.hipolito 7091d07dc3 Merge remote-tracking branch 'origin/feat/tests-http-endpoint' into feat/tests-http-endpoint 2025-12-02 15:36:05 +01:00
lucas.hipolito f8d46d7afe PR improvements. More DRY, less clutter 2025-12-02 15:35:41 +01:00
lukhipolito-nexxbiz e3645566e4
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/Workflows/FileUploadWorkflow.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-02 15:05:17 +01:00
lukhipolito-nexxbiz 3c3154a7ee
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/Workflows/FormDataWorkflow.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-02 13:42:09 +01:00
lukhipolito-nexxbiz 65159e2665
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/Workflows/RouteParametersWorkflow.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-02 13:02:59 +01:00
lukhipolito-nexxbiz a3b46d1419
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/Workflows/RouteParametersWorkflow.cs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-02 13:01:02 +01:00
lukhipolito-nexxbiz c62a882ad8
Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Http/README.md
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-02 13:00:46 +01:00
lucas.hipolito 656208bbf7 Http endpoint unit, integration and component tests 2025-12-02 12:03:01 +01:00
Sipke Schoorstra faebea76a0
Adds Publish Event Activity Tests (#7093)
* Refactor workflow instance deletion to use `IWorkflowRuntime` for enhanced coordination and separation of concerns.

* Remove `EnumerableTypeConverter` and update related usages for serialization.

- Deleted the `EnumerableTypeConverter` class and its JSON serialization logic.
- Removed associated type descriptor attribute in `DefaultFormattersFeature`.
- Updated `ObjectFormatter` to handle collection serialization directly with JSON.

* Remove `EnumerableTypeConverter` tests and consolidate serialization logic into `ObjectFormatter`.

- Deleted `EnumerableTypeConverterTests` as the related functionality was removed.
- Added comprehensive tests in `ObjectFormatterTests` to handle serialization of collections and arrays with JSON.

* Add integration tests for `TriggerIndexer` to handle workflows with failing materialization

- Introduced comprehensive test scenarios verifying `DeleteTriggersAsync` behavior when workflows fail to load or partially succeed.
- Enhanced error handling in `TriggerIndexer` to skip failed workflows while ensuring remaining workflows are processed.

* Add exception handling in `TriggerIndexer.DeleteTriggersAsync` and integration tests

- Enhanced `DeleteTriggersAsync` with exception handling to skip failed workflows while processing others.
- Logged warnings for failed workflows without halting execution.
- Added comprehensive integration tests to verify behavior across success, failure, and mixed scenarios.
- Refactored tests for improved clarity, maintainability, and consistency.

* Add exception handling for `ResumeWorkflowTask` to skip deleted workflow instances

- Enhanced `ResumeWorkflowTask.ExecuteAsync` to handle `WorkflowInstanceNotFoundException` gracefully when a scheduled workflow instance is missing.
- Logged warnings for skipped executions to improve observability.
- Ensured remaining workflows and scheduled tasks are processed seamlessly without disruption.

* Add thread safety to `LocalScheduler` to prevent race conditions during concurrent scheduling

- Introduced a `lock` object to synchronize access to internal dictionaries.
- Resolved `IndexOutOfRangeException` caused by concurrent modifications during startup.
- Ensured thread-safe operations in `ScheduleAsync`, `ClearScheduleAsync`, and related methods.
- Improved reliability and stability of scheduling under concurrent workloads.

* Improve exception handling, thread safety, and workflow instance deletion

- Added exception handling in `TriggerIndexer.DeleteTriggersAsync` to skip failed workflows while continuing processing.
- Enhanced `ResumeWorkflowTask` to handle missing workflow instances gracefully and log warnings.
- Introduced thread synchronization in `LocalScheduler` with `lock` to prevent concurrent access issues.
- Implemented and refactored tests to ensure behavior consistency and improve maintainability.
- Added component tests for workflow deletion scenarios, covering running, completed, and non-existent workflows.

* Add component tests for workflow instance deletion and refactor bulk delete logic

- Added comprehensive component tests for workflow instance deletion scenarios (running, completed, bulk, and non-existent instances).
- Refactored `BulkDelete` API to use `IWorkflowInstanceManager` for proper cleanup of related records (execution logs, activity executions, bookmarks).

* Add integration tests and fakes for `TriggerIndexer` to verify behavior with failing and successful workflows

- Introduced `FailingMaterializer` and `WorkingMaterializer` for simulating failing and successful workflow materializations.
- Added `TriggerDeletionTestScenario`, `TriggerTestDataBuilder`, and related test data classes to define comprehensive test cases.
- Updated `DeleteTriggersAsync` tests with scenarios for materialization failures and mixed success.
- Improved test coverage and maintainability with reusable test data builders and utilities.

* Refactor `ActivityExecutionContextExtensions` to use instance methods for improved readability and encapsulation

* Refactor extension methods to use instance methods for improved encapsulation and readability in core workflow modules

* Add component tests for event-based workflows and update usages of `Event` activity

- Added `BlockingEventWorkflow` and `TriggerEventWorkflow` for testing event-based workflow scenarios.
- Added `EventTests` to verify workflow behavior with event publishing and triggering.
- Refactored existing integration tests to use `Runtime.Activities.Event` for consistency.

* Add unit tests for `EventBase` functionality

- Introduced `EventBaseTests` to validate core `EventBase` logic, including bookmark creation, event stimulus handling, and callback invocation.
- Added tests for scenarios involving event payloads, trigger indexing, and result output determination.
- Verified behavior consistency with various event names and callback executions.

* Add tests and workflows to validate event publishing and consumption

- Introduced `ConsumerWorkflow`, `PublishGlobalEventWorkflow`, and `PublishAndConsumeEventWorkflow` to test global and local event publishing scenarios.
- Added component tests (`PublishEventTests`) to verify event propagation and workflow triggering mechanisms.
- Implemented unit tests for `PublishEvent` with various parameters (event name, payload, correlation ID).

* Remove unused `using` directives in event-related component tests and workflows

* Refactor `PublishEventTests` and `EventBaseTests` to improve test coverage, simplify test logic, and consolidate duplicate code.

* Add `NullIfWhiteSpace` extension method and update `PublishEvent` logic to use it in correlation ID handling

- Refactored `PublishEventTests` to account for cases where correlation ID is whitespace.
- Improved test coverage for `PublishEvent` activity with additional inline test cases.

* Refactor `PublishEventTests` to verify payload transmission and enhance `ConsumerWorkflow` to capture and validate event payloads.

* Refactor `PublishEventTests` to add timeout mechanism for workflow instance retrieval; enhance `ConsumerWorkflow` to declare output variable for payload validation.

* Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/Primitives/Event/PublishEventTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Remove `EventBaseTests` and `CancelInboundAncestorsAsync` for cleanup and redundant logic removal.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-25 19:06:16 +01:00
Sipke Schoorstra a5a9597ef3
Adds unit tests for EventBase activity (#7090)
* Refactor workflow instance deletion to use `IWorkflowRuntime` for enhanced coordination and separation of concerns.

* Remove `EnumerableTypeConverter` and update related usages for serialization.

- Deleted the `EnumerableTypeConverter` class and its JSON serialization logic.
- Removed associated type descriptor attribute in `DefaultFormattersFeature`.
- Updated `ObjectFormatter` to handle collection serialization directly with JSON.

* Remove `EnumerableTypeConverter` tests and consolidate serialization logic into `ObjectFormatter`.

- Deleted `EnumerableTypeConverterTests` as the related functionality was removed.
- Added comprehensive tests in `ObjectFormatterTests` to handle serialization of collections and arrays with JSON.

* Add integration tests for `TriggerIndexer` to handle workflows with failing materialization

- Introduced comprehensive test scenarios verifying `DeleteTriggersAsync` behavior when workflows fail to load or partially succeed.
- Enhanced error handling in `TriggerIndexer` to skip failed workflows while ensuring remaining workflows are processed.

* Add exception handling in `TriggerIndexer.DeleteTriggersAsync` and integration tests

- Enhanced `DeleteTriggersAsync` with exception handling to skip failed workflows while processing others.
- Logged warnings for failed workflows without halting execution.
- Added comprehensive integration tests to verify behavior across success, failure, and mixed scenarios.
- Refactored tests for improved clarity, maintainability, and consistency.

* Add exception handling for `ResumeWorkflowTask` to skip deleted workflow instances

- Enhanced `ResumeWorkflowTask.ExecuteAsync` to handle `WorkflowInstanceNotFoundException` gracefully when a scheduled workflow instance is missing.
- Logged warnings for skipped executions to improve observability.
- Ensured remaining workflows and scheduled tasks are processed seamlessly without disruption.

* Add thread safety to `LocalScheduler` to prevent race conditions during concurrent scheduling

- Introduced a `lock` object to synchronize access to internal dictionaries.
- Resolved `IndexOutOfRangeException` caused by concurrent modifications during startup.
- Ensured thread-safe operations in `ScheduleAsync`, `ClearScheduleAsync`, and related methods.
- Improved reliability and stability of scheduling under concurrent workloads.

* Improve exception handling, thread safety, and workflow instance deletion

- Added exception handling in `TriggerIndexer.DeleteTriggersAsync` to skip failed workflows while continuing processing.
- Enhanced `ResumeWorkflowTask` to handle missing workflow instances gracefully and log warnings.
- Introduced thread synchronization in `LocalScheduler` with `lock` to prevent concurrent access issues.
- Implemented and refactored tests to ensure behavior consistency and improve maintainability.
- Added component tests for workflow deletion scenarios, covering running, completed, and non-existent workflows.

* Add component tests for workflow instance deletion and refactor bulk delete logic

- Added comprehensive component tests for workflow instance deletion scenarios (running, completed, bulk, and non-existent instances).
- Refactored `BulkDelete` API to use `IWorkflowInstanceManager` for proper cleanup of related records (execution logs, activity executions, bookmarks).

* Add integration tests and fakes for `TriggerIndexer` to verify behavior with failing and successful workflows

- Introduced `FailingMaterializer` and `WorkingMaterializer` for simulating failing and successful workflow materializations.
- Added `TriggerDeletionTestScenario`, `TriggerTestDataBuilder`, and related test data classes to define comprehensive test cases.
- Updated `DeleteTriggersAsync` tests with scenarios for materialization failures and mixed success.
- Improved test coverage and maintainability with reusable test data builders and utilities.

* Refactor `ActivityExecutionContextExtensions` to use instance methods for improved readability and encapsulation

* Refactor extension methods to use instance methods for improved encapsulation and readability in core workflow modules

* Add component tests for event-based workflows and update usages of `Event` activity

- Added `BlockingEventWorkflow` and `TriggerEventWorkflow` for testing event-based workflow scenarios.
- Added `EventTests` to verify workflow behavior with event publishing and triggering.
- Refactored existing integration tests to use `Runtime.Activities.Event` for consistency.

* Add unit tests for `EventBase` functionality

- Introduced `EventBaseTests` to validate core `EventBase` logic, including bookmark creation, event stimulus handling, and callback invocation.
- Added tests for scenarios involving event payloads, trigger indexing, and result output determination.
- Verified behavior consistency with various event names and callback executions.

* Update test/component/Elsa.Workflows.ComponentTests/Elsa.Workflows.ComponentTests.csproj

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Remove duplicate `CancelInboundAncestorsAsync` method from `ActivityExecutionContextExtensions`.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-25 18:52:23 +01:00
Sipke Schoorstra aee09bb06f
Improves workflow deletion and task scheduling (#7088)
* Refactor workflow instance deletion to use `IWorkflowRuntime` for enhanced coordination and separation of concerns.

* Remove `EnumerableTypeConverter` and update related usages for serialization.

- Deleted the `EnumerableTypeConverter` class and its JSON serialization logic.
- Removed associated type descriptor attribute in `DefaultFormattersFeature`.
- Updated `ObjectFormatter` to handle collection serialization directly with JSON.

* Remove `EnumerableTypeConverter` tests and consolidate serialization logic into `ObjectFormatter`.

- Deleted `EnumerableTypeConverterTests` as the related functionality was removed.
- Added comprehensive tests in `ObjectFormatterTests` to handle serialization of collections and arrays with JSON.

* Add integration tests for `TriggerIndexer` to handle workflows with failing materialization

- Introduced comprehensive test scenarios verifying `DeleteTriggersAsync` behavior when workflows fail to load or partially succeed.
- Enhanced error handling in `TriggerIndexer` to skip failed workflows while ensuring remaining workflows are processed.

* Add exception handling in `TriggerIndexer.DeleteTriggersAsync` and integration tests

- Enhanced `DeleteTriggersAsync` with exception handling to skip failed workflows while processing others.
- Logged warnings for failed workflows without halting execution.
- Added comprehensive integration tests to verify behavior across success, failure, and mixed scenarios.
- Refactored tests for improved clarity, maintainability, and consistency.

* Add exception handling for `ResumeWorkflowTask` to skip deleted workflow instances

- Enhanced `ResumeWorkflowTask.ExecuteAsync` to handle `WorkflowInstanceNotFoundException` gracefully when a scheduled workflow instance is missing.
- Logged warnings for skipped executions to improve observability.
- Ensured remaining workflows and scheduled tasks are processed seamlessly without disruption.

* Add thread safety to `LocalScheduler` to prevent race conditions during concurrent scheduling

- Introduced a `lock` object to synchronize access to internal dictionaries.
- Resolved `IndexOutOfRangeException` caused by concurrent modifications during startup.
- Ensured thread-safe operations in `ScheduleAsync`, `ClearScheduleAsync`, and related methods.
- Improved reliability and stability of scheduling under concurrent workloads.

* Improve exception handling, thread safety, and workflow instance deletion

- Added exception handling in `TriggerIndexer.DeleteTriggersAsync` to skip failed workflows while continuing processing.
- Enhanced `ResumeWorkflowTask` to handle missing workflow instances gracefully and log warnings.
- Introduced thread synchronization in `LocalScheduler` with `lock` to prevent concurrent access issues.
- Implemented and refactored tests to ensure behavior consistency and improve maintainability.
- Added component tests for workflow deletion scenarios, covering running, completed, and non-existent workflows.

* Add component tests for workflow instance deletion and refactor bulk delete logic

- Added comprehensive component tests for workflow instance deletion scenarios (running, completed, bulk, and non-existent instances).
- Refactored `BulkDelete` API to use `IWorkflowInstanceManager` for proper cleanup of related records (execution logs, activity executions, bookmarks).

* Add integration tests and fakes for `TriggerIndexer` to verify behavior with failing and successful workflows

- Introduced `FailingMaterializer` and `WorkingMaterializer` for simulating failing and successful workflow materializations.
- Added `TriggerDeletionTestScenario`, `TriggerTestDataBuilder`, and related test data classes to define comprehensive test cases.
- Updated `DeleteTriggersAsync` tests with scenarios for materialization failures and mixed success.
- Improved test coverage and maintainability with reusable test data builders and utilities.
2025-11-21 20:58:38 +01:00
Sipke Schoorstra 2f9eac110e
Upgrade projects to target .NET 10, add conditional System.Linq.Async dependencies for compatibility with earlier frameworks, and update project files for consistency across the solution. (#7062)
* Upgrade projects to target .NET 10, add conditional `System.Linq.Async` dependencies for compatibility with earlier frameworks, and update project files for consistency across the solution.

* Suppress null comparison warning in `WorkflowDefinitionStore` and remove xUnit references from performance test project.

* Refactor performance test projects to remove xUnit references and update MSBuild properties for BenchmarkDotNet.
2025-11-21 20:55:30 +01:00
Sipke Schoorstra 2c0b3da5de
Addresses warnings and enforces null safety (#7051)
* Enhance null-safety annotations across modules and refactor for improved consistency:

- Added `null!` annotations to enforce non-nullability expectations.
- Updated workflows, tests, and runtime services to handle default null values reliably.
- Removed obsolete and unused APIs, simplifying interfaces and improving maintainability.
- Refactored methods and properties for clarity, thread-safety, and consistency.
- Adjusted test configurations for code coverage tracking and integration improvements.

* Refactor activity iteration in container serialization tests to simplify type casting.
2025-11-12 16:56:31 +01:00
Sipke Schoorstra 8747151330
Add code coverage configuration and adjust test projects (#7049)
* Add code coverage configuration and adjust test projects

- Introduced `Include` and `Threshold` properties across test project files for improved code coverage tracking.
- Added `coverlet.collector` as a dependency for coverage data collection.
- Removed unused `global using` directives and redundant imports for cleaner test codebases.

* Update GitHub Actions workflows for pull request triggers

- Adjusted `pr.yml` to include `patch/*` and `develop/*` branches.
- Removed redundant pull request triggers in `packages.yml` for cleaner configuration.

* Expand pull request triggers in GitHub Actions

- Renamed `PR` workflow to `pr` for consistency.
- Included `patch/*` and `develop/*` branches in `pr.yml` and `Build.CI.GitHubActions.cs`.

* Remove pack target from pull request workflows

- Updated `pr.yml` to exclude the pack step.
- Adjusted `Build.CI.GitHubActions.cs` to reflect the removal of the pack target.

* Remove `Elsa.Workflows.Api` from integration test project references

- Updated `Elsa.Workflows.IntegrationTests.csproj` to exclude `Elsa.Workflows.Api` from the `Include` list and project references for cleanup and simplification.
2025-11-12 13:59:36 +01:00
FuJa0815 c017082f01
Added IEnumerableTypeConverter (#7020)
* Added IEnumerableTypeConverter

* fixed bug and added tests

* Add resource disposal mechanism in ScheduledCronTask

- Introduced `_disposed` flag to prevent execution after disposal.
- Updated disposal logic to ensure proper release of resources.
- Adjusted unit tests to verify new disposal behavior and prevent unintended timer actions.

* Enhance scheduling tasks with edge case handling and disposal improvements

- Added `_disposed` flag to `ScheduledRecurringTask` and `ScheduledSpecificInstantTask` to prevent execution after disposal.
- Adjusted timer setup logic to handle zero/negative delays with a minimum delay of 1ms.
- Updated disposal logic to ensure proper resource cleanup even during timer callbacks.
- Introduced extensive unit tests for edge cases such as small, zero, or negative delay scenarios and proper disposal behavior.

* Update test/component/Elsa.Workflows.ComponentTests/Scenarios/VariablesArray/Activities/RemoveTopElementStep.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/modules/Elsa.Common/Serialization/IEnumerableTypeConverter.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/modules/Elsa.Common/Serialization/IEnumerableTypeConverter.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Add integration tests for EnumerableTypeConverter and update solution file

- Introduced `Elsa.Common.IntegrationTests` project for testing serialization behavior in `EnumerableTypeConverter`.
- Added tests to verify proper handling of strings, byte arrays, and collections during JSON serialization.
- Registered `EnumerableTypeConverter` in `DefaultFormattersFeature`.
- Renamed `IEnumerableTypeConverter` to `EnumerableTypeConverter` for consistency.
- Updated solution file to include the new integration test project.

---------

Co-authored-by: Sipke Schoorstra <sipkeschoorstra@outlook.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-12 11:07:33 +01:00
Sipke Schoorstra 54af5ea714
Merge remote-tracking branch 'origin/patch/3.5.2' into develop/3.6.0 2025-11-11 17:01:22 +01:00
Sipke Schoorstra e2a1b83ec8
Fix semaphore release logic in scheduled task execution (#7045)
* Fix semaphore release logic in scheduled task execution

- Ensure `_executionSemaphore` is only released when acquired.
- Refactor `acquired` variable initialization for better reliability and readability across `ScheduledRecurringTask`, `ScheduledCronTask`, and `ScheduledSpecificInstantTask`.

* Fix test isolation in WorkflowDefinitionActivity cache eviction test (#7046)

* Add thread-safety and resource disposal to `WorkflowDefinitionActivity`

- Introduced `SemaphoreSlim` to ensure thread-safe initialization.
- Implemented `IDisposable` to clean up semaphore resources.

* Introduce thread-safety in `CacheManager` with per-key locking

- Added `ConcurrentDictionary` for managing per-key `SemaphoreSlim` instances.
- Ensured thread-safe `GetOrCreateAsync` operations with key-specific locks.
- Cleaned up unused locks when cache entries are removed.

* Add definition IDs filter to WorkflowDefinitionActivityTests

- Updated `WorkflowInstanceFilter` to include `DefinitionIds` for more precise faulted workflow filtering.
- Improved test coverage for workflow definition scenarios.

* Revert "Introduce thread-safety in `CacheManager` with per-key locking"

This reverts commit cda89d4e6aea1810364cdb0145a59d7b6448bc49.

* Revert "Add thread-safety and resource disposal to `WorkflowDefinitionActivity`"

This reverts commit 08750890a16a8b539941d6d161b4061d2fdbe1b8.

* Remove unnecessary whitespace in WorkflowDefinitionActivityTests
2025-11-09 14:14:25 +01:00
Sipke Schoorstra f51f1e918e
Add extensive unit and component tests for scheduling activities (#7036)
* Add DispatchWorkflow tests with new workflow definitions

- Introduced multiple workflow definitions with varied scenarios including input handling, correlation IDs, and fault handling.
- Enhanced `DispatchWorkflowsTests` with comprehensive test cases to validate `DispatchWorkflow` behavior under different configurations.
- Updated existing workflows and tests for improved structure, readability, and accuracy.
- Refactored and renamed related workflows for consistency across test suites.

* Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/DispatchWorkflows/DispatchWorkflowsTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Refactor DispatchWorkflowsTests for readability and maintainability

- Replaced hardcoded constants with named variables for improved clarity.
- Enhanced assertions using utility methods like `Assert.Single` for cleaner code.
- Updated WriteLine activity tests to handle null values reliably.
- Introduced timeout handling for child workflow execution.

* Update GUID length validation in JintJavaScriptFunctionBehaviorTests

- Adjusted `shortGuid` length assertion to accommodate a range of 19-22 characters instead of 20-22.

* Add extensive unit and component tests for scheduling activities

- Introduced unit tests for `Cron`, `Delay`, `Timer`, and `StartAt` scheduling activities, covering general usage and corner cases.
- Added component tests validating `Cron`, `Delay`, `Timer`, and `StartAt` workflows within broader scenarios, focusing on workflow execution, blocking, and resumption of activities.
- Enhanced test project structures with new folder setups aligning to activity categories.
- Updated namespaces and project files to match the new structure and added validation for scheduling logic.

* Refactor Timer activity tests for consistency and reusability

- Extracted shared logic for timer activity tests into `TimerActivityTestBase`.
- Refactored `DelayTests`, `TimerTests`, `CronTests`, and `StartAtTests` to inherit from `TimerActivityTestBase`.
- Removed redundant code and improved test consistency across all timer activity test cases.
- Cleaned up unused imports and optimized namespaces.

* Remove unused folder references from test project files

* [WIP] Update unit and component tests for scheduling activities (#7037)

* Initial plan

* Replace ContainsKey + indexer with TryGetValue in CronTests

Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>

* Fixing build after merge

* Remove DispatchWorkflowsTests and related references from the test suite

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
Co-authored-by: lucas.hipolito <lukhipolito@yahoo.com.br>
2025-11-07 21:54:50 +01:00
Sipke Schoorstra b32a067d03
Add DispatchWorkflow tests with new workflow definitions (#7035)
* Add DispatchWorkflow tests with new workflow definitions

- Introduced multiple workflow definitions with varied scenarios including input handling, correlation IDs, and fault handling.
- Enhanced `DispatchWorkflowsTests` with comprehensive test cases to validate `DispatchWorkflow` behavior under different configurations.
- Updated existing workflows and tests for improved structure, readability, and accuracy.
- Refactored and renamed related workflows for consistency across test suites.

* Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/DispatchWorkflows/DispatchWorkflowsTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Refactor DispatchWorkflowsTests for readability and maintainability

- Replaced hardcoded constants with named variables for improved clarity.
- Enhanced assertions using utility methods like `Assert.Single` for cleaner code.
- Updated WriteLine activity tests to handle null values reliably.
- Introduced timeout handling for child workflow execution.

* Update GUID length validation in JintJavaScriptFunctionBehaviorTests

- Adjusted `shortGuid` length assertion to accommodate a range of 19-22 characters instead of 20-22.

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-06 20:47:20 +01:00
Sipke Schoorstra a3278ccf97
Add BulkDispatchWorkflows tests and improve activity coverage (#7026)
* Refactor BulkDispatchWorkflows tests and improve activity coverage

- Migrate `BulkDispatchWorkflows` tests to a new structure under `Scenarios/BulkDispatch`.
- Introduce comprehensive test cases for bulk dispatch scenarios, including empty items, correlation IDs, child ports, dictionary items, and invalid definitions.
- Add multiple reusable workflows such as `BulkChildWorkflow`, `BulkDispatchAndWaitWorkflow`, and `BulkDispatchFireAndForgetWorkflow` for enhanced test coverage.
- Update namespaces and project files to reflect the restructuring and new workflow definitions.
- Enhance functionality for `IWorkflowInstanceVariableManager` by adding methods for variable retrieval from workflow states and instances.

* Add additional assertions for WriteLine activity tests and update workflow builder in BulkDispatch tests

- Enhanced `BulkDispatchWorkflowsTests` by validating written texts for accuracy.
- Refactored `BulkDispatchFireAndForgetWorkflow` to update activity and namespace references.

* Add `SlowBulkChildWorkflow` and update `BulkDispatchFireAndForgetWorkflow` test structure

- Introduced `SlowBulkChildWorkflow` with a delay and logging functionality for bulk dispatch testing.
- Modified `BulkDispatchFireAndForgetWorkflow` to use `SlowBulkChildWorkflow` and updated test items.
- Enhanced `BulkDispatchWorkflowsTests` with child workflow completion validation and timing assertions.

* Refactor BulkDispatch tests by removing dictionary item workflow and streamlining child workflow handling

- Removed `BulkDispatchWithDictionaryItemsWorkflow` and associated test cases.
- Updated `BulkChildWorkflow` to use input binding.
- Streamlined child workflow event handling in `BulkDispatchWorkflowsTests` using a reusable helper method.
- Enhanced `CorrelationIdFunction` support with JavaScript expression handling.

* Move unit test workflows to `Scenarios/Activities` and update namespace references

- Relocated all test workflows from `Scenarios/BulkDispatch` and `Scenarios/ExecuteWorkflows` to `Scenarios/Activities`.
- Updated namespaces and imports to reflect the new folder structure.

* Refactor BulkDispatch and FlowJoin test workflows:

- Moved `BulkDispatch` workflows to `Scenarios/Activities/BulkDispatchWorkflows`.
- Renamed `FlowJoins` to `FlowJoin` and updated namespaces to match.
- Adjusted imports and references to align with new folder structure and updated class definitions.

* Remove unused folder reference from `Elsa.Workflows.ComponentTests.csproj`.

* Update test/component/Elsa.Workflows.ComponentTests/Scenarios/Activities/BulkDispatchWorkflows/BulkDispatchWorkflowsTests.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-11-04 15:44:44 +01:00
Sipke Schoorstra a74502d3ad
Fix trigger indexing logic and add tests for trigger persistence after workflow reload. (#6958)
* Fix outbound connection processing logic

Corrected `completedActivityExcecutedByBackwardConnection` to `completedActivityExecutedByBackwardConnection`. Improved flowgraph outbound connection handling by separating visitation and processing logic, ensuring skipped connections are propagated consistently.

* Add tests for decision implicit join workflows

Introduce new integration tests to verify workflows with implicit joins on both decision outcomes. Added corresponding workflow definitions and updated the test project to ensure compatibility. Refactored connection visit logic for better readability and maintainability.

* Refactor trigger indexing logic and add tests for trigger persistence after workflow reload.

Streamlined conditional trigger indexing in `DefaultWorkflowDefinitionStorePopulator`. Introduced a test to validate trigger persistence across reloads after publishing a new workflow version.
2025-10-10 09:21:11 +02:00