Observe room info updates and automatically dismiss the room if meanwhile left or banned (#4122)

* Fix #3302 - Observe room info updates and automatically dismiss the room if meanwhile left or banned.
This commit is contained in:
Stefan Ceriu
2025-05-16 12:55:33 +03:00
committed by GitHub
parent f5089e8d81
commit 35f615ddd1
3 changed files with 42 additions and 1 deletions
@@ -268,6 +268,31 @@ class RoomFlowCoordinatorTests: XCTestCase {
XCTAssertNil(navigationStackCoordinator.sheetCoordinator, "The media upload sheet shouldn't be shown when sharing text.")
}
func testLeavingRoom() async throws {
await setupRoomFlowCoordinator()
var configuration = JoinedRoomProxyMockConfiguration()
let roomProxy = JoinedRoomProxyMock(configuration)
let roomInfoSubject = CurrentValueSubject<RoomInfoProxy, Never>(.init(roomInfo: .init(configuration)))
roomProxy.infoPublisher = roomInfoSubject.asCurrentValuePublisher()
clientProxy.roomForIdentifierClosure = { _ in
.joined(roomProxy)
}
try await process(route: .room(roomID: "1", via: []))
let fulfillment = deferFulfillment(roomFlowCoordinator.actions) { action in
action == .finished
}
configuration.membership = .left
roomInfoSubject.send(.init(roomInfo: .init(configuration)))
try await fulfillment.fulfill()
}
// MARK: - Private
private func process(route: AppRoute) async throws {