Skip to content

Verify edge cases and input validation for tracking fallback#5399

Merged
JhaSourav07 merged 1 commit into
JhaSourav07:mainfrom
realtushartyagi:test/tracking-empty-fallback
Jun 12, 2026
Merged

Verify edge cases and input validation for tracking fallback#5399
JhaSourav07 merged 1 commit into
JhaSourav07:mainfrom
realtushartyagi:test/tracking-empty-fallback

Conversation

@realtushartyagi

Copy link
Copy Markdown
Contributor

Description

Fixes #4309

This PR Adds empty-input and fallback tests for utils/tracking.ts.

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 (Integration Test update)

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 review requested due to automatic review settings June 12, 2026 14:02
@vercel

vercel Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds Vitest coverage for trackUser edge cases, focusing on empty-username no-ops and runtime fallbacks between navigator.sendBeacon and fetch.

Changes:

  • Introduces a new test suite validating empty input short-circuit behavior.
  • Adds tests for server/headless execution safety (missing window/navigator).
  • Adds tests for sendBeacon absence/failure and fetch fallback error handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +10 to +20
beforeEach(() => {
originalWindow = globalThis.window;
originalNavigator = globalThis.navigator;
originalFetch = globalThis.fetch;
originalBlob = globalThis.Blob;

globalThis.window = {} as unknown as typeof globalThis.window;
globalThis.navigator = {
sendBeacon: vi.fn().mockReturnValue(true),
} as unknown as typeof globalThis.navigator;
globalThis.fetch = vi.fn().mockResolvedValue({ ok: true });
Comment on lines +22 to +30
// Ensure Blob is polyfilled securely to prevent hydration or runtime errors in CI
if (typeof globalThis.Blob === 'undefined') {
globalThis.Blob = class Blob {
constructor(
public parts: string[],
public options: Record<string, string>
) {}
} as unknown as typeof globalThis.Blob;
}
Comment on lines +92 to +93
// Wait a tick to ensure async catch block executes cleanly
await new Promise(process.nextTick);

@Aamod-Dev Aamod-Dev 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.

Thanks for adding the edge case coverage for the tracking fallback! Ensuring sendBeacon queuing failures properly route to the fetch API prevents silent telemetry loss, which is great.

Your test coverage is perfect. However, you will notice the CI pipeline is currently failing due to an unrelated divergence in lib/svg/themes.test.ts on the main branch.

To secure a green build, simply run git pull --rebase origin main and force push your branch. I'll be ready to approve once that runs!

Labels Applied:

  • level:beginner: Standard API fallback testing.
  • type:testing: Edge case validation.
  • quality:clean: Excellent isolation of network limits.
  • mentor:Aamod007

@realtushartyagi realtushartyagi force-pushed the test/tracking-empty-fallback branch from d511419 to b7bdd54 Compare June 12, 2026 18:56

@Aamod-Dev Aamod-Dev 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.

Great job resolving the issues! The pipeline divergence is fixed and the code looks completely solid. Approved! 🎉

@Aamod-Dev Aamod-Dev 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.

Great job resolving the issues! The pipeline divergence is fixed and the code looks completely solid. Approved! 🎉

@Aamod-Dev Aamod-Dev added GSSoc26 GSSoC 2026 level:advanced Complex contributions involving architecture, optimization, or significant feature work quality:clean PR follows clean coding practices, proper formatting, documentation, and maintainability standards. type:feature New features, additions, or enhancements mentor:Aamod007 and removed GSSoc26 labels Jun 12, 2026

@Aamod-Dev Aamod-Dev 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.

Thanks for the contribution. I went through the changes and the overall approach looks good.

@JhaSourav07 JhaSourav07 added the gssoc:approved PR has been reviewed and accepted for valid contribution points label Jun 12, 2026
@JhaSourav07 JhaSourav07 merged commit e76bd9e into JhaSourav07:main Jun 12, 2026
11 checks passed
@github-actions github-actions Bot added this to the GSSoC 2026 milestone Jun 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🎉 Congratulations @realtushartyagi! Your PR has been successfully merged. 🚀

Thank you for contributing to CommitPulse. Your work helps us build a better tool for the community.

⚠️ Important for GSSoC Contributors:
You are strictly advised to join our Discord Server as it is mandatory for all GSSoC participants. All important announcements, point claims, and community discussions happen there.

Keep building! 💻✨

@Aamod-Dev Aamod-Dev 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.

Looks great! I went through the changes and ensuring tracking edge cases are verified makes the telemetry pipeline much safer.
Labels applied:

  • level:advanced: Complex input verification.
  • quality:clean: Robust coverage.
  • ype:feature: Feature telemetry testing.

@github-actions github-actions Bot added type:testing Adding, updating, or fixing tests and removed type:feature New features, additions, or enhancements labels Jun 15, 2026
@JhaSourav07 JhaSourav07 added gssoc:approved PR has been reviewed and accepted for valid contribution points and removed gssoc:approved PR has been reviewed and accepted for valid contribution points labels Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved PR has been reviewed and accepted for valid contribution points GSSoC 2026 level:advanced Complex contributions involving architecture, optimization, or significant feature work 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(tracking-empty-fallback): verify Edge Cases & Empty/Missing Inputs Verification (Variation 1)

4 participants