Skip to content

test : added unit tests for repo-health-insights pure helpers#2467

Open
tmdeveloper007 wants to merge 1 commit into
Umbrella-io:mainfrom
tmdeveloper007:#2462
Open

test : added unit tests for repo-health-insights pure helpers#2467
tmdeveloper007 wants to merge 1 commit into
Umbrella-io:mainfrom
tmdeveloper007:#2462

Conversation

@tmdeveloper007

Copy link
Copy Markdown
Contributor

Closes #2462.

Summary of What Has Been Done:
Added a dedicated vitest test file test/repo-health-insights.test.ts that pins the behaviour of every pure helper in src/lib/repo-health-insights.ts: gradeLetter, gradeLabel, buildRadarData, buildBreakdown, and generateInsights. Tests are deterministic and use the existing RepoHealthSignals type from src/types/repo-health.ts.

Changes Made:

  • New file: test/repo-health-insights.test.ts (19 tests, all passing under npm test).
  • Coverage for 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- and B- use the U+2212 minus sign , matching the source).
  • Coverage for gradeLabel: each tier ("green" → "Healthy", "yellow" → "Needs Attention", "red" → "At Risk").
  • Coverage for 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.
  • Coverage for buildBreakdown: 5 rows with the expected labels, the sum of weightPct is 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 for daysSinceLastCommit.
  • Coverage for 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.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:testing GSSoC type bonus: tests (+10 pts) labels Jun 15, 2026
@github-actions

Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Umbrella-io — please apply the appropriate labels before merging:

Difficulty (pick one):

  • level:beginner — 20 pts
  • level:intermediate — 35 pts
  • level:advanced — 55 pts
  • level:critical — 80 pts

Quality (optional):

  • quality:clean — ×1.2 multiplier
  • quality:exceptional — ×1.5 multiplier

Validation (required to score):

  • gssoc:approved — counts for points
  • gssoc:invalid / gssoc:spam / gssoc:ai-slop — does not score

Type labels (type:*) are auto-detected from files and title. Review and adjust if needed.
Points formula: (difficulty × quality_multiplier) + type_bonus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc26 GSSoC 2026 contribution type:testing GSSoC type bonus: tests (+10 pts)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test : add unit tests for repo-health-insights pure helpers

1 participant