Skip to content

refactor(tests): extract makeMockExecaProcess helper in log-streamer.test.ts#3482

Merged
lpcox merged 2 commits into
mainfrom
copilot/fix-duplicate-code-in-log-streamer-tests
May 21, 2026
Merged

refactor(tests): extract makeMockExecaProcess helper in log-streamer.test.ts#3482
lpcox merged 2 commits into
mainfrom
copilot/fix-duplicate-code-in-log-streamer-tests

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 20, 2026

A 10-line mockStdout + mockProcess construction block was copy-pasted 3 times across src/logs/log-streamer.test.ts, meaning any change to the mock process shape (e.g. adding stderr) required edits in multiple places.

Changes

  • src/logs/log-streamer.test.ts: Extracted a makeMockExecaProcess helper that creates an empty Readable stdout and a jest.fn() kill mock, replacing the 3 identical inline blocks:
function makeMockExecaProcess(): { stdout: Readable; kill: jest.Mock } {
  const stdout = new Readable({ read() { this.push(null); } });
  return { stdout, kill: jest.fn() };
}

// Each call site becomes:
const mockProcess = makeMockExecaProcess();
mockedExeca.mockReturnValue(mockProcess as never);

The first test's mock (which pushes actual log data to exercise output assertions) is left as-is since it has distinct behaviour.

Copilot AI changed the title [WIP] Refactor duplicate mockStdout and mockProcess in log-streamer tests refactor(tests): extract makeMockExecaProcess helper in log-streamer.test.ts May 20, 2026
Copilot finished work on behalf of lpcox May 20, 2026 23:19
Copilot AI requested a review from lpcox May 20, 2026 23:19
@lpcox lpcox marked this pull request as ready for review May 20, 2026 23:55
Copilot AI review requested due to automatic review settings May 20, 2026 23:55
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 log-streamer unit tests by extracting a small helper to build a minimal mocked execa child-process, reducing repeated mock setup and making future mock-shape changes easier to apply consistently.

Changes:

  • Added makeMockExecaProcess() helper to centralize creation of an empty Readable stdout and kill mock.
  • Replaced three duplicated inline mockStdout + mockProcess blocks with calls to the new helper.
  • Kept the first test’s bespoke stdout mock (which emits log data) unchanged.
Show a summary per file
File Description
src/logs/log-streamer.test.ts Deduplicates repeated execa process mock construction via a new makeMockExecaProcess() helper.

Copilot's findings

Tip

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

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

@github-actions
Copy link
Copy Markdown
Contributor

✅ Coverage Check Passed

Overall Coverage

Metric Base PR Delta
Lines 95.73% 95.80% 📈 +0.07%
Statements 95.56% 95.63% 📈 +0.07%
Functions 96.86% 96.86% ➡️ +0.00%
Branches 89.30% 89.34% 📈 +0.04%
📁 Per-file Coverage Changes (1 files)
File Lines (Before → After) Statements (Before → After)
src/config-writer.ts 83.0% → 85.6% (+2.54%) 83.0% → 85.6% (+2.54%)

Coverage comparison generated by scripts/ci/compare-coverage.ts

@github-actions
Copy link
Copy Markdown
Contributor

🔬 Smoke Test Results

Test Status
GitHub MCP connectivity
GitHub.com HTTP connectivity ⚠️ pre-step data unavailable
File write/read ⚠️ pre-step data unavailable

PR: refactor(tests): extract makeMockExecaProcess helper in log-streamer.test.ts
Author: @Copilot · Assignees: @lpcox, @Copilot

Overall: PARTIAL — GitHub MCP confirmed working; pre-computed smoke data was not expanded (template variables not substituted by runner).

📰 BREAKING: Report filed by Smoke Copilot

@github-actions
Copy link
Copy Markdown
Contributor

🔥 Smoke Test: Copilot BYOK (Offline) Mode

Test Result
GitHub MCP connectivity
GitHub.com HTTP ⚠️ (pre-step template not expanded)
File write/read ⚠️ (pre-step template not expanded)
BYOK inference (this response)

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

Author: @Copilot | Assignees: @lpcox, @Copilot

Overall: PARTIAL PASS (BYOK inference and MCP confirmed ✅; pre-step data unavailable)

🔑 BYOK report filed by Smoke Copilot BYOK

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test Results

GitHub API - 2 PR entries confirmed in recent-prs.json
Playwright - GitHub.com loads successfully (title contains "GitHub")
File Verify - Smoke test file exists and validates

Status: PASS — All smoke tests passed.

💥 [THE END] — Illustrated by Smoke Claude

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test: FAIL
Merged PRs: fix: align OTEL attributes with gen_ai semconv spec; fix: Use --build-local in smoke-otel-tracing for latest api-proxy code
✅ GitHub PR review
❌ Safe Inputs GH CLI (safeinputs-gh unavailable)
✅ Playwright title
❌ Tavily search (no exposed tools)
✅ File write/read
❌ Discussion safe-input (github-discussion-query unavailable; fallback comment posted)
✅ 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

Chroot Version Comparison Results

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

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

Tested by Smoke Chroot

@github-actions
Copy link
Copy Markdown
Contributor

Smoke test result: FAIL. Connectivity and MCP PR listing failed. File writing and bash tools passed.

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

🏗️ 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 #3482 · ● 3.9M ·

@github-actions
Copy link
Copy Markdown
Contributor

Smoke Test: GitHub Actions Services Connectivity

Check Result
Redis PING ❌ Timeout (no response on host.docker.internal:6379)
PostgreSQL pg_isready ❌ No response on host.docker.internal:5432
PostgreSQL SELECT 1 ❌ Could not connect

Overall: FAIL — Service containers are unreachable. host.docker.internal does not resolve to a reachable host, and localhost also shows no services running on ports 6379/5432. The GitHub Actions service containers may not have started or are not accessible from this runner context.

🔌 Service connectivity validated by Smoke Services

@lpcox lpcox merged commit 27e609a into main May 21, 2026
66 of 70 checks passed
@lpcox lpcox deleted the copilot/fix-duplicate-code-in-log-streamer-tests branch May 21, 2026 00:22
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] Repeated mockStdout/mockProcess construction block duplicated 4 times in log-streamer.test.ts

3 participants