refactor: split server.test.js into focused test files#2969
Conversation
|
/copilot review |
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (1 files)
Coverage comparison generated by |
🔬 Smoke Test Results
Overall: FAIL — GitHub MCP authentication unavailable in this environment. Triggered by workflow run 25706647304
|
Smoke Test: Copilot BYOK (Offline) Mode
Running in BYOK offline mode ( Overall: FAIL — GitHub MCP returned 401; pre-step template variables (
|
Smoke Test Codex
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 ❌ GitHub MCP Testing — gh CLI auth failed (HTTP 401) Overall Status: FAIL (GitHub MCP auth issue)
|
There was a problem hiding this comment.
Pull request overview
This PR refactors the api-proxy Jest test suite by removing the monolithic containers/api-proxy/server.test.js and splitting its coverage into smaller, concern-focused test files to improve navigability and failure localization without changing production behavior.
Changes:
- Removed
containers/api-proxy/server.test.js(previously large, mixed concerns). - Added focused test suites for network helpers, model helpers, lifecycle/provider-server behavior, and billing/auth helpers.
Show a summary per file
| File | Description |
|---|---|
| containers/api-proxy/server.test.js | Removes the previous monolithic test file. |
| containers/api-proxy/server.network.test.js | Adds tests for network helpers (probe/fetch/model discovery/reflect). |
| containers/api-proxy/server.models.test.js | Adds tests for model transforms, models.json generation/writes, and composed transforms. |
| containers/api-proxy/server.lifecycle.test.js | Adds tests for health response, provider server behavior, alwaysBind behavior, and BYOK model fetch. |
| containers/api-proxy/server.billing.test.js | Adds tests for key validation and billing header extraction. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comments suppressed due to low confidence (2)
containers/api-proxy/server.lifecycle.test.js:438
- jest.restoreAllMocks() already restores the process.stdout.write spy returned by collectLogOutput(). Calling spy.mockRestore() immediately afterwards is redundant and can be error-prone across Jest versions. Either remove spy.mockRestore() here or avoid restoreAllMocks and restore only the spies you created in this test.
jest.restoreAllMocks();
spy.mockRestore();
containers/api-proxy/server.lifecycle.test.js:464
- jest.restoreAllMocks() already restores the process.stdout.write spy returned by collectLogOutput(). Calling spy.mockRestore() immediately afterwards is redundant and can be error-prone across Jest versions. Either remove spy.mockRestore() here or avoid restoreAllMocks and restore only the spies you created in this test.
jest.restoreAllMocks();
spy.mockRestore();
- Files reviewed: 5/5 changed files
- Comments generated: 2
| afterEach((done) => { | ||
| let remaining = servers.length; | ||
| if (!remaining) { done(); return; } | ||
| servers.splice(0).forEach((s) => s.close(() => { if (!--remaining) done(); })); | ||
| }); |
| jest.restoreAllMocks(); | ||
| spy.mockRestore(); | ||
|
|
Chroot Version Comparison Results
Overall: Not all tests passed — Python and Node.js versions differ between host and chroot environments. Go versions match.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
Smoke Test Results
Overall: FAIL —
|
✨ Enhancement
What does this improve?
containers/api-proxy/server.test.jshad grown to 1,696 lines and mixed 15 unrelateddescribeblocks into a single flat file. This change splits that coverage by concern so failures are easier to localize and the test surface is easier to navigate.Why is this valuable?
The largest block in the file (
createProviderServer) alone spanned ~400 lines, while network helpers, model transforms, lifecycle behavior, and billing/auth concerns all lived together. Breaking these apart makes targeted iteration practical without changing production behavior.Implementation approach:
Test file split
containers/api-proxy/server.test.jscontainers/api-proxy/server.network.test.jscontainers/api-proxy/server.models.test.jscontainers/api-proxy/server.lifecycle.test.jscontainers/api-proxy/server.billing.test.jsConcern-based grouping
httpProbe,fetchJson,extractModelIds,fetchStartupModels,reflectEndpointsmakeModelBodyTransform,buildModelsJson,writeModelsJson,composeBodyTransformshealthResponse,createProviderServer, provideralwaysBindbehavior, Copilot BYOK model fetchvalidateApiKeys,extractBillingHeadersMinimal refactor surface