Skip to content

test : add unit tests for repo-health-insights.ts #2808

Description

@tmdeveloper007

Summary of What Needs to be Done: Add unit tests for the pure repository health visualization utilities exported from src/lib/repo-health-insights.ts: gradeLetter(), gradeLabel(), buildRadarData(), buildBreakdown(), and generateInsights().

Changes that Need to be Made: Create test/repo-health-insights.test.ts using vitest. Import RepoHealthSignals type from @/types/repo-health. Test gradeLetter() boundaries: below 20 (D), 20-29 (C+), 30-39 (C), 40-49 (B-), 50-59 (B), 60-69 (B+), 70-79 (A-), 80-89 (A), 90+ (A+). Test gradeLabel(): green->Healthy, yellow->Needs Attention, red->At Risk. Test buildRadarData(): with zero values (all 0), with realistic signals (values 0-100). Test buildBreakdown(): all-zero signals, mixed signals, values at boundary. Test generateInsights(): commitFrequency=0 (warning), 1-2 (warning), 10+ (success); prMergeRate 0.9 (success), 0.3 (warning); avgPrOpenTimeHours 12 (success), 200 (warning); openIssuesCount 0 (success), 25 (warning); daysSinceLastCommit 1 (success), 45 (warning).

Impact that it would Provide: Provides test coverage for the repo health explorer presentation layer. Ensures grade thresholds and insight generation rules are correct and consistent with the underlying scoring logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions