openpencil/apps/web/server/__tests__
Fini ab35c0d777 test(ai): Nitro /api/mcp/exec-tool endpoint unit tests (12 cases)
Covers the endpoint's full responsibility matrix:
- 400: missing body / unknown tool name (via different branches)
- 404: unknown tool, invalid pageId, invalid parent_id,
  invalid default_parent_id
- 409: no live-canvas doc synced (element-tool route + DSL route)
- 501: real filePath (live://canvas is accepted as sentinel)
- 400: DSL with parse errors (per-line preview in message)
- happy paths: element-tool writes to sync-state; parent_id
  actually nests inserted node under named container; DSL
  route invokes runBatchDesignDsl + returns inserted IDs

Uses `vi.mock('h3', ...)` so the handler runs as a plain async
function — no live Nitro runtime. `clearSyncState()` in each
beforeEach isolates doc-mutation cases. server-logger mocked to
keep test output clean.

Full-repo: 2010 tests across 209 files.
2026-04-22 00:41:15 +08:00
..
agent-tool-guard.test.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
exec-tool-endpoint.test.ts test(ai): Nitro /api/mcp/exec-tool endpoint unit tests (12 cases) 2026-04-22 00:41:15 +08:00
mcp-screenshot-rpc.test.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
mcp-sync-state-active.test.ts V0.7.1 (#102) 2026-04-13 21:30:23 +08:00
provider-url-presets.test.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
provider-url.test.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00
security.test.ts V0.7.2-bugfix (#109) 2026-04-14 21:42:56 +08:00
sse-keepalive.test.ts V0.7.0 (#95) 2026-04-11 23:25:13 +08:00