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)
The
hooks/__tests__/directory only covers utility hooks (debounce, throttle, local-storage, click-outside, etc.). The newer mutation hooks inhooks/use-bounty-application.tsandhooks/use-competition-bounty.tshave 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.tsxcovering at minimum:useApplyToBounty— successful contract call, rollback on contract error, missing wallet address throwsuseSelectApplicant— optimistic status update toIN_PROGRESS, rollback on erroruseApproveApplicationSubmission— optimistic status update toCOMPLETED, rollback on erroruseRequestRevisions— optimistic status update toUNDER_REVIEW, rollback on erroruseApplyForSlot— slot count increment, contributor added to funnel, rollback on erroruseReleasePayment— escrow pool released amount increment, rollback on erroruseRemoveContributor— contributor removed from progress list andtotalSlotsOccupieddecrementeduseDeclineApplicant— applicant removed fromapplicationslist, rollback on erroruseRaiseDispute— POSTs to/api/disputes, invalidates bounty queries on successStub the contract bindings by injecting
globalThis.__applicationContractsandglobalThis.__contestContractsin the test setup. Mock/api/disputeswithmswor by stubbingglobal.fetch.Use
renderHookfrom@testing-library/reactand theQueryClientProviderwrapper pattern already used inhooks/__tests__/use-submission-draft.test.tsx.Acceptance criteria
hooks/__tests__/use-bounty-application.test.tsxpnpm testgreenFiles
hooks/__tests__/use-bounty-application.test.tsx(new)hooks/use-bounty-application.ts(reference)