Skip to content

Conversation

@AndyTWF
Copy link
Contributor

@AndyTWF AndyTWF commented Dec 13, 2025

A lot of our integraiton tests are just unit tests with different mocking methods. This change removes tests that are covered by unit tests, moves some tests into relevant unit/e2e.

Summary by CodeRabbit

  • Tests
    • Reorganized test infrastructure, migrating from integration to unit tests.
    • Removed multiple integration test suites and consolidated test utilities.
    • Expanded unit test coverage for channels publish functionality and rooms message handling, including delay, ordering, and error scenarios.

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

@vercel
Copy link

vercel bot commented Dec 13, 2025

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

Project Deployment Review Updated (UTC)
cli-web-cli Ready Ready Preview, Comment Dec 15, 2025 5:27pm

@coderabbitai
Copy link

coderabbitai bot commented Dec 13, 2025

Walkthrough

The PR removes multiple integration test files across authentication, channels, rooms, spaces, and core CLI features, along with the shared test-utils module. Two test descriptions are renamed for clarity. Corresponding unit tests for channels publish and rooms messages are added to replace removed integration coverage.

Changes

Cohort / File(s) Summary
Test description updates
test/e2e/control-api.test.ts, test/unit/base-command/agent-header.test.ts
Renamed describe block labels: "Control API Integration Tests" → "Control API E2E Tests" and "Agent Header Integration Tests" → "Agent Header Unit Tests".
Deleted integration test suites
test/integration/auth/auth-flow.test.ts, test/integration/auth/enhanced-login-flow.test.ts, test/integration/commands/channels-publish-ordering.test.ts, test/integration/commands/channels.test.ts, test/integration/commands/minimal-test.test.ts, test/integration/commands/rooms-messages-ordering.test.ts, test/integration/commands/rooms.test.ts, test/integration/commands/spaces.test.ts, test/integration/core/autocomplete.test.ts, test/integration/core/help.test.ts, test/integration/topic-command-display.test.ts
Removed 11 integration test files covering auth flows, channel/room/space operations, CLI help/autocomplete, and topic command display.
Deleted test utilities
test/integration/test-utils.ts
Removed shared test helpers: getMockAblyRest(), registerMock<T>(), and getMock<T>(), plus internal mock infrastructure.
Added unit tests
test/unit/commands/channels/publish.test.ts, test/unit/commands/rooms/messages.test.ts
New unit test suites for transport selection, message delay/ordering, error handling in channels publish and rooms message commands.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • Primary concern: Verify that removal of test-utils.ts and 11 integration test files does not break remaining tests or leave gaps in coverage.
  • Secondary concern: Review new unit tests for channels publish and rooms messages to ensure they adequately replace integration test coverage.
  • Additional focus areas:
    • Check for any remaining references to deleted test-utils functions throughout the test suite.
    • Confirm mocked behavior in new unit tests aligns with the integration test expectations that were removed.
    • Validate that environment variable setup/teardown formerly handled in deleted integration tests is now properly managed elsewhere.

Poem

🐰 Hoppin' through the tests, we clean up the way,
Integration tests fade, unit tests stay,
Mock helpers retired, test-utils gone,
Leaner and meaner—we hop right along! 🚀✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test: remove redundant integration tests' clearly and concisely describes the main change: removing integration tests identified as redundant.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch remove-missing-integration-tests

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 AndyTWF changed the base branch from add-missing-unit-tests to main December 13, 2025 23:31
A lot of our integraiton tests are just unit tests with different mocking methods. This change removes
tests that are covered by unit tests, moves some tests into relevant unit/e2e.
@AndyTWF AndyTWF force-pushed the remove-missing-integration-tests branch from b4d8031 to 1bc60e4 Compare December 15, 2025 17:26
@AndyTWF AndyTWF changed the title [WIP] test: remove redundant integration tests test: remove redundant integration tests Dec 15, 2025
@AndyTWF AndyTWF marked this pull request as ready for review December 15, 2025 17:27
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
test/unit/commands/rooms/messages.test.ts (1)

239-342: Reduce reliance on real-time sleeps in delay/ordering tests

These tests assert on wall‑clock durations (e.g., ≥80ms, ≥200ms) using real timers, which can both slow the suite and be flaky on loaded CI runners.

Consider:

  • Using Vitest fake timers (vi.useFakeTimers(), vi.advanceTimersByTime(...)) to drive the delay loop deterministically, or
  • Making the timing assertions much more forgiving (e.g., only asserting that non‑zero delay takes “longer than zero” rather than specific millisecond thresholds), while still checking call counts and ordered text values.

This keeps the behavioral guarantees while making the tests faster and more stable.

test/unit/commands/channels/publish.test.ts (1)

408-563: Make timing-sensitive tests more robust and trim unused timing artifacts

The delay/ordering and multi‑message error‑handling tests look logically sound and mirror the rooms semantics, but a couple of refinements would improve robustness:

  • Delay tests use real timers and assert on specific durations (>= 80ms, >= 200ms, < 50ms). On slower or noisy CI, especially the < 50ms check can intermittently fail even if behavior is correct.
  • timestamps in Line 410 are collected but never asserted; they can be removed or used to assert ordering if you decide to keep time-based checks.

