Repository navigation
test: add API Service health-route failure tests (SW-044) - #282
Merged
Merged
Conversation
## 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
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:/healthendpoint/health/,/health/status,/invalid, and/pathsAll tests use ephemeral ports and
127.0.0.1to ensure no external network dependencies.Testing
package.json(syntax error),src/diagnostics/run.ts(missingbounds.jsmodule), and multiple type errors in diagnostics filesNote: 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
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
No documentation change required - this is purely a test coverage improvement.
Checklist
docs/contributing/wave-architecture.mdfor Stellar Wave work - Not applicable (test addition, not Wave work)