-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add missing channel modes for message channel #89
Conversation
WalkthroughThe pull request introduces modifications to the Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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
🧹 Outside diff range and nitpick comments (1)
chat-android/src/test/java/com/ably/chat/SandboxTest.kt (1)
131-149
: Consider adding more test scenarios.While the new test validates the fix for rooms with all features enabled, consider adding tests for:
- Message reception when toggling features on/off
- Edge cases like rapid feature changes
- Concurrent message operations with feature changes
This will ensure the fix is robust across different scenarios.
Would you like me to help draft these additional test cases?
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
chat-android/src/main/java/com/ably/chat/RoomOptions.kt
(1 hunks)chat-android/src/test/java/com/ably/chat/SandboxTest.kt
(2 hunks)
🔇 Additional comments (2)
chat-android/src/main/java/com/ably/chat/RoomOptions.kt (1)
124-137
: LGTM! Fix ensures message modes are always present.
The refactoring ensures that basic message modes (publish
and subscribe
) are always added first, followed by conditional presence modes. This fixes the core issue where rooms with all features enabled could stop receiving messages.
Let's verify the channel modes are correctly set:
chat-android/src/test/java/com/ably/chat/SandboxTest.kt (1)
112-112
: LGTM! Clear test name improvement.
The renamed test better describes its purpose by explicitly stating it tests messaging without room features.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RoomFeatureSharedChannelTest.kt
failing at Line 44
It expects 2 modes when presenceOptions
are set.
You can update test to check for 4 modes accordingly.
This will also include updating checks as per
|
2c12aa3
to
cabed6a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
chat-android/src/main/java/com/ably/chat/RoomOptions.kt
(1 hunks)chat-android/src/test/java/com/ably/chat/SandboxTest.kt
(2 hunks)chat-android/src/test/java/com/ably/chat/room/RoomFeatureSharedChannelTest.kt
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- chat-android/src/main/java/com/ably/chat/RoomOptions.kt
- chat-android/src/test/java/com/ably/chat/SandboxTest.kt
🧰 Additional context used
📓 Learnings (1)
chat-android/src/test/java/com/ably/chat/room/RoomFeatureSharedChannelTest.kt (1)
Learnt from: sacOO7
PR: ably/ably-chat-kotlin#75
File: chat-android/src/test/java/com/ably/chat/room/RoomFeatureSharedChannelTest.kt:43-45
Timestamp: 2024-12-02T12:10:18.954Z
Learning: In the `RoomFeatureSharedChannelTest.kt` tests, prefer using assertions like `Assert.assertEquals` that provide detailed error messages over general assertions like `Assert.assertTrue`, to aid in debugging when a test fails due to a missing mode.
Assert.assertEquals(4, capturedChannelOptions[0].modes.size) | ||
Assert.assertEquals(ChannelMode.publish, capturedChannelOptions[0].modes[0]) | ||
Assert.assertEquals(ChannelMode.subscribe, capturedChannelOptions[0].modes[1]) | ||
Assert.assertEquals(ChannelMode.presence, capturedChannelOptions[0].modes[2]) | ||
Assert.assertEquals(ChannelMode.presence_subscribe, capturedChannelOptions[0].modes[3]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the order of channel modes to match requirements
The order of channel modes needs to be adjusted according to the specified requirements. The current implementation has publish
first and subscribe
second, but the requirements state that subscribe
should be first, followed by publish
.
Apply this diff to fix the order:
Assert.assertEquals(4, capturedChannelOptions[0].modes.size)
-Assert.assertEquals(ChannelMode.publish, capturedChannelOptions[0].modes[0])
-Assert.assertEquals(ChannelMode.subscribe, capturedChannelOptions[0].modes[1])
+Assert.assertEquals(ChannelMode.subscribe, capturedChannelOptions[0].modes[0])
+Assert.assertEquals(ChannelMode.publish, capturedChannelOptions[0].modes[1])
Assert.assertEquals(ChannelMode.presence, capturedChannelOptions[0].modes[2])
Assert.assertEquals(ChannelMode.presence_subscribe, capturedChannelOptions[0].modes[3])
Good use of Assert.assertEquals
for detailed error messages when tests fail. This follows the recommended practice for better debugging.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
Assert.assertEquals(4, capturedChannelOptions[0].modes.size) | |
Assert.assertEquals(ChannelMode.publish, capturedChannelOptions[0].modes[0]) | |
Assert.assertEquals(ChannelMode.subscribe, capturedChannelOptions[0].modes[1]) | |
Assert.assertEquals(ChannelMode.presence, capturedChannelOptions[0].modes[2]) | |
Assert.assertEquals(ChannelMode.presence_subscribe, capturedChannelOptions[0].modes[3]) | |
Assert.assertEquals(4, capturedChannelOptions[0].modes.size) | |
Assert.assertEquals(ChannelMode.subscribe, capturedChannelOptions[0].modes[0]) | |
Assert.assertEquals(ChannelMode.publish, capturedChannelOptions[0].modes[1]) | |
Assert.assertEquals(ChannelMode.presence, capturedChannelOptions[0].modes[2]) | |
Assert.assertEquals(ChannelMode.presence_subscribe, capturedChannelOptions[0].modes[3]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@coderabbitai order for first two modes doesn't matter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sacOO7, thanks for the clarification. I understand that the order of the first two channel modes (ChannelMode.publish
and ChannelMode.subscribe
) does not matter. I'll note this for future reviews.
✏️ Learnings added
Learnt from: sacOO7
PR: ably/ably-chat-kotlin#89
File: chat-android/src/test/java/com/ably/chat/room/RoomFeatureSharedChannelTest.kt:44-48
Timestamp: 2024-12-10T14:47:31.404Z
Learning: In tests in `RoomFeatureSharedChannelTest.kt` for the Ably Chat Kotlin project, the order of `ChannelMode.publish` and `ChannelMode.subscribe` in the `modes` array does not affect functionality; assertions should not enforce a specific order for these modes.
Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.
Code Coverage
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fix bug then room with all features enabled stops receiving messages
Summary by CodeRabbit
New Features
Bug Fixes
Tests