Skip to content

Test/streak calculation unit tests#1100

Open
palakjaiswal16 wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
palakjaiswal16:test/streak-calculation-unit-tests
Open

Test/streak calculation unit tests#1100
palakjaiswal16 wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
palakjaiswal16:test/streak-calculation-unit-tests

Conversation

@palakjaiswal16
Copy link
Copy Markdown

Summary

Adds comprehensive unit tests for the streak calculation utility functions and moves the streak calculation logic into a shared reusable utility.

Closes #1069

Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Refactor / code cleanup

Changes Made

  • Extracted streak calculation logic into src/lib/streak.ts
  • Updated the streak metrics API route to use the shared utility
  • Added 10 focused unit tests covering current streak, longest streak, missed days, streak freezes, at-risk detection, timezone boundaries, leap years, and month length edge cases
  • Fixed the existing clipboard mock setup in StreakTracker.test.ts so tests pass in the current Vitest environment

How to Test

Steps for the reviewer to verify this works:

  1. Run npm test
  2. Run npm run type-check
  3. Confirm test/streak.test.ts passes and covers the requested streak calculation scenarios

Screenshots (if UI change)

Not applicable. This PR only updates utilities and tests.

Checklist

  • Linked issue in summary
  • npm run lint passes locally
  • No TypeScript errors (npm run type-check)
  • Self-reviewed the diff
  • Added/updated tests if applicable

@vercel
Copy link
Copy Markdown

vercel Bot commented May 25, 2026

@palakjaiswal16 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 25, 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: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 streak calculation utility functions

1 participant