Skip to content

fix: Metrics Agent test failures — configuration and data validation #2164

Description

@ashleyshaw

Summary

Pre-existing test failures in scripts/metrics/__tests__/metrics-agent.test.js are blocking CI checks on the main branch. These failures are unrelated to active development and prevent valid PRs from merging.

Test Failures

Multiple test assertions failing in ConfigurationLoader, MetricsCollector, and data validation:

ConfigurationLoader Tests (9 failures)

  • ✕ merges defaults with provided config
  • ✕ validates context value (github-control-plane)
  • ✕ validates context value (wordpress-plugin)
  • ✕ validates context value (wordpress-theme)
  • ✕ validates collection_period is positive number
  • ✕ validates collection_period is number type
  • ✕ validates repositories is array
  • ✕ validates repositories is non-empty
  • ✕ validates each repository has owner/name

MetricsCollector Tests (6 failures)

  • ✕ calculates total issues
  • ✕ calculates closed issues
  • ✕ calculates closure rate
  • ✕ handles empty issue list
  • ✕ counts stale issues (no activity >30 days)
  • ✕ extracts label distribution
  • ✕ handles empty array (percentile calculation)

Impact

  • Pre-existing failures on develop branch
  • Blocking CI checks on all PRs
  • Not caused by recent changes (only package-lock.json modifications)

Root Cause

Test expectations don't match current implementation behavior. Issues appear to be:

  1. Configuration validation logic mismatch
  2. Metrics calculation implementation differences
  3. Data structure assumptions in tests

Remediation Plan

  1. Review ConfigurationLoader implementation vs test expectations
  2. Verify metrics calculation logic for accuracy
  3. Update test assertions to match current behavior or fix implementation
  4. Ensure all 50+ metrics-agent tests pass
  5. Maintain >80% code coverage
  6. Document any behavioral changes

Priority

Medium — Pre-existing issue, not blocking critical functionality but prevents valid PRs from merging.

Related Issues


Definition of Ready (DoR)

  • Issue has clear acceptance criteria
  • Related issues are linked
  • Scope is well-defined
  • Severity/impact assessed

Definition of Done (DoD)

  • Root cause identified and documented
  • All failing tests fixed or expectations updated
  • Tests passing with >80% coverage maintained
  • No new warnings or errors introduced
  • Changelog entry added
  • CI green on all branches

Metadata

Metadata

Assignees

Type

No type

Fields

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions