test: テスト不足箇所の改善 (#821) - #822
Conversation
- test/settings-hooks.test.js (新規): .claude/settings.jsonのhooks設定構造を 31テストで検証。全hookイベント(PreToolUse/PostToolUse/Stop)の存在確認、 hookスクリプトの実ファイル存在確認、permissions構造の検証を含む。 - test/eslint-runtime.test.js (新規): ESLintをサブプロセス実行し13テストで 実際の動作を検証。設定ファイルのロード確認、no-console/no-unused-vars等の ルール有効性確認、テストファイル向けoverrides検証を含む。 - test/integration/lib_functions.bats (追加): platform.sh の実行動作を 12テストで検証。platform::detect_os/is_linux/is_supported等のランタイム 動作確認、環境非依存のスキップ対応付き。 Total: 469 → 512 tests (+43 Jest) + 20 → 32 BATS tests (+12) Co-authored-by: keito4 <keito4@users.noreply.github.com>
📝 WalkthroughWalkthroughThis PR adds three independent test suites covering ESLint runtime validation, platform.sh shell utility functions, and Claude settings hooks and permission structure. All changes are test-only additions with no code modifications. ChangesTest Coverage Expansion
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Claude finished @keito4's task in 2m 21s —— View job PRレビュー: test: テスト不足箇所の改善 (#821)
総評テストカバレッジを 469→512(Jest +43)、BATS 20→32(+12)に拡張する意義のある変更です。テストのロジックは全体的に正確で、実際の設定・スクリプトを参照して検証する設計は妥当です。以下いくつかの minor 指摘と recommendation を挙げます。CI ブロッカー相当(critical/major)は存在しません。
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@test/settings-hooks.test.js`:
- Around line 122-126: The test currently uses substring checks on
settings.hooks.PreToolUse.matcher which can match unintended strings; update the
matcher assertion in the test 'should have a Write|Edit|MultiEdit matcher for
config edit blocking' to check for exact equality to the canonical matcher
string "Write|Edit|MultiEdit" (i.e., replace the includes(...) checks with
e.matcher === 'Write|Edit|MultiEdit'), keeping the rest of the expectation
(expect at least one matching hook) unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 40de06de-78f7-4b30-a0fa-f6ee50fd29b1
📒 Files selected for processing (3)
test/eslint-runtime.test.jstest/integration/lib_functions.batstest/settings-hooks.test.js
| test('should have a Write|Edit|MultiEdit matcher for config edit blocking', () => { | ||
| const editHooks = settings.hooks.PreToolUse.filter( | ||
| (e) => e.matcher.includes('Write') || e.matcher.includes('Edit'), | ||
| ); | ||
| expect(editHooks.length).toBeGreaterThan(0); |
There was a problem hiding this comment.
Strengthen matcher assertion to avoid false positives.
At Line 123, substring checks (includes('Write') / includes('Edit')) can pass unintended matcher values (e.g., any random string containing Edit). If the intent is the canonical config matcher, assert exact equality with Write|Edit|MultiEdit.
Suggested patch
- const editHooks = settings.hooks.PreToolUse.filter(
- (e) => e.matcher.includes('Write') || e.matcher.includes('Edit'),
- );
+ const editHooks = settings.hooks.PreToolUse.filter(
+ (e) => e.matcher === 'Write|Edit|MultiEdit',
+ );🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@test/settings-hooks.test.js` around lines 122 - 126, The test currently uses
substring checks on settings.hooks.PreToolUse.matcher which can match unintended
strings; update the matcher assertion in the test 'should have a
Write|Edit|MultiEdit matcher for config edit blocking' to check for exact
equality to the canonical matcher string "Write|Edit|MultiEdit" (i.e., replace
the includes(...) checks with e.matcher === 'Write|Edit|MultiEdit'), keeping the
rest of the expectation (expect at least one matching hook) unchanged.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 42f2143255
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const settingsPath = path.join(repoPath, '.claude', 'settings.json'); | ||
| const hooksDir = path.join(repoPath, '.claude', 'hooks'); |
There was a problem hiding this comment.
Add CI paths for Claude settings hook tests
Because this suite validates .claude/settings.json and the hook scripts under .claude/hooks, it currently does not run when those are the only files changed: I checked .github/workflows/ci.yml, and the dorny paths-filter only marks code for JS/TS/MJS/CJS/test files and tsconfig.json (lines 64-71), while .py hooks are not included in the workflow trigger paths at all. A PR that only edits the Claude settings or removes/renames a hook script can therefore skip the unit-test job/no workflow entirely, so these assertions won’t protect the files they are meant to cover unless those paths are added to the CI filters.
Useful? React with 👍 / 👎.
|
🎉 This PR is included in version 1.116.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Closes #821
変更内容
test/settings-hooks.test.js(新規)31テスト): .claude/settings.jsonのhooks設定構造を検証test/eslint-runtime.test.js(新規)13テスト): ESLintサブプロセス実行テストtest/integration/lib_functions.bats(12テスト追加): platform.sh実行動作テストJest: 469 → 512 tests (+43), BATS: 20 → 32 (+12)
Generated with Claude Code
Summary by CodeRabbit