mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-11 13:59:13 +00:00

* added the address section * updated code and strings * syncing name and address * improved code * added a way to reset the state * better documentation * update strings * handling the alias * alias error state * update strings * error handling * improved the error handling * new preview tests, even if they do not work well * improved tests * unit tests * pr comments and using the correct value * fix * pr comments * to improve safety and control of the FF * fixed a test * updated tests * update SDK
101 lines
4.6 KiB
Swift
101 lines
4.6 KiB
Swift
//
|
|
// Copyright 2024 New Vector Ltd.
|
|
//
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
// Please see LICENSE in the repository root for full details.
|
|
//
|
|
|
|
import Combine
|
|
import Foundation
|
|
|
|
struct ClientProxyMockConfiguration {
|
|
var homeserver = ""
|
|
var userIDServerName: String?
|
|
var userID: String = RoomMemberProxyMock.mockMe.userID
|
|
var deviceID: String?
|
|
var roomSummaryProvider: RoomSummaryProviderProtocol? = RoomSummaryProviderMock(.init())
|
|
var roomDirectorySearchProxy: RoomDirectorySearchProxyProtocol?
|
|
|
|
var recoveryState: SecureBackupRecoveryState = .enabled
|
|
}
|
|
|
|
enum ClientProxyMockError: Error {
|
|
case generic
|
|
}
|
|
|
|
extension ClientProxyMock {
|
|
convenience init(_ configuration: ClientProxyMockConfiguration) {
|
|
self.init()
|
|
|
|
userID = configuration.userID
|
|
deviceID = configuration.deviceID
|
|
|
|
homeserver = configuration.homeserver
|
|
userIDServerName = configuration.userIDServerName
|
|
|
|
roomSummaryProvider = configuration.roomSummaryProvider
|
|
alternateRoomSummaryProvider = RoomSummaryProviderMock(.init())
|
|
|
|
roomDirectorySearchProxyReturnValue = configuration.roomDirectorySearchProxy
|
|
|
|
actionsPublisher = PassthroughSubject<ClientProxyAction, Never>().eraseToAnyPublisher()
|
|
loadingStatePublisher = CurrentValuePublisher<ClientProxyLoadingState, Never>(.notLoading)
|
|
verificationStatePublisher = CurrentValuePublisher<SessionVerificationState, Never>(.unknown)
|
|
|
|
userAvatarURLPublisher = CurrentValueSubject<URL?, Never>(nil).asCurrentValuePublisher()
|
|
|
|
userDisplayNamePublisher = CurrentValueSubject<String?, Never>("User display name").asCurrentValuePublisher()
|
|
|
|
ignoredUsersPublisher = CurrentValueSubject<[String]?, Never>([RoomMemberProxyMock].allMembers.map(\.userID)).asCurrentValuePublisher()
|
|
|
|
notificationSettings = NotificationSettingsProxyMock(with: .init())
|
|
|
|
isOnlyDeviceLeftReturnValue = .success(false)
|
|
accountURLActionReturnValue = "https://matrix.org/account"
|
|
canDeactivateAccount = false
|
|
directRoomForUserIDReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
|
|
createDirectRoomWithExpectedRoomNameReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
|
|
createRoomNameTopicIsRoomPrivateIsKnockingOnlyUserIDsAvatarURLAliasLocalPartReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
|
|
uploadMediaReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
|
|
loadUserDisplayNameReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
|
|
setUserDisplayNameReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
|
|
loadUserAvatarURLReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
|
|
setUserAvatarMediaReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
|
|
removeUserAvatarReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
|
|
isAliasAvailableReturnValue = .success(true)
|
|
logoutReturnValue = nil
|
|
searchUsersSearchTermLimitReturnValue = .success(.init(results: [], limited: false))
|
|
profileForReturnValue = .success(.init(userID: "@a:b.com", displayName: "Some user"))
|
|
ignoreUserReturnValue = .success(())
|
|
unignoreUserReturnValue = .success(())
|
|
|
|
slidingSyncVersion = .native
|
|
availableSlidingSyncVersionsClosure = {
|
|
[]
|
|
}
|
|
|
|
trackRecentlyVisitedRoomReturnValue = .success(())
|
|
recentlyVisitedRoomsReturnValue = .success([])
|
|
recentConversationCounterpartsReturnValue = []
|
|
|
|
getElementWellKnownReturnValue = .success(nil)
|
|
|
|
loadMediaContentForSourceThrowableError = ClientProxyError.sdkError(ClientProxyMockError.generic)
|
|
loadMediaThumbnailForSourceWidthHeightThrowableError = ClientProxyError.sdkError(ClientProxyMockError.generic)
|
|
loadMediaFileForSourceFilenameThrowableError = ClientProxyError.sdkError(ClientProxyMockError.generic)
|
|
|
|
secureBackupController = SecureBackupControllerMock(.init(recoveryState: configuration.recoveryState))
|
|
resetIdentityReturnValue = .success(IdentityResetHandleSDKMock(.init()))
|
|
|
|
roomForIdentifierClosure = { [weak self] identifier in
|
|
guard let room = self?.roomSummaryProvider?.roomListPublisher.value.first(where: { $0.id == identifier }) else {
|
|
return nil
|
|
}
|
|
|
|
return await .joined(JoinedRoomProxyMock(.init(id: room.id, name: room.name)))
|
|
}
|
|
|
|
userIdentityForReturnValue = .success(UserIdentitySDKMock(configuration: .init()))
|
|
}
|
|
}
|