Skip to content

Test/test most core func#30

Merged
claude-code-best merged 15 commits intomainfrom
test/test-most-core-func
Apr 2, 2026
Merged

Test/test most core func#30
claude-code-best merged 15 commits intomainfrom
test/test-most-core-func

Conversation

@claude-code-best
Copy link
Copy Markdown
Owner

@claude-code-best claude-code-best commented Apr 2, 2026

Summary by CodeRabbit

  • Documentation

    • Added comprehensive testing specifications outlining test framework, structure, and coverage priorities for the project.
    • Added test plan documentation detailing coverage strategies for core systems including tools, utilities, permissions, and configuration modules.
  • Tests

    • Added extensive unit test coverage for utilities, tools, and shared functionality to improve code reliability.

claude-code-best and others added 15 commits April 1, 2026 21:19
覆盖 buildTool、toolMatchesName、findToolByName、getEmptyToolPermissionContext、
filterToolProgressMessages、parseToolPreset、parseGitCommitId、detectGitOperation
共 46 个测试用例全部通过。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
覆盖 xml, hash, stringUtils, semver, uuid, format, frontmatterParser,
file, glob, diff 共 10 个模块的纯函数测试。
json.ts 因模块加载链路过重暂跳过。
共 190 个测试用例(含已有 array/set)全部通过。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
覆盖 stripHtmlComments、isMemoryFilePath、getLargeMemoryFiles、
buildEffectiveSystemPrompt 等函数,共 25 个测试用例全部通过。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
覆盖 escapeRuleContent、unescapeRuleContent、permissionRuleValueFromString、
permissionRuleValueToString、normalizeLegacyToolName,共 25 个测试用例。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
覆盖 isModelAlias、isModelFamilyAlias、getAPIProvider、
isFirstPartyAnthropicBaseUrl、firstPartyNameToCanonical,共 40 个测试用例。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
覆盖 parseCronExpression、computeNextCronRun、cronToHuman,
包含有效/无效表达式、字段范围验证、下次运行计算、人类可读描述,
共 38 个测试用例。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
为 normalizeGitRemoteUrl 添加 18 个测试用例,覆盖 SSH、HTTPS、
ssh://、CCR 代理 URL 格式、大小写规范化及边界条件。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
为 SettingsSchema、PermissionsSchema、AllowedMcpServerEntrySchema
验证,MCP 类型守卫,设置常量函数,以及 validation 工具函数添加
62 个测试用例。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
为消息创建、查询、文本提取、规范化等函数添加 56 个测试用例,
覆盖 createAssistantMessage、createUserMessage、isSyntheticMessage、
extractTag、isNotEmptyMessage、normalizeMessages 等核心功能。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
在 testing-spec.md 新增第 11 节,按 P0/P1/P2 分类记录 25 个
测试文件的覆盖范围、测试数量及已知的重依赖限制。

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- json.test.ts: 27 tests (safeParseJSON, safeParseJSONC, parseJSONL, addItemToJSONCArray)
- truncate.test.ts: 24 tests (truncateToWidth, truncateStartToWidth, truncatePathMiddle, truncate, wrapText)
- path.test.ts: 15 tests (containsPathTraversal, normalizePathForConfigKey)
- tokens.test.ts: 22 tests (getTokenCountFromUsage, getTokenUsage, tokenCountFromLastAPIResponse, etc.)

使用 mock.module() 切断 log.ts/tokenEstimation.ts/slowOperations.ts 重依赖链

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- FileEditTool/utils.test.ts: 24 tests (normalizeQuotes, stripTrailingWhitespace, findActualString, preserveQuoteStyle, applyEditToFile)
- permissions/permissions.test.ts: 13 tests (getDenyRuleForTool, getAskRuleForTool, getDenyRuleForAgent, filterDeniedAgents)
- tools.test.ts: 扩展 5 tests (filterToolsByDenyRules 过滤逻辑)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- 新增 json/truncate/path/tokens/FileEditTool/permissions 测试记录
- 更新已知限制(Bun.JSONL bug, spawnMultiAgent 重依赖)
- 添加 Mock 策略总结章节

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@mintlify
Copy link
Copy Markdown

