mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Adopt room info power levels (#4245)
* Use the newly RoomInfo published PowerLevels; update permissions at the same time as the room info and avoid unnecessary async calls. * Introduce a RoomInfoProxyProtocol and associated mock and move away from mocked SDK RoomInfos * Bump the SDK to v25.06.23 * Expose new non-throwing methods for checking one's own user permissions * Fix the unit and preview tests (except the TimelineMediaPreviewDetails for which simplified snapshots were generated) * Converge on one single implementation for computing a room's avatar. * Fix more unit tests * Fix the TimelineMediaPreviewDetailsView snapshot tests This reverts commit 9b6c819e611ad2fa3de2c34a4a7aa556fc9faadd. --------- Co-authored-by: Doug <douglase@element.io>
This commit is contained in:
@@ -468,7 +468,7 @@ class TimelineViewModelTests: XCTestCase {
|
||||
var configuration = JoinedRoomProxyMockConfiguration(name: "",
|
||||
pinnedEventIDs: .init(["test1"]))
|
||||
let roomProxyMock = JoinedRoomProxyMock(configuration)
|
||||
let infoSubject = CurrentValueSubject<RoomInfoProxy, Never>(.init(roomInfo: RoomInfo(configuration)))
|
||||
let infoSubject = CurrentValueSubject<RoomInfoProxyProtocol, Never>(RoomInfoProxyMock(configuration))
|
||||
roomProxyMock.underlyingInfoPublisher = infoSubject.asCurrentValuePublisher()
|
||||
|
||||
let viewModel = TimelineViewModel(roomProxy: roomProxyMock,
|
||||
@@ -489,7 +489,7 @@ class TimelineViewModelTests: XCTestCase {
|
||||
let deferred = deferFulfillment(viewModel.context.$viewState) { value in
|
||||
value.pinnedEventIDs == ["test1", "test2"]
|
||||
}
|
||||
infoSubject.send(.init(roomInfo: RoomInfo(configuration)))
|
||||
infoSubject.send(RoomInfoProxyMock(configuration))
|
||||
try await deferred.fulfill()
|
||||
}
|
||||
|
||||
@@ -497,7 +497,7 @@ class TimelineViewModelTests: XCTestCase {
|
||||
let configuration = JoinedRoomProxyMockConfiguration(name: "",
|
||||
powerLevelsConfiguration: .init(canUserPin: true))
|
||||
let roomProxyMock = JoinedRoomProxyMock(configuration)
|
||||
let infoSubject = CurrentValueSubject<RoomInfoProxy, Never>(.init(roomInfo: RoomInfo(configuration)))
|
||||
let infoSubject = CurrentValueSubject<RoomInfoProxyProtocol, Never>(RoomInfoProxyMock(configuration))
|
||||
roomProxyMock.underlyingInfoPublisher = infoSubject.asCurrentValuePublisher()
|
||||
|
||||
let viewModel = TimelineViewModel(roomProxy: roomProxyMock,
|
||||
@@ -518,14 +518,17 @@ class TimelineViewModelTests: XCTestCase {
|
||||
}
|
||||
try await deferred.fulfill()
|
||||
|
||||
let powerLevelsMock = RoomPowerLevelsProxyMock(configuration: .init())
|
||||
powerLevelsMock.canUserPinOrUnpinUserIDReturnValue = .success(false)
|
||||
roomProxyMock.powerLevelsReturnValue = .success(powerLevelsMock)
|
||||
let powerLevelsProxyMock = RoomPowerLevelsProxyMock(configuration: .init())
|
||||
powerLevelsProxyMock.canUserPinOrUnpinUserIDReturnValue = .success(false)
|
||||
roomProxyMock.powerLevelsReturnValue = .success(powerLevelsProxyMock)
|
||||
|
||||
let roomInfoProxyMock = RoomInfoProxyMock(configuration)
|
||||
roomInfoProxyMock.powerLevels = powerLevelsProxyMock
|
||||
|
||||
deferred = deferFulfillment(viewModel.context.$viewState) { value in
|
||||
!value.canCurrentUserPin
|
||||
}
|
||||
infoSubject.send(.init(roomInfo: RoomInfo(configuration)))
|
||||
infoSubject.send(roomInfoProxyMock)
|
||||
try await deferred.fulfill()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user