test: increase critical utils coverage from 50% to 97% (exceeds 80% v1.0 target)#597
Merged
Conversation
…utils Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Contributor
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
Copilot
AI
changed the title
[WIP] Increase test coverage to 80% for critical utility modules
test: increase critical utils coverage from 50% to 97% (exceeds 80% v1.0 target)
Nov 14, 2025
pethers
marked this pull request as ready for review
November 14, 2025 17:29
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR successfully increases test coverage for three critical utility modules from an average of 50.44% to 97.38%, exceeding the 80% target by 17.38 points. The changes are test-only additions with no modifications to production code, adding 138 comprehensive test cases across risk, security level, and level value utilities.
Key Changes:
- Added 64 test cases to
riskUtils.test.tsachieving 95.68% coverage (up from 51.07%) - Added 50 test cases to
securityLevelUtils.test.tsachieving 99.02% coverage (up from 59.22%) - Added 24 test cases to
levelValuesUtils.test.tsachieving 97.43% coverage (up from 41.02%)
Reviewed Changes
Copilot reviewed 3 out of 198 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/utils/riskUtils.test.ts |
Comprehensive tests for risk calculation functions, business impact methods, risk level formatting/parsing, and legacy function mappings |
src/utils/securityLevelUtils.test.ts |
Tests for security level percentages, CSS classes, badge variants, type guards, and status mappings with edge case handling |
src/utils/levelValuesUtils.test.ts |
Tests for all calculation strategies (min/max/avg/weighted), security level comparisons, value normalization, and boundary conditions |
| Coverage HTML files | Updated coverage reports showing improved metrics across all three utility modules |
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.
Pull Request Description
Three critical utility modules (
riskUtils,securityLevelUtils,levelValuesUtils) had 41-59% coverage, below the 80% v1.0 release requirement. Added 138 comprehensive test cases achieving 97% average coverage.Coverage improvements:
riskUtils.ts: 51% → 96% (+45 points)securityLevelUtils.ts: 59% → 99% (+40 points)levelValuesUtils.ts: 41% → 97% (+56 points)Key additions:
it.each()Example test pattern:
Type of Change
Component(s) Modified
CIA Impact Area
Security Level Impact
Test Coverage Impact
Testing Performed
Related Issues
Closes #[issue_number]
Checklist
Additional Notes
Test execution time: <3 seconds. No production code modified - test-only changes.
Original prompt
This section details on the original issue you should resolve
<issue_title>✅ Increase Test Coverage to 80%+ for Critical Utility Modules</issue_title>
<issue_description>## 🎯 Objective
Increase test coverage from current 75% average to 80%+ for critical utility modules to meet v1.0 release requirements and improve code quality.
📋 Background
The repository custom instructions specify a target of 80%+ test coverage for v1.0 release. Current test coverage analysis shows:
Low Coverage Areas:
src/utils/riskUtils.ts: 51.07% coverage (572 lines)src/utils/securityLevelUtils.ts: 59.22% coverage (474 lines)src/utils/levelValuesUtils.ts: 41.02% coverage (133 lines)src/utils/typeGuards.ts: 71.73% coverage (912 lines)src/utils/index.ts: 48.57% coverage (222 lines)Current State:
Why This Matters:
✅ Acceptance Criteria
src/utils/riskUtils.tscoverage from 51% to 80%+getDefaultBusinessImpact()functionsrc/utils/securityLevelUtils.tscoverage from 59% to 80%+getSecurityLevelValue()with all security levelscompareSecurityLevels()edge casessrc/utils/levelValuesUtils.tscoverage from 41% to 80%+🛠️ Implementation Guidance
Files to Modify
src/utils/riskUtils.test.ts- Expand test coveragesrc/utils/securityLevelUtils.test.ts- Add missing test casessrc/utils/levelValuesUtils.test.ts- Add comprehensive testsApproach
it.each()for testing multiple security levelsdescribe()blocksEdge Cases to Handle
Example Test Pattern