refactor: split server.proxy.test.js into 6 focused test modules#3827
refactor: split server.proxy.test.js into 6 focused test modules#3827Copilot wants to merge 2 commits into
Conversation
Split the 1,711-line server.proxy.test.js into focused modules: - server.websocket.test.js (~280 lines) — proxyWebSocket suite - server.proxy-headers.test.js (~130 lines) — X-Initiator + tool_calls - server.anthropic-beta.test.js (~530 lines) — anthropic deprecated beta - server.error-handling.test.js (~160 lines) — error handling tests - server.token-guards.test.js (~190 lines) — token guard tests - server.token-steering.test.js (~390 lines) — token steering utilities All 50 original test cases pass across the new files.
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (1 files)
Coverage comparison generated by |
Smoke Test: Claude Engine ✅
Result: PASS
|
There was a problem hiding this comment.
Pull request overview
This PR refactors the API proxy test suite by splitting the previously monolithic containers/api-proxy/server.proxy.test.js into six focused Jest modules, improving navigability and allowing more targeted test runs without changing production behavior.
Changes:
- Deleted
server.proxy.test.jsand redistributed its 50 test cases into 6 concern-specific test files. - Each new module performs its own isolated module/env setup (
jest.resetModules()+HTTPS_PROXYhandling) to avoid cross-test contamination. - Preserved coverage across WebSocket proxying, header sanitization, Anthropic beta retry behavior, error handling, token guards, and token steering.
Show a summary per file
| File | Description |
|---|---|
| containers/api-proxy/server.proxy.test.js | Removed the 1,711-line combined test file in favor of focused modules. |
| containers/api-proxy/server.websocket.test.js | WebSocket upgrade validation + CONNECT tunneling + auth/header injection tests. |
| containers/api-proxy/server.proxy-headers.test.js | x-initiator injection and tool_calls normalization tests. |
| containers/api-proxy/server.anthropic-beta.test.js | Anthropic deprecated beta header retry/learning/proactive stripping tests. |
| containers/api-proxy/server.error-handling.test.js | Client/upstream stream error handling and metrics/log assertions. |
| containers/api-proxy/server.token-guards.test.js | Effective-token and max-runs 429 guard behavior tests. |
| containers/api-proxy/server.token-steering.test.js | Timeout/token steering message generation + body injection unit/integration tests. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 7/7 changed files
- Comments generated: 2
| // Load a fresh proxyRequest that shares the same proxy-request module instance | ||
| // as the steering functions (assigned in the top-level beforeAll above). | ||
| // This ensures the same module instance handles both the threshold crossing | ||
| // and the body injection. |
| wsProxy(makeUpgradeReq(), socket, Buffer.alloc(0), 'api.openai.com', { 'Authorization': 'Bearer key' }, 'openai'); | ||
|
|
||
| return new Promise(resolve => setTimeout(() => { | ||
| expect(socket.write).toHaveBeenCalledWith(expect.stringContaining('HTTP/1.1 502 Bad Gateway')); | ||
| expect(socket.destroy).toHaveBeenCalled(); | ||
| resolve(); | ||
| }, 30)); | ||
| }); |
This comment has been minimized.
This comment has been minimized.
|
refactor: split server.proxy.test.js into 6 focused test modules Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
🧪 Smoke Test Results
Overall: PARTIAL — MCP is functional; pre-computed step outputs ( PR: refactor: split server.proxy.test.js into 6 focused test modules — author
|
🔬 Smoke Test: API Proxy OpenTelemetry Tracing
All 5 scenarios pass. ✅
|
Chroot Runtime Version Comparison
Result: Not all tests passed — Python and Node.js versions differ between host and chroot.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Smoke Test Results: FAIL
|
Smoke Test Results (Gemini)
Overall Status: FAIL Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "localhost"See Network Configuration for more information.
|
Smoke Test: Copilot BYOK (Offline) Mode
Running in BYOK offline mode ( PR: refactor: split server.proxy.test.js into 6 focused test modules by Overall: PARTIAL (smoke-data pre-step outputs not injected; BYOK inference confirmed ✅)
|
containers/api-proxy/server.proxy.test.jshad grown to 1,711 lines covering 7 distinct test concerns acrossproxyWebSocket,proxyRequest, and token steering utilities — making navigation, parallel execution, and targeted test runs awkward.Split
The file is deleted and replaced with six focused modules, each with its own self-contained module setup:
server.websocket.test.jsproxyWebSocket— request validation, CONNECT tunnel, auth injectionserver.proxy-headers.test.jstool_callsnormalisationserver.anthropic-beta.test.jsserver.error-handling.test.jsserver.token-guards.test.jsserver.token-steering.test.jsgetAndClearPendingSteeringMessage,injectSteeringMessage, integrationApproach
beforeAll/afterAllloading only the symbols it needs from./serverand./proxy-request, withjest.resetModules()guard forHTTPS_PROXYisolation.beforeAllwas hoisted to file scope and the duplicate guard-reset calls that resulted were deduplicated.