mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Add user search for dm chats (#739)
* Add searchUsers in ClientProxy * Add UserSearchProtocol * Delete UserSearch file * Add search * Refine StartChatScreen * Improve StartChatViewModel * Add localizations * Fix no result style * Update localizations * Add UTs * Add UI tests * Cleanup * Refine tests * Add changelog.d file * Naming refactor * Refactor ClientProxyProtocol api * Fix typo * Add mark * Rename tests * Update Dangerfile * Improve UI test code * Refactor search api * Improve style * Improve combine chain * Add comment * Improve StartChatScreen * Improve updateState * Add extension Published.Publisher * Improve UI tests * Remove Combine import * Cleanup * Remove “proxy” wording * Delete extra extensions * Refactor Publisher api
This commit is contained in:
@@ -21,12 +21,38 @@ import XCTest
|
||||
@MainActor
|
||||
class StartChatScreenViewModelTests: XCTestCase {
|
||||
var viewModel: StartChatViewModelProtocol!
|
||||
var context: StartChatViewModelType.Context!
|
||||
var clientProxy: MockClientProxy!
|
||||
|
||||
@MainActor override func setUpWithError() throws {
|
||||
let userSession = MockUserSession(clientProxy: MockClientProxy(userID: ""),
|
||||
mediaProvider: MockMediaProvider())
|
||||
var context: StartChatViewModel.Context {
|
||||
viewModel.context
|
||||
}
|
||||
|
||||
override func setUpWithError() throws {
|
||||
clientProxy = .init(userID: "")
|
||||
let userSession = MockUserSession(clientProxy: clientProxy, mediaProvider: MockMediaProvider())
|
||||
viewModel = StartChatViewModel(userSession: userSession, userIndicatorController: nil)
|
||||
context = viewModel.context
|
||||
}
|
||||
|
||||
func test_queryShowingNoResults() async throws {
|
||||
viewModel.context.searchQuery = "A"
|
||||
XCTAssertEqual(context.viewState.usersSection.type, .suggestions)
|
||||
|
||||
viewModel.context.searchQuery = "AA"
|
||||
XCTAssertEqual(context.viewState.usersSection.type, .suggestions)
|
||||
|
||||
viewModel.context.searchQuery = "AAA"
|
||||
_ = await context.$viewState.nextValue
|
||||
XCTAssertEqual(context.viewState.usersSection.type, .searchResult)
|
||||
XCTAssert(context.viewState.hasEmptySearchResults)
|
||||
}
|
||||
|
||||
func test_queryShowingResults() async throws {
|
||||
clientProxy.searchUsersResult = .success(.init(results: [UserProfile.mockAlice], limited: true))
|
||||
|
||||
viewModel.context.searchQuery = "AAA"
|
||||
_ = await context.$viewState.nextValue
|
||||
XCTAssertEqual(context.viewState.usersSection.type, .searchResult)
|
||||
XCTAssertEqual(context.viewState.usersSection.users.count, 1)
|
||||
XCTAssertFalse(context.viewState.hasEmptySearchResults)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user