-
-
Notifications
You must be signed in to change notification settings - Fork 163
test: align mocks with CommandExecutor options #172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
commit: |
WalkthroughThis pull request introduces test utility refactoring and standardisation across the codebase. A new 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
src/mcp/tools/logging/__tests__/stop_sim_log_cap.test.ts (3)
26-46: Critical: Direct file system access violates DI and lacks cleanup.The helper function creates actual files on disk (line 38) and directly manipulates global state. This approach has multiple issues:
- No DI: Uses
fs/promisesdirectly instead of an injected FileSystemExecutor- No cleanup: Files created in
/tmp/are never deleted, causing test pollution- Global state: Directly mutates
activeLogSessionsmap- Limited testability: Cannot simulate file system errors (permissions, disk full, etc.) without actually causing them
Based on the coding guidelines, this should be refactored to accept and use a mock FileSystemExecutor that can simulate various file operations and error conditions without touching the real filesystem.
11-11: Misleading comment about dependency injection.The comment claims "Converted to pure dependency injection" but the implementation doesn't use DI. Whilst it correctly avoids Vitest mocking utilities (
vi.mock(),vi.fn()), it doesn't inject any executors. Instead, it directly uses the file system and manipulates global state.True DI would involve passing mock FileSystemExecutor instances to the logic function.
14-17: Production code architecture violates DI principles and prevents proper test isolation.The
stopLogCapturefunction insrc/utils/log_capture.tsdoes not accept aFileSystemExecutorparameter, forcing tests to create actual files on disk and directly manipulate the globalactiveLogSessionsstate. This violates the strict DI testing philosophy enforced by the coding guidelines.Contrast with
startLogCapture(line 37 ofsrc/utils/log_capture.ts), which correctly accepts aCommandExecutorparameter—this is the pattern that should be extended tostopLogCapture.Required changes:
- Update
stopLogCapturesignature to acceptFileSystemExecutorparameter- Replace direct
fs.promisescalls (line 169) with executor calls- Update
stop_sim_log_capLogicto accept and pass through the executor- Update test file to inject mock
FileSystemExecutorinstead of creating files in/tmp/- Remove the misleading comment on line 11 claiming "pure dependency injection"—the current implementation is not DI-based
🤖 Fix all issues with AI agents
In @src/mcp/tools/logging/__tests__/stop_sim_log_cap.test.ts:
- Around line 92-94: Refactor stop_sim_log_capLogic to accept a
FileSystemExecutor dependency: change its signature to
stop_sim_log_capLogic(params: StopSimLogCapParams, fileSystem:
FileSystemExecutor): Promise<ToolResponse>, replace any direct filesystem/global
calls inside the function with methods on the injected fileSystem, and update
all call sites and tests (including the instances referenced around lines with
tests creating files) to pass a mock FileSystemExecutor instead of manipulating
real files or globals; ensure the tests construct and inject the mock executor
and assert behavior via the mock rather than filesystem side effects.
🧹 Nitpick comments (4)
src/mcp/tools/session-management/__tests__/session_show_defaults.test.ts (1)
36-36: Consider safer type handling instead of type assertions.The
as stringtype assertion bypasses TypeScript's type checking and assumesresult.content[0].textis always a string. Consider adding runtime validation or ensuring the return type is properly typed upstream.♻️ Proposed refactor for safer type handling
- const parsed = JSON.parse(result.content[0].text as string); + expect(result.content).toHaveLength(1); + expect(typeof result.content[0].text).toBe('string'); + const parsed = JSON.parse(result.content[0].text as string);Alternatively, if the return type can be properly typed in the handler implementation, the type assertion could be removed entirely.
Also applies to: 44-44
src/mcp/tools/ui-testing/__tests__/key_press.test.ts (1)
82-90: Consider usingcreateMockCommandResponsefor consistency.The tracking executors manually construct response objects, whilst
button.test.tsusescreateMockCommandResponsein similar scenarios. For consistency across the test suite, consider refactoring these to use the helper function.♻️ Example refactor for the first tracking executor
const trackingExecutor = async (command: string[]) => { capturedCommand = command; - return { - success: true, - output: 'key press completed', - error: undefined, - process: mockProcess, - }; + return createMockCommandResponse({ + success: true, + output: 'key press completed', + error: undefined, + }); };Note: You'll need to add
createMockCommandResponseto the imports on line 7.Also applies to: 126-134, 172-181, 216-225
src/mcp/tools/macos/__tests__/build_run_macos.test.ts (1)
8-9: Consider importing mockProcess from test-utils.The
mockProcessconstant is defined locally, but it's already exported fromtest-utils/mock-executors.tsand used by other test files in this PR. Importing it would eliminate duplication and improve consistency across the test suite.♻️ Suggested change
import { describe, it, expect, beforeEach } from 'vitest'; -import type { ChildProcess } from 'child_process'; import * as z from 'zod'; -import { createMockExecutor } from '../../../../test-utils/mock-executors.ts'; +import { createMockExecutor, mockProcess } from '../../../../test-utils/mock-executors.ts'; import { sessionStore } from '../../../../utils/session-store.ts'; import tool, { buildRunMacOSLogic } from '../build_run_macos.ts'; -const mockProcess = { pid: 12345 } as unknown as ChildProcess; - describe('build_run_macos', () => {src/mcp/tools/device/__tests__/list_devices.test.ts (1)
249-258: Consider using underscore-prefixed parameter names for consistency.The
voidstatements work to suppress unused parameter warnings, but underscore-prefixed names (e.g.,_command,_logPrefix) would be more idiomatic TypeScript and consistent with the pattern used inmockFsDeps.readFileabove.💡 Suggested refactor
const mockExecutor = async ( - command: string[], - logPrefix?: string, - useShell?: boolean, + _command: string[], + _logPrefix?: string, + _useShell?: boolean, opts?: { env?: Record<string, string> }, - detached?: boolean, + _detached?: boolean, ) => { callCount++; - void command; - void logPrefix; - void useShell; void opts; - void detached;
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (59)
src/mcp/resources/__tests__/simulators.test.tssrc/mcp/tools/device/__tests__/build_device.test.tssrc/mcp/tools/device/__tests__/get_device_app_path.test.tssrc/mcp/tools/device/__tests__/install_app_device.test.tssrc/mcp/tools/device/__tests__/launch_app_device.test.tssrc/mcp/tools/device/__tests__/list_devices.test.tssrc/mcp/tools/device/__tests__/stop_app_device.test.tssrc/mcp/tools/device/__tests__/test_device.test.tssrc/mcp/tools/logging/__tests__/start_device_log_cap.test.tssrc/mcp/tools/logging/__tests__/stop_sim_log_cap.test.tssrc/mcp/tools/macos/__tests__/build_run_macos.test.tssrc/mcp/tools/macos/__tests__/get_mac_app_path.test.tssrc/mcp/tools/macos/__tests__/launch_mac_app.test.tssrc/mcp/tools/macos/__tests__/test_macos.test.tssrc/mcp/tools/project-discovery/__tests__/list_schemes.test.tssrc/mcp/tools/project-discovery/__tests__/show_build_settings.test.tssrc/mcp/tools/project-scaffolding/__tests__/scaffold_ios_project.test.tssrc/mcp/tools/project-scaffolding/__tests__/scaffold_macos_project.test.tssrc/mcp/tools/session-management/__tests__/session_show_defaults.test.tssrc/mcp/tools/simulator-management/__tests__/set_sim_appearance.test.tssrc/mcp/tools/simulator-management/__tests__/set_sim_location.test.tssrc/mcp/tools/simulator-management/__tests__/sim_statusbar.test.tssrc/mcp/tools/simulator/__tests__/boot_sim.test.tssrc/mcp/tools/simulator/__tests__/build_run_sim.test.tssrc/mcp/tools/simulator/__tests__/build_sim.test.tssrc/mcp/tools/simulator/__tests__/install_app_sim.test.tssrc/mcp/tools/simulator/__tests__/list_sims.test.tssrc/mcp/tools/simulator/__tests__/open_sim.test.tssrc/mcp/tools/simulator/__tests__/record_sim_video.test.tssrc/mcp/tools/simulator/__tests__/screenshot.test.tssrc/mcp/tools/simulator/__tests__/stop_app_sim.test.tssrc/mcp/tools/swift-package/__tests__/swift_package_build.test.tssrc/mcp/tools/swift-package/__tests__/swift_package_clean.test.tssrc/mcp/tools/swift-package/__tests__/swift_package_list.test.tssrc/mcp/tools/swift-package/__tests__/swift_package_run.test.tssrc/mcp/tools/swift-package/__tests__/swift_package_test.test.tssrc/mcp/tools/ui-testing/__tests__/button.test.tssrc/mcp/tools/ui-testing/__tests__/describe_ui.test.tssrc/mcp/tools/ui-testing/__tests__/gesture.test.tssrc/mcp/tools/ui-testing/__tests__/key_press.test.tssrc/mcp/tools/ui-testing/__tests__/key_sequence.test.tssrc/mcp/tools/ui-testing/__tests__/long_press.test.tssrc/mcp/tools/ui-testing/__tests__/screenshot.test.tssrc/mcp/tools/ui-testing/__tests__/swipe.test.tssrc/mcp/tools/ui-testing/__tests__/tap.test.tssrc/mcp/tools/ui-testing/__tests__/touch.test.tssrc/mcp/tools/ui-testing/__tests__/type_text.test.tssrc/mcp/tools/ui-testing/button.tssrc/mcp/tools/ui-testing/describe_ui.tssrc/mcp/tools/ui-testing/gesture.tssrc/mcp/tools/ui-testing/key_press.tssrc/mcp/tools/ui-testing/key_sequence.tssrc/mcp/tools/ui-testing/long_press.tssrc/mcp/tools/ui-testing/swipe.tssrc/mcp/tools/ui-testing/tap.tssrc/mcp/tools/ui-testing/touch.tssrc/mcp/tools/ui-testing/type_text.tssrc/mcp/tools/utilities/__tests__/clean.test.tssrc/test-utils/mock-executors.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.{ts,tsx}: Use TypeScript file extensions (.ts) for all relative imports to ensure compatibility with native TypeScript runtimes
Never use .js extensions for internal file imports; always use .ts extensions
Use .js extensions only for external package imports (e.g., @modelcontextprotocol/sdk/server/mcp.js)
Files:
src/mcp/tools/ui-testing/gesture.tssrc/mcp/tools/ui-testing/tap.tssrc/mcp/tools/macos/__tests__/launch_mac_app.test.tssrc/mcp/tools/simulator/__tests__/record_sim_video.test.tssrc/mcp/tools/ui-testing/swipe.tssrc/mcp/tools/project-scaffolding/__tests__/scaffold_macos_project.test.tssrc/mcp/tools/project-discovery/__tests__/show_build_settings.test.tssrc/mcp/tools/ui-testing/long_press.tssrc/mcp/tools/project-scaffolding/__tests__/scaffold_ios_project.test.tssrc/mcp/tools/ui-testing/__tests__/key_sequence.test.tssrc/mcp/tools/device/__tests__/list_devices.test.tssrc/mcp/tools/ui-testing/__tests__/touch.test.tssrc/mcp/tools/ui-testing/__tests__/key_press.test.tssrc/mcp/tools/device/__tests__/install_app_device.test.tssrc/mcp/tools/ui-testing/touch.tssrc/mcp/tools/ui-testing/__tests__/gesture.test.tssrc/mcp/tools/device/__tests__/test_device.test.tssrc/mcp/tools/ui-testing/button.tssrc/mcp/tools/simulator/__tests__/build_sim.test.tssrc/mcp/tools/simulator/__tests__/install_app_sim.test.tssrc/mcp/tools/ui-testing/key_sequence.tssrc/mcp/tools/simulator-management/__tests__/set_sim_location.test.tssrc/test-utils/mock-executors.tssrc/mcp/tools/device/__tests__/get_device_app_path.test.tssrc/mcp/tools/device/__tests__/stop_app_device.test.tssrc/mcp/tools/simulator-management/__tests__/set_sim_appearance.test.tssrc/mcp/tools/macos/__tests__/get_mac_app_path.test.tssrc/mcp/tools/session-management/__tests__/session_show_defaults.test.tssrc/mcp/tools/ui-testing/__tests__/button.test.tssrc/mcp/tools/ui-testing/type_text.tssrc/mcp/tools/swift-package/__tests__/swift_package_build.test.tssrc/mcp/tools/ui-testing/__tests__/screenshot.test.tssrc/mcp/tools/ui-testing/__tests__/describe_ui.test.tssrc/mcp/tools/ui-testing/__tests__/swipe.test.tssrc/mcp/tools/device/__tests__/build_device.test.tssrc/mcp/tools/macos/__tests__/test_macos.test.tssrc/mcp/tools/swift-package/__tests__/swift_package_test.test.tssrc/mcp/tools/utilities/__tests__/clean.test.tssrc/mcp/tools/simulator-management/__tests__/sim_statusbar.test.tssrc/mcp/tools/logging/__tests__/stop_sim_log_cap.test.tssrc/mcp/resources/__tests__/simulators.test.tssrc/mcp/tools/ui-testing/describe_ui.tssrc/mcp/tools/swift-package/__tests__/swift_package_list.test.tssrc/mcp/tools/swift-package/__tests__/swift_package_clean.test.tssrc/mcp/tools/simulator/__tests__/open_sim.test.tssrc/mcp/tools/simulator/__tests__/stop_app_sim.test.tssrc/mcp/tools/device/__tests__/launch_app_device.test.tssrc/mcp/tools/swift-package/__tests__/swift_package_run.test.tssrc/mcp/tools/ui-testing/__tests__/type_text.test.tssrc/mcp/tools/ui-testing/__tests__/tap.test.tssrc/mcp/tools/simulator/__tests__/build_run_sim.test.tssrc/mcp/tools/simulator/__tests__/screenshot.test.tssrc/mcp/tools/ui-testing/__tests__/long_press.test.tssrc/mcp/tools/logging/__tests__/start_device_log_cap.test.tssrc/mcp/tools/macos/__tests__/build_run_macos.test.tssrc/mcp/tools/simulator/__tests__/list_sims.test.tssrc/mcp/tools/simulator/__tests__/boot_sim.test.tssrc/mcp/tools/ui-testing/key_press.tssrc/mcp/tools/project-discovery/__tests__/list_schemes.test.ts
src/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
When Claude Code is detected, automatically consolidate multiple content blocks into a single text response separated by --- dividers to work around MCP specification violation
Files:
src/mcp/tools/ui-testing/gesture.tssrc/mcp/tools/ui-testing/tap.tssrc/mcp/tools/macos/__tests__/launch_mac_app.test.tssrc/mcp/tools/simulator/__tests__/record_sim_video.test.tssrc/mcp/tools/ui-testing/swipe.tssrc/mcp/tools/project-scaffolding/__tests__/scaffold_macos_project.test.tssrc/mcp/tools/project-discovery/__tests__/show_build_settings.test.tssrc/mcp/tools/ui-testing/long_press.tssrc/mcp/tools/project-scaffolding/__tests__/scaffold_ios_project.test.tssrc/mcp/tools/ui-testing/__tests__/key_sequence.test.tssrc/mcp/tools/device/__tests__/list_devices.test.tssrc/mcp/tools/ui-testing/__tests__/touch.test.tssrc/mcp/tools/ui-testing/__tests__/key_press.test.tssrc/mcp/tools/device/__tests__/install_app_device.test.tssrc/mcp/tools/ui-testing/touch.tssrc/mcp/tools/ui-testing/__tests__/gesture.test.tssrc/mcp/tools/device/__tests__/test_device.test.tssrc/mcp/tools/ui-testing/button.tssrc/mcp/tools/simulator/__tests__/build_sim.test.tssrc/mcp/tools/simulator/__tests__/install_app_sim.test.tssrc/mcp/tools/ui-testing/key_sequence.tssrc/mcp/tools/simulator-management/__tests__/set_sim_location.test.tssrc/test-utils/mock-executors.tssrc/mcp/tools/device/__tests__/get_device_app_path.test.tssrc/mcp/tools/device/__tests__/stop_app_device.test.tssrc/mcp/tools/simulator-management/__tests__/set_sim_appearance.test.tssrc/mcp/tools/macos/__tests__/get_mac_app_path.test.tssrc/mcp/tools/session-management/__tests__/session_show_defaults.test.tssrc/mcp/tools/ui-testing/__tests__/button.test.tssrc/mcp/tools/ui-testing/type_text.tssrc/mcp/tools/swift-package/__tests__/swift_package_build.test.tssrc/mcp/tools/ui-testing/__tests__/screenshot.test.tssrc/mcp/tools/ui-testing/__tests__/describe_ui.test.tssrc/mcp/tools/ui-testing/__tests__/swipe.test.tssrc/mcp/tools/device/__tests__/build_device.test.tssrc/mcp/tools/macos/__tests__/test_macos.test.tssrc/mcp/tools/swift-package/__tests__/swift_package_test.test.tssrc/mcp/tools/utilities/__tests__/clean.test.tssrc/mcp/tools/simulator-management/__tests__/sim_statusbar.test.tssrc/mcp/tools/logging/__tests__/stop_sim_log_cap.test.tssrc/mcp/resources/__tests__/simulators.test.tssrc/mcp/tools/ui-testing/describe_ui.tssrc/mcp/tools/swift-package/__tests__/swift_package_list.test.tssrc/mcp/tools/swift-package/__tests__/swift_package_clean.test.tssrc/mcp/tools/simulator/__tests__/open_sim.test.tssrc/mcp/tools/simulator/__tests__/stop_app_sim.test.tssrc/mcp/tools/device/__tests__/launch_app_device.test.tssrc/mcp/tools/swift-package/__tests__/swift_package_run.test.tssrc/mcp/tools/ui-testing/__tests__/type_text.test.tssrc/mcp/tools/ui-testing/__tests__/tap.test.tssrc/mcp/tools/simulator/__tests__/build_run_sim.test.tssrc/mcp/tools/simulator/__tests__/screenshot.test.tssrc/mcp/tools/ui-testing/__tests__/long_press.test.tssrc/mcp/tools/logging/__tests__/start_device_log_cap.test.tssrc/mcp/tools/macos/__tests__/build_run_macos.test.tssrc/mcp/tools/simulator/__tests__/list_sims.test.tssrc/mcp/tools/simulator/__tests__/boot_sim.test.tssrc/mcp/tools/ui-testing/key_press.tssrc/mcp/tools/project-discovery/__tests__/list_schemes.test.ts
**/*.test.{ts,tsx}
📄 CodeRabbit inference engine (AGENTS.md)
**/*.test.{ts,tsx}: Enforce strict Dependency Injection (DI) testing philosophy - completely ban the use of Vitest mocking utilities (vi.mock(), vi.fn(), vi.spyOn(), etc.)
Use injectable executors (CommandExecutor and FileSystemExecutor) for all external interactions instead of mocking
Import core logic functions from tool files and pass mock executors to simulate different test outcomes
Files:
src/mcp/tools/macos/__tests__/launch_mac_app.test.tssrc/mcp/tools/simulator/__tests__/record_sim_video.test.tssrc/mcp/tools/project-scaffolding/__tests__/scaffold_macos_project.test.tssrc/mcp/tools/project-discovery/__tests__/show_build_settings.test.tssrc/mcp/tools/project-scaffolding/__tests__/scaffold_ios_project.test.tssrc/mcp/tools/ui-testing/__tests__/key_sequence.test.tssrc/mcp/tools/device/__tests__/list_devices.test.tssrc/mcp/tools/ui-testing/__tests__/touch.test.tssrc/mcp/tools/ui-testing/__tests__/key_press.test.tssrc/mcp/tools/device/__tests__/install_app_device.test.tssrc/mcp/tools/ui-testing/__tests__/gesture.test.tssrc/mcp/tools/device/__tests__/test_device.test.tssrc/mcp/tools/simulator/__tests__/build_sim.test.tssrc/mcp/tools/simulator/__tests__/install_app_sim.test.tssrc/mcp/tools/simulator-management/__tests__/set_sim_location.test.tssrc/mcp/tools/device/__tests__/get_device_app_path.test.tssrc/mcp/tools/device/__tests__/stop_app_device.test.tssrc/mcp/tools/simulator-management/__tests__/set_sim_appearance.test.tssrc/mcp/tools/macos/__tests__/get_mac_app_path.test.tssrc/mcp/tools/session-management/__tests__/session_show_defaults.test.tssrc/mcp/tools/ui-testing/__tests__/button.test.tssrc/mcp/tools/swift-package/__tests__/swift_package_build.test.tssrc/mcp/tools/ui-testing/__tests__/screenshot.test.tssrc/mcp/tools/ui-testing/__tests__/describe_ui.test.tssrc/mcp/tools/ui-testing/__tests__/swipe.test.tssrc/mcp/tools/device/__tests__/build_device.test.tssrc/mcp/tools/macos/__tests__/test_macos.test.tssrc/mcp/tools/swift-package/__tests__/swift_package_test.test.tssrc/mcp/tools/utilities/__tests__/clean.test.tssrc/mcp/tools/simulator-management/__tests__/sim_statusbar.test.tssrc/mcp/tools/logging/__tests__/stop_sim_log_cap.test.tssrc/mcp/resources/__tests__/simulators.test.tssrc/mcp/tools/swift-package/__tests__/swift_package_list.test.tssrc/mcp/tools/swift-package/__tests__/swift_package_clean.test.tssrc/mcp/tools/simulator/__tests__/open_sim.test.tssrc/mcp/tools/simulator/__tests__/stop_app_sim.test.tssrc/mcp/tools/device/__tests__/launch_app_device.test.tssrc/mcp/tools/swift-package/__tests__/swift_package_run.test.tssrc/mcp/tools/ui-testing/__tests__/type_text.test.tssrc/mcp/tools/ui-testing/__tests__/tap.test.tssrc/mcp/tools/simulator/__tests__/build_run_sim.test.tssrc/mcp/tools/simulator/__tests__/screenshot.test.tssrc/mcp/tools/ui-testing/__tests__/long_press.test.tssrc/mcp/tools/logging/__tests__/start_device_log_cap.test.tssrc/mcp/tools/macos/__tests__/build_run_macos.test.tssrc/mcp/tools/simulator/__tests__/list_sims.test.tssrc/mcp/tools/simulator/__tests__/boot_sim.test.tssrc/mcp/tools/project-discovery/__tests__/list_schemes.test.ts
🧠 Learnings (5)
📓 Common learnings
Learnt from: CR
Repo: cameroncooke/XcodeBuildMCP PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-05T22:47:54.969Z
Learning: Applies to **/*.test.{ts,tsx} : Import core logic functions from tool files and pass mock executors to simulate different test outcomes
Learnt from: CR
Repo: cameroncooke/XcodeBuildMCP PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-05T22:47:54.969Z
Learning: Applies to **/*.test.{ts,tsx} : Use injectable executors (CommandExecutor and FileSystemExecutor) for all external interactions instead of mocking
📚 Learning: 2026-01-05T22:47:54.969Z
Learnt from: CR
Repo: cameroncooke/XcodeBuildMCP PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-05T22:47:54.969Z
Learning: Applies to **/*.test.{ts,tsx} : Use injectable executors (CommandExecutor and FileSystemExecutor) for all external interactions instead of mocking
Applied to files:
src/mcp/tools/ui-testing/gesture.tssrc/mcp/tools/ui-testing/tap.tssrc/mcp/tools/macos/__tests__/launch_mac_app.test.tssrc/mcp/tools/simulator/__tests__/record_sim_video.test.tssrc/mcp/tools/project-scaffolding/__tests__/scaffold_macos_project.test.tssrc/mcp/tools/project-discovery/__tests__/show_build_settings.test.tssrc/mcp/tools/ui-testing/long_press.tssrc/mcp/tools/ui-testing/__tests__/key_sequence.test.tssrc/mcp/tools/device/__tests__/list_devices.test.tssrc/mcp/tools/ui-testing/__tests__/touch.test.tssrc/mcp/tools/ui-testing/__tests__/key_press.test.tssrc/mcp/tools/device/__tests__/install_app_device.test.tssrc/mcp/tools/ui-testing/touch.tssrc/mcp/tools/ui-testing/__tests__/gesture.test.tssrc/mcp/tools/device/__tests__/test_device.test.tssrc/mcp/tools/ui-testing/button.tssrc/mcp/tools/simulator/__tests__/build_sim.test.tssrc/mcp/tools/simulator/__tests__/install_app_sim.test.tssrc/mcp/tools/ui-testing/key_sequence.tssrc/mcp/tools/simulator-management/__tests__/set_sim_location.test.tssrc/test-utils/mock-executors.tssrc/mcp/tools/device/__tests__/get_device_app_path.test.tssrc/mcp/tools/device/__tests__/stop_app_device.test.tssrc/mcp/tools/simulator-management/__tests__/set_sim_appearance.test.tssrc/mcp/tools/macos/__tests__/get_mac_app_path.test.tssrc/mcp/tools/ui-testing/__tests__/button.test.tssrc/mcp/tools/ui-testing/type_text.tssrc/mcp/tools/swift-package/__tests__/swift_package_build.test.tssrc/mcp/tools/ui-testing/__tests__/screenshot.test.tssrc/mcp/tools/ui-testing/__tests__/describe_ui.test.tssrc/mcp/tools/ui-testing/__tests__/swipe.test.tssrc/mcp/tools/device/__tests__/build_device.test.tssrc/mcp/tools/macos/__tests__/test_macos.test.tssrc/mcp/tools/swift-package/__tests__/swift_package_test.test.tssrc/mcp/tools/utilities/__tests__/clean.test.tssrc/mcp/tools/simulator-management/__tests__/sim_statusbar.test.tssrc/mcp/tools/logging/__tests__/stop_sim_log_cap.test.tssrc/mcp/resources/__tests__/simulators.test.tssrc/mcp/tools/ui-testing/describe_ui.tssrc/mcp/tools/swift-package/__tests__/swift_package_list.test.tssrc/mcp/tools/swift-package/__tests__/swift_package_clean.test.tssrc/mcp/tools/simulator/__tests__/open_sim.test.tssrc/mcp/tools/simulator/__tests__/stop_app_sim.test.tssrc/mcp/tools/device/__tests__/launch_app_device.test.tssrc/mcp/tools/swift-package/__tests__/swift_package_run.test.tssrc/mcp/tools/ui-testing/__tests__/type_text.test.tssrc/mcp/tools/ui-testing/__tests__/tap.test.tssrc/mcp/tools/simulator/__tests__/build_run_sim.test.tssrc/mcp/tools/simulator/__tests__/screenshot.test.tssrc/mcp/tools/ui-testing/__tests__/long_press.test.tssrc/mcp/tools/logging/__tests__/start_device_log_cap.test.tssrc/mcp/tools/macos/__tests__/build_run_macos.test.tssrc/mcp/tools/simulator/__tests__/list_sims.test.tssrc/mcp/tools/simulator/__tests__/boot_sim.test.tssrc/mcp/tools/ui-testing/key_press.tssrc/mcp/tools/project-discovery/__tests__/list_schemes.test.ts
📚 Learning: 2026-01-05T22:47:54.969Z
Learnt from: CR
Repo: cameroncooke/XcodeBuildMCP PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-05T22:47:54.969Z
Learning: Applies to **/*.test.{ts,tsx} : Import core logic functions from tool files and pass mock executors to simulate different test outcomes
Applied to files:
src/mcp/tools/ui-testing/gesture.tssrc/mcp/tools/ui-testing/tap.tssrc/mcp/tools/macos/__tests__/launch_mac_app.test.tssrc/mcp/tools/simulator/__tests__/record_sim_video.test.tssrc/mcp/tools/project-scaffolding/__tests__/scaffold_macos_project.test.tssrc/mcp/tools/project-discovery/__tests__/show_build_settings.test.tssrc/mcp/tools/ui-testing/long_press.tssrc/mcp/tools/project-scaffolding/__tests__/scaffold_ios_project.test.tssrc/mcp/tools/ui-testing/__tests__/key_sequence.test.tssrc/mcp/tools/device/__tests__/list_devices.test.tssrc/mcp/tools/ui-testing/__tests__/touch.test.tssrc/mcp/tools/ui-testing/__tests__/key_press.test.tssrc/mcp/tools/device/__tests__/install_app_device.test.tssrc/mcp/tools/ui-testing/touch.tssrc/mcp/tools/ui-testing/__tests__/gesture.test.tssrc/mcp/tools/device/__tests__/test_device.test.tssrc/mcp/tools/ui-testing/button.tssrc/mcp/tools/simulator/__tests__/build_sim.test.tssrc/mcp/tools/simulator/__tests__/install_app_sim.test.tssrc/mcp/tools/ui-testing/key_sequence.tssrc/mcp/tools/simulator-management/__tests__/set_sim_location.test.tssrc/test-utils/mock-executors.tssrc/mcp/tools/device/__tests__/get_device_app_path.test.tssrc/mcp/tools/device/__tests__/stop_app_device.test.tssrc/mcp/tools/simulator-management/__tests__/set_sim_appearance.test.tssrc/mcp/tools/macos/__tests__/get_mac_app_path.test.tssrc/mcp/tools/ui-testing/__tests__/button.test.tssrc/mcp/tools/ui-testing/type_text.tssrc/mcp/tools/swift-package/__tests__/swift_package_build.test.tssrc/mcp/tools/ui-testing/__tests__/screenshot.test.tssrc/mcp/tools/ui-testing/__tests__/describe_ui.test.tssrc/mcp/tools/ui-testing/__tests__/swipe.test.tssrc/mcp/tools/device/__tests__/build_device.test.tssrc/mcp/tools/macos/__tests__/test_macos.test.tssrc/mcp/tools/swift-package/__tests__/swift_package_test.test.tssrc/mcp/tools/utilities/__tests__/clean.test.tssrc/mcp/tools/simulator-management/__tests__/sim_statusbar.test.tssrc/mcp/tools/logging/__tests__/stop_sim_log_cap.test.tssrc/mcp/resources/__tests__/simulators.test.tssrc/mcp/tools/ui-testing/describe_ui.tssrc/mcp/tools/swift-package/__tests__/swift_package_list.test.tssrc/mcp/tools/swift-package/__tests__/swift_package_clean.test.tssrc/mcp/tools/simulator/__tests__/open_sim.test.tssrc/mcp/tools/simulator/__tests__/stop_app_sim.test.tssrc/mcp/tools/device/__tests__/launch_app_device.test.tssrc/mcp/tools/swift-package/__tests__/swift_package_run.test.tssrc/mcp/tools/ui-testing/__tests__/type_text.test.tssrc/mcp/tools/ui-testing/__tests__/tap.test.tssrc/mcp/tools/simulator/__tests__/build_run_sim.test.tssrc/mcp/tools/simulator/__tests__/screenshot.test.tssrc/mcp/tools/ui-testing/__tests__/long_press.test.tssrc/mcp/tools/logging/__tests__/start_device_log_cap.test.tssrc/mcp/tools/macos/__tests__/build_run_macos.test.tssrc/mcp/tools/simulator/__tests__/list_sims.test.tssrc/mcp/tools/simulator/__tests__/boot_sim.test.tssrc/mcp/tools/ui-testing/key_press.tssrc/mcp/tools/project-discovery/__tests__/list_schemes.test.ts
📚 Learning: 2026-01-05T22:47:54.969Z
Learnt from: CR
Repo: cameroncooke/XcodeBuildMCP PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-05T22:47:54.969Z
Learning: Applies to **/*.test.{ts,tsx} : Enforce strict Dependency Injection (DI) testing philosophy - completely ban the use of Vitest mocking utilities (vi.mock(), vi.fn(), vi.spyOn(), etc.)
Applied to files:
src/mcp/tools/macos/__tests__/launch_mac_app.test.tssrc/mcp/tools/simulator/__tests__/record_sim_video.test.tssrc/mcp/tools/project-discovery/__tests__/show_build_settings.test.tssrc/mcp/tools/ui-testing/__tests__/key_sequence.test.tssrc/mcp/tools/device/__tests__/list_devices.test.tssrc/mcp/tools/ui-testing/__tests__/touch.test.tssrc/mcp/tools/ui-testing/__tests__/gesture.test.tssrc/mcp/tools/device/__tests__/test_device.test.tssrc/mcp/tools/simulator/__tests__/build_sim.test.tssrc/mcp/tools/simulator-management/__tests__/set_sim_location.test.tssrc/mcp/tools/device/__tests__/get_device_app_path.test.tssrc/mcp/tools/simulator-management/__tests__/set_sim_appearance.test.tssrc/mcp/tools/macos/__tests__/get_mac_app_path.test.tssrc/mcp/tools/ui-testing/__tests__/button.test.tssrc/mcp/tools/ui-testing/__tests__/screenshot.test.tssrc/mcp/tools/ui-testing/__tests__/describe_ui.test.tssrc/mcp/tools/ui-testing/__tests__/swipe.test.tssrc/mcp/tools/device/__tests__/build_device.test.tssrc/mcp/tools/macos/__tests__/test_macos.test.tssrc/mcp/tools/utilities/__tests__/clean.test.tssrc/mcp/tools/simulator-management/__tests__/sim_statusbar.test.tssrc/mcp/tools/logging/__tests__/stop_sim_log_cap.test.tssrc/mcp/resources/__tests__/simulators.test.tssrc/mcp/tools/simulator/__tests__/open_sim.test.tssrc/mcp/tools/simulator/__tests__/stop_app_sim.test.tssrc/mcp/tools/swift-package/__tests__/swift_package_run.test.tssrc/mcp/tools/ui-testing/__tests__/type_text.test.tssrc/mcp/tools/ui-testing/__tests__/tap.test.tssrc/mcp/tools/simulator/__tests__/build_run_sim.test.tssrc/mcp/tools/ui-testing/__tests__/long_press.test.tssrc/mcp/tools/macos/__tests__/build_run_macos.test.tssrc/mcp/tools/simulator/__tests__/list_sims.test.tssrc/mcp/tools/simulator/__tests__/boot_sim.test.tssrc/mcp/tools/project-discovery/__tests__/list_schemes.test.ts
📚 Learning: 2026-01-05T22:47:54.969Z
Learnt from: CR
Repo: cameroncooke/XcodeBuildMCP PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-05T22:47:54.969Z
Learning: Applies to src/tools/**/*.ts : Organize tools into directories by their functionality and use automatic loading via plugin-based MCP architecture
Applied to files:
src/mcp/tools/project-scaffolding/__tests__/scaffold_macos_project.test.tssrc/mcp/tools/device/__tests__/test_device.test.tssrc/mcp/tools/device/__tests__/build_device.test.tssrc/mcp/tools/utilities/__tests__/clean.test.tssrc/mcp/tools/project-discovery/__tests__/list_schemes.test.ts
🧬 Code graph analysis (39)
src/mcp/tools/macos/__tests__/launch_mac_app.test.ts (1)
src/test-utils/mock-executors.ts (1)
createMockCommandResponse(26-36)
src/mcp/tools/project-scaffolding/__tests__/scaffold_macos_project.test.ts (1)
src/test-utils/mock-executors.ts (1)
createMockCommandResponse(26-36)
src/mcp/tools/project-discovery/__tests__/show_build_settings.test.ts (3)
src/test-utils/mock-executors.ts (1)
CommandExecutor(22-22)src/utils/command.ts (1)
CommandExecutor(20-20)src/utils/CommandExecutor.ts (1)
CommandExecutor(11-17)
src/mcp/tools/ui-testing/__tests__/key_sequence.test.ts (1)
src/test-utils/mock-executors.ts (1)
mockProcess(24-24)
src/mcp/tools/device/__tests__/list_devices.test.ts (1)
src/test-utils/mock-executors.ts (1)
createMockCommandResponse(26-36)
src/mcp/tools/ui-testing/__tests__/touch.test.ts (1)
src/test-utils/mock-executors.ts (1)
mockProcess(24-24)
src/mcp/tools/ui-testing/__tests__/key_press.test.ts (1)
src/test-utils/mock-executors.ts (1)
mockProcess(24-24)
src/mcp/tools/device/__tests__/install_app_device.test.ts (1)
src/test-utils/mock-executors.ts (1)
createMockExecutor(43-105)
src/mcp/tools/ui-testing/__tests__/gesture.test.ts (1)
src/test-utils/mock-executors.ts (1)
mockProcess(24-24)
src/mcp/tools/device/__tests__/test_device.test.ts (1)
src/test-utils/mock-executors.ts (1)
createMockCommandResponse(26-36)
src/mcp/tools/simulator/__tests__/build_sim.test.ts (3)
src/test-utils/mock-executors.ts (2)
CommandExecutor(22-22)createMockCommandResponse(26-36)src/utils/command.ts (1)
CommandExecutor(20-20)src/utils/CommandExecutor.ts (1)
CommandExecutor(11-17)
src/mcp/tools/simulator-management/__tests__/set_sim_location.test.ts (1)
src/test-utils/mock-executors.ts (1)
createMockCommandResponse(26-36)
src/test-utils/mock-executors.ts (1)
src/utils/CommandExecutor.ts (1)
CommandResponse(22-28)
src/mcp/tools/device/__tests__/get_device_app_path.test.ts (1)
src/test-utils/mock-executors.ts (1)
createMockCommandResponse(26-36)
src/mcp/tools/device/__tests__/stop_app_device.test.ts (1)
src/test-utils/mock-executors.ts (1)
createMockExecutor(43-105)
src/mcp/tools/simulator-management/__tests__/set_sim_appearance.test.ts (1)
src/test-utils/mock-executors.ts (1)
createMockCommandResponse(26-36)
src/mcp/tools/macos/__tests__/get_mac_app_path.test.ts (1)
src/test-utils/mock-executors.ts (1)
createMockCommandResponse(26-36)
src/mcp/tools/ui-testing/__tests__/button.test.ts (3)
src/test-utils/mock-executors.ts (2)
CommandExecutor(22-22)createMockCommandResponse(26-36)src/utils/command.ts (1)
CommandExecutor(20-20)src/utils/CommandExecutor.ts (1)
CommandExecutor(11-17)
src/mcp/tools/swift-package/__tests__/swift_package_build.test.ts (3)
src/test-utils/mock-executors.ts (2)
CommandExecutor(22-22)createMockCommandResponse(26-36)src/utils/command.ts (1)
CommandExecutor(20-20)src/utils/CommandExecutor.ts (1)
CommandExecutor(11-17)
src/mcp/tools/ui-testing/__tests__/screenshot.test.ts (1)
src/test-utils/mock-executors.ts (1)
mockProcess(24-24)
src/mcp/tools/ui-testing/__tests__/swipe.test.ts (1)
src/test-utils/mock-executors.ts (1)
mockProcess(24-24)
src/mcp/tools/device/__tests__/build_device.test.ts (1)
src/test-utils/mock-executors.ts (1)
createMockCommandResponse(26-36)
src/mcp/tools/macos/__tests__/test_macos.test.ts (2)
src/test-utils/mock-executors.ts (3)
FileSystemExecutor(22-22)createMockFileSystemExecutor(195-211)createMockCommandResponse(26-36)src/utils/FileSystemExecutor.ts (1)
FileSystemExecutor(5-16)
src/mcp/tools/swift-package/__tests__/swift_package_test.test.ts (2)
src/test-utils/mock-executors.ts (2)
CommandExecutor(22-22)createMockCommandResponse(26-36)src/utils/CommandExecutor.ts (1)
CommandExecutor(11-17)
src/mcp/tools/utilities/__tests__/clean.test.ts (1)
src/test-utils/mock-executors.ts (1)
createMockCommandResponse(26-36)
src/mcp/tools/simulator-management/__tests__/sim_statusbar.test.ts (2)
src/test-utils/mock-executors.ts (2)
CommandExecutor(22-22)createMockCommandResponse(26-36)src/utils/CommandExecutor.ts (1)
CommandExecutor(11-17)
src/mcp/tools/logging/__tests__/stop_sim_log_cap.test.ts (1)
src/mcp/tools/logging/stop_sim_log_cap.ts (1)
stop_sim_log_capLogic(24-41)
src/mcp/resources/__tests__/simulators.test.ts (1)
src/test-utils/mock-executors.ts (1)
createMockCommandResponse(26-36)
src/mcp/tools/swift-package/__tests__/swift_package_list.test.ts (1)
src/test-utils/mock-executors.ts (1)
mockProcess(24-24)
src/mcp/tools/swift-package/__tests__/swift_package_clean.test.ts (2)
src/test-utils/mock-executors.ts (2)
CommandExecutor(22-22)createMockCommandResponse(26-36)src/utils/CommandExecutor.ts (1)
CommandExecutor(11-17)
src/mcp/tools/swift-package/__tests__/swift_package_run.test.ts (3)
src/test-utils/mock-executors.ts (2)
CommandExecutor(22-22)createMockCommandResponse(26-36)src/utils/command.ts (1)
CommandExecutor(20-20)src/utils/CommandExecutor.ts (1)
CommandExecutor(11-17)
src/mcp/tools/ui-testing/__tests__/type_text.test.ts (1)
src/test-utils/mock-executors.ts (1)
mockProcess(24-24)
src/mcp/tools/simulator/__tests__/build_run_sim.test.ts (3)
src/test-utils/mock-executors.ts (2)
CommandExecutor(22-22)createMockCommandResponse(26-36)src/utils/command.ts (1)
CommandExecutor(20-20)src/utils/CommandExecutor.ts (1)
CommandExecutor(11-17)
src/mcp/tools/simulator/__tests__/screenshot.test.ts (1)
src/utils/CommandExecutor.ts (1)
CommandExecutor(11-17)
src/mcp/tools/ui-testing/__tests__/long_press.test.ts (1)
src/test-utils/mock-executors.ts (1)
mockProcess(24-24)
src/mcp/tools/macos/__tests__/build_run_macos.test.ts (1)
src/test-utils/mock-executors.ts (1)
mockProcess(24-24)
src/mcp/tools/simulator/__tests__/list_sims.test.ts (1)
src/test-utils/mock-executors.ts (1)
createMockCommandResponse(26-36)
src/mcp/tools/simulator/__tests__/boot_sim.test.ts (1)
src/test-utils/mock-executors.ts (1)
createMockCommandResponse(26-36)
src/mcp/tools/project-discovery/__tests__/list_schemes.test.ts (1)
src/test-utils/mock-executors.ts (1)
createMockCommandResponse(26-36)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Seer Code Review
- GitHub Check: Cursor Bugbot
ec133eb to
7c7a7fd
Compare
Summary
Testing
Note
Modernizes executor interfaces and test harnesses, plus adds filesystem DI to logging workflows.
CommandExecutorusage: mocks now acceptopts(env/cwd) and return fullCommandResponseviacreateMockCommandResponseFileSystemExecutorDI to logging and launch flows:start_device_log_cap,stop_device_log_cap,stop_sim_log_cap, andlaunch_app_devicenow use injected FS for temp files, cleanup, and retentiontsconfig.test.json(singletypecheck/typecheck:tests)Written by Cursor Bugbot for commit 7c7a7fd. This will update automatically on new commits. Configure here.