Skip to content

Add full test coverage for the services CRUD and bulk endpoints #42

@mikewheeleer

Description

@mikewheeleer

Test the services CRUD and bulk endpoints

Description

The service registry in src/index.ts exposes register, list (with prefix/q/limit/ETag), get-one, delete, bulk register, price patch, metadata put/get, and disabled toggle — but src/health.test.ts only covers basic register/list and one disabled case. Most of the registry surface is untested. This issue brings the services endpoints to full coverage.

Requirements and context

  • Repository scope: Agentpay-Org/Agentpay-backend only.
  • Cover POST /api/v1/services (create vs update status codes 201/200), GET /api/v1/services/:serviceId (200 and 404), and DELETE (204 and 404).
  • Cover GET /api/v1/services filters (prefix, q, limit) and the weak-ETag/If-None-Match 304 path.
  • Cover POST /api/v1/services/bulk (mixed valid/invalid items, >50 rejection), PATCH .../price, PUT .../metadata + GET .../metadata, and PATCH .../disabled.
  • Assert the standard 400 invalid_request shape (with requestId) on every validation failure.

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b test/testing-12-services-crud
  • Implement changes
    • Write comprehensive tests in: new src/services.test.ts using supertest against the exported app.
    • Write code in: no production change expected; if a real bug is found, fix it and note it in the PR.
    • Add documentation: none required beyond test descriptions.
    • Add clear describe/it titles.
    • Validate security assumptions: confirm validation bounds (128-char serviceId, 256-char metadata) are enforced.
  • Test and commit

Test and commit

  • Run npm run build, npm test, and npm run lint.
  • Cover edge cases: ETag stability, 304 on unchanged list, bulk partial failure, delete-then-get 404.
  • Include the full npm test output in the PR description.

Example commit message

test: cover services crud, bulk, metadata, and disabled endpoints

Guidelines

  • Minimum 95 percent test coverage for impacted modules.
  • Clear, reviewer-focused documentation.
  • Timeframe: 96 hours.

Community & contribution rewards

  • 💬 Join the AgentPay community on Discord for questions, reviews, and faster merges: https://discord.gg/eXvRKkgcv
  • ⭐ This is a GrantFox OSS / Official Campaign task and may be rewarded. When your PR is merged you'll be prompted to rate the project — if this issue and the maintainers helped you ship, we'd be grateful for a 5-star rating. Clear questions in Discord and tidy, well-tested PRs are the fastest path to a merge and a reward.

Metadata

Metadata

Assignees

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions