Description
Add comprehensive integration tests to verify the complete usage tracking flow from API request through to cost calculation and spend updates.
Background
The new usage tracking middleware (UsageTrackingMiddleware) has been implemented to track actual token usage from provider responses, replacing the crude character÷4 estimation. While unit tests exist, we need integration tests to ensure the entire flow works correctly.
Acceptance Criteria
Technical Details
- Tests should use
WebApplicationFactory for realistic HTTP pipeline testing
- Mock external dependencies (providers, database) but keep middleware pipeline intact
- Verify both successful and error scenarios
- Test files:
SimpleUsageTrackingTest.cs and UsageTrackingMiddlewareTests.cs exist with basic coverage
Priority
Medium - Important for ensuring reliability but core functionality is already unit tested
Description
Add comprehensive integration tests to verify the complete usage tracking flow from API request through to cost calculation and spend updates.
Background
The new usage tracking middleware (
UsageTrackingMiddleware) has been implemented to track actual token usage from provider responses, replacing the crude character÷4 estimation. While unit tests exist, we need integration tests to ensure the entire flow works correctly.Acceptance Criteria
Technical Details
WebApplicationFactoryfor realistic HTTP pipeline testingSimpleUsageTrackingTest.csandUsageTrackingMiddlewareTests.csexist with basic coveragePriority
Medium - Important for ensuring reliability but core functionality is already unit tested