Skip to content

refactor: extract shared service test imports into service-test-setup.test-utils#3324

Merged
lpcox merged 2 commits into
mainfrom
copilot/fix-duplicate-test-setup
May 18, 2026
Merged

refactor: extract shared service test imports into service-test-setup.test-utils#3324
lpcox merged 2 commits into
mainfrom
copilot/fix-duplicate-test-setup

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 18, 2026

The same 3-line import block was duplicated verbatim across all 13 src/services/*.test.ts files, meaning any change to generateDockerCompose, WrapperConfig, or the fixture exports required touching every file.

Changes

  • New: src/services/service-test-setup.test-utils.ts — re-exports generateDockerCompose, WrapperConfig, baseConfig, mockNetworkConfig, and useTempWorkDir from their respective source modules
  • Updated: All 13 service test files replace 3 import lines with a single import from the shared module

Before / After

// Before (repeated in all 13 files)
import { generateDockerCompose } from '../compose-generator';
import { WrapperConfig } from '../types';
import { baseConfig, mockNetworkConfig, useTempWorkDir } from '../test-helpers/docker-test-fixtures.test-utils';

// After
import { generateDockerCompose, WrapperConfig, baseConfig, mockNetworkConfig, useTempWorkDir } from './service-test-setup.test-utils';

The jest.mock('execa', ...) call and let mockConfig: WrapperConfig declaration remain per-file — Jest hoists jest.mock() before imports are resolved, so the factory cannot reference variables from an imported module. This constraint is documented in the new shared module's JSDoc.

Copilot AI changed the title [WIP] Refactor duplicate test setup across service test files refactor: extract shared service test imports into service-test-setup.test-utils May 18, 2026
Copilot AI requested a review from lpcox May 18, 2026 13:56
Copilot finished work on behalf of lpcox May 18, 2026 13:56
@lpcox lpcox marked this pull request as ready for review May 18, 2026 14:49
Copilot AI review requested due to automatic review settings May 18, 2026 14:49
@lpcox lpcox requested a review from Mossaka as a code owner May 18, 2026 14:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the duplicated 3-line import block found in all 13 src/services/*.test.ts files into a single shared re-export module, so future changes to generateDockerCompose, WrapperConfig, or the test fixtures only require updating one file.

Changes:

  • Adds src/services/service-test-setup.test-utils.ts re-exporting generateDockerCompose, WrapperConfig, baseConfig, mockNetworkConfig, and useTempWorkDir.
  • Updates all 13 service test files to import these symbols from the new shared module.
  • Documents (via JSDoc) why jest.mock('execa', ...) and the mockConfig binding must remain per-file.
Show a summary per file
File Description
src/services/service-test-setup.test-utils.ts New shared re-export module with JSDoc explaining the jest.mock hoisting constraint.
src/services/squid-service.test.ts Replaces 3 imports with the shared one.
src/services/doh-proxy-service.test.ts Replaces 3 imports with the shared one.
src/services/cli-proxy-service.test.ts Replaces 3 imports with the shared one.
src/services/api-proxy-service-rate-limit.test.ts Replaces 3 imports with the shared one.
src/services/api-proxy-service-key-isolation.test.ts Replaces 3 imports with the shared one.
src/services/api-proxy-service-env-forwarding.test.ts Replaces 3 imports with the shared one.
src/services/api-proxy-service-config.test.ts Replaces 3 imports with the shared one.
src/services/agent-volumes.test.ts Replaces 3 imports with the shared one.
src/services/agent-service.test.ts Replaces 3 imports with the shared one.
src/services/agent-environment-runtime.test.ts Replaces 3 imports with the shared one.
src/services/agent-environment-proxy.test.ts Replaces 3 imports with the shared one.
src/services/agent-environment-options.test.ts Replaces 3 imports with the shared one.
src/services/agent-environment-credentials.test.ts Replaces 3 imports with the shared one.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 14/14 changed files
  • Comments generated: 0

@github-actions
Copy link
Copy Markdown
Contributor

🧪 Smoke Test: Copilot BYOK (Offline) Mode

Test Result
GitHub MCP connectivity ❌ 401 Bad credentials (MCP token unavailable)
GitHub.com HTTP connectivity ⚠️ Template vars not substituted (${{ steps.smoke-data.outputs.SMOKE_HTTP_CODE }})
File write/read ⚠️ Template vars not substituted — cannot verify
BYOK inference (agent → api-proxy → api.githubcopilot.com) ✅ Confirmed — agent is responding

Running in BYOK offline mode (COPILOT_OFFLINE=true) via api-proxy → api.githubcopilot.com.

Overall: ⚠️ PARTIAL — BYOK inference works, but pre-step template variables were not interpolated and GitHub MCP returned 401.

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Results

GitHub API: Bad credentials
Playwright: Navigated to github.com, title confirmed
File Verify: smoke-test file exists and readable

Result: FAIL (1/3 tests failed)

💥 [THE END] — Illustrated by Smoke Claude

@github-actions
Copy link
Copy Markdown
Contributor

🔬 Smoke Test Results

Test Status
GitHub MCP connectivity ❌ 401 Bad credentials
GitHub.com HTTP connectivity ⚠️ Template vars not expanded
File write/read (smoke-test-copilot-26038026778.txt) ✅ Content verified

Overall: FAIL — GitHub MCP returned 401; template variables were not substituted before agent invocation.

No PR author/assignee info available (MCP auth unavailable).

📰 BREAKING: Report filed by Smoke Copilot

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test

PR titles: fix: resolve test failures on macOS; fix: postprocess claude-token-optimizer lock file to use local awf build
❌ GitHub MCP review (MCP unavailable; titles retrieved)
❌ safeinputs-gh PR query (tool unavailable)
✅ Playwright title contains GitHub
❌ Tavily search (no tools exposed)
✅ File write/read; ❌ discussion query/comment; ✅ build
Overall status: FAIL

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • registry.npmjs.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "registry.npmjs.org"

See Network Configuration for more information.

🔮 The oracle has spoken through Smoke Codex

@github-actions
Copy link
Copy Markdown
Contributor

🏗️ Build Test Suite Results

Ecosystem Project Build/Install Tests Status
Bun elysia 1/1 passed ✅ PASS
Bun hono 1/1 passed ✅ PASS
C++ fmt N/A ✅ PASS
C++ json N/A ✅ PASS
Deno oak N/A 1/1 passed ✅ PASS
Deno std N/A 1/1 passed ✅ PASS
.NET hello-world N/A ✅ PASS
.NET json-parse N/A ✅ PASS
Go color 1/1 passed ✅ PASS
Go env 1/1 passed ✅ PASS
Go uuid 1/1 passed ✅ PASS
Java gson 1/1 passed ✅ PASS
Java caffeine 1/1 passed ✅ PASS
Node.js clsx All passed ✅ PASS
Node.js execa All passed ✅ PASS
Node.js p-limit All passed ✅ PASS
Rust fd 1/1 passed ✅ PASS
Rust zoxide 1/1 passed ✅ PASS

Overall: 8/8 ecosystems passed — ✅ PASS

Generated by Build Test Suite for issue #3324 · ● 4.4M ·

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test: GitHub Actions Services Connectivity

Check Result
Redis PING ❌ Timeout (no response)
PostgreSQL pg_isready no response
PostgreSQL SELECT 1 ❌ Timeout (no response)

host.docker.internal resolves to 172.17.0.1 but TCP connections to ports 6379 and 5432 timed out — service containers appear unreachable from this runner.

Overall: FAIL

🔌 Service connectivity validated by Smoke Services

@github-actions
Copy link
Copy Markdown
Contributor

Gemini Smoke Test: PASS

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • localhost

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "localhost"

See Network Configuration for more information.

💎 Faceted by Smoke Gemini

@github-actions
Copy link
Copy Markdown
Contributor

Chroot Smoke Test Results

Runtime Host Version Chroot Version Match?
Python Python 3.12.13 Python 3.12.3
Node.js v24.15.0 v20.20.2
Go go1.22.12 go1.22.12

Overall: ❌ Not all tests passed — Python and Node.js versions differ between host and chroot.

Tested by Smoke Chroot

@lpcox lpcox merged commit 6e59b62 into main May 18, 2026
69 of 73 checks passed
@lpcox lpcox deleted the copilot/fix-duplicate-test-setup branch May 18, 2026 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Duplicate Code] Test setup boilerplate duplicated across 13+ service test files

3 participants