test: improve branch coverage for CRE API and controllers#2829
test: improve branch coverage for CRE API and controllers#2829sydseter merged 1 commit intoOWASP:masterfrom
Conversation
|
Hi! 👋 I noticed that both CI jobs are failing due to the global coverage threshold (95%). I’ve added targeted tests for CRE API, MappingController, and CRE Controller, which improved coverage to ~93%. I also explored additional edge cases, but the remaining uncovered branches seem to be: These don’t appear to be straightforward to cover via unit tests without either introducing artificial test setups or modifying production code. Would you prefer: Happy to proceed in whichever direction you suggest 🙂 |
|
Thanks for reviewing and merging! |
|
@theanand108 The pleasure is mine. ;) |
Description
Adds targeted tests to improve branch coverage for CRE API, MappingController, and CRE Controller.
Changes
• Added CRE API tests:
• Invalid language and edition (404)
• Missing cards and mappings (500)
• Partial/missing mapping scenarios
• Successful response case
• Added MappingController test:
• Handles missing card mapping scenario
• Added CRE Controller tests:
• Handles missing mapping data
• Throws when mapping is undefined
• Added minimal health endpoint test for COPI
Coverage
• Improved overall branch coverage to ~93%
• Focused on covering meaningful and reachable execution paths
Coverage Note
The remaining uncovered branches are associated with:
• Environment-dependent logic (import.meta.url in fileSystemHelper.ts)
• Defensive or non-reachable branches in CRE controller and API flow
These branches cannot be reliably triggered via unit tests without modifying production code. All practically reachable execution paths have been covered.
Builds on previous test coverage improvements introduced in #2807.
AI Tool Disclosure
Affirmation