Skip to content

Write tests for help, streak, and usage server actions #97

@Ayush-Patel-56

Description

@Ayush-Patel-56

What

Three smaller server actions have no tests. Good starting point if you're new to testing in this codebase - the files are small and focused.

Files to test

src/app/actions/help.tshelp.test.ts

sendHelpRequest
- accepts plain text message
- accepts a valid GitHub PR URL
- rejects if user is not authenticated
- enforces cooldown (returns rate_limited if same key used within window)
- rejects if rec does not belong to user

src/app/actions/streak.tsstreak.test.ts

getStreak
- returns current streak count for authenticated user
- returns 0 when user has no activity
- returns not_authenticated when no session

src/app/actions/usage.tsusage.test.ts

getUsageStats
- returns activity log entries for authenticated user
- respects limit parameter
- returns empty array when no activity exists

Notes

  • All three files follow the same pattern: get user from Supabase auth, query with service client, return Result
  • Mock getServerSupabase and getServiceSupabase consistently across all three
  • The existing src/app/actions/github-sync.test.ts is a good reference for how to set up the mocks

Metadata

Metadata

Labels

GSSOC26GirlScript Summer of Code 2026backendBackend / API / DB relateddxDeveloper experiencegood first issueGood for newcomers

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions