-
Notifications
You must be signed in to change notification settings - Fork 7
[ECO-5596] Presence subscribe tests #463
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughMocks were enhanced to store and emit presence callbacks; MockRealtimeChannel now initializes presence in init and delegates emissions. Tests were updated to use synchronous initializations, annotated with @mainactor, and a new test verifies subscribe/unsubscribe and enter/update/leave event flow through the channel. Changes
Sequence Diagram(s)sequenceDiagram
participant Test
participant DefaultPresence
participant MockRealtimeChannel
participant MockRealtimePresence
participant Callback
Test->>DefaultPresence: subscribe(callback)
DefaultPresence->>MockRealtimePresence: subscribe(callback)
MockRealtimePresence->>MockRealtimePresence: store callback
MockRealtimePresence-->>DefaultPresence: ARTEventListener
Test->>MockRealtimeChannel: emitPresenceMessage(enter)
MockRealtimeChannel->>MockRealtimePresence: emitMessage(enter)
MockRealtimePresence->>Callback: invoke with enter
Callback-->>Test: record enter
Test->>MockRealtimeChannel: emitPresenceMessage(update)
MockRealtimeChannel->>MockRealtimePresence: emitMessage(update)
MockRealtimePresence->>Callback: invoke with update
Callback-->>Test: record update
Test->>MockRealtimeChannel: emitPresenceMessage(leave)
MockRealtimeChannel->>MockRealtimePresence: emitMessage(leave)
MockRealtimePresence->>Callback: invoke with leave
Callback-->>Test: record leave
Test->>DefaultPresence: unsubscribe(listener)
DefaultPresence->>MockRealtimePresence: unsubscribe(listener)
MockRealtimePresence->>MockRealtimePresence: clear callbacks
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
0436cfc to
efcd5cf
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: 3
📜 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.
📒 Files selected for processing (3)
Tests/AblyChatTests/DefaultPresenceTests.swift(17 hunks)Tests/AblyChatTests/Mocks/MockRealtimeChannel.swift(3 hunks)Tests/AblyChatTests/Mocks/MockRealtimePresence.swift(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- Tests/AblyChatTests/DefaultPresenceTests.swift
- Tests/AblyChatTests/Mocks/MockRealtimeChannel.swift
🧰 Additional context used
📓 Path-based instructions (4)
**/*.swift
📄 CodeRabbit inference engine (CLAUDE.md)
**/*.swift: Use protocol-based design; expose SDK functionality via protocols and prefer associated types with opaque return types (some Protocol) instead of existentials (any Protocol)
Isolate all mutable state to the main actor; mark stateful objects with @mainactor
Public API must use typed throws with ErrorInfo; use InternalError internally and convert at the public API boundary
For public structs emitted by the API, provide an explicit public memberwise initializer
When using AsyncSequence operators in @mainactor contexts, mark operator closures as @sendable
Task, CheckedContinuation, and AsyncThrowingStream do not support typed errors; use Result and call .get() to surface typed errors
Do not use Dictionary.mapValues for typed throws; use ablyChat_mapValuesWithTypedThrow instead
When the compiler struggles with typed throws, explicitly declare the error type on do blocks (e.g., do throws(InternalError))
Specify error types in closures using the throws(ErrorType) syntax (e.g., try items.map { jsonValue throws(InternalError) in ... })
Mark any test-only APIs with testsOnly_ prefix and wrap them in #if DEBUG
Files:
Tests/AblyChatTests/Mocks/MockRealtimePresence.swift
Tests/AblyChatTests/**/*.swift
📄 CodeRabbit inference engine (CLAUDE.md)
Tests/AblyChatTests/**/*.swift: Use test attribution tags to reference spec coverage: @SPEC, @specOneOf(m/n), @specPartial, @specUntested, @specNotApplicable
For Swift Testing #expect(throws:) with typed errors, move typed-throw code into a separate non-typed-throw function until Xcode 16.3+
Files:
Tests/AblyChatTests/Mocks/MockRealtimePresence.swift
Tests/AblyChatTests/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place tests under Tests/AblyChatTests/ as the root for test targets
Files:
Tests/AblyChatTests/Mocks/MockRealtimePresence.swift
Tests/AblyChatTests/Mocks/**/*.swift
📄 CodeRabbit inference engine (CLAUDE.md)
Put mock implementations under Tests/AblyChatTests/Mocks/
Files:
Tests/AblyChatTests/Mocks/MockRealtimePresence.swift
🧬 Code graph analysis (1)
Tests/AblyChatTests/Mocks/MockRealtimePresence.swift (5)
Tests/AblyChatTests/Mocks/MockRealtimeChannel.swift (3)
subscribe(142-144)subscribe(147-153)unsubscribe(161-163)Sources/AblyChat/AblyCocoaExtensions/InternalAblyCocoaTypes.swift (9)
subscribe(279-281)subscribe(283-285)subscribe(383-385)subscribe(387-389)subscribe(501-503)subscribe(505-507)unsubscribe(287-289)unsubscribe(391-393)unsubscribe(497-499)Sources/AblyChat/DefaultPresence.swift (1)
subscribe(175-200)Sources/AblyChat/Presence.swift (2)
subscribe(126-140)subscribe(143-145)Sources/AblyChat/Subscription.swift (2)
unsubscribe(63-65)unsubscribe(90-92)
⏰ 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). (1)
- GitHub Check: Xcode, iOS (Xcode 26.0)
Closes #396
Summary by CodeRabbit