Skip to content

Conversation

@AndyTWF
Copy link
Contributor

@AndyTWF AndyTWF commented Dec 10, 2025

This change adds unit tests for commands that don't have them, so that we can continue to build a strong testing platform to underpin further CLI enhancements.

Due to an unrelated bug (race conditions in testing config), I've disabled parallel unit test execution to fix in a separate PR, as this is already big enough.

FTF-156

Summary by CodeRabbit

  • Tests

    • Expanded test coverage for channel management, authentication, integrations, logs, rooms, spaces, and cursors commands.
    • Added comprehensive test scenarios covering success paths, error handling, and JSON output formatting.
  • Chores

    • Updated test environment configuration.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Dec 10, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
cli-web-cli Ready Ready Preview Comment Dec 12, 2025 0:24am

@coderabbitai
Copy link

coderabbitai bot commented Dec 10, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This PR significantly expands unit test coverage for the Ably CLI, adding comprehensive test suites for dozens of commands across authentication, channel rules, integrations, logs, rooms, spaces, and configuration modules. Tests cover success paths, error handling, various output formats (JSON, pretty-JSON), and flag validation using vitest, oclif/test, and nock for HTTP mocking. A minor comment is added to source code and vitest configuration is updated with environment variables.

Changes

Cohort / File(s) Summary
Source code comments
src/commands/logs/channel-lifecycle.ts
Added explanatory comment "// Wait until interrupted" above await call; no functional changes.
Configuration
vitest.config.ts
Added ABLY_API_KEY: undefined to unit, integration, e2e, and hooks project env configs; introduced fileParallelism: false workaround in unit project to address test config setup race condition.
App & channel-rules tests
test/unit/commands/apps/channel-rules/create.test.ts, delete.test.ts, list.test.ts, update.test.ts
Added test suites covering create, list, update, delete operations with success paths, JSON output, and error handling (401, 400, network errors).
Channel-rule alias tests
test/unit/commands/channel-rule/create.test.ts, delete.test.ts, list.test.ts, update.test.ts
Added tests validating alias command behavior matching corresponding apps:channel-rules:* commands.
App management tests
test/unit/commands/apps/current.test.ts, set-apns-p12.test.ts, update.test.ts
Added tests for displaying current app info, APNS P12 certificate upload, and app update operations with various flags and error scenarios.
App logs tests
test/unit/commands/apps/logs/history.test.ts, subscribe.test.ts
Added tests for log history retrieval and real-time log subscription with field validation and JSON output.
Authentication tests
test/unit/commands/auth/issue-ably-token.test.ts, issue-jwt-token.test.ts, revoke-token.test.ts
Added tests for Ably and JWT token issuance, TTL handling, capabilities, and client ID support; updated revoke-token debug assertion format.
Auth keys tests
test/unit/commands/auth/keys/current.test.ts, get.test.ts, list.test.ts, revoke.test.ts, update.test.ts
Added comprehensive tests for listing, retrieving, updating, revoking API keys with JSON output and error handling.
Channel tests
test/unit/commands/channels/list.test.ts, occupancy/subscribe.test.ts
Updated list command assertions to include numeric metrics; added occupancy subscription tests with mock real-time events.
Config tests
test/unit/commands/config/path.test.ts, show.test.ts
Added tests for config path display and configuration show (including malformed TOML handling) with multiple output formats.
Integration tests
test/unit/commands/integrations/create.test.ts, delete.test.ts, get.test.ts, update.test.ts
Added tests for HTTP/AMQP integration CRUD operations, batch mode, and various source/target configurations.
Log subscription tests
test/unit/commands/logs/app/subscribe.test.ts, channel-lifecycle.test.ts, channel-lifecycle/subscribe.test.ts
Added tests for app-level, channel lifecycle, and channel lifecycle subscription commands with rewind and JSON support.
Additional log tests
test/unit/commands/logs/connection-lifecycle/history.test.ts, push/history.test.ts
Added tests for connection lifecycle and push notification log history retrieval.
Rooms tests
test/unit/commands/rooms/messages/reactions/remove.test.ts, send.test.ts, subscribe.test.ts, presence/subscribe.test.ts, reactions/subscribe.test.ts, typing/subscribe.test.ts
Added comprehensive tests for room reactions (send, remove, subscribe), presence subscription, and typing indicators with mocked real-time events.
Spaces tests
test/unit/commands/spaces/cursors/get-all.test.ts, subscribe.test.ts, locations/get-all.test.ts, locations/subscribe.test.ts, locks/get-all.test.ts, locks/get.test.ts, locks/subscribe.test.ts
Added extensive test coverage for spaces cursors, locations, and locks with getAll/subscribe operations and real-time event mocking.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Areas requiring attention:

  • Test pattern consistency: Verify that all ~50 new test files follow consistent setup/teardown patterns for temporary config directories, environment variable management, and mock cleanup to ensure proper test isolation.
  • Mock fidelity: Confirm that nock HTTP mocks and global test mocks (via __TEST_MOCKS__ and globalThis injections) accurately reflect API behavior and that mock interactions are properly asserted.
  • Real-time event simulation: Review tests for rooms, spaces, logs subscriptions and occupancy to ensure event mocking with SIGINT termination is correctly implemented and doesn't introduce race conditions.
  • Error path coverage: Audit that all test suites properly validate error scenarios (401, 404, 400, network errors) and that error messages are correctly propagated and asserted.
  • JSON output validation: Verify JSON output tests correctly parse and validate structure across different commands.
  • vitest config changes: Confirm that fileParallelism: false and ABLY_API_KEY: undefined additions don't inadvertently affect test behavior or performance elsewhere.

Poem

🐰 Fifty tests hopped into the warren,
Each one checking if the CLI's soarin',
Mocks and assertions in every file,
Real-time events make the tests worthwhile,
Coverage blooming, the audit's complete—
Now every command gets a thorough beat! 🎯

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'test: add more unit tests' is generic and vague, using non-descriptive language that doesn't convey the specific scope or purpose of the changes. Consider a more specific title that highlights the main objective, such as 'test: add comprehensive unit test coverage for CLI commands' or 'test: add unit tests following test audit requirements'.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed The PR adds extensive unit test coverage for multiple CLI commands (channel-rules, apps, auth, integrations, rooms, spaces, logs) that were previously lacking tests, directly addressing the test audit requirement from FTF-156 to improve test coverage and quality.
Out of Scope Changes check ✅ Passed A single source code change (channel-lifecycle.ts comment addition) and a configuration change (vitest.config.ts) are present alongside the test additions, both related to the test infrastructure improvements mentioned in the PR objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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 and usage tips.

AndyTWF and others added 26 commits December 12, 2025 00:23
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Explicitly unset ABLY_API_KEY in all test projects (unit, integration,
e2e, hooks) to prevent shell environment variables from leaking into
test execution.
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ntegrations/update

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Also refactor command to use waitUntilInterruptedOrTimeout for
consistent test mode handling.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link
Member

@denissellu denissellu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a doozy as always 😵‍💫

@AndyTWF AndyTWF merged commit 57e61ac into main Dec 15, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants