Skip to content

test : added unit tests for consistency-score calculation functions#2701

Closed
tmdeveloper007 wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
tmdeveloper007:#2696
Closed

test : added unit tests for consistency-score calculation functions#2701
tmdeveloper007 wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
tmdeveloper007:#2696

Conversation

@tmdeveloper007

Copy link
Copy Markdown
Contributor

Closes #2696.

Summary of What Has Been Done: Added unit tests for the pure calculation functions exported from src/lib/consistency-score.ts. Exported six previously-private helper functions to enable isolated unit testing.

Changes Made:

  • Exported scoreToGrade, getImprovementTip, computeLongestGap, hasActivityInLastNDays, computeWeeklyConsistency, and computeMonthlyTrend from src/lib/consistency-score.ts
  • Created test/consistency-score.test.ts with 24 test cases covering grade boundaries, tip thresholds, gap calculation, activity window detection, weekly consistency scoring, monthly trend computation, full score calculation, and recent-activity flag

Impact it Made: Consistency scoring drives user-visible grades and improvement tips. Test coverage here prevents regressions in scoring logic that would affect developer gamification and streak tracking.

@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:testing GSSoC type bonus: tests (+10 pts) labels Jun 22, 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

@github-actions github-actions Bot added type:bug GSSoC type bonus: bug fix type:feature GSSoC type bonus: new feature type:performance GSSoC type bonus: performance (+15 pts) labels Jun 22, 2026
@Priyanshu-byte-coder

Copy link
Copy Markdown
Owner

Two things before this can merge:

  1. Hard conflict with test : added unit tests for consistency-score.ts isRecentlyActiveFromScore #2762 (already merged): both PRs create test/consistency-score.test.ts as a new file. Please rebase onto main and drop the isRecentlyActiveFromScore describe block entirely — test : added unit tests for consistency-score.ts isRecentlyActiveFromScore #2762 already covers it with stronger assertions (exact formula boundary conditions vs your typeof-boolean check).

  2. Keep the rest: the five new describe blocks (scoreToGrade, getImprovementTip, computeLongestGap, hasActivityInLastNDays, computeWeeklyConsistency/Monthly, calculateConsistencyScore) are genuinely new coverage and worth merging. The six export additions to the source file are also fine.

Rebase + remove the duplicate block and this is good to go.

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

Labels

gssoc26 GSSoC 2026 contribution type:bug GSSoC type bonus: bug fix type:feature GSSoC type bonus: new feature type:performance GSSoC type bonus: performance (+15 pts) 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 consistency-score calculation functions

2 participants