Skip to content

[ECO-5251] Reactions tests#262

Merged
maratal merged 2 commits intomainfrom
fix/235-reactions-tests
Jun 30, 2025
Merged

[ECO-5251] Reactions tests#262
maratal merged 2 commits intomainfrom
fix/235-reactions-tests

Conversation

@maratal
Copy link
Copy Markdown
Collaborator

@maratal maratal commented Apr 5, 2025

Part of #235

Summary by CodeRabbit

  • Tests
    • Improved test coverage for reaction event subscriptions, including handling of malformed realtime events to ensure only valid reactions are received by subscribers.
  • Chores
    • Enhanced internal handling of realtime event data for safer processing.
  • Refactor
    • Updated subscription method to allow ignoring return values without warnings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 5, 2025

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

"""

Walkthrough

This update revises and expands unit tests for room reactions. It renames a test for reaction event subscriptions, enhances its logic with detailed mock channel setups, and adds a new test to ensure malformed realtime reaction events are filtered out and not delivered to subscribers. Additionally, the subscribe(_:) method in DefaultRoomReactions is marked with @discardableResult, and the mock realtime channel's JSON handling is improved by switching to a safer JSONValue type.

Changes

File(s) Change Summary
Tests/AblyChatTests/DefaultRoomReactionsTests.swift Renamed and enhanced reaction subscription test; added test for filtering malformed realtime events.
Sources/AblyChat/DefaultRoomReactions.swift Added @discardableResult attribute to subscribe(_:) method in DefaultRoomReactions class.
Tests/AblyChatTests/Mocks/MockRealtimeChannel.swift Changed messageJSONToEmitOnSubscribe type to [String: JSONValue]?; updated JSON parsing logic.

Sequence Diagram(s)

sequenceDiagram
    participant Test as Test Case
    participant MockChannel as Mock Realtime Channel
    participant Subscriber as Reaction Event Subscriber

    Test->>MockChannel: Setup with valid and malformed messages
    Test->>Subscriber: Subscribe to reaction events
    MockChannel-->>Subscriber: Emit malformed message
    Subscriber--xSubscriber: Ignore malformed event
    MockChannel-->>Subscriber: Emit valid reaction message
    Subscriber->>Test: Receive and assert valid reaction event
Loading

Assessment against linked issues

Objective Addressed Explanation
Restore and improve room reactions tests (ECO-5251)

Possibly related PRs

Suggested reviewers

  • lawrence-forooghian

Poem

In the warren of tests, a bunny did hop,
Checking reactions that bubble and pop.
Malformed events? We shoo them away!
Only good vibes are allowed to stay.
With every assert, the code grows strong—
In the meadow of Swift, bugs don’t belong! 🐇
"""

✨ Finishing Touches
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment
  • Commit Unit Tests in branch fix/235-reactions-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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@maratal maratal changed the base branch from main to fix/235-messages-tests April 5, 2025 20:13
@github-actions github-actions Bot temporarily deployed to staging/pull/262/AblyChat April 5, 2025 20:13 Inactive
@github-actions github-actions Bot temporarily deployed to staging/pull/262/AblyChat April 11, 2025 13:56 Inactive
@github-actions github-actions Bot temporarily deployed to staging/pull/262/AblyChat April 11, 2025 14:28 Inactive
@maratal
Copy link
Copy Markdown
Collaborator Author

maratal commented Apr 11, 2025

I'll fix commit history before merging.

@maratal maratal marked this pull request as ready for review April 11, 2025 14:34
@github-actions github-actions Bot temporarily deployed to staging/pull/262/AblyChat April 11, 2025 14:34 Inactive
@maratal maratal linked an issue Apr 11, 2025 that may be closed by this pull request
@lawrence-forooghian
Copy link
Copy Markdown
Collaborator

@maratal according to the spec coverage report, there are some CHA-ER spec points that are not tested. Please can you address?

@maratal maratal force-pushed the fix/235-messages-tests branch 8 times, most recently from c57d8d1 to c9f0256 Compare May 23, 2025 13:35
@maratal maratal force-pushed the fix/235-reactions-tests branch from 4db48ee to c071197 Compare May 23, 2025 15:53
@github-actions github-actions Bot temporarily deployed to staging/pull/262/AblyChat May 23, 2025 15:54 Inactive
Copy link
Copy Markdown

@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: 4

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4db48ee and c071197.

