[docs]Add tests for CallJoinInterceptor#1131
Conversation
📝 WalkthroughWalkthroughA new Swift documentation example file is added to demonstrate a custom Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as Caller
participant ViewModel as CallViewModel
participant Interceptor as ParticipantReadyCallJoinInterceptor
participant StreamVideo as streamVideo.state
participant EventStream as CustomVideoEvent Stream
Caller->>ViewModel: callReadyToJoin()
activate Interceptor
ViewModel->>Interceptor: callReadyToJoin()
Interceptor->>Interceptor: Send custom event<br/>(current user id)
Interceptor->>StreamVideo: Monitor ringingCall
Interceptor->>EventStream: Subscribe to events
EventStream->>Interceptor: Receive event (other user)
Interceptor->>Interceptor: Filter & publish<br/>readiness = true
Interceptor->>Interceptor: Await readiness signal
Interceptor-->>ViewModel: Return (join allowed)
deactivate Interceptor
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
DocumentationTests/DocumentationTests/DocumentationTests/05-ui-cookbook/10-call-join-interceptor.swift (1)
22-22: Wrap long Swift lines to match the project style.These lines exceed the 80-character Swift guideline; wrapping them keeps the documentation examples consistent with the rest of the project. As per coding guidelines,
**/*.swift: “Use 80 characters as the maximum line length”.♻️ Proposed wrapping
- private let hasOtherReadyParticipants = CurrentValueSubject<Bool, Never>(false) + private let hasOtherReadyParticipants = + CurrentValueSubject<Bool, Never>(false) - .sinkTask(storeIn: disposableBag) { `@MainActor` [weak self] ringingCall in + .sinkTask(storeIn: disposableBag) { + `@MainActor` [weak self] ringingCall in self?.didUpdate(ringingCall: ringingCall) } - callViewModel.callJoinInterceptor = ParticipantReadyCallJoinInterceptor(streamVideo: streamVideo) + callViewModel.callJoinInterceptor = + ParticipantReadyCallJoinInterceptor(streamVideo: streamVideo)Also applies to: 37-37, 85-85
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@DocumentationTests/DocumentationTests/DocumentationTests/05-ui-cookbook/10-call-join-interceptor.swift` at line 22, The single long Swift declaration private let hasOtherReadyParticipants = CurrentValueSubject<Bool, Never>(false) (and the similar long lines at the other mentioned locations) should be wrapped to respect the 80-character line-length rule; break the initializer across lines so the identifier and type stay on one line and the CurrentValueSubject generic/type and initializer arguments are on subsequent indented lines (e.g., split after = or after the generic), updating the declarations for hasOtherReadyParticipants and the two other long lines referenced to match the project style.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@DocumentationTests/DocumentationTests/DocumentationTests.xcodeproj/project.pbxproj`:
- Line 10: Project contains duplicate cookbook filename prefixes (e.g.,
"10-call-join-interceptor.swift" conflicts with
"10-network-quality-indicator.swift"); rename the new file to the next unused
numeric prefix and update all Xcode project references accordingly: change the
PBXBuildFile entry (e.g., 41A1C0DE2F82100100A1B2C3) and the corresponding
PBXFileReference (e.g., 41A1C0DE2F82100200A1B2C3) to point to the renamed file,
and also rename the file on disk; apply the same fix for other duplicates noted
(95-95, 283-284, 457-457) so cookbook ordering by filename prefix remains unique
and consistent.
In
`@DocumentationTests/DocumentationTests/DocumentationTests/05-ui-cookbook/10-call-join-interceptor.swift`:
- Around line 53-55: The readiness wait currently swallows CancellationError by
using "try?" on hasOtherReadyParticipants.filter { $0 }.nextValue(); update the
call in callReadyToJoin to remove the "try?" so that nextValue() is awaited with
normal error propagation (allowing CancellationError to bubble up) — locate the
invocation using hasOtherReadyParticipants and nextValue() inside the
callReadyToJoin async throws function and replace the try? usage with a plain
try/await so cancellation propagates.
---
Nitpick comments:
In
`@DocumentationTests/DocumentationTests/DocumentationTests/05-ui-cookbook/10-call-join-interceptor.swift`:
- Line 22: The single long Swift declaration private let
hasOtherReadyParticipants = CurrentValueSubject<Bool, Never>(false) (and the
similar long lines at the other mentioned locations) should be wrapped to
respect the 80-character line-length rule; break the initializer across lines so
the identifier and type stay on one line and the CurrentValueSubject
generic/type and initializer arguments are on subsequent indented lines (e.g.,
split after = or after the generic), updating the declarations for
hasOtherReadyParticipants and the two other long lines referenced to match the
project style.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: f19df8fd-f28e-44a4-a013-fa1b2b019e3c
📒 Files selected for processing (2)
DocumentationTests/DocumentationTests/DocumentationTests.xcodeproj/project.pbxprojDocumentationTests/DocumentationTests/DocumentationTests/05-ui-cookbook/10-call-join-interceptor.swift
| objects = { | ||
|
|
||
| /* Begin PBXBuildFile section */ | ||
| 41A1C0DE2F82100100A1B2C3 /* 10-call-join-interceptor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 41A1C0DE2F82100200A1B2C3 /* 10-call-join-interceptor.swift */; }; |
There was a problem hiding this comment.
Avoid duplicate cookbook numbering.
The new page uses the 10- prefix while 10-network-quality-indicator.swift already exists. If docs are ordered by filename prefix, this makes the cookbook order ambiguous. Consider renaming this to the next unused prefix and updating the project references plus the file on disk together.
Also applies to: 95-95, 283-284, 457-457
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@DocumentationTests/DocumentationTests/DocumentationTests.xcodeproj/project.pbxproj`
at line 10, Project contains duplicate cookbook filename prefixes (e.g.,
"10-call-join-interceptor.swift" conflicts with
"10-network-quality-indicator.swift"); rename the new file to the next unused
numeric prefix and update all Xcode project references accordingly: change the
PBXBuildFile entry (e.g., 41A1C0DE2F82100100A1B2C3) and the corresponding
PBXFileReference (e.g., 41A1C0DE2F82100200A1B2C3) to point to the renamed file,
and also rename the file on disk; apply the same fix for other duplicates noted
(95-95, 283-284, 457-457) so cookbook ordering by filename prefix remains unique
and consistent.
| _ = try? await hasOtherReadyParticipants | ||
| .filter { $0 } | ||
| .nextValue() |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Inspect the project's `nextValue` implementation and call sites that may swallow cancellation.
# Expected: `nextValue` is throwing/cancellation-aware, and join-gating usages should not use `try?`.
rg -n -C4 --type swift '\bfunc\s+nextValue\b|\btry\?\s+await\s+.*nextValue\s*\('Repository: GetStream/stream-video-swift
Length of output: 1188
🏁 Script executed:
# Get the full nextValue() implementation
cat -n Sources/StreamVideo/Utils/Extensions/Combine/Publisher+AsyncStream.swift | sed -n '100,180p'Repository: GetStream/stream-video-swift
Length of output: 1512
🏁 Script executed:
# Check the actual file and lines being reviewed
cat -n DocumentationTests/DocumentationTests/DocumentationTests/05-ui-cookbook/10-call-join-interceptor.swift | sed -n '40,75p'Repository: GetStream/stream-video-swift
Length of output: 1675
🏁 Script executed:
# Search for all try? await nextValue usages to understand the pattern
rg -n "try\?" --type swift -A2 -B2 | grep -A2 -B2 "nextValue"Repository: GetStream/stream-video-swift
Length of output: 1648
Propagate cancellation from the readiness wait.
try? suppresses all errors including CancellationError from nextValue(), allowing a cancelled join to proceed without waiting for participant readiness. Since callReadyToJoin is marked async throws, cancellation should propagate to the caller. Remove try? to preserve cancellation semantics.
🐛 Proposed fix
- _ = try? await hasOtherReadyParticipants
+ _ = try await hasOtherReadyParticipants
.filter { $0 }
.nextValue()📝 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.
| _ = try? await hasOtherReadyParticipants | |
| .filter { $0 } | |
| .nextValue() | |
| _ = try await hasOtherReadyParticipants | |
| .filter { $0 } | |
| .nextValue() |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@DocumentationTests/DocumentationTests/DocumentationTests/05-ui-cookbook/10-call-join-interceptor.swift`
around lines 53 - 55, The readiness wait currently swallows CancellationError by
using "try?" on hasOtherReadyParticipants.filter { $0 }.nextValue(); update the
call in callReadyToJoin to remove the "try?" so that nextValue() is awaited with
normal error propagation (allowing CancellationError to bubble up) — locate the
invocation using hasOtherReadyParticipants and nextValue() inside the
callReadyToJoin async throws function and replace the try? usage with a plain
try/await so cancellation propagates.
🎯 Goal
Add docs for https://github.com/GetStream/docs-content/pull/1220
☑️ Contributor Checklist
Summary by CodeRabbit