Skip to content

test : added unit tests for StreakTracker component#792

Open
tmdeveloper007 wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
tmdeveloper007:#772
Open

test : added unit tests for StreakTracker component#792
tmdeveloper007 wants to merge 2 commits into
Priyanshu-byte-coder:mainfrom
tmdeveloper007:#772

Conversation

@tmdeveloper007
Copy link
Copy Markdown
Contributor

Closes #772.

Summary of What Has Been Done:
Added test/StreakTracker.test.ts with 24 vitest tests covering the StreakTracker component's data structures and UI logic.

Changes Made:
New file: test/StreakTracker.test.ts

Test coverage:

  • STREAK_MILESTONES: expected values [7,30,50,100,200,365], sorted ascending order
  • StreakData interface: zero streak and active streak representations
  • Clipboard API: writeText integration, unavailable environment handling
  • Freeze badge display: shown when freezeDates has entries, hidden when empty
  • Milestone banner logic: shows at correct thresholds, first milestone only when multiple reached, null when no milestone reached
  • useCountUp integration: correct target values for current and longest streaks
  • Loading/data/error states: null data with loading flag, complete data, error object handling
  • ContributionData structure: days/total/data fields, empty contributions case

Impact it Made:
All 24 tests pass. Streak display logic validated across all data states (loading, success, error, zero).

@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

Copy link
Copy Markdown
Owner

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

Choose a reason for hiding this comment

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

Tests must import from source — not reimplement the function locally.

The test file re-implements the function being tested inside the test itself. This defeats the purpose of testing — changes to the real implementation won't fail these tests.

Fix: import the actual function from its source file and test that import. Example:

import { safeCompare } from '../src/lib/crypto'
// then test safeCompare directly

Also fix:

  • Add "test": "vitest run" to scripts in package.json
  • Add vitest.config.ts with resolve.alias: { '@': path.resolve(__dirname, 'src') }
  • Add EOF newline to test file

@Priyanshu-byte-coder Priyanshu-byte-coder added gssoc:approved GSSoC: PR approved for scoring level:beginner GSSoC: Beginner difficulty (20 pts) labels May 23, 2026
@tmdeveloper007 tmdeveloper007 force-pushed the #772 branch 3 times, most recently from eb90a40 to e8c79db Compare May 23, 2026 14:59
Test User added 2 commits May 23, 2026 20:53
Closes Priyanshu-byte-coder#772

Added test/StreakTracker.test.ts covering:
- STREAK_MILESTONES: expected values, ascending order
- StreakData interface: zero streak, active streak with freezes
- Clipboard API: writeText behavior, unavailable clipboard handling
- Freeze badge: shown/hidden based on freezeDates array
- Milestone banner: shows at 7/30/50/100/200/365 days, first milestone logic, null when not reached
- useCountUp integration: correct target values, zero handling
- Loading/data/error states: null data with loading, complete data, error object
- ContributionData: structure with days/total/data, empty case

Impact: All 24 tests pass. Streak data handling and milestone detection validated.
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 level:beginner GSSoC: Beginner difficulty (20 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 StreakTracker component

2 participants