tests: unit-test cli/plugins-hooks.js (validateHooks, validateNodeHook, executeOutputHooks)#324
tests: unit-test cli/plugins-hooks.js (validateHooks, validateNodeHook, executeOutputHooks)#324javimosch wants to merge 3 commits into
Conversation
…, stale-lock detection
Add 60 tests in __tests__/config-sync-advanced.test.js covering the six
exports not yet tested: runServerPluginPostInstall (hook policy, timeout
cap, path-traversal guard, spawnSync result handling), extractZipToDir
(ENOENT/non-zero exit, code-105 error shape), ensurePluginDir (sanitization,
recursive mkdir), syncServerPlugins (conflict resolution via shadowed_by_local,
partial updates with unchanged/updated split, stale-lock removal, checksum
detection, disabled-plugin skip, missing manifest throw, zip download+extract
path), syncClientPluginResources (skip when no server_resources, POST body
includes client_id, network/non-ok error handling), syncCliAdapters (stale
local file removal, header generation, per-adapter failure counting).
Also fix a pre-existing scope bug in cli/config-sync.js: `const manifest`
was declared inside the try{} block but referenced after the catch{} close,
causing a ReferenceError for every non-zip plugin install. Moved the
declaration to before the try block.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…lveHookScriptPath, serializeHook)
- Export parsePostInstallResult, resolveHookScriptPath, serializeHook for direct testing
- 26 unit tests across three describe blocks:
- parsePostInstallResult (10): null/undefined/empty/whitespace→null, valid JSON
object/array parsed, invalid JSON→{raw:text} fallback, trim before parse,
raw fallback preserves trimmed text
- resolveHookScriptPath (7): ../traversal throws code 85, absolute outside dir
throws code 85, multi-level subdir/../../ traversal throws code 85,
missing file throws code 92 (resource_not_found), valid path+exists returns
resolved path, nested path within dir allowed, kind label in error message
- serializeHook (9): null/undefined hook→null, full serialized object with all
fields, round-trip script_name===basename(script_path), readFileSync called
with correct path, validateNodeHook error propagated, traversal code 85
propagated, missing script code 92 propagated, underscores→hyphens in kind
Closes #456 _(mago task #456)_
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…k, executeNodeHook, executeOutputHooks, runHook)
55 tests covering:
- validateHooks: valid/invalid manifest-level and command-level hook kinds, missing-field guards,
multi-error accumulation, namespace.resource.action in error messages
- validateNodeHook: null/undefined guards, code-85 on missing/non-string script, non-node runtime,
out-of-range/NaN/missing timeout_ms, boundary acceptance at 1 and 15000, return shape
- executeNodeHook: code-92 on missing script, code-105 on spawnSync error/non-zero exit,
JSON parse/null return, timeout propagation, context serialisation
- executeOutputHooks: no-hook → [], null/empty/undefined output mutation, hook result push,
null-stdout → [], {} truthy → pushed, commandManifest preference over pluginManifest, throw propagation
- runHook: null routing, missing kind, no-script no-op, context.kind mutation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reached
More reviews will be available in 56 minutes and 58 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 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 |
|
Review — Head of Org Engineering: The PR adds a new test file for (approved — review-only mode; merge when ready.) |
What changed
Added
__tests__/plugins-hooks.test.js— 55 unit tests forcli/plugins-hooks.js.Coverage
validateHooksvalidateNodeHookexecuteNodeHook{}on empty stdout, timeout propagation, context JSON arg serialisationexecuteOutputHooks[], missing on_output →[], no-script hookDef →[], output mutation (string/null/undefined/empty), hook result push, null stdout →[],{}truthy → pushed, commandManifest preference, throw propagationrunHookHow verified
Closes #455 (mago task #455)