Skip to content

Add handleTool() integration tests for browser, pane, dev-server, and repro handlers #28

Description

@vincentvella

Problem

35 of 45 tool handlers in src/toolLayer.ts have no handleTool() integration test. The only handler-level tests are in test/nativeTools.test.ts (error paths for native_* and ext_*). Unit tests for individual modules (diagnose, HAR, registry) exist, but there is no test that exercises the full handleTool() dispatch path for:

  • All 16 browser control tools (browser_navigate, browser_click, browser_snapshot, browser_emulate, browser_throttle, repro, etc.)
  • All 6 pane management tools (pane_list, pane_new, pane_select, pane_close, pane_pop, pane_set_label)
  • All 3 dev-server tools (dev_start, dev_stop, dev_status)
  • All 5 logging/diagnostic tools (get_logs, get_logs_around, clear_logs, diagnose, export_bundle)
  • All 2 network tools (get_network, export_har)

This means that regressions in the dispatch switch, argument coercion, or error formatting are invisible to bun test until a smoke test or manual test catches them.

Proposed Approach

Follow the pattern established in test/nativeTools.test.ts: create mock implementations of IBrowserController, IDevServer, ILogBuffer, and related deps, inject them via configureTools(), then call handleTool("tool_name", args) and assert on the result shape and the calls made to the mocks.

Suggested file breakdown:

  • test/browserTools.test.ts — browser control + snapshot + emulate + throttle
  • test/paneTools.test.ts — pane_* (using a mock IBrowserManager)
  • test/devServerTools.test.ts — dev_start / dev_stop / dev_status
  • test/logTools.test.ts — get_logs, get_logs_around, diagnose, export_bundle
  • test/reproHandler.test.ts — single-action, multi-step, continueOnError, stoppedAtStep, error accumulation

Coverage target: every handler reachable from handleTool() exercised at least for the happy path and the primary error path.

Run with: bun test

Affected Files

  • src/toolLayer.ts (switch cases being tested)
  • test/ (new test files)
  • test/nativeTools.test.ts (existing pattern to follow)

Metadata

Metadata

Assignees

Labels

testTest coverage

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions