Skip to content

Add test coverage for the deep readiness probe degraded and paused branches #81

Description

@mikewheeleer

Test the deep health probe degraded and paused states

Description

GET /api/v1/health/deep in src/index.ts returns status: "ok", "degraded" (503), or "paused" based on runHealthChecks() and the paused flag, and it reports checks[], uptime, memory, pid, and node. Only the happy ok path is covered today; the degraded 503 branch (a failing check) and the paused 200 branch are untested, as is the per-check { name, status, durationMs } shape. This issue adds coverage for all three states.

Requirements and context

  • Repository scope: StableRoute-Org/Stableroute-backend only.
  • Assert the ok path returns 200 with both storage and clock checks present and status: "ok".
  • Force the degraded branch (e.g. by stubbing pairMeta/storage so the storage check fails, or by injecting a failing check) and assert a 503 with status: "degraded".
  • Toggle pause via POST /api/v1/admin/pause, assert GET /api/v1/health/deep returns 200 with status: "paused", then unpause to restore state.
  • Assert the response carries uptimeSeconds, memory.rssMb, memory.heapUsedMb, pid, and node.

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b test/health-33-deep-probe-branches
  • Implement changes
    • Write comprehensive tests in: create src/__tests__/healthDeep.test.ts.
    • Add documentation: none beyond test names.
    • Restore any stubbed globals and the pause flag in afterEach to avoid cross-test bleed.
    • Validate security: confirm the probe body exposes no secrets.
  • Test and commit

Test and commit

  • Run npm run build, npm run lint, and npm test.
  • Cover edge cases: ok, degraded (503), paused (200), all check fields present.
  • Paste the full npm test output and a coverage summary in the PR.

Example commit message

test(health): cover deep probe degraded and paused branches

Guidelines

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

Community & contribution rewards

  • 💬 Join the StableRoute community on Discord for questions, reviews, and faster merges: https://discord.gg/37aCpusvx
  • ⭐ 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