* Remove bookmark-based resumption logic for lost HTTP context scenarios in `WriteHttpResponse` and `WriteFileHttpResponse`. Simplify error handling by throwing descriptive exceptions for workflows resuming without an available HTTP context. * Add integration tests for HTTP context loss scenarios in `WriteHttpResponse` and `WriteFileHttpResponse`. * Add integration tests for handling HTTP context loss in response activities. * Replace bookmark-based logic with fault exceptions in tests for `WriteHttpResponse` and `WriteFileHttpResponse` when HTTP context is unavailable. * Update agent-logs/http-context-loss-error-messaging.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update test/integration/Elsa.Http.IntegrationTests/Elsa.Http.IntegrationTests.csproj Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| Activities | ||
| Helpers | ||
| Elsa.Http.IntegrationTests.csproj | ||
| README.md | ||
| Usings.cs | ||
Elsa.Http Integration Tests
This test project contains integration tests for HTTP-related activities in Elsa Workflows, specifically focusing on HTTP context loss scenarios.
Status
✅ Tests are working! All tests pass successfully and are properly discovered by xUnit.
Test Coverage
HttpContextLossTests
Tests that verify the behavior of HTTP response activities when the HTTP context is lost during workflow execution.
Test Scenarios
-
WriteHttpResponse_WithNoHttpContext_ShouldRecordIncident
- Verifies that
WriteHttpResponseactivity records an incident when HTTP context is null - Validates that the incident message clearly explains the HTTP context loss scenario
- Status: ✅ Passing
- Verifies that
-
WriteFileHttpResponse_WithNoHttpContext_ShouldRecordIncident
- Verifies that
WriteFileHttpResponseactivity records an incident when HTTP context is null - Validates the incident message contains expected information
- Status: ✅ Passing
- Verifies that
Expected Behavior
When HTTP context is not available:
- Fault Code:
NoHttpContext - Fault Category:
HTTP - Fault Type:
System - Error Message: Detailed explanation including:
- What happened: HTTP context was lost during workflow execution
- Why it happened: Workflow suspended and resumed in different execution context
- Common scenarios: Background processing, virtual actor, workflow transition
- Impact: Original HTTP request context no longer available
- Result: An
ActivityIncidentis recorded with the fault message
Project Structure
Elsa.Http.IntegrationTests/
├── Activities/
│ ├── HttpContextLossTests.cs # Test class using WorkflowTestFixture
│ └── Workflows/
│ ├── WriteHttpResponseWithoutHttpContextWorkflow.cs
│ └── WriteFileHttpResponseWithoutHttpContextWorkflow.cs
├── Helpers/
│ └── NullHttpContextAccessor.cs # Mock HTTP context accessor
├── Elsa.Http.IntegrationTests.csproj
├── README.md
└── Usings.cs
Running the Tests
dotnet test Elsa.Http.IntegrationTests.csproj
Or run specific tests:
dotnet test --filter "FullyQualifiedName~HttpContextLossTests"
Test Results
Passed! - Failed: 0, Passed: 2, Skipped: 0, Total: 2
Implementation Notes
- Tests use
WorkflowTestFixturefromElsa.Testing.Sharedfor consistent test setup - Workflow classes are separated into individual files in the
Workflowssubfolder for better organization NullHttpContextAccessoris a test helper that simulates HTTP context loss by always returning null- Tests automatically build the fixture and populate registries before execution