mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Rename UserProfileProxy to UserProfile. It's a pure struct and proxies nothing.
Also remove the redundant `userID` property given `id` already exists (for Identifiable conformance).
This commit is contained in:
@@ -19,7 +19,7 @@ final class CreateRoomScreenViewModelTests {
|
||||
|
||||
private let appSettings: AppSettings
|
||||
|
||||
private let usersSubject = CurrentValueSubject<[UserProfileProxy], Never>([])
|
||||
private let usersSubject = CurrentValueSubject<[UserProfile], Never>([])
|
||||
|
||||
var context: CreateRoomScreenViewModel.Context {
|
||||
viewModel.context
|
||||
|
||||
@@ -29,7 +29,7 @@ final class InviteUsersScreenViewModelTests {
|
||||
#expect(context.viewState.selectedUsers.isEmpty)
|
||||
context.send(viewAction: .toggleUser(.mockAlice))
|
||||
#expect(context.viewState.selectedUsers.count == 1)
|
||||
#expect(context.viewState.selectedUsers.first?.userID == UserProfileProxy.mockAlice.userID)
|
||||
#expect(context.viewState.selectedUsers.first?.id == UserProfile.mockAlice.id)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -41,7 +41,7 @@ final class InviteUsersScreenViewModelTests {
|
||||
#expect(context.viewState.selectedUsers.isEmpty)
|
||||
context.send(viewAction: .toggleUser(.mockAlice))
|
||||
#expect(context.viewState.selectedUsers.count == 1)
|
||||
#expect(context.viewState.selectedUsers.first?.userID == UserProfileProxy.mockAlice.userID)
|
||||
#expect(context.viewState.selectedUsers.first?.id == UserProfile.mockAlice.id)
|
||||
context.send(viewAction: .toggleUser(.mockAlice))
|
||||
#expect(context.viewState.selectedUsers.isEmpty)
|
||||
}
|
||||
@@ -55,7 +55,7 @@ final class InviteUsersScreenViewModelTests {
|
||||
#expect(context.viewState.selectedUsers.isEmpty)
|
||||
context.send(viewAction: .toggleUser(.mockAlice))
|
||||
#expect(context.viewState.selectedUsers.count == 1)
|
||||
#expect(context.viewState.selectedUsers.first?.userID == UserProfileProxy.mockAlice.userID)
|
||||
#expect(context.viewState.selectedUsers.first?.id == UserProfile.mockAlice.id)
|
||||
context.send(viewAction: .toggleUser(.mockAlice))
|
||||
#expect(context.viewState.selectedUsers.isEmpty)
|
||||
}
|
||||
@@ -174,7 +174,7 @@ final class InviteUsersScreenViewModelTests {
|
||||
appSettings: .volatile())
|
||||
|
||||
// The locked invitee starts pre-selected and locked.
|
||||
#expect(context.viewState.selectedUsers.map(\.userID) == [UserProfileProxy.mockAlice.userID])
|
||||
#expect(context.viewState.selectedUsers.map(\.id) == [UserProfile.mockAlice.id])
|
||||
#expect(context.viewState.isInviteeMandatory(.mockAlice))
|
||||
// The proceed button is disabled while the only selected user is the locked invitee.
|
||||
#expect(!context.viewState.hasInvitableSelectedUsers)
|
||||
@@ -218,7 +218,7 @@ final class InviteUsersScreenViewModelTests {
|
||||
#expect(args.topic == nil)
|
||||
#expect(args.accessType == .private)
|
||||
#expect(args.isSpace == false)
|
||||
#expect(args.userIDs == [UserProfileProxy.mockAlice.userID, UserProfileProxy.mockBob.userID])
|
||||
#expect(args.userIDs == [UserProfile.mockAlice.id, UserProfile.mockBob.id])
|
||||
#expect(args.avatarURL == nil)
|
||||
#expect(args.aliasLocalPart == nil)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import Testing
|
||||
struct RoomSummaryTests {
|
||||
// swiftlint:disable:next large_tuple
|
||||
let roomDetails: (id: String, name: String, avatarURL: URL) = ("room_id", "Room Name", "mxc://hs.tld/room/avatar")
|
||||
let heroes = [UserProfileProxy(userID: "hero_1", displayName: "Hero 1", avatarURL: "mxc://hs.tld/user/avatar")]
|
||||
let heroes = [UserProfile(userID: "hero_1", displayName: "Hero 1", avatarURL: "mxc://hs.tld/user/avatar")]
|
||||
|
||||
@Test
|
||||
func roomAvatar() {
|
||||
|
||||
@@ -14,7 +14,7 @@ struct UserDiscoveryServiceTest {
|
||||
private var service: UserDiscoveryService
|
||||
private var clientProxy: ClientProxyMock
|
||||
|
||||
private var searchResults: [UserProfileProxy] {
|
||||
private var searchResults: [UserProfile] {
|
||||
[.mockAlice, .mockBob, .mockCharlie]
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ struct UserDiscoveryServiceTest {
|
||||
|
||||
@Test
|
||||
func queryShowingResults() async {
|
||||
clientProxy.searchUsersSearchTermLimitReturnValue = .success(.init(results: [UserProfileProxy.mockAlice], limited: true))
|
||||
clientProxy.searchUsersSearchTermLimitReturnValue = .success(.init(results: [UserProfile.mockAlice], limited: true))
|
||||
|
||||
let results = await (try? search(query: "AAA").get()) ?? []
|
||||
assertSearchResults(results, toBe: 1)
|
||||
@@ -33,7 +33,7 @@ struct UserDiscoveryServiceTest {
|
||||
|
||||
@Test
|
||||
func ownerIsFiltered() async {
|
||||
clientProxy.searchUsersSearchTermLimitReturnValue = .success(.init(results: [UserProfileProxy(userID: "@foo:matrix.org")], limited: true))
|
||||
clientProxy.searchUsersSearchTermLimitReturnValue = .success(.init(results: [UserProfile(userID: "@foo:matrix.org")], limited: true))
|
||||
|
||||
let results = await (try? search(query: "AAA").get()) ?? []
|
||||
assertSearchResults(results, toBe: 0)
|
||||
@@ -104,7 +104,7 @@ struct UserDiscoveryServiceTest {
|
||||
let results = await (try? search(query: "@a:b.com").get()) ?? []
|
||||
|
||||
assertSearchResults(results, toBe: 3)
|
||||
let firstUserID = results.first?.userID
|
||||
let firstUserID = results.first?.id
|
||||
#expect(firstUserID == "@bob:matrix.org")
|
||||
#expect(clientProxy.profileForCalled)
|
||||
}
|
||||
@@ -116,20 +116,20 @@ struct UserDiscoveryServiceTest {
|
||||
|
||||
let results = await (try? search(query: "@a:b.com").get()) ?? []
|
||||
|
||||
let firstUserID = results.first?.userID
|
||||
let firstUserID = results.first?.id
|
||||
#expect(firstUserID == "@a:b.com")
|
||||
#expect(clientProxy.profileForCalled)
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func assertSearchResults(_ results: [UserProfileProxy], toBe count: Int) {
|
||||
private func assertSearchResults(_ results: [UserProfile], toBe count: Int) {
|
||||
#expect(count >= 0)
|
||||
#expect(results.count == count)
|
||||
#expect(results.isEmpty == (count == 0))
|
||||
}
|
||||
|
||||
private func search(query: String) async -> Result<[UserProfileProxy], UserDiscoveryErrorType> {
|
||||
private func search(query: String) async -> Result<[UserProfile], UserDiscoveryErrorType> {
|
||||
await service.searchProfiles(with: query)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@ struct UserProfileScreenViewModelTests {
|
||||
func initialState() async throws {
|
||||
let userIndicatorController = UserIndicatorControllerMock()
|
||||
|
||||
let profile = UserProfileProxy(userID: "@alice:matrix.org", displayName: "Alice", avatarURL: .mockMXCAvatar)
|
||||
let profile = UserProfile(userID: "@alice:matrix.org", displayName: "Alice", avatarURL: .mockMXCAvatar)
|
||||
let clientProxy = ClientProxyMock(.init())
|
||||
clientProxy.profileForReturnValue = .success(profile)
|
||||
|
||||
let viewModel = UserProfileScreenViewModel(userID: profile.userID,
|
||||
let viewModel = UserProfileScreenViewModel(userID: profile.id,
|
||||
isPresentedModally: false,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||
userIndicatorController: userIndicatorController,
|
||||
@@ -39,11 +39,11 @@ struct UserProfileScreenViewModelTests {
|
||||
func initialStateAccountOwner() async throws {
|
||||
let userIndicatorController = UserIndicatorControllerMock()
|
||||
|
||||
let profile = UserProfileProxy(userID: RoomMemberProxyMock.mockMe.userID, displayName: "Me", avatarURL: .mockMXCAvatar)
|
||||
let profile = UserProfile(userID: RoomMemberProxyMock.mockMe.userID, displayName: "Me", avatarURL: .mockMXCAvatar)
|
||||
let clientProxy = ClientProxyMock(.init())
|
||||
clientProxy.profileForReturnValue = .success(profile)
|
||||
|
||||
let viewModel = UserProfileScreenViewModel(userID: profile.userID,
|
||||
let viewModel = UserProfileScreenViewModel(userID: profile.id,
|
||||
isPresentedModally: false,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||
userIndicatorController: userIndicatorController,
|
||||
@@ -63,13 +63,13 @@ struct UserProfileScreenViewModelTests {
|
||||
func startingDmWithUnknownUserFetchesIdentity() async throws {
|
||||
let userIndicatorController = UserIndicatorControllerMock()
|
||||
|
||||
let profile = UserProfileProxy.mockAlice
|
||||
let profile = UserProfile.mockAlice
|
||||
|
||||
let clientProxy = ClientProxyMock(.init())
|
||||
clientProxy.directRoomForUserIDReturnValue = .success(nil)
|
||||
clientProxy.userIdentityForFallBackToServerReturnValue = .success(nil)
|
||||
|
||||
let viewModel = UserProfileScreenViewModel(userID: profile.userID,
|
||||
let viewModel = UserProfileScreenViewModel(userID: profile.id,
|
||||
isPresentedModally: false,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||
userIndicatorController: userIndicatorController,
|
||||
|
||||
Reference in New Issue
Block a user