Skip to content

test: add integration tests for /api/goals/sync endpoint#1875

Merged
Priyanshu-byte-coder merged 1 commit into
Priyanshu-byte-coder:mainfrom
Subhra-Nandi:test/goals-sync-integration
Jun 3, 2026
Merged

test: add integration tests for /api/goals/sync endpoint#1875
Priyanshu-byte-coder merged 1 commit into
Priyanshu-byte-coder:mainfrom
Subhra-Nandi:test/goals-sync-integration

Conversation

@Subhra-Nandi
Copy link
Copy Markdown
Contributor

Summary

Closes #947

Adds integration tests for the /api/goals/sync endpoint. The sync endpoint touches GitHub Search API, Supabase, and NextAuth — these tests verify the full flow end-to-end with mocked dependencies.

Changes

File Description
test/goals-sync.test.ts New — 25 integration tests for POST /api/goals/sync

Acceptance Criteria

  • Returns 401 when no session
  • Fetches commit count from GitHub Search API using correct date range
  • Updates all commit-based goals with the fetched count
  • Handles GitHub API 429 — returns 429, does not update goals
  • Handles Supabase update failure gracefully

Test Results

All 25 tests passing:

  • authentication (4)
  • user lookup (1)
  • when no goals exist (1)
  • commit goal syncing (5)
  • PR goal syncing (2)
  • GitHub API rate limiting (4)
  • GitHub API non-rate-limit errors (1)
  • Supabase failure handling (3)
  • date range correctness (2)
  • commit pagination (1)
  • mixed commit and PR goals (1)

Screenshots

Screenshot 2026-06-02 174857 Screenshot 2026-06-02 174926

Testing

npx vitest run test/goals-sync.test.ts

- 401 when no session or missing session fields
- 404 when user not found in DB
- Correct GitHub Search API query with author + date range
- Commit goals updated with fetched count
- Multiple commit goals updated independently
- last_synced_at set on each updated goal
- GitHub 429/403 returns 429, does not update goals
- Reset time included in rate limit message
- Supabase fetch failure returns 500
- Supabase update failure returns 500
- PR goals use GitHub Issues Search API
- Commit pagination: page 2 fetched when page 1 has 100 items
- Mixed commit + PR goals return combined updated count

Closes Priyanshu-byte-coder#947
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 2, 2026

@Subhra-Nandi 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:feature GSSoC type bonus: new feature type:testing GSSoC type bonus: tests (+10 pts) labels Jun 2, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

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

@Priyanshu-byte-coder Priyanshu-byte-coder added gssoc:approved GSSoC: PR approved for scoring level:intermediate GSSoC: Intermediate difficulty (35 pts) quality:clean GSSoC: Clean quality multiplier (×1.2) labels Jun 3, 2026
@Priyanshu-byte-coder Priyanshu-byte-coder merged commit 85d7950 into Priyanshu-byte-coder:main Jun 3, 2026
10 checks passed
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

🎉 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 level:intermediate GSSoC: Intermediate difficulty (35 pts) quality:clean GSSoC: Clean quality multiplier (×1.2) 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.

[TESTS] Add integration tests for /api/goals/sync endpoint

2 participants