mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Improve user profile search (#1266)
* Filter account owner in UserDiscoveryService * Add tests and refine logics
This commit is contained in:
@@ -24,7 +24,7 @@ class UserDiscoveryServiceTest: XCTestCase {
|
||||
var clientProxy: MockClientProxy!
|
||||
|
||||
override func setUpWithError() throws {
|
||||
clientProxy = .init(userID: "")
|
||||
clientProxy = .init(userID: "@foo:matrix.org")
|
||||
service = UserDiscoveryService(clientProxy: clientProxy)
|
||||
}
|
||||
|
||||
@@ -34,6 +34,13 @@ class UserDiscoveryServiceTest: XCTestCase {
|
||||
let results = await (try? search(query: "AAA").get()) ?? []
|
||||
assertSearchResults(results, toBe: 1)
|
||||
}
|
||||
|
||||
func testOwnerIsFiltered() async throws {
|
||||
clientProxy.searchUsersResult = .success(.init(results: [UserProfileProxy(userID: "@foo:matrix.org")], limited: true))
|
||||
|
||||
let results = await (try? search(query: "AAA").get()) ?? []
|
||||
assertSearchResults(results, toBe: 0)
|
||||
}
|
||||
|
||||
func testGetProfileIsNotCalled() async {
|
||||
clientProxy.searchUsersResult = .success(.init(results: searchResults, limited: true))
|
||||
@@ -43,6 +50,15 @@ class UserDiscoveryServiceTest: XCTestCase {
|
||||
assertSearchResults(results, toBe: 3)
|
||||
XCTAssertFalse(clientProxy.getProfileCalled)
|
||||
}
|
||||
|
||||
func testGetProfileIsNotCalledForAccountOwnerID() async {
|
||||
clientProxy.searchUsersResult = .success(.init(results: searchResults, limited: true))
|
||||
clientProxy.getProfileResult = .success(.init(userID: "@alice:matrix.org"))
|
||||
|
||||
let results = await (try? search(query: "foo:matrix.org").get()) ?? []
|
||||
assertSearchResults(results, toBe: 3)
|
||||
XCTAssertFalse(clientProxy.getProfileCalled)
|
||||
}
|
||||
|
||||
func testLocalResultShows() async {
|
||||
clientProxy.searchUsersResult = .success(.init(results: searchResults, limited: true))
|
||||
|
||||
Reference in New Issue
Block a user