Public Search View (#2585)

Co-authored-by: Doug <6060466+pixlwave@users.noreply.github.com>
This commit is contained in:
Mauro
2024-03-21 15:34:35 +01:00
committed by GitHub
parent a62c96f1c5
commit 562e5e739d
44 changed files with 954 additions and 35 deletions
@@ -1131,6 +1131,23 @@ class ClientProxyMock: ClientProxyProtocol {
return profileForReturnValue
}
}
//MARK: - roomDirectorySearchProxy
var roomDirectorySearchProxyCallsCount = 0
var roomDirectorySearchProxyCalled: Bool {
return roomDirectorySearchProxyCallsCount > 0
}
var roomDirectorySearchProxyReturnValue: RoomDirectorySearchProxyProtocol!
var roomDirectorySearchProxyClosure: (() -> RoomDirectorySearchProxyProtocol)?
func roomDirectorySearchProxy() -> RoomDirectorySearchProxyProtocol {
roomDirectorySearchProxyCallsCount += 1
if let roomDirectorySearchProxyClosure = roomDirectorySearchProxyClosure {
return roomDirectorySearchProxyClosure()
} else {
return roomDirectorySearchProxyReturnValue
}
}
//MARK: - ignoreUser
var ignoreUserCallsCount = 0
@@ -2245,6 +2262,52 @@ class PollInteractionHandlerMock: PollInteractionHandlerProtocol {
}
}
}
class RoomDirectorySearchProxyMock: RoomDirectorySearchProxyProtocol {
var resultsPublisher: CurrentValuePublisher<[RoomDirectorySearchResult], Never> {
get { return underlyingResultsPublisher }
set(value) { underlyingResultsPublisher = value }
}
var underlyingResultsPublisher: CurrentValuePublisher<[RoomDirectorySearchResult], Never>!
//MARK: - search
var searchQueryCallsCount = 0
var searchQueryCalled: Bool {
return searchQueryCallsCount > 0
}
var searchQueryReceivedQuery: String?
var searchQueryReceivedInvocations: [String?] = []
var searchQueryReturnValue: Result<Void, RoomDirectorySearchError>!
var searchQueryClosure: ((String?) async -> Result<Void, RoomDirectorySearchError>)?
func search(query: String?) async -> Result<Void, RoomDirectorySearchError> {
searchQueryCallsCount += 1
searchQueryReceivedQuery = query
searchQueryReceivedInvocations.append(query)
if let searchQueryClosure = searchQueryClosure {
return await searchQueryClosure(query)
} else {
return searchQueryReturnValue
}
}
//MARK: - nextPage
var nextPageCallsCount = 0
var nextPageCalled: Bool {
return nextPageCallsCount > 0
}
var nextPageReturnValue: Result<Void, RoomDirectorySearchError>!
var nextPageClosure: (() async -> Result<Void, RoomDirectorySearchError>)?
func nextPage() async -> Result<Void, RoomDirectorySearchError> {
nextPageCallsCount += 1
if let nextPageClosure = nextPageClosure {
return await nextPageClosure()
} else {
return nextPageReturnValue
}
}
}
class RoomMemberProxyMock: RoomMemberProxyProtocol {
var userID: String {
get { return underlyingUserID }
@@ -505,6 +505,23 @@ class SDKClientMock: SDKClientProtocol {
restoreSessionSessionReceivedInvocations.append(session)
try restoreSessionSessionClosure?(session)
}
//MARK: - roomDirectorySearch
public var roomDirectorySearchCallsCount = 0
public var roomDirectorySearchCalled: Bool {
return roomDirectorySearchCallsCount > 0
}
public var roomDirectorySearchReturnValue: RoomDirectorySearch!
public var roomDirectorySearchClosure: (() -> RoomDirectorySearch)?
public func roomDirectorySearch() -> RoomDirectorySearch {
roomDirectorySearchCallsCount += 1
if let roomDirectorySearchClosure = roomDirectorySearchClosure {
return roomDirectorySearchClosure()
} else {
return roomDirectorySearchReturnValue
}
}
//MARK: - rooms
public var roomsCallsCount = 0
@@ -0,0 +1,31 @@
//
// Copyright 2024 New Vector Ltd
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
import Combine
import Foundation
struct RoomDirectorySearchProxyMockConfiguration {
let results: [RoomDirectorySearchResult]
}
extension RoomDirectorySearchProxyMock {
convenience init(configuration: RoomDirectorySearchProxyMockConfiguration) {
self.init()
resultsPublisher = CurrentValueSubject(configuration.results).asCurrentValuePublisher()
searchQueryReturnValue = .success(())
nextPageReturnValue = .success(())
}
}