Refactor service tests to share temp workDir lifecycle setup#3204
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors 10 service test files in src/services/ to share temp workDir lifecycle setup via a new useTempWorkDir helper, eliminating ~230 lines of duplicated beforeEach/afterEach code while preserving per-file jest.mock() hoisting semantics.
Changes:
- Added
useTempWorkDir(fixtureConfig, setConfig, getConfig)helper indocker-test-fixtures.test-utils.tsthat sets up anawf-test-temp dir before each test and cleans it up after. - Replaced inline temp-dir lifecycle blocks in 10 service test files with calls to
useTempWorkDir. - Removed now-unused
fs/os/pathimports from test files that no longer reference them directly.
Show a summary per file
| File | Description |
|---|---|
| src/test-helpers/docker-test-fixtures.test-utils.ts | Adds useTempWorkDir helper encapsulating temp workDir lifecycle. |
| src/services/squid-service.test.ts | Switches to useTempWorkDir; drops fs/os/path imports. |
| src/services/doh-proxy-service.test.ts | Switches to useTempWorkDir; drops fs/os/path imports. |
| src/services/cli-proxy-service.test.ts | Switches to useTempWorkDir; drops fs/os/path imports. |
| src/services/api-proxy-service.test.ts | Switches to useTempWorkDir; drops os import (keeps fs/path for other usage). |
| src/services/agent-volumes.test.ts | Switches to useTempWorkDir; retains other fs/path/os usage. |
| src/services/agent-service.test.ts | Switches to useTempWorkDir; retains other fs/path/os usage. |
| src/services/agent-environment-runtime.test.ts | Switches to useTempWorkDir; drops fs/os/path imports. |
| src/services/agent-environment-proxy.test.ts | Switches to useTempWorkDir; drops fs/os/path imports. |
| src/services/agent-environment-options.test.ts | Switches to useTempWorkDir; retains other fs/path/os usage. |
| src/services/agent-environment-credentials.test.ts | Switches to useTempWorkDir; drops fs/os/path imports. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 11/11 changed files
- Comments generated: 0
Smoke Test Results✅ GitHub API - Listed last 2 merged PRs PASS — All 3/3 tests passed
|
Smoke Test Results
Overall: FAIL
|
|
Smoke test Codex: FAIL 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.
|
Chroot Smoke Test Results
Overall: ❌ Not all versions match — Python and Node.js versions differ between host and chroot environment.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
|
Smoke Test: Copilot BYOK — Run #859 (attempt 2)
Running in BYOK offline mode ( Overall:
|
Smoke Test Results — FAIL
|
|
Smoke test result: FAIL. Details: Files OK, GitHub/MCP 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.
|
|
@copilot address review feedback |
I checked this PR’s reviews and review threads, and there aren’t any actionable review comments to address right now (the Copilot review reports 0 comments). If you want me to handle specific feedback, please point me to the exact comment(s) or check output and I’ll apply the changes immediately. |
✨ Enhancement
10 service/environment tests in
src/services/duplicated the same preamble formockConfigtemp-dir setup/teardown, creating ~230 lines of repeated lifecycle code and forcing N-way edits for any fixture changes. This PR centralizes that lifecycle while preserving per-filejest.mock('execa', ...)hoisting behavior.What does this improve?
beforeEach/afterEachtempworkDirsetup across 10 service test files.mockConfigremains file-scoped in each test).Why is this valuable?
Implementation approach:
useTempWorkDir(...)tosrc/test-helpers/docker-test-fixtures.test-utils.ts.useTempWorkDir(...)insidedescribe(...):agent-environment-credentials.test.tsagent-environment-options.test.tsagent-environment-proxy.test.tsagent-environment-runtime.test.tsagent-service.test.tsagent-volumes.test.tsapi-proxy-service.test.tscli-proxy-service.test.tsdoh-proxy-service.test.tssquid-service.test.ts