Skip to content

Add workflow testing endpoint with comprehensive test coverage - #2

Open
LeftTwixWand wants to merge 9 commits into
mohdali:mainfrom
LeftTwixWand:main
Open

Add workflow testing endpoint with comprehensive test coverage#2
LeftTwixWand wants to merge 9 commits into
mohdali:mainfrom
LeftTwixWand:main

Conversation

@LeftTwixWand

Copy link
Copy Markdown

Summary

  • Implement real workflow execution in /api/workflow/test endpoint using IWorkflowRunner
  • Add comprehensive test project with unit tests for WorkflowController
  • Restore proper Aspire resource management while preserving workflow improvements
  • Maintain database storage configuration for production use

Key Changes

  • WorkflowController: Real workflow execution that creates actual workflow instances visible in Elsa Studio
  • Test Coverage: Unit tests for all controller endpoints, HTTP attributes, and controller structure
  • Aspire Integration: Restored PostgreSQL, RabbitMQ, and Keycloak container management
  • Database Configuration: Maintained EntityFrameworkCore with PostgreSQL for persistence

Test Plan

  • Unit tests pass for all controller endpoints
  • WorkflowController properly implements MVC attributes
  • Aspire resource management functional
  • Database storage configuration restored
  • Real workflow execution creates unique instances

🤖 Generated with Claude Code

LeftTwixWand and others added 9 commits September 24, 2025 15:56
- Fix null reference warning in KeycloakClaimsTransformation.cs by adding null check
- Replace obsolete RabbitMQ ConfigureServiceBus with ConfigureTransportBus API
- Remove unnecessary Microsoft.Extensions.Configuration package reference
- Update KubernetesClient to 17.0.14 to resolve security vulnerability
- All builds now succeed with 0 warnings (except informational .NET preview messages)

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add missing using directive for Elsa.Studio.Login.BlazorServer.Extensions
- Register AddLoginModule() to resolve IRefreshTokenService dependency
- Fixes System.InvalidOperationException on startup for AuthenticatingApiHttpMessageHandler
- Application now starts successfully without DI errors

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Commented out AddLoginModule() registration that required IRefreshTokenService
- Removed AuthenticatingApiHttpMessageHandler from Keycloak module as it depends on IRefreshTokenService
- Added Elsa.Studio.Login package reference for access to login contracts
- Application now starts successfully without dependency injection errors

The Login module was causing issues because it registers AuthenticatingApiHttpMessageHandler
which requires IRefreshTokenService, but the correct LoginResponse type for the interface
wasn't available in the current package versions. By using only the Keycloak module
for authentication, we bypass this dependency while maintaining Keycloak authentication functionality.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Created basic TestWorkflow class demonstrating Elsa workflow structure
- Verified complete application stack builds successfully
- System includes:
  * PostgreSQL database for workflow storage
  * RabbitMQ for messaging and distributed cache
  * Keycloak for authentication
  * Elsa Server with workflow runtime (2 replicas)
  * Elsa Studio with Keycloak authentication integration
  * Aspire orchestration with health checks and service dependencies

The application successfully starts with all services properly orchestrated
and can be accessed via the Aspire dashboard at https://localhost:17296

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Created WorkflowController with multiple endpoints for workflow management:
- GET /api/workflow/status - Check workflow runtime status
- GET /api/workflow/definitions - List available workflow information
- POST /api/workflow/trigger - Trigger workflow execution
- GET /api/workflow/test - Test workflow execution endpoint

Features implemented:
- Controller-based workflow execution for reliable testing
- JSON API responses with timestamp and status information
- Error handling and proper HTTP status codes
- Endpoint discovery and documentation via status endpoint

The system now provides multiple ways to interact with workflows:
1. Direct API endpoints for testing and integration
2. Full Aspire orchestration with dashboard monitoring
3. Extensible architecture for adding actual Elsa workflow definitions

Ready for workflow development and execution testing!

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Replace mock workflow responses with actual Elsa workflow execution using IWorkflowRunner
- Configure Elsa Server to use in-memory storage for simplified testing
- Remove external dependencies (PostgreSQL, RabbitMQ, Keycloak) from AppHost
- Add proper error handling and real workflow instance tracking
- Verified through 3 complete test cycles creating unique workflow instances
- Each request now creates and executes a real workflow with unique ID

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Create new Elsa.Aspire.Tests project with unit tests for WorkflowController
- Add test coverage for all controller endpoints (definitions, status, trigger, test)
- Verify controller attributes and HTTP method mappings
- Restore proper Aspire resource management for PostgreSQL, RabbitMQ, and Keycloak
- Maintain database storage configuration while keeping workflow improvements
- Include TestWebApplicationFactory for future integration testing expansion

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@mohdali

mohdali commented May 3, 2026

Copy link
Copy Markdown
Owner

@LeftTwixWand sorry I missed this PR, I have already done some work to modernize this sample with latest Elsa, Aspire and bring it to .NET 10. Are you still interested to refresh this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants