Skip to content

tests: 52 unit tests for cli/config-core.js (fetchRemoteConfig schema validation, writeCache error handling)#321

Open
javimosch wants to merge 1 commit into
masterfrom
mago/task-419
Open

tests: 52 unit tests for cli/config-core.js (fetchRemoteConfig schema validation, writeCache error handling)#321
javimosch wants to merge 1 commit into
masterfrom
mago/task-419

Conversation

@javimosch

Copy link
Copy Markdown
Owner

What changed

Added __tests__/config-core.test.js — 52 unit tests directly targeting cli/config-core.js.

Coverage

fetchRemoteConfig (schema validation)

  • Throws "SUPERCLI_SERVER is not configured" for undefined, null, and "" server values
  • Fetches from the correct URL (<server>/api/config)
  • Throws with status code + message on non-ok HTTP responses (404, 500)
  • Propagates network-level fetch rejections
  • Returns raw JSON on success (full schema, minimal schema, extra fields, object-style mcpServers)

writeCache (error handling)

  • Creates cache directory when absent; skips mkdirSync when dir exists
  • Writes pretty-printed JSON to the correct cache file path
  • Appends fetchedAt timestamp; returns the written data object
  • Propagates writeFileSync errors to caller
  • Propagates mkdirSync errors when directory cannot be created
  • Normalizes mcp_servers (strips null/invalid entries)
  • Handles null config input (falls back to emptyConfig defaults)
  • Merges mcpServers object-style into mcp_servers array

Other exports

  • readCache: missing file → null; valid file → normalized config; corrupt JSON → null; readFileSync throw → null
  • normalizeConfig: null input, version passthrough, non-array specs/commands replaced
  • normalizeMcpServerEntry: falsy/non-string name, null/array entry, url, args filtering, header stripping, timeout_ms, stateful
  • normalizeMcpServers: empty config, object-to-array conversion + sort, dedup (array wins), invalid entry skipping
  • loadConfig: no cache fallback, plugin command merging, corrupt cache graceful handling
  • emptyConfig: correct structure, fresh object per call
  • getClientId: env var override, stable sha256 hash
  • ensureCacheDir: creates dir / skips if present
  • cacheFilePath: returns correct path

Verification

npx jest __tests__/config-core.test.js --no-coverage
Tests: 52 passed, 52 total

Closes #419 (mago task #419)

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@javimosch, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 46 minutes and 13 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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 745c6eb5-8b64-4127-bbf0-1be5cfbccc5a

📥 Commits

Reviewing files that changed from the base of the PR and between afda2f7 and 4650eab.

📒 Files selected for processing (1)
  • __tests__/config-core.test.js
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch mago/task-419

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.

❤️ Share

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

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