Skip to content

test: add API Service health-route failure tests (SW-044) - #282

Merged
dDevAhmed merged 1 commit into
DigiNodes:mainfrom
Dekah101:main
Oct 21, 2026
Merged

dDevAhmed merged 1 commit into
DigiNodes:mainfrom
Dekah101:main

Conversation

@Dekah101

@Dekah101 Dekah101 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds comprehensive health-route failure tests to the API Service template to verify invalid HTTP methods and paths are rejected predictably. This ensures the generated API service has proper route validation and error handling before it reaches production.

Related Issue

Closes #146

Scope

Added three new test cases to templates/api-service/test/server.test.js:

  1. Invalid HTTP method rejection - Tests POST, PUT, DELETE, and PATCH methods against /health endpoint
  2. Invalid path rejection - Tests /health/, /health/status, /invalid, and / paths
  3. Response structure stability - Validates payload structure and headers across network configurations

All tests use ephemeral ports and 127.0.0.1 to ensure no external network dependencies.

Testing

  • Tests added/updated where applicable - Added 3 new test cases
  • Existing relevant tests pass - Unable to verify due to pre-existing CI issues (typecheck/lint errors in codebase unrelated to this change)
  • Lint/type/build checks pass where available - Blocked by pre-existing issues in package.json (syntax error), src/diagnostics/run.ts (missing bounds.js module), and multiple type errors in diagnostics files

Note: The template test file itself passes syntax validation with node --check. The CI failures are due to pre-existing issues in the main codebase that exist in HEAD before this change.

Security Impact

  • No security-sensitive behavior is changed
  • Security-sensitive behavior is changed and explained below

Security notes: N/A - only test additions

Release Impact

  • No published/user-visible behavior change

  • Patch

  • Minor

  • Breaking/pre-1.0 contract change

  • Changeset included where required

  • Changeset not required; reason explained below

Release notes: This change only adds test coverage to a template file. It does not modify any published or user-visible behavior. The generated API service behavior remains unchanged; only its test coverage is improved.

Documentation

  • Documentation updated where applicable
  • No documentation change required

No documentation change required - this is purely a test coverage improvement.

Checklist

  • I read docs/contributing/wave-architecture.md for Stellar Wave work - Not applicable (test addition, not Wave work)
  • I stayed within the agreed issue scope
  • I checked for overlapping open contributor PRs
  • I did not include secrets or sensitive data
  • I reviewed new/updated dependencies if any - No new dependencies added
  • I considered failure/error paths, not only the happy path - Tests specifically cover error paths (404 responses)
  • I am not disclosing an unresolved vulnerability publicly

## PR Title

```
test: add API Service health-route failure tests (SW-044)
```

## PR Description

Implements expanded API Service test coverage for health-route method/path/error behavior as specified in SW-044.

### Changes

Added three new test cases to `templates/api-service/test/server.test.js`:

1. **Invalid HTTP method rejection** - Verifies that `/health` endpoint rejects POST, PUT, DELETE, and PATCH methods with 404 responses
2. **Invalid path rejection** - Tests 404 responses for `/health/`, `/health/status`, `/invalid`, and `/` paths
3. **Response structure stability** - Validates health response payload structure and content-type header across network configurations

### Acceptance Criteria

- ✅ Supported health response remains stable
- ✅ Invalid methods/paths fail predictably (404 with `{ error: 'not_found' }`)
- ✅ No network dependencies (uses `127.0.0.1` with ephemeral ports)
- ✅ Template file passes syntax validation

### Implementation Notes

All tests use the built-in `globalThis.fetch` API with ephemeral ports (`server.listen(0)`) to ensure no external network calls are made. The implementation follows existing test patterns in the codebase.

Fixes DigiNodes#146
@coderabbitai

coderabbitai Bot commented Oct 20, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 710e774e-1910-484e-8d89-1461e862d197
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@dDevAhmed
dDevAhmed merged commit 1741eb4 into DigiNodes:main Oct 21, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SW-044 — Add API Service health-route failure tests

2 participants