Skip to content

Add unit tests for the bounty application mutation hooks #282

Description

@Benjtalkshow

The hooks/__tests__/ directory only covers utility hooks (debounce, throttle, local-storage, click-outside, etc.). The newer mutation hooks in hooks/use-bounty-application.ts and hooks/use-competition-bounty.ts have no test coverage, despite being the most-edited files in the repo and the source of repeated regressions across PRs #253, #256, #265, #268, and #269.

What to do

Add hooks/__tests__/use-bounty-application.test.tsx covering at minimum:

  • useApplyToBounty — successful contract call, rollback on contract error, missing wallet address throws
  • useSelectApplicant — optimistic status update to IN_PROGRESS, rollback on error
  • useApproveApplicationSubmission — optimistic status update to COMPLETED, rollback on error
  • useRequestRevisions — optimistic status update to UNDER_REVIEW, rollback on error
  • useApplyForSlot — slot count increment, contributor added to funnel, rollback on error
  • useReleasePayment — escrow pool released amount increment, rollback on error
  • useRemoveContributor — contributor removed from progress list and totalSlotsOccupied decremented
  • useDeclineApplicant — applicant removed from applications list, rollback on error
  • useRaiseDispute — POSTs to /api/disputes, invalidates bounty queries on success

Stub the contract bindings by injecting globalThis.__applicationContracts and globalThis.__contestContracts in the test setup. Mock /api/disputes with msw or by stubbing global.fetch.

Use renderHook from @testing-library/react and the QueryClientProvider wrapper pattern already used in hooks/__tests__/use-submission-draft.test.tsx.

Acceptance criteria

  • New test file at hooks/__tests__/use-bounty-application.test.tsx
  • Each mutation listed above has at least a happy path and a rollback test
  • pnpm test green
  • No real network or contract calls during the test run

Files

  • hooks/__tests__/use-bounty-application.test.tsx (new)
  • hooks/use-bounty-application.ts (reference)

Metadata

Metadata

Assignees

Labels

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