Skip to content

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

Merged
Priyanshu-byte-coder merged 43 commits into
Priyanshu-byte-coder:mainfrom
Shanidhya01:test/streak-calculation-1069
Jul 1, 2026
Merged

test: add comprehensive unit tests for streak calculation utilities#2746
Priyanshu-byte-coder merged 43 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 Outdated
Comment thread package-lock.json Outdated
@Shanidhya01

Copy link
Copy Markdown
Contributor Author

Ok will fix it by the end of the day

Shanidhya01 and others added 5 commits June 24, 2026 15:15
Swap hardcoded stats table for dynamic shields.io badges (stars, forks),
add komarev view counter, and remove good-first-issues badge.
- Remove duplicate ThemeToggle from hero section (navbar-only now)
- Fix hardcoded Priyanshu-byte-coder#222 footer color → use MUTED CSS variable for dark mode
- Add missing lnd-footer-link CSS class
- Deduplicate lnd-cta-secondary CSS rule
- Remove unused ThemeToggle import
- Remove duplicate widget section that rendered everything twice
- Move orphaned sidebar into proper 2-column grid (1fr + 320px)
- Standardize spacing with space-y-8 wrapper
- Fix duplicate id="goals" → id="goals-insights"
- Fix StreakTracker break-all → tabular-nums (numbers no longer break mid-digit)
- Fix PRMetrics lg:grid-cols-6 → lg:grid-cols-3 (readable stat cards)
- Make CodingActivityInsightsCard chart height responsive
- Remove 7 dead imports and 2 unused dynamic components
…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 and others added 3 commits June 24, 2026 17:08
All 11 widgets that were rendered directly in page.tsx are already
handled by CustomizableDashboard with better skeletons, error
boundaries, and ssr:false. Removed duplicates:
- RepoAnalyticsExplorer, PRMetrics, CommunityMetrics
- PRBreakdownChart, CommitTimeChart, ActivityRingChart
- CodingActivityInsightsCard, PRReviewTrendChart
- StreakTracker, LocalCodingTime, CodingTimeWidget

Kept RoastHypeWidget (not in CustomizableDashboard).
Deleted DashboardWidgets.tsx (dead code, zero importers).
page.tsx: 245 → 152 lines.
@Shanidhya01
Shanidhya01 requested a review from Legit-Ox June 24, 2026 15:14
dependabot Bot and others added 8 commits June 24, 2026 23:29
…r#2709)

Bumps [actions/setup-node](https://github.com/actions/setup-node) from 4 to 6.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](actions/setup-node@v4...v6)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-version: '6'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…der#2711)

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3 to 4.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](github/codeql-action@v3...v4)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-version: '4'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…2710)

Bumps [actions/checkout](https://github.com/actions/checkout) from 4 to 7.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v4...v7)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-version: '7'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…der users (Priyanshu-byte-coder#2783)

Adds a visually-hidden skip navigation link as the first focusable element
in the root layout, targeting #main-content so keyboard-only users can bypass
the navbar. Wraps page children with the skip target div and promotes the
dashboard's top-level container to a semantic <main> element.
)

Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
…r#2777)

Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
@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.

Priyanshu-byte-coder and others added 14 commits June 25, 2026 14:19
- sanitize.ts: run stripHtml iteratively until stable, preventing
  nested/split-tag bypass (CodeQL js/incomplete-multi-character-sanitization)