Suggested adjustments:

  • Prefer Vitest fake timers (vi.useFakeTimers() / vi.advanceTimersByTime) to avoid real sleeps, or
  • Loosen the assertions to only distinguish “non‑zero delay vs zero delay” without tight millisecond bounds, and keep ordering verified via the publishedData array.

This will keep coverage of delay semantics and sequential ordering while reducing flakiness and runtime cost.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 57e61ac and 1bc60e4.

📒 Files selected for processing (16)
  • test/e2e/control-api.test.ts (1 hunks)
  • test/integration/auth/auth-flow.test.ts (0 hunks)
  • test/integration/auth/enhanced-login-flow.test.ts (0 hunks)
  • test/integration/commands/channels-publish-ordering.test.ts (0 hunks)
  • test/integration/commands/channels.test.ts (0 hunks)
  • test/integration/commands/minimal-test.test.ts (0 hunks)
  • test/integration/commands/rooms-messages-ordering.test.ts (0 hunks)
  • test/integration/commands/rooms.test.ts (0 hunks)
  • test/integration/commands/spaces.test.ts (0 hunks)
  • test/integration/core/autocomplete.test.ts (0 hunks)
  • test/integration/core/help.test.ts (0 hunks)
  • test/integration/test-utils.ts (0 hunks)
  • test/integration/topic-command-display.test.ts (0 hunks)
  • test/unit/base-command/agent-header.test.ts (1 hunks)
  • test/unit/commands/channels/publish.test.ts (1 hunks)
  • test/unit/commands/rooms/messages.test.ts (1 hunks)
💤 Files with no reviewable changes (12)
  • test/integration/core/help.test.ts
  • test/integration/commands/rooms-messages-ordering.test.ts
  • test/integration/test-utils.ts
  • test/integration/commands/channels.test.ts
  • test/integration/commands/rooms.test.ts
  • test/integration/commands/spaces.test.ts
  • test/integration/commands/channels-publish-ordering.test.ts
  • test/integration/commands/minimal-test.test.ts
  • test/integration/core/autocomplete.test.ts
  • test/integration/topic-command-display.test.ts
  • test/integration/auth/enhanced-login-flow.test.ts
  • test/integration/auth/auth-flow.test.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.test.ts

📄 CodeRabbit inference engine (.cursor/rules/AI-Assistance.mdc)

**/*.test.ts: When testing, mock the Ably SDK properly by stubbing the constructor (e.g., sinon.stub(Ably, 'Rest').returns(mockClient)).
Always ensure resources are properly closed/cleaned up in tests (e.g., call await client.close() and sinon.restore() in afterEach).

Files:

  • test/unit/commands/rooms/messages.test.ts
  • test/e2e/control-api.test.ts
  • test/unit/base-command/agent-header.test.ts
  • test/unit/commands/channels/publish.test.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/Development.mdc)

**/*.{ts,tsx}: Use TypeScript and follow best practice naming conventions
ESLint is used to ensure all code adheres best practices; ensure you check that all code passes the linter before concluding your work.

Files:

  • test/unit/commands/rooms/messages.test.ts
  • test/e2e/control-api.test.ts
  • test/unit/base-command/agent-header.test.ts
  • test/unit/commands/channels/publish.test.ts
{test/**/*.{ts,js},**/*.{test,spec}.{ts,js}}

📄 CodeRabbit inference engine (.cursor/rules/Development.mdc)

When new features are added or changes made, tests must be updated or added, and it is your responsibility to ensure the tests pass before deeming your work complete.

Files:

  • test/unit/commands/rooms/messages.test.ts
  • test/e2e/control-api.test.ts
  • test/unit/base-command/agent-header.test.ts
  • test/unit/commands/channels/publish.test.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: session-tests
  • GitHub Check: ui-tests
  • GitHub Check: auth-tests
  • GitHub Check: e2e-cli
  • GitHub Check: test
🔇 Additional comments (3)
test/unit/base-command/agent-header.test.ts (1)

18-18: Describe label rename correctly reflects unit-test scope

Renaming the suite to "Agent Header Unit Tests" matches the file’s placement under test/unit and clarifies intent without changing behavior.

test/e2e/control-api.test.ts (1)

6-6: E2E suite label is clearer and consistent with test type

Updating the description to "Control API E2E Tests" accurately signals that this is an end‑to‑end suite and doesn’t affect runtime behavior.

test/unit/commands/channels/publish.test.ts (1)

339-406: Transport-selection tests clearly encode expected defaults

The new “transport selection” cases capture the intended matrix (multi‑message → realtime by default, explicit rest respected, single message → REST by default) and should help prevent regressions as transport logic evolves. No issues from my side.

Copy link
Member

@jamiehenson jamiehenson left a comment

Choose a reason for hiding this comment

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

@AndyTWF AndyTWF merged commit f3e813a 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