test: add unit tests for cv-classifier.ts (#3029)#3197
Open
aaniya22 wants to merge 1 commit into
Open
Conversation
GSSoC Label Checklist 🏷️@Priyanshu-byte-coder — 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.
Summary
Adds a new test file
test/cv-classifier.test.tswith unit tests covering all six pure functions insrc/lib/cv/cv-classifier.ts:detectTechnologies,mapToDomains,scoreContributions,analyzeRepository,classifyContributions, andfilterByRole, per issue #3029.Closes #3029
Type of Change
What Changed
test/cv-classifier.test.ts(new, 36 tests) with fixture builders (makePR,makeCommit,makeRepo,makeContributionData,makeClassification) matching the existing style used intest/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, syntheticFullStackdomain 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),avgPRSizecomputation (including the zero-merged-PRs case),topLanguagessorted and capped at 5,totalIssues/totalReviewspassthrough.analyzeRepository— complexity classification across all low/medium/high boundary conditions (both the lines-changed and PR-count thresholds),prsMergedonly counting merged state,detectedDomainspopulation,relevanceByRolekey completeness and 100-cap.classifyContributions— valid object shape with all required fields,FullStackfallback forprimaryDomainwhen no domains detected, correctprimaryDomainselection otherwise.filterByRole— unchanged passthrough for unrecognized roles, tech stack filtering by role domain, repo filtering (removing zero-relevance repos) and sorting by relevance descending,domainsarray preserved unfiltered.How to Test
pnpm install(use--ignore-scriptsif the optionaltree-sitternative build fails locally — unrelated to this change).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
console.log, debug code, or commented-out blocksnpm run lintpasses locallynpm run type-check)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 syntheticFullStackdomain, which I caught by actually running the suite and adjusted the fixture accordingly rather than assuming the math.