Skip to content

test(streak): add unit tests for commit streak calculator edge cases - #3254

Open
Nareshkumawat-star wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
Nareshkumawat-star:test/commit-streak-unit-tests
Open

test(streak): add unit tests for commit streak calculator edge cases#3254
Nareshkumawat-star wants to merge 1 commit into
Priyanshu-byte-coder:mainfrom
Nareshkumawat-star:test/commit-streak-unit-tests

Conversation

@Nareshkumawat-star

Copy link
Copy Markdown

Summary

Adds comprehensive unit test coverage for the commit streak calculation engine (src/lib/streak.ts). This ensures streak counts remain accurate across critical edge cases like day boundaries, timezone differences, streak freeze tokens, intraday deduplication, and active grace periods.
Closes #3251


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 cleamprovement
  • 🔒 Security fix
  • 🧪 Tests only

What Changed

  • Created src/lib/__tests__/streak.test.ts to test edge cases:
    • 5 consecutive days calculation (streak = 5).
    • Streak freeze token bridging 1-day gap.
    • Streak broken when gap exceeds available freeze tokens.
    • Midnight boundary commits (23:59 vs 00:01 on adjacent days).
    • Timezone-aware date bucketing (UTC vs IST).
    • Intraday commit deduplication (multiple commits on same day = 1 streak day).
    • Grace period validation (committed yesterday, no commit today yet).

How to Test

  1. Run the Vitest test runner for the streak test file:
    npx vitest run src/lib/__tests__/streak.test.ts

Expected result: All unit tests for streak calculation pass cleanly.

Checklist
Linked the related issue above
Self-reviewed my own diff
No unnecessary console.log, debug code, or commented-out blocks
Added or updated tests where applicable
Additional Context
Branch: test/commit-streak-unit-tests
Direct PR creation link: https://github.com/Nareshkumawat-star/devtrack/pull/new/test/commit-streak-unit-tests
1:41 PM

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

@github-actions github-actions Bot added type:bug GSSoC type bonus: bug fix type:performance GSSoC type bonus: performance (+15 pts) labels Jul 28, 2026
@Nareshkumawat-star

Copy link
Copy Markdown
Author

Hi @Priyanshu-byte-coder kindly review and merge it

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 streak calculation logic — edge cases for missed days, timezones, and freeze days

1 participant