Background
PR #784 quarantined several backend tests that were failing because the routes/features they test are not yet implemented in the current codebase.
Routes to implement
The following routes exist as test stubs in backend/src/routes/contributions.test.js but the actual route handlers are not implemented in backend/src/routes/contributions.js:
Freighter contribution flow
GET /api/contributions/quote - Path payment quote for conversion
POST /api/contributions/prepare - Returns unsigned XDR and prepare token for Freighter signing
POST /api/contributions/submit-signed - Accepts Freighter-signed XDR and submits
GET /api/contributions/finalization/:txHash - Returns finalization status of a contribution
Refund flow
POST /api/contributions/:id/refund - Contract-mode contribution refund for failed campaigns
Pagination
GET /api/contributions/campaign/:campaignId - List contributions for a campaign with pagination
Additional route enhancements
The test stubs also expect these behaviors on POST /api/contributions that may not be fully implemented:
migration_in_progress check (503 CAMPAIGN_MIGRATION_IN_PROGRESS)
CAMPAIGN_DISPUTED status check (409)
max_per_user cap enforcement with advisory lock
min_contribution / max_contribution validation
platform_fee_amount in response and metadata
Test response shape mismatch
embed.test.js: The test POST contribute accepts valid contribution... expects response {success, amount, txHash} but the route returns {id, raised_amount, target_amount}
nftRewards.test.js: The test POST /api/nft-rewards/claim prevents duplicates... has a stub mismatch with the actual route's database interactions
Related
Acceptance criteria
Background
PR #784 quarantined several backend tests that were failing because the routes/features they test are not yet implemented in the current codebase.
Routes to implement
The following routes exist as test stubs in
backend/src/routes/contributions.test.jsbut the actual route handlers are not implemented inbackend/src/routes/contributions.js:Freighter contribution flow
GET /api/contributions/quote- Path payment quote for conversionPOST /api/contributions/prepare- Returns unsigned XDR and prepare token for Freighter signingPOST /api/contributions/submit-signed- Accepts Freighter-signed XDR and submitsGET /api/contributions/finalization/:txHash- Returns finalization status of a contributionRefund flow
POST /api/contributions/:id/refund- Contract-mode contribution refund for failed campaignsPagination
GET /api/contributions/campaign/:campaignId- List contributions for a campaign with paginationAdditional route enhancements
The test stubs also expect these behaviors on
POST /api/contributionsthat may not be fully implemented:migration_in_progresscheck (503 CAMPAIGN_MIGRATION_IN_PROGRESS)CAMPAIGN_DISPUTEDstatus check (409)max_per_usercap enforcement with advisory lockmin_contribution/max_contributionvalidationplatform_fee_amountin response and metadataTest response shape mismatch
embed.test.js: The testPOST contribute accepts valid contribution...expects response{success, amount, txHash}but the route returns{id, raised_amount, target_amount}nftRewards.test.js: The testPOST /api/nft-rewards/claim prevents duplicates...has a stub mismatch with the actual route's database interactionsRelated
{ skip: 'Route not implemented - see #785' }or similarAcceptance criteria
POST /api/contributionswith missing validation logic