mintlify bot commented Apr 2, 2026

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
ccb-863780bf 🟢 Ready View Preview Apr 2, 2026, 12:46 AM

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 2, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The PR introduces comprehensive test planning documentation and implementing test suites across the codebase. It adds nine test-plan documents specifying coverage requirements for tool systems, utilities, context building, permissions, model routing, message handling, cron operations, git utilities, and configuration. Additionally, a testing specification is included alongside numerous test files implementing coverage for the specified modules using Bun's testing framework. The README is also updated with sponsorship information and V5 roadmap details.

Changes

Cohort / File(s) Summary
Documentation Updates
README.md
Updated sponsorship amount ($800 → $1000), expanded V5 roadmap details, modified blockquote wording, updated survival record entries with new milestones (48 小时), and removed sponsor address paragraph.
Test Plans
docs/test-plans/01-tool-system.md, docs/test-plans/02-utils-pure-functions.md, docs/test-plans/03-context-building.md, docs/test-plans/04-permission-system.md, docs/test-plans/05-model-routing.md, docs/test-plans/06-message-handling.md, docs/test-plans/07-cron.md, docs/test-plans/08-git-utils.md, docs/test-plans/09-config-settings.md
Added nine comprehensive test-plan documents specifying unit and integration test coverage for tool systems, utility pure functions, context building, permissions, model routing, message handling, cron utilities, git utilities, and configuration/settings modules.
Testing Specification
docs/testing-spec.md
New document defining testing conventions using Bun framework, test organization, mock strategies, coverage targets by priority level (P0/P1/P2), CI integration, and current coverage status.
Tool and Shared Utilities Tests
src/__tests__/Tool.test.ts, src/__tests__/tools.test.ts, src/tools/FileEditTool/__tests__/utils.test.ts, src/tools/shared/__tests__/gitOperationTracking.test.ts
Added test suites for tool construction, preset parsing, file edit utilities, and git operation tracking with validation of defaults, aliases, filtering, and detection logic.
Core Utility Tests
src/utils/__tests__/claudemd.test.ts, src/utils/__tests__/cron.test.ts, src/utils/__tests__/diff.test.ts, src/utils/__tests__/file.test.ts, src/utils/__tests__/format.test.ts, src/utils/__tests__/frontmatterParser.test.ts, src/utils/__tests__/git.test.ts, src/utils/__tests__/glob.test.ts, src/utils/__tests__/hash.test.ts, src/utils/__tests__/json.test.ts, src/utils/__tests__/messages.test.ts, src/utils/__tests__/path.test.ts, src/utils/__tests__/semver.test.ts, src/utils/__tests__/stringUtils.test.ts, src/utils/__tests__/systemPrompt.test.ts, src/utils/__tests__/tokens.test.ts, src/utils/__tests__/truncate.test.ts, src/utils/__tests__/uuid.test.ts, src/utils/__tests__/xml.test.ts
Comprehensive test coverage for utility functions including parsing, formatting, hashing, file operations, message handling, path utilities, and string transformations with edge case and boundary validation.
Model Routing Tests
src/utils/model/__tests__/aliases.test.ts, src/utils/model/__tests__/model.test.ts, src/utils/model/__tests__/providers.test.ts
Test suites for model alias recognition, canonical name mapping, and API provider selection with environment variable handling and base URL validation.
Permission System Tests
src/utils/permissions/__tests__/permissionRuleParser.test.ts, src/utils/permissions/__tests__/permissions.test.ts
Test coverage for permission rule parsing/serialization, escaping/unescaping, legacy tool name normalization, and deny/ask rule matching with context-based filtering.
Configuration and Settings Tests
src/utils/settings/__tests__/config.test.ts
Test suite for settings schema validation, MCP server entry validation, source mapping utilities, and error formatting with coverage for valid/invalid configurations and strict mode validation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~28 minutes

Poem

🐰 With whiskers twitching, plans in paw,
I chart the tests with careful law—
Each file, each case, a carrot bright,
Coverage grows from dusk to light!
Hop by hop, we test it all, 🧪✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Test/test most core func' is vague and generic—it uses non-descriptive terms like 'most core func' without conveying what specific functionality is being tested or changed. Clarify the PR title to be more specific. Examples: 'Add comprehensive unit tests for Tool, messages, and utility functions' or 'Test tool system, message handling, and core utilities'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/test-most-core-func

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude-code-best claude-code-best merged commit 2ca5697 into main Apr 2, 2026
5 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant