Test/claude code config verify - #8
Merged
Merged
Conversation
…开关双向联动
产物一:docs/test-plan-claude-code-config.md(测试方案,待 mentor 审阅)
前置调研(三类配置落盘位置/格式、设置页开关读写链路、关=删除非停用)、
三次核心检验、自动化 vs 手动分工、回归说明、发现的问题记录。
产物二:自动化测试
- tests/test_claude_code_config_verify.py(后端/API 层,27 例,fake_home + TestClient)
检验一:init 写入三份文件内容正确 + detect 三开关全开 + 开关↔文件一致
检验二:关某开关 → 配置项被物理移除(非停用标记)+ 保留用户其他配置 + 幂等
检验三:再开 → 恢复写入,内容与初次逐字段等价 + 多轮循环稳定
独立性:单开关开/关不扰动另外两个 + 8 种开关组合矩阵逐一核验
引导契约护栏:拒绝非法 kind、重复初始化保持开启
- tests/frontend/test_claude_code_config.py(前端,静态 9 + 浏览器 5)
静态:开关绑定 clientStatus、点击调 configureClient(plat.key,kind.key)、
configureClient 双向取反 + POST/DELETE 分支 + 回读、单写锁、
guideExecute 用 .key 且只「确保开启」
浏览器(全量 mock /api/**,真跑 Alpine,零副作用不碰真实 ~/.claude):
开关 on/off ↔ mock 配置态一致、点击发对方向 HTTP 动词并回读翻转、
三开关独立、guideExecute 不误删已配置项 / 未配置时写全三种
测→修→再测:修复 frontend/js/store.js::guideExecute 两个缺陷(详见方案文档「发现的问题」)
#1 kind 传成 {key,label,desc} 对象而非字符串 → URL /api/client-config/X/[object Object]
→ 后端 400 被 catch 吞掉 → 初始化引导三份配置一个都写不进去(结论页却显示「初始化完成」)
#2 (修完 #1 才显形)guideExecute 拿双向开关 configureClient 当「确保开启」用,
对已配置项会走 DELETE → 「重新运行初始化引导」把已有配置误删
修复:取 kindMeta.key 字符串 + 已开启的 kind 直接 continue(不改 configureClient 双向语义)
frontend/index.html 的 store.js?v= 内容哈希随 store.js 改动更新(build.py 版本化,
CI check_build.py ④ 一致性检查要求匹配)。index.standalone.html 为 gitignore 构建产物,不入库。
不改动任何既有测试。既有测试基线(改动前后一致):后端全量 758 passed;
tests/frontend/ 78 passed / 115 skipped / 3 pre-existing failed
(test_smoke.py::TestRouteRendering 3 例缺 backend_running skip 守卫,与本改动无关)。
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SSMDrsmrXR5kr68SUS5D5P
MVP 平台 = ClaudeCode + CodeBuddyIDE(client_config.py 注释),共用同一套
configureClient / write_kind / remove_kind / detect_platform,仅落盘目录不同:
ClaudeCode → ~/.claude.json / ~/.claude/settings.json / ~/.claude/agents/
CodeBuddyIDE → ~/.codebuddy/mcp.json / ~/.codebuddy/settings.json / ~/.codebuddy/agents/
hooks matcher: ClaudeCode "Bash|Write|Edit" + curl -d @-;CodeBuddyIDE "*" + hooks_forward
agent frontmatter: CodeBuddyIDE 额外带 agentMode/enabled/enabledAutoRun/mcpServers
改动:
- 重命名(去平台名,与 tests/test_client_config.py 对齐):
tests/test_claude_code_config_verify.py → tests/test_client_config_verify.py
tests/frontend/test_claude_code_config.py → tests/frontend/test_client_config_toggle.py
- test_client_config_verify.py:platform fixture 参数化 ["ClaudeCode","CodeBuddyIDE"],
三次核心检验 + 开关独立性 8 组合矩阵对两平台各跑一遍;新增 TestCrossPlatformIsolation
(同一 home 下两平台配置互不干扰)。27 → 56 例。
- test_client_config_toggle.py:TestConfigToggleBrowser 用 @parametrize("plat",[...])
对两平台跑开关 UI 双向/独立/关开循环/guideExecute 回归;新增 test_full_off_on_cycle_via_ui。
静态断言补两平台 kinds + toggle markup 平台无关。14 → 24 例。
- docs/test-plan-claude-code-config.md:新增 §2.1b CodeBuddy IDE 对照表、§6 打包产物;
三次检验表格补 CodeBuddyIDE 列;发现的问题补「CodeBuddy IDE 未发现新问题」
(问题 #1/#2 同样影响 CodeBuddyIDE,已由同一处 store.js 修复覆盖,新用例参数化验证)。
CodeBuddy IDE 三次检验 + 独立性全部通过,未发现平台专属 bug。
不改动任何既有测试文件。测试结果:
tests/test_client_config_verify.py 56 passed
tests/frontend/test_client_config_toggle.py 24 passed
后端全量 787 passed;tests/frontend/ 88 passed / 115 skipped / 3 pre-existing failed
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SSMDrsmrXR5kr68SUS5D5P
CoderMoray
approved these changes
Sep 3, 2026
CoderMoray
left a comment
Owner
There was a problem hiding this comment.
已审查并实测:guideExecute 两处缺陷修复正确(kindMeta.key + 已开启跳过),新增 80 例测试全通过,全量回归 787 passed 无破坏。LGTM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
目的
验证 Claude Code / CodeBuddy IDE(MVP 两平台)初始化后 MCP/Hooks/Agent
三种配置能否正确写入,以及设置页三个开关能否双向控制(开→写入、关→移除、
再开→恢复)。全程本地验证,不依赖 Claude Code 联网。
产物
自动化 vs 手动分工、回归说明)
测→修→再测:修复 2 个 store.js::guideExecute 缺陷
三份配置一个都写不进去(结论页却显示"初始化完成")
三次检验结果
初始化 / 关 / 再开 + 开关独立性,两平台均通过。测试全绿。