claude-code-best/tests/mocks/api-responses.ts
James Feng 76c47956dd fix: resolve ~50 CodeQL alerts — unused, injection, type issues
unused-local-variable / useless-assignment (~30 alerts):
- mcp-client: manager.ts (11), connection.ts (3)
- acp-link: server.ts (4), rcs-upstream.ts
- remote-control-server: 10 files (SessionDetail, acp/client, transports, etc.)
- src: constants/tools.ts, attribution.ts, win32.ts, main.tsx, attachments.ts

log-injection (2):
- chromeNativeHost.ts, rcs-upstream.ts — apply sanitizeLog()

indirect-command-line-injection (4):
- imagePaste.ts: convert shell:true to explicit sh -c pattern

use-before-declaration (4):
- query.ts, claude.ts, tools.ts, attachments.ts — move feature() import up

comparison-between-incompatible-types (2):
- ExitPlanModePermissionRequest.tsx, useTerminalNotification.ts

shared: sensitive.ts — sanitizeLog() helper
2026-06-08 17:15:22 +08:00

35 lines
773 B
TypeScript

export const mockStreamResponse = {
type: 'message_start' as const,
message: {
id: 'msg_mock_001',
type: 'message' as const,
role: 'assistant',
content: [],
model: 'claude-sonnet-4-20250514',
stop_reason: null,
stop_sequence: null,
usage: { input_tokens: 100, output_tokens: 0 },
},
}
export const mockTextBlock = {
type: 'content_block_start' as const,
index: 0,
content_block: { type: 'text' as const, text: 'Mock response' },
}
export const mockToolUseBlock = {
type: 'content_block_start' as const,
index: 1,
content_block: {
type: 'tool_use' as const,
id: 'toolu_mock_001',
name: 'Read',
input: { file_path: '/tmp/test.txt' },
},
}
export const mockEndEvent = {
type: 'message_stop' as const,
}