Skip to content

Improve test coverage for src/core.ts security-critical functions

Objective

Improve test coverage for security-critical functions in src/core.ts to meet the 90% coverage target.

Current Coverage Status

  • Lines: 27.8% (target: 90%)
  • Functions: 33.3% (target: 90%)
  • Branches: 28.6% (target: 90%)

Security-Critical Functions Requiring Coverage

  • createAuthenticatedRequest - Currently covered but needs more edge cases
  • handleApiResponse - Currently covered but needs error scenarios
  • encodeProjectId - Currently not covered (0% function coverage)
  • trackProjectIdUsage - Currently not covered
  • getProjectIdUsageStats - Currently not covered
  • buildGitLabUrl - Currently not covered

Tasks

  • Write comprehensive tests for encodeProjectId function
  • Add tests for trackProjectIdUsage analytics
  • Add tests for getProjectIdUsageStats reporting
  • Add tests for buildGitLabUrl URL construction
  • Add error scenario tests for createAuthenticatedRequest
  • Add error scenario tests for handleApiResponse
  • Test edge cases for token validation logic
  • Test various GitLab API URL configurations

Acceptance Criteria

  • Line coverage ≥ 80% (progressive toward 90%)
  • Function coverage ≥ 80% (progressive toward 90%)
  • Branch coverage ≥ 80% (progressive toward 90%)
  • All security-critical functions have comprehensive test cases
  • Error scenarios and edge cases are covered

Priority

High - Security-critical code should have comprehensive test coverage

Related

  • Part of MR #7 (closed) coverage testing integration
  • Contributes to overall project coverage goals