Files
element-x-ios/ElementX/Sources/Mocks/SpaceServiceProxyMock.swift
T
Doug cde9714a83 Implement the SpaceAddRoomsScreen. (#4951)
* Update proxies ready for adding rooms to a space.

- ClientProxy.recentlyVisitedRooms to take a filter and to return room proxies.
- Expose SpaceServiceProxy.addChildToSpace.

* Implement the SpaceAddRoomsScreen.

* Fix the designs of the selected carousels.

Add more snapshot tests for inviting users.

* Fix for screen using wrong avatar size.
2026-01-14 12:07:57 +00:00

57 lines
2.2 KiB
Swift

//
// Copyright 2025 Element Creations Ltd.
// Copyright 2025 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
import Combine
import Foundation
import MatrixRustSDK
import MatrixRustSDKMocks
extension SpaceServiceProxyMock {
struct Configuration {
var topLevelSpaces: [SpaceServiceRoomProtocol] = []
var joinedParentSpaces: [SpaceServiceRoomProtocol] = []
var spaceRoomLists: [String: SpaceRoomListProxyMock] = [:]
var leaveSpaceRooms: [LeaveSpaceRoom] = []
}
convenience init(_ configuration: Configuration) {
self.init()
topLevelSpacesPublisher = .init(configuration.topLevelSpaces)
joinedParentsChildIDReturnValue = .success(configuration.joinedParentSpaces)
spaceRoomListSpaceIDClosure = { spaceID in
if let spaceRoomList = configuration.spaceRoomLists[spaceID] {
.success(spaceRoomList)
} else {
.failure(.sdkError(ClientProxyMockError.generic))
}
}
leaveSpaceSpaceIDClosure = { spaceID in
.success(LeaveSpaceHandleProxy(spaceID: spaceID,
leaveHandle: LeaveSpaceHandleSDKMock(.init(rooms: configuration.leaveSpaceRooms))))
}
spaceForIdentifierSpaceIDClosure = { spaceID in
.success(configuration.topLevelSpaces.first { $0.id == spaceID })
}
addChildToReturnValue = .success(())
}
}
extension SpaceServiceProxyMock.Configuration {
static var populated: SpaceServiceProxyMock.Configuration {
let spaceRoomLists = [SpaceServiceRoomProtocol].mockJoinedSpaces.map {
($0.id, SpaceRoomListProxyMock(.init(spaceServiceRoom: $0, initialSpaceRooms: .mockSpaceList)))
}
let subSpaceRoomLists = [SpaceServiceRoomProtocol].mockSpaceList.map {
($0.id, SpaceRoomListProxyMock(.init(spaceServiceRoom: $0, initialSpaceRooms: .mockSingleRoom)))
}
return .init(topLevelSpaces: .mockJoinedSpaces, spaceRoomLists: .init(uniqueKeysWithValues: spaceRoomLists + subSpaceRoomLists))
}
}