This issue is best handled by the Testing Agent - an expert in test coverage improvement and branch testing.
🎯 Objective
Add comprehensive branch coverage tests for constants files to ensure conditional logic is properly tested and achieve 70%+ branch coverage for v1.0 release.
📋 Background
Many constant files in src/constants/ have 0% branch coverage despite containing conditional logic, type guards, and data transformations. This creates risk of untested code paths and reduces overall branch coverage below the 70% ISMS requirement.
📊 Current State (Measured Metrics)
Constants Files with 0% or Low Branch Coverage:
src/constants/appConstants.ts: 90.24% statements / 0% branches
src/constants/businessConstants.ts: 53.33% statements / 0% branches
src/constants/costConstants.ts: 80% statements / 0% branches
src/constants/riskConstants.ts: 86.66% statements / 0% branches
src/constants/securityLevels.ts: 72.72% statements / 0% branches
src/constants/testIds.ts: 81.66% statements / 0% branches (64.51% functions)
src/constants/uiConstants.ts: 50% statements / 16.66% branches
Overall Impact:
- Current branch coverage: 64.9%
- Target branch coverage: 70%
- Gap: 5.1% - constants contribute significantly to this gap
✅ Acceptance Criteria
🛠️ Implementation Guidance for @testing-agent
Test Files to Create:
src/constants/appConstants.test.ts - Test app configuration logic
src/constants/businessConstants.test.ts - Test business logic constants
src/constants/costConstants.test.ts - Test cost calculation constants
src/constants/riskConstants.test.ts - Test risk assessment logic
src/constants/securityLevels.test.ts - Test security level mappings
src/constants/uiConstants.test.ts - Test UI configuration branches
src/constants/testIds.test.ts - Test ID generation functions
Agent-Specific Testing Strategy:
✅ Use Vitest for all constant file tests
✅ Follow Arrange-Act-Assert pattern
✅ Test all conditional branches: if/else, ternary operators, switch statements
✅ Test helper functions with edge cases (null, undefined, empty strings)
✅ Test type guards and validation functions
✅ Use descriptive test names that explain what is being tested
Example Test Pattern:
// src/constants/securityLevels.test.ts
import { describe, it, expect } from 'vitest';
import {
SECURITY_LEVELS,
getSecurityLevelName,
isValidSecurityLevel
} from './securityLevels';
describe('securityLevels', () => {
describe('SECURITY_LEVELS constant', () => {
it('contains all required levels', () => {
expect(SECURITY_LEVELS).toContain('None');
expect(SECURITY_LEVELS).toContain('Low');
expect(SECURITY_LEVELS).toContain('Moderate');
expect(SECURITY_LEVELS).toContain('High');
expect(SECURITY_LEVELS).toContain('Very High');
});
});
describe('getSecurityLevelName', () => {
it('returns correct name for each level', () => {
expect(getSecurityLevelName('None')).toBe('No Security');
expect(getSecurityLevelName('Low')).toBe('Basic Security');
expect(getSecurityLevelName('High')).toBe('Advanced Security');
});
it('handles invalid levels', () => {
expect(getSecurityLevelName('invalid')).toBe('Unknown');
});
it('handles edge cases', () => {
expect(getSecurityLevelName(null as any)).toBe('Unknown');
expect(getSecurityLevelName(undefined as any)).toBe('Unknown');
expect(getSecurityLevelName('')).toBe('Unknown');
});
});
describe('isValidSecurityLevel', () => {
it('returns true for valid levels', () => {
SECURITY_LEVELS.forEach(level => {
expect(isValidSecurityLevel(level)).toBe(true);
});
});
it('returns false for invalid levels', () => {
expect(isValidSecurityLevel('invalid')).toBe(false);
expect(isValidSecurityLevel('')).toBe(false);
expect(isValidSecurityLevel(null as any)).toBe(false);
});
});
});
Testing Patterns by File:
appConstants.ts:
- Test environment-specific configurations
- Test feature flag logic
- Test version and build metadata
businessConstants.ts:
- Test business rules with different inputs
- Test calculation thresholds and limits
- Test data classification logic
costConstants.ts:
- Test cost tier logic (small, medium, large)
- Test percentage calculations
- Test currency formatting functions
riskConstants.ts:
- Test risk level classification
- Test risk score calculations
- Test risk categorization logic
testIds.ts:
- Test ID generation for different component types
- Test ID sanitization logic
- Test edge cases (empty strings, special characters)
Verification Commands:
# Run tests for constants
npm test -- src/constants
# Check coverage for specific file
npm run coverage -- src/constants/securityLevels.ts
# Run all tests with coverage
npm run coverage
🔗 Related Resources
📊 Metadata
Agent: @testing-agent | Priority: Medium | Effort: S (3-4h)
Labels: type:test, domain:testing, priority:medium, size:small, v1.0
🤖 Recommended Agent: @testing-agent
🎯 Objective
Add comprehensive branch coverage tests for constants files to ensure conditional logic is properly tested and achieve 70%+ branch coverage for v1.0 release.
📋 Background
Many constant files in
src/constants/have 0% branch coverage despite containing conditional logic, type guards, and data transformations. This creates risk of untested code paths and reduces overall branch coverage below the 70% ISMS requirement.📊 Current State (Measured Metrics)
Constants Files with 0% or Low Branch Coverage:
src/constants/appConstants.ts: 90.24% statements / 0% branchessrc/constants/businessConstants.ts: 53.33% statements / 0% branchessrc/constants/costConstants.ts: 80% statements / 0% branchessrc/constants/riskConstants.ts: 86.66% statements / 0% branchessrc/constants/securityLevels.ts: 72.72% statements / 0% branchessrc/constants/testIds.ts: 81.66% statements / 0% branches (64.51% functions)src/constants/uiConstants.ts: 50% statements / 16.66% branchesOverall Impact:
✅ Acceptance Criteria
🛠️ Implementation Guidance for @testing-agent
Test Files to Create:
src/constants/appConstants.test.ts- Test app configuration logicsrc/constants/businessConstants.test.ts- Test business logic constantssrc/constants/costConstants.test.ts- Test cost calculation constantssrc/constants/riskConstants.test.ts- Test risk assessment logicsrc/constants/securityLevels.test.ts- Test security level mappingssrc/constants/uiConstants.test.ts- Test UI configuration branchessrc/constants/testIds.test.ts- Test ID generation functionsAgent-Specific Testing Strategy:
✅ Use Vitest for all constant file tests
✅ Follow Arrange-Act-Assert pattern
✅ Test all conditional branches: if/else, ternary operators, switch statements
✅ Test helper functions with edge cases (null, undefined, empty strings)
✅ Test type guards and validation functions
✅ Use descriptive test names that explain what is being tested
Example Test Pattern:
Testing Patterns by File:
appConstants.ts:
businessConstants.ts:
costConstants.ts:
riskConstants.ts:
testIds.ts:
Verification Commands:
🔗 Related Resources
src/services/*.test.ts📊 Metadata
Agent: @testing-agent | Priority: Medium | Effort: S (3-4h)
Labels:
type:test,domain:testing,priority:medium,size:small,v1.0