Skip to content

test: add comprehensive unit tests for streak calculation utilities#2746

Open
Shanidhya01 wants to merge 6 commits into
Priyanshu-byte-coder:mainfrom
Shanidhya01:test/streak-calculation-1069
Open

test: add comprehensive unit tests for streak calculation utilities#2746
Shanidhya01 wants to merge 6 commits into
Priyanshu-byte-coder:mainfrom
Shanidhya01:test/streak-calculation-1069

Conversation

@Shanidhya01

Copy link
Copy Markdown
Contributor

Summary

Adds comprehensive unit tests for streak calculation utility functions to improve reliability and prevent regressions in DevTrack's streak tracking system.

Closes #1069

Changes Made

  • Added unit tests for current streak calculation
  • Added unit tests for longest streak calculation
  • Added unit tests for streak-at-risk detection
  • Added tests for streak reset behavior
  • Added tests for empty commit history
  • Added tests for date boundary edge cases
  • Added tests for leap year handling
  • Added tests for month transitions (28/29/30/31 days)
  • Added tests for timezone-related scenarios
  • Added tests for commits made after midnight

Test Coverage

Covered scenarios:

  • Returns 0 for empty commit history
  • Counts consecutive days correctly
  • Resets streak on missed day
  • Handles streak freeze functionality (if implemented)
  • Calculates longest streak accurately
  • Detects streak at risk when no commit exists today
  • Handles timezone boundaries correctly
  • Counts today correctly for post-midnight commits
  • Handles leap year dates (Feb 29)
  • Handles month length variations

Type of Change

  • Test addition
  • Bug fix
  • New feature
  • Breaking change

Checklist

  • Tests added
  • Existing tests pass
  • No production behavior changed
  • Code follows project conventions

@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) and removed gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature labels Jun 23, 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

@Legit-Ox Legit-Ox left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test coverage is solid — good edge case variety across leap years, month transitions, timezone boundaries, and freeze dates. Three issues before merging:

  1. rolldown added to production dependencies — unrelated to this PR and shouldn't be there at all
  2. One test name directly contradicts its assertion
  3. package-lock.json accidentally narrows the Node engine range

Comment thread package.json Outdated
Comment thread test/streak.test.ts
Comment thread package-lock.json
@Shanidhya01

Copy link
Copy Markdown
Contributor Author

Ok will fix it by the end of the day

…e range, fix test name

- Remove rolldown from dependencies (build tool, not a runtime lib)
- Restore engines.node to >=20.0.0 to avoid excluding Node 22/24
- Rename misleading test that said does not treat Feb 28 → Mar 1 as consecutive
  when the assertion proves they are consecutive in a non-leap year
@github-actions github-actions Bot added gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature labels Jun 24, 2026
@Shanidhya01 Shanidhya01 requested a review from Legit-Ox June 24, 2026 15:14
@Priyanshu-byte-coder

Copy link
Copy Markdown
Owner

The test coverage here is genuinely strong — the timezone edge cases, leap year handling, and streak-utils coverage are valuable. A few things to fix before merge:

  1. Remove the package.json change — changing engines from 20.x to >=20.0.0 is unrelated to tests and belongs in a separate PR.

  2. package-lock.json changes — the added resolved/integrity fields for rolldown are also unrelated. Please drop these.

  3. File conflict with test : added unit tests for streak.ts #2776 — both PRs create test/streak.test.ts. Since test : added unit tests for streak.ts #2776 has already been merged, please either rename your file (e.g. test/streak-comprehensive.test.ts) or consolidate the tests into the existing file to avoid conflicts.

Fix these and the test quality is solid enough to merge.

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

Labels

gssoc26 GSSoC 2026 contribution type:feature GSSoC type bonus: new feature 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

3 participants