📒 Files selected for processing (1)
  • Tests/AblyChatTests/DefaultRoomReactionsTests.swift (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (34)
  • GitHub Check: Example app, tvOS (Xcode 16.3)
  • GitHub Check: Example app, tvOS (Xcode 16.2)
  • GitHub Check: Example app, macOS (Xcode 16.3)
  • GitHub Check: Example app, iOS (Xcode 16.2)
  • GitHub Check: Example app, iOS (Xcode 16.3)
  • GitHub Check: Example app, iOS (Xcode 16.1)
  • GitHub Check: Example app, tvOS (Xcode 16.1)
  • GitHub Check: Xcode, release configuration, tvOS (Xcode 16.3)
  • GitHub Check: Example app, macOS (Xcode 16.2)
  • GitHub Check: Example app, macOS (Xcode 16.1)
  • GitHub Check: Xcode, release configuration, iOS (Xcode 16.2)
  • GitHub Check: Xcode, release configuration, iOS (Xcode 16.1)
  • GitHub Check: Xcode, release configuration, macOS (Xcode 16.2)
  • GitHub Check: Xcode, release configuration, tvOS (Xcode 16.1)
  • GitHub Check: Xcode, release configuration, tvOS (Xcode 16.2)
  • GitHub Check: Xcode, release configuration, iOS (Xcode 16.3)
  • GitHub Check: Xcode, release configuration, macOS (Xcode 16.3)
  • GitHub Check: Xcode, tvOS (Xcode 16.2)
  • GitHub Check: Xcode, macOS (Xcode 16.3)
  • GitHub Check: Xcode, tvOS (Xcode 16.3)
  • GitHub Check: Xcode, iOS (Xcode 16.3)
  • GitHub Check: Xcode, release configuration, macOS (Xcode 16.1)
  • GitHub Check: Xcode, tvOS (Xcode 16.1)
  • GitHub Check: Xcode, iOS (Xcode 16.2)
  • GitHub Check: Xcode, iOS (Xcode 16.1)
  • GitHub Check: Xcode, macOS (Xcode 16.2)
  • GitHub Check: Xcode, macOS (Xcode 16.1)
  • GitHub Check: SPM, release configuration (Xcode 16.3)
  • GitHub Check: SPM, release configuration (Xcode 16.2)
  • GitHub Check: SPM, release configuration (Xcode 16.1)
  • GitHub Check: SPM (Xcode 16.3)
  • GitHub Check: SPM (Xcode 16.2)
  • GitHub Check: SPM (Xcode 16.1)
  • GitHub Check: Generate code coverage
🔇 Additional comments (1)
Tests/AblyChatTests/DefaultRoomReactionsTests.swift (1)

32-34: LGTM! Improved test method naming.

The rename from subscribe_returnsSubscription to subscriptionCanBeRegisteredToReceiveReactionEvents is more descriptive and aligns better with the test's actual purpose.

Comment thread Tests/AblyChatTests/DefaultRoomReactionsTests.swift Outdated
Comment thread Tests/AblyChatTests/DefaultRoomReactionsTests.swift
Comment thread Tests/AblyChatTests/DefaultRoomReactionsTests.swift
Comment thread Tests/AblyChatTests/DefaultRoomReactionsTests.swift
@github-actions github-actions Bot temporarily deployed to staging/pull/262/AblyChat May 23, 2025 16:12 Inactive
@maratal
Copy link
Copy Markdown
Collaborator Author

maratal commented May 23, 2025

@coderabbitai pause

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2025

✅ Actions performed

Reviews paused.

@github-actions github-actions Bot temporarily deployed to staging/pull/262/AblyChat May 24, 2025 21:15 Inactive
@maratal maratal force-pushed the fix/235-reactions-tests branch from f50e30c to df785f5 Compare May 25, 2025 10:44
@github-actions github-actions Bot temporarily deployed to staging/pull/262/AblyChat May 25, 2025 10:46 Inactive
@maratal maratal force-pushed the fix/235-reactions-tests branch from df785f5 to 016d94c Compare May 25, 2025 10:49
@github-actions github-actions Bot temporarily deployed to staging/pull/262/AblyChat June 12, 2025 20:51 Inactive
Comment thread Tests/AblyChatTests/Mocks/MockRealtimeChannel.swift Outdated
@maratal maratal force-pushed the fix/235-messages-tests branch 5 times, most recently from d85e713 to 912abb3 Compare June 22, 2025 23:05
@maratal maratal force-pushed the fix/235-reactions-tests branch from 726e936 to 7ba9745 Compare June 22, 2025 23:12
@github-actions github-actions Bot temporarily deployed to staging/pull/262/AblyChat June 22, 2025 23:13 Inactive
@maratal maratal force-pushed the fix/235-messages-tests branch from 912abb3 to 02b8d33 Compare June 28, 2025 22:54
@maratal maratal force-pushed the fix/235-reactions-tests branch from 7ba9745 to e92fc1d Compare June 28, 2025 23:00
@github-actions github-actions Bot temporarily deployed to staging/pull/262/AblyChat June 28, 2025 23:02 Inactive
@maratal maratal force-pushed the fix/235-messages-tests branch from 02b8d33 to 7039a6a Compare June 30, 2025 17:17
Base automatically changed from fix/235-messages-tests to main June 30, 2025 19:11
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.

Restore messages, presence, and room reactions tests

2 participants