test(uws-platform): assert HEAD route registration on static-asset single-call tests#116
Merged
Conversation
…tic-asset tests The static-asset implementation registers both GET and HEAD routes (uws-platform.adapter.ts:822-823), but the six single-call tests in the 'static assets' describe block only asserted the GET registration - so a refactor that accidentally dropped the HEAD line would have passed the test suite. Each of the six tests now asserts toHaveBeenCalledTimes(2) plus the corresponding HEAD registration alongside the GET one. The multi-call test that already verified the 4-registration shape and the error-path tests (no registrations to assert) are unchanged. All 66 tests in the file still pass. Closes FOSSFORGE#82
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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
The
useStaticAssets()implementation registers both GET and HEAD routes per call (uws-platform.adapter.ts:822-823), but six of the seven success-path tests in thestatic assetsdescribe block only asserted the GET registration. The one multi-call test already verifies the GET+HEAD = 4 shape; the single-call tests were the gap the issue calls out.Closes #82
Why this matters
If a refactor accidentally drops the
this.head(routePattern, ...)line, today's tests would still pass because none of the single-call cases check for the HEAD registration. That's the bug class issue #82 surfaces. Strengthening the assertions to match the multi-call test's pattern closes the loop and keeps the suite a true regression net for static-asset routing.Change
src/http/platform/uws-platform.adapter.spec.tsonly. Six single-call success-path tests now asserttoHaveBeenCalledTimes(2)plus the correspondingHEADregistration alongside the existingGETassertion:should enable static assets and register catch-all route,should respect silent option and not log,should register static assets route when custom options provided,should support prefix option for scoped static routes,should normalize prefix by removing trailing slash,should handle empty prefix by using default catch-all.Untouched: the multi-call
should register multiple static asset routes when called multiple times(already correct - asserts 4 registrations) and the two error-path tests for invalid input (no registrations to assert).Verification
npm test -- --testPathPatterns=uws-platform->Test Suites: 1 passed, 1 total / Tests: 66 passed, 66 total. No production code touched.Risk
None - tests-only strengthening.
Summary by CodeRabbit