refactor(tests): extract useAgentVolumesTestConfig to eliminate duplicated setup boilerplate#4263
Conversation
Adds `useAgentVolumesTestConfig()` to `service-test-setup.test-utils.ts` and updates all four `agent-volumes-*.test.ts` files to use it, removing the ~18 duplicated lines of useTempWorkDir boilerplate from each file. Closes #3320
✅ Coverage Check PassedOverall Coverage
📁 Per-file Coverage Changes (3 files)
Coverage comparison generated by |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
This PR refactors the agent-volumes-*.test.ts service unit tests to reduce duplicated test setup by extracting the repeated mockConfig + useTempWorkDir(baseConfig, ...) boilerplate into a shared helper in service-test-setup.test-utils.ts.
Changes:
- Added
useAgentVolumesTestConfig()helper to encapsulate temp workDir lifecycle wiring and expose agetConfig()accessor. - Updated
agent-volumes-{logs,security,workspace,mounts}.test.tsto useuseAgentVolumesTestConfig()instead of per-filelet mockConfig+useTempWorkDir(...)blocks. - Simplified imports in updated tests by dropping no-longer-needed setup imports/types.
Show a summary per file
| File | Description |
|---|---|
| src/services/service-test-setup.test-utils.ts | Introduces useAgentVolumesTestConfig() to centralize repeated agent-volumes test setup. |
| src/services/agent-volumes-workspace.test.ts | Replaces local temp-dir setup with shared getConfig() accessor. |
| src/services/agent-volumes-security.test.ts | Replaces local temp-dir setup with shared getConfig() accessor. |
| src/services/agent-volumes-mounts.test.ts | Replaces local temp-dir setup with shared getConfig() accessor (formatting issues introduced in a couple blocks). |
| src/services/agent-volumes-logs.test.ts | Replaces local temp-dir setup with shared getConfig() accessor. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 5/5 changed files
- Comments generated: 3
| export function useAgentVolumesTestConfig(): { getConfig: () => WrapperConfig } { | ||
| let mockConfig: WrapperConfig; | ||
| useTempWorkDir( | ||
| baseConfig, | ||
| (c) => { | ||
| mockConfig = c; | ||
| }, | ||
| () => mockConfig, | ||
| ); | ||
| return { getConfig: () => mockConfig }; | ||
| } |
| it('should mount required volumes in agent container (default behavior)', () => { | ||
| const result = generateDockerCompose(getConfig(), mockNetworkConfig); |
| it('should use custom volume mounts when specified', () => { | ||
| const configWithMounts = { | ||
| ...mockConfig, | ||
| ...getConfig(), | ||
| volumeMounts: ['/workspace:/workspace:ro', '/data:/data:rw'] | ||
| }; |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@copilot address review feedback |
Smoke Test: Claude Engine
Result: PASS
|
🔥 Smoke Test: Copilot BYOK (Offline) Mode
Overall: PARTIAL — BYOK inference and MCP tools work. Pre-step template variables were not substituted in the prompt. PR author:
|
|
Remove test-only 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 — PASS
PR: "refactor(tests): extract useAgentVolumesTestConfig to eliminate duplicated setup boilerplate" 🟢 Overall: PASS
|
Gemini Engine Smoke Test Results
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.
|
🧪 Chroot Version Comparison Results
Overall: ❌ 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: GitHub Actions Services Connectivity
Overall: FAIL —
|
The
let mockConfig: WrapperConfig+useTempWorkDir(baseConfig, …)block was copy-pasted verbatim across all fouragent-volumes-*.test.tsfiles (~18 lines × 4 = 72 duplicated lines), meaning any change touseTempWorkDir's API orbaseConfigshape required edits in four places.Changes
service-test-setup.test-utils.ts— addsuseAgentVolumesTestConfig(), which encapsulates thelet mockConfigbinding anduseTempWorkDir(baseConfig, …)call, returning agetConfigaccessor:agent-volumes-{logs,security,workspace,mounts}.test.ts— replace the duplicated block with a single call at module scope:Files that only used
WrapperConfigfor thelet mockConfigdeclaration also drop that import.