test : added unit tests for repo-health-insights pure helpers#2467
Open
tmdeveloper007 wants to merge 1 commit into
Open
test : added unit tests for repo-health-insights pure helpers#2467tmdeveloper007 wants to merge 1 commit into
tmdeveloper007 wants to merge 1 commit into
Conversation
GSSoC Label Checklist 🏷️@Umbrella-io — please apply the appropriate labels before merging: Difficulty (pick one):
Quality (optional):
Validation (required to score):
|
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.
Closes #2462.
Summary of What Has Been Done:
Added a dedicated vitest test file
test/repo-health-insights.test.tsthat pins the behaviour of every pure helper insrc/lib/repo-health-insights.ts:gradeLetter,gradeLabel,buildRadarData,buildBreakdown, andgenerateInsights. Tests are deterministic and use the existingRepoHealthSignalstype fromsrc/types/repo-health.ts.Changes Made:
test/repo-health-insights.test.ts(19 tests, all passing undernpm test).gradeLetter: 0/19/20/29/30/39/40/49/50/59/60/69/70/79/80/89/90/100 pinning the right letter/modifier for each band (note:A-andB-use the U+2212 minus sign−, matching the source).gradeLabel: each tier ("green" → "Healthy", "yellow" → "Needs Attention", "red" → "At Risk").buildRadarData: axis labels and order,fullMark: 100, integer 0-100 values, and that the best-case signals produce 100 on every axis while the worst-case signals produce 0.buildBreakdown: 5 rows with the expected labels, the sum ofweightPctis 100, singular vs plural formatting ("1 commit"/"1 open issue" vs "N commits"/"N open issues"), the "No PRs" / "h avg" / "%" formatting rules, and the "Today"/"d ago"/"Unknown" rendering fordaysSinceLastCommit.generateInsights: emitted IDs for the warning/success/info paths (no-commits, good-commits, no-issues, active-repo, high-issues, slow-prs, no-commit-data).Impact it Made:
Locks down the data-shaping contract consumed by the Repository Health Explorer UI. Refactors of the scoring engine or the recommendations rules will surface a test failure rather than a silent visual regression. No production code is modified; the change is limited to one new test file.