Skip to content

test : added unit tests for calculateCurrentStreak in leaderboard#802

Open
tmdeveloper007 wants to merge 3 commits into
Priyanshu-byte-coder:mainfrom
tmdeveloper007:#782
Open

test : added unit tests for calculateCurrentStreak in leaderboard#802
tmdeveloper007 wants to merge 3 commits into
Priyanshu-byte-coder:mainfrom
tmdeveloper007:#782

Conversation

@tmdeveloper007
Copy link
Copy Markdown
Contributor

Closes #782.

Summary of What Has Been Done:
Added test/leaderboard-streak.test.ts with 15 vitest tests covering the calculateCurrentStreak function from src/app/api/leaderboard/route.ts.

Changes Made:
New file: test/leaderboard-streak.test.ts

Test coverage:

  • calculateCurrentStreak: empty array (0), single contribution today/yesterday (1), 0 when last contribution before yesterday, consecutive day streak count, today/yesterday boundary, duplicate dates handling, multiple runs returns 0 when last run is not today/yesterday
  • dateDiffDays: consecutive days (1), reverse order (-1), same day (0), year boundary
  • toDateStr: YYYY-MM-DD format, zero-padding

Impact it Made:
All 15 tests pass. Streak ranking calculation validated across year boundaries and day-edge cases.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 23, 2026

@TESTPERSONAL is attempting to deploy a commit to the PRIYANSHU DOSHI's projects Team on Vercel.

A member of the Team first needs to authorize it.

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

Test User added 3 commits May 23, 2026 09:30
Closes Priyanshu-byte-coder#782

Added test/leaderboard-streak.test.ts covering:
- calculateCurrentStreak: empty array, single contribution today/yesterday, 0 when last contribution before yesterday, consecutive day streak count, today/yesterday boundary, duplicate dates
- dateDiffDays: consecutive days, reverse order, same day, year boundary
- toDateStr: YYYY-MM-DD format, zero-padding

Impact: All 15 tests pass. Leaderboard streak ranking validated.
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 calculateCurrentStreak in leaderboard

1 participant