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)
Problem
35 of 45 tool handlers in
src/toolLayer.tshave nohandleTool()integration test. The only handler-level tests are intest/nativeTools.test.ts(error paths fornative_*andext_*). Unit tests for individual modules (diagnose, HAR, registry) exist, but there is no test that exercises the fullhandleTool()dispatch path for:browser_navigate,browser_click,browser_snapshot,browser_emulate,browser_throttle,repro, etc.)pane_list,pane_new,pane_select,pane_close,pane_pop,pane_set_label)dev_start,dev_stop,dev_status)get_logs,get_logs_around,clear_logs,diagnose,export_bundle)get_network,export_har)This means that regressions in the dispatch switch, argument coercion, or error formatting are invisible to
bun testuntil a smoke test or manual test catches them.Proposed Approach
Follow the pattern established in
test/nativeTools.test.ts: create mock implementations ofIBrowserController,IDevServer,ILogBuffer, and related deps, inject them viaconfigureTools(), then callhandleTool("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 + throttletest/paneTools.test.ts— pane_* (using a mockIBrowserManager)test/devServerTools.test.ts— dev_start / dev_stop / dev_statustest/logTools.test.ts— get_logs, get_logs_around, diagnose, export_bundletest/reproHandler.test.ts— single-action, multi-step, continueOnError, stoppedAtStep, error accumulationCoverage target: every handler reachable from
handleTool()exercised at least for the happy path and the primary error path.Run with:
bun testAffected Files
src/toolLayer.ts(switch cases being tested)test/(new test files)test/nativeTools.test.ts(existing pattern to follow)