Refactor the JoinRoom screen to take advantage of newer APIs and support more joinRule/membership combinations (i.e. invite required, restricted, banned) (#3685)

- expose the full RoomPreview and RoomMembershipDetails through their own proxies
- implement standard mocks for all the different combinations
- converge on a single room info provider
- rebuild all the previews
- prioritise the preview data over the room one.
This commit is contained in:
Stefan Ceriu
2025-01-20 19:07:11 +02:00
committed by GitHub
parent f20847f62b
commit 8577f53613
48 changed files with 504 additions and 248 deletions
@@ -74,33 +74,25 @@ class JoinRoomScreenViewModelTests: XCTestCase {
}
private func setupViewModel(throwing: Bool = false, knocked: Bool = false) {
ServiceLocator.shared.settings.knockingEnabled = true
let clientProxy = ClientProxyMock(.init())
clientProxy.joinRoomViaReturnValue = throwing ? .failure(.sdkError(ClientProxyMockError.generic)) : .success(())
clientProxy.roomPreviewForIdentifierViaReturnValue = .success(.init(roomID: "",
name: nil,
canonicalAlias: nil,
topic: nil,
avatarURL: nil,
memberCount: 0,
isHistoryWorldReadable: nil,
isJoined: false,
isInvited: false,
isPublic: false,
canKnock: false))
if knocked {
clientProxy.roomPreviewForIdentifierViaReturnValue = .success(RoomPreviewProxyMock.knocked)
clientProxy.roomForIdentifierClosure = { _ in
let roomProxy = KnockedRoomProxyMock(.init())
// to test the cancel knock function
roomProxy.cancelKnockUnderlyingReturnValue = .success(())
return .knocked(roomProxy)
}
} else {
clientProxy.roomPreviewForIdentifierViaReturnValue = .success(RoomPreviewProxyMock.joinable)
}
ServiceLocator.shared.settings.knockingEnabled = true
viewModel = JoinRoomScreenViewModel(roomID: "1",
via: [],
appSettings: ServiceLocator.shared.settings,