- project-tutor/route.ts: encodeURIComponent on owner/repo before
  embedding in GitHub API URLs (CodeQL js/request-forgery Priyanshu-byte-coder#6-8)
- MembersPanel.tsx: encodeURIComponent on github_username in img src
  (CodeQL js/xss-through-dom Priyanshu-byte-coder#17)
- README.md: replace all stale Umbrella-io/devtrack refs with
  Priyanshu-byte-coder/devtrack
Move security overrides into pnpm.overrides (the overrides field was
npm-only and ignored by pnpm). Forces:
- serialize-javascript >=7.0.3 (HIGH RCE via RegExp, GHSA-5c6j-r48x-rmvq)
- postcss >=8.4.31 (XSS via unescaped </style>, GHSA-qx2v-qp2m-jg93)
- uuid >=9.0.1 (buffer bounds, GHSA-w5hq-g745-h8pq)
- js-yaml >=4.1.0 (quadratic DoS, GHSA-h67p-54hq-rp68)
…errides

pnpm 11 moved overrides from package.json to pnpm-workspace.yaml.
Lockfile regenerated — vulnerable old versions eliminated:
- serialize-javascript 4.0.0/6.0.2 -> 7.0.6 (HIGH RCE GHSA-5c6j-r48x-rmvq)
- js-yaml 3.14.2 removed (quadratic DoS GHSA-h67p-54hq-rp68)
- postcss/uuid already at patched versions

Also approve needed native build deps in allowBuilds.
…iyanshu-byte-coder#2706)

* fix: replace npm with pnpm in README and ignore package-lock.json

* ci: update github workflows to use pnpm

* ci: fix missing pnpm/action-setup in github workflows

* chore: approve native build scripts for pnpm

* ci: remove global pnpm install to use setup action version

---------

Co-authored-by: DESIREDDY MOHITH REDDY <desireddymohithreddy@MRD-2.local>
…coder#2703)

Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
…coder#2702)

Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
…yanshu-byte-coder#2700)

Co-authored-by: tmdeveloper007 <tmdeveloper007@users.noreply.github.com>
pnpm 9 does not read overrides from pnpm-workspace.yaml, causing
ERR_PNPM_LOCKFILE_CONFIG_MISMATCH on frozen install. pnpm 11 is the
version in use locally and is the correct version for this lockfile.
- Accept package-lock.json deletion (project uses pnpm)
- Revert engines.node to "20.x" (no scope change)
- Resolve test/streak.test.ts conflict by keeping upstream version (Priyanshu-byte-coder#2776)
- Add test/streak-comprehensive.test.ts with our timezone/leap-year/freeze tests
Our comprehensive tests live in test/streak-comprehensive.test.ts.
@Shanidhya01
Shanidhya01 force-pushed the test/streak-calculation-1069 branch from 30a9a28 to 7df0840 Compare June 25, 2026 14:25
@github-actions github-actions Bot added type:design GSSoC type bonus: UI/design (+10 pts) type:devops GSSoC type bonus: devops (+15 pts) type:docs GSSoC type bonus: documentation (+5 pts) type:bug GSSoC type bonus: bug fix type:performance GSSoC type bonus: performance (+15 pts) labels Jun 25, 2026

@Priyanshu-byte-coder Priyanshu-byte-coder left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Excellent comprehensive streak tests — timezone boundaries, leap years, freeze dates, edge cases. Well structured.

@Priyanshu-byte-coder Priyanshu-byte-coder added gssoc:approved GSSoC: PR approved for scoring level2 GSSoC Level 2 - Medium complexity (25 points) labels Jul 1, 2026
@Priyanshu-byte-coder
Priyanshu-byte-coder merged commit fb41036 into Priyanshu-byte-coder:main Jul 1, 2026
16 of 18 checks passed
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

🎉 Merged! Thanks for contributing to DevTrack.

If the project has been useful to you, a ⭐ star on the repo is the easiest way to support it — it helps DevTrack get discovered by more developers.

Keep an eye on open issues for your next contribution!

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

Labels

gssoc:approved GSSoC: PR approved for scoring gssoc26 GSSoC 2026 contribution level2 GSSoC Level 2 - Medium complexity (25 points) type:bug GSSoC type bonus: bug fix type:design GSSoC type bonus: UI/design (+10 pts) type:devops GSSoC type bonus: devops (+15 pts) type:docs GSSoC type bonus: documentation (+5 pts) 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 utility functions

10 participants