mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user