Skip to content

Build Agreement Integration Test Suite #62

Description

@Kalchaqui

Agreement Integration Test Suite (corrected endpoints)

Depends on: #61 (for activity assertions)

Task Description

Add/extend integration tests for the Agreements module. A Jest setup already exists (jest.config.js, src/integration/migrated-flows.integration.spec.ts, plus module .spec.ts files), so this builds on the existing suite rather than starting new. The goal is trustworthy coverage of the real endpoints and their error paths.

Background / Current State

  • The original test issue referenced GET /agreements, which does not exist — the real route is GET /agreements/by-wallet.
  • PATCH /agreements/:id/link-contract was missing from the original list and must be covered.

Deliverable

An integration test suite covering the real Agreements endpoints and their error paths.

Requirements

Test the actual endpoints (corrected against the current controller):

Endpoint Method
/agreements POST
/agreements/by-wallet?wallet= GET (not GET /agreements)
/agreements/:id GET
/agreements/:id/link-contract PATCH (was missing originally)
/agreements/:id/status PATCH
/agreements/:id/milestones PATCH
/agreements/:id/activity GET
/agreements/by-contract/:contractId GET
  • Happy path + error path for each (invalid token, not found, unauthorized wallet).
  • Assert activity entries are created on status/milestone changes (depends on Issue A).

Validation System

  • All tests pass in CI (pnpm test) before merge.
  • Each endpoint has at least one success and one failure case.

Technical Requirements

  • Reuse the existing Jest config and Supabase mock utilities already in the repo.
  • Use a test JWT/wallet fixture.
  • Do not introduce a parallel test harness — extend the current suite.

Additional Notes

The corrected endpoint list is the key value here: the original issue would have produced tests against a non-existent GET /agreements route. This issue fixes that and adds link-contract.

Testing (required)

  • Success + failure case implemented for each endpoint in the table.
  • Activity assertions verify entries are created on status/milestone changes.
  • Suite runs green in CI via pnpm test.

Proof of Completion (required)

  • Link the merged PR.
  • Paste the passing CI pnpm test output showing the Agreements suite.
  • Confirm (link/diff) the tests target GET /agreements/by-wallet and include PATCH /agreements/:id/link-contract.

Metadata

Metadata

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions