📌 Description
src/lib/schemas/apiContracts.ts declares the response schemas for the public
API, and src/lib/backend/apiResponse.ts is the standard envelope. There are
per-route tests, but no single contract test that parses representative
responses from the read routes through the apiContracts schemas to catch
breaking shape changes.
Goal: add a schema-contract test that validates real handler responses
against the declared apiContracts schemas.
🎯 Requirements and Context
- For each covered read route (e.g. commitments list/detail, marketplace
listings, protocol constants), call the handler and safeParse the body with
its apiContracts schema; assert success.
- Assert the standard success envelope (
success: true, data) and the error
envelope shape for a forced error.
- Centralize a route→schema mapping so adding a route is a one-line change.
- Mock data sources consistently with
tests/api/helpers.ts.
🛠️ Suggested Execution
1. Fork the repo and create a branch
git checkout -b test/api-contract-schemas
2. Implement changes
- Add
tests/api/contract-schemas.test.ts (Vitest) importing schemas from
src/lib/schemas/apiContracts.ts.
3. Test and commit
- Run the repo suite:
pnpm test
- Edge cases: error envelope, optional/nullable fields, empty collections.
Example commit message
test: contract-test API routes against apiContracts schemas
✅ Guidelines
- Minimum 95% test coverage on the schemas/envelope under test.
- Clear, reviewer-friendly test names.
- Timeframe: 96 hours.
🏷️ Labels
type-testing · area-frontend · MAYBE REWARDED · GRANTFOX OSS ·
OFFICIAL CAMPAIGN
💬 Community & Support
- Join the CommitLabs contributor Discord: https://discord.gg/WV7tdYkJk
- Please introduce yourself before you start so we can avoid duplicate work.
📌 Description
src/lib/schemas/apiContracts.tsdeclares the response schemas for the publicAPI, and
src/lib/backend/apiResponse.tsis the standard envelope. There areper-route tests, but no single contract test that parses representative
responses from the read routes through the
apiContractsschemas to catchbreaking shape changes.
🎯 Requirements and Context
listings, protocol constants), call the handler and
safeParsethe body withits
apiContractsschema; assert success.success: true,data) and the errorenvelope shape for a forced error.
tests/api/helpers.ts.🛠️ Suggested Execution
1. Fork the repo and create a branch
2. Implement changes
tests/api/contract-schemas.test.ts(Vitest) importing schemas fromsrc/lib/schemas/apiContracts.ts.3. Test and commit
pnpm testExample commit message
✅ Guidelines
🏷️ Labels
type-testing·area-frontend·MAYBE REWARDED·GRANTFOX OSS·OFFICIAL CAMPAIGN💬 Community & Support