Skip to content

test: add unit tests for cv-classifier.ts (#3029)#3197

Open
aaniya22 wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
aaniya22:test/3029-cv-classifier-unit-tests
Open

test: add unit tests for cv-classifier.ts (#3029)#3197
aaniya22 wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
aaniya22:test/3029-cv-classifier-unit-tests

Conversation

@aaniya22

Copy link
Copy Markdown

Summary

Adds a new test file test/cv-classifier.test.ts with unit tests covering all six pure functions in src/lib/cv/cv-classifier.ts: detectTechnologies, mapToDomains, scoreContributions, analyzeRepository, classifyContributions, and filterByRole, per issue #3029.

Closes #3029


Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that changes existing behavior)
  • 📝 Documentation update
  • ♻️ Refactor / code cleanup (no functional change)
  • ⚡ Performance improvement
  • 🔒 Security fix
  • 🧪 Tests only

What Changed

  • test/cv-classifier.test.ts (new, 36 tests) with fixture builders (makePR, makeCommit, makeRepo, makeContributionData, makeClassification) matching the existing style used in test/cv-prompts.test.ts:
    • detectTechnologies — empty input, bucketing into languages/frameworks/tools, occurrence summing across signals, confidence upgrading, sort order, PR-body low-confidence detection.
    • mapToDomains — no-signal case, direct tech-match scoring, keyword-match evidence, synthetic FullStack domain creation (and non-creation when only one side exceeds 30), sort order, score capped at 100.
    • scoreContributions — all-zero baseline, summing merged PRs/commits/additions/deletions (excluding non-merged PRs), avgPRSize computation (including the zero-merged-PRs case), topLanguages sorted and capped at 5, totalIssues/totalReviews passthrough.
    • analyzeRepository — complexity classification across all low/medium/high boundary conditions (both the lines-changed and PR-count thresholds), prsMerged only counting merged state, detectedDomains population, relevanceByRole key completeness and 100-cap.
    • classifyContributions — valid object shape with all required fields, FullStack fallback for primaryDomain when no domains detected, correct primaryDomain selection otherwise.
    • filterByRole — unchanged passthrough for unrecognized roles, tech stack filtering by role domain, repo filtering (removing zero-relevance repos) and sorting by relevance descending, domains array preserved unfiltered.

How to Test

  1. Pull this branch.
  2. Run pnpm install (use --ignore-scripts if the optional tree-sitter native build fails locally — unrelated to this change).
  3. Run npx vitest run test/cv-classifier.test.ts.

Expected result: All 36 tests pass.


Screenshots / Recordings

Not applicable — test-only change, no UI impact.


Checklist

  • Linked the related issue above
  • Self-reviewed my own diff
  • No unnecessary console.log, debug code, or commented-out blocks
  • npm run lint passes locally
  • No TypeScript errors (npm run type-check)
  • Added or updated tests where applicable
  • Updated documentation / comments if behavior changed

Accessibility (UI changes only)

Not applicable — no UI changes.


Additional Context

This module had no existing test coverage on main, so this is a genuinely new test suite rather than filling a gap in existing tests. One test (adds a synthetic FullStack domain...) initially failed against my first fixture — the domain-scoring formula (tech matches capped at 50 + keyword matches capped at 30 + popularity bonus) came out to 28 instead of the >30 needed to trigger the synthetic FullStack domain, which I caught by actually running the suite and adjusted the fixture accordingly rather than assuming the math.

@github-actions github-actions Bot added type:testing GSSoC type bonus: tests (+10 pts) gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature labels Jul 13, 2026
@github-actions

Copy link
Copy Markdown

GSSoC Label Checklist 🏷️

@Priyanshu-byte-coder — 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:feature GSSoC type bonus: new feature 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 cv-classifier.ts

1 participant