Implement Mock Testing Harness for Video Server with Undici Interceptors#818
Draft
Implement Mock Testing Harness for Video Server with Undici Interceptors#818
Conversation
…ents Co-authored-by: ingalls <1297009+ingalls@users.noreply.github.com>
…tests Co-authored-by: ingalls <1297009+ingalls@users.noreply.github.com>
…tration tests Co-authored-by: ingalls <1297009+ingalls@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Generate a Mock Testing harness for intercepting undici requests to the Video Server and update the test/video-lease.test.ts file to use the new harness
Implement Mock Testing Harness for Video Server with Undici Interceptors
Aug 9, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements a comprehensive mock testing harness for intercepting undici requests to the MediaMTX video server, addressing the need for reliable testing of video lease functionality without requiring a real video server.
Problem
The existing
video-lease.srv.test.tstest file was making real HTTP requests to a video server, which:Solution
Created a
MockVideoServerclass that uses undici'sMockAgentto intercept HTTP requests and provide realistic mock responses for all MediaMTX API endpoints used by CloudTAK:Key Features
Comprehensive Endpoint Coverage:
/v3/config/global/get- Global video server configuration/v3/paths/list- List active video paths/v3/config/paths/add/{path}- Add new video path/v3/paths/get/{path}- Get path information/v3/config/paths/patch/{path}- Update path configuration/v3/config/paths/delete/{path}- Delete video path/v3/recordings/get/{path}- Get recording informationStateful Simulation:
Testing Utilities:
Implementation Details
The mock server uses undici's
MockAgentwith persistent interceptors to handle requests:Test Coverage
Files Added/Modified
api/test/mock-video-server.ts- Core MockVideoServer implementationapi/test/mock-video-server.test.ts- Comprehensive test suite (32 tests)api/test/video-lease.srv.test.ts- Updated to demonstrate mock usageapi/test/README-MockVideoServer.md- Complete documentation and usage guideapi/lib/control/video-service.ts- Fixed return type forrunOnDemandmethodUsage Example
This implementation provides a robust foundation for testing video-related functionality in CloudTAK without external dependencies, enabling more reliable and comprehensive test coverage.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.