Feat: Add HTTP compression E2E test#123
Conversation
|
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 |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/http/compression.e2e.spec.ts`:
- Around line 37-41: The test for non-compressible content-type is ineffective
because image(`@Res`() res: UwsResponse) currently sends a tiny Buffer so
compression is skipped by the threshold rather than by content-type; update the
test handler (image) to send a payload larger than the compression threshold
(e.g., allocate >1024 bytes) or set the compression threshold to 0 for this test
so compression decision is driven by Content-Type 'image/png' and then keep the
assertion block in the spec (the checks around compression headers/assertions)
to validate that image/png is not compressed.
- Around line 60-61: Replace the fixed port constant (port = 13358) and any
other hardcoded port usage with dynamic port allocation and bind to the loopback
address: stop using the literal port variable and instead start the test server
with port 0 and host '127.0.0.1' (e.g., server.listen(0, '127.0.0.1', ...)),
then read the assigned port from server.address().port for constructing URLs;
update any references to the original port variable (including the other
occurrence around line 81) to use the discovered port so tests avoid port
collisions and use an explicit loopback host.
- Around line 105-117: The httpGet helper currently creates an
http.ClientRequest (variable req) but never sets a request-level timeout, so
tests can hang; update the httpGet function to call req.setTimeout(<timeoutMs>,
() => req.destroy(new Error('Request timeout'))) (or similar) after creating
req, ensure the timeout value is configurable or a defined constant, and make
sure the request 'error' handler and response listeners properly handle the
destroyed request so the Promise rejects on timeout; reference the existing
local variable req and the httpGet function to locate where to add
req.setTimeout and the timeout error handling.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 68d9e247-5f50-4ba1-9b94-69e07f97deb4
📒 Files selected for processing (1)
test/http/compression.e2e.spec.ts
791cc90 to
3935338
Compare
Tests added:
Closes #120
Summary by CodeRabbit