Skip to content

test(utils): Enhance unit test coverage for getViewerLocalHour with invalid date strings - #9031

Open
Rakshak05 wants to merge 1 commit into
JhaSourav07:mainfrom
Rakshak05:issue-#8633
Open

test(utils): Enhance unit test coverage for getViewerLocalHour with invalid date strings#9031
Rakshak05 wants to merge 1 commit into
JhaSourav07:mainfrom
Rakshak05:issue-#8633

Conversation

@Rakshak05

Copy link
Copy Markdown
Contributor

Description

Fixes #8633

This PR adds comprehensive unit test coverage for the getViewerLocalHour utility function in utils/dateHelpers.ts.

Changes Included:

  • Added unit tests for:
    • Valid ISO strings with various timezone offsets (+02:00, -05:00, Z).
    • Partial ISO date strings (2024-03-10, 2024-03).
    • Empty strings ('').
    • Malformed date strings with invalid characters (invalid-date, 2024-03-XX, hello world).
    • Incomplete / out-of-range ISO strings (2024-03-10T, 2024-13-99T25:99:00).
    • Invalid ancient dates before year 0 (-9999999-01-01).
    • Out-of-bounds future dates (999999999-01-01).
    • Safe handling of non-string / missing values (null, undefined).
  • Added type guard validation in getViewerLocalHour (typeof isoDate !== 'string') for added runtime safety.
  • Ensured deterministic test execution across timezones in CI using bounded range assertions (0 to 23).

Pillar

  • 🎨 Pillar 1 — New Theme Design
  • 📐 Pillar 2 — Geometric SVG Improvement
  • 🕐 Pillar 3 — Timezone Logic Optimization
  • 🛠️ Other (Bug fix, refactoring, docs)

Visual Preview

N/A (Unit test coverage expansion)

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally (localhost:3000/api/streak?user=YOUR_USERNAME).
  • I have run npm run format and npm run lint locally and resolved all errors (CI will fail otherwise).
  • My commits follow the Conventional Commits format (e.g., feat(themes): ..., fix(calculate): ...).
  • I have updated README.md if I added a new theme or URL parameter.
  • I have started the repo.
  • I have made sure that i have only one commit to merge in this PR.
  • The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts).
  • (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.

Copilot AI lite review requested due to automatic review settings August 14, 2026 08:23
@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

@Rakshak05 is attempting to deploy a commit to the jhasourav07's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@retenta-bot

retenta-bot Bot commented Aug 14, 2026

Copy link
Copy Markdown

This PR adds significant unit test coverage for the getViewerLocalHour function, addressing various invalid date scenarios. This aligns with previous decisions to enhance testing around timezone normalization and calendar boundary handling, ensuring our date calculations remain robust across different contexts. Great work on this! Looking forward to your next contributions.

@retenta-bot retenta-bot Bot changed the title test(utils): add unit test coverage for getViewerLocalHour with invalid date strings (#8633) test(utils): Enhance unit test coverage for getViewerLocalHour with invalid date strings Aug 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📦 Next.js Bundle Size Report (Gzipped Sizes)

✨ No significant bundle size changes detected.

📊 Summary of Totals

Category PR Size Base Size Difference
Total JS 5004.34 KB 5004.32 KB +0.02 KB (+0.00%)
Total CSS 354.80 KB 354.80 KB 0 B

@Aamod007 Aamod007 added mentor:Aamod007 type:testing Adding, updating, or fixing tests level:beginner Small changes Usually isolated fixes or simple UI/text updates. quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. labels Aug 16, 2026

@Aamod007 Aamod007 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.

Solid set of edge case tests! The extra type guard on \isoDate\ is a great small addition for runtime safety. Approved!

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

Labels

level:beginner Small changes Usually isolated fixes or simple UI/text updates. mentor:Aamod007 quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:testing Adding, updating, or fixing tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test : add coverage for getViewerLocalHour with invalid date strings

3 participants