@@ -7,9 +7,11 @@ import { describe, expect, it, vi } from 'vitest'
77/**
88 * The handler map is a wiring table from tool id to implementation. Only its
99 * shape is asserted here, so every implementation module it imports is stubbed
10- * — loading them for real reaches the block registry, the executor, and most
11- * of `lib/`. Every export resolves to a mock function, which is all the table
12- * needs to bind.
10+ * except `workflow/mutations`, which holds the cancellation handler under test
11+ * and loads for real so a renamed or removed export fails at link time.
12+ * Loading the rest reaches the block registry, the executor, and most of
13+ * `lib/`; every stubbed export resolves to a mock function, which is all the
14+ * table needs to bind.
1315 */
1416const { stubHandlerModule } = vi . hoisted ( ( ) => ( {
1517 stubHandlerModule : ( ) =>
@@ -40,19 +42,20 @@ vi.mock('@/lib/copilot/tools/handlers/restore-resource', stubHandlerModule)
4042vi . mock ( '@/lib/copilot/tools/handlers/run-code' , stubHandlerModule )
4143vi . mock ( '@/lib/copilot/tools/handlers/vfs' , stubHandlerModule )
4244vi . mock ( '@/lib/copilot/tools/handlers/vfs-mutate' , stubHandlerModule )
43- vi . mock ( '@/lib/copilot/tools/handlers/workflow/mutations' , stubHandlerModule )
4445vi . mock ( '@/lib/copilot/tools/handlers/workflow/queries' , stubHandlerModule )
4546
4647/** Server-router tools are appended to the map from their own registry, which this test does not cover. */
4748vi . mock ( '@/lib/copilot/tools/server/router' , ( ) => ( { getRegisteredServerToolNames : ( ) => [ ] } ) )
4849
4950import { hasHandler } from '@/lib/copilot/tool-executor/executor'
51+ import { buildHandlerMap } from '@/lib/copilot/tool-executor/handler-map'
5052import { ensureHandlersRegistered } from '@/lib/copilot/tool-executor/register-handlers'
5153import {
5254 getToolEntry ,
5355 isSimExecuted ,
5456 toolRequiresApproval ,
5557} from '@/lib/copilot/tool-executor/router'
58+ import { executeCancelWorkflowRun } from '@/lib/copilot/tools/handlers/workflow/mutations'
5659
5760describe ( 'workflow-run cancellation tool routing' , ( ) => {
5861 it ( 'routes cancellation through Sim with write permission and explicit approval' , ( ) => {
@@ -68,5 +71,7 @@ describe('workflow-run cancellation tool routing', () => {
6871 await ensureHandlersRegistered ( )
6972
7073 expect ( hasHandler ( 'cancel_workflow_run' ) ) . toBe ( true )
74+ expect ( executeCancelWorkflowRun ) . toBeTypeOf ( 'function' )
75+ expect ( buildHandlerMap ( ) . cancel_workflow_run ) . toBe ( executeCancelWorkflowRun )
7176 } )
7277} )
0 commit comments