mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Fixes #2414 - Move member loading to the room member detail screen, avoid blocking the whole application
This commit is contained in:
@@ -203,131 +203,6 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
XCTAssertEqual(viewModel.state.timelineViewState.itemViewStates[2].groupStyle, .last, "Reactions on the last message should not prevent it from being grouped.")
|
||||
}
|
||||
|
||||
// MARK: - User Details
|
||||
|
||||
func testGoToUserDetailsSuccessNoDelay() async {
|
||||
// Setup
|
||||
let expectation = expectation(description: #function)
|
||||
let timelineController = MockRoomTimelineController()
|
||||
let roomProxyMock = RoomProxyMock(with: .init(displayName: ""))
|
||||
let roomMemberMock = RoomMemberProxyMock()
|
||||
roomMemberMock.userID = "bob"
|
||||
roomProxyMock.getMemberUserIDReturnValue = .success(roomMemberMock)
|
||||
|
||||
let viewModel = RoomScreenViewModel(roomProxy: roomProxyMock,
|
||||
timelineController: timelineController,
|
||||
mediaProvider: MockMediaProvider(),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock(),
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
notificationCenter: NotificationCenterMock())
|
||||
viewModel.actions
|
||||
.sink { action in
|
||||
switch action {
|
||||
case .displayRoomMemberDetails(let member):
|
||||
XCTAssert(member === roomMemberMock)
|
||||
default:
|
||||
XCTFail("Did not received the expected action")
|
||||
}
|
||||
expectation.fulfill()
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
// Test
|
||||
viewModel.context.send(viewAction: .tappedOnUser(userID: "bob"))
|
||||
await fulfillment(of: [expectation])
|
||||
XCTAssert(userIndicatorControllerMock.submitIndicatorDelayCallsCount == 1)
|
||||
XCTAssert(roomProxyMock.getMemberUserIDCallsCount == 1)
|
||||
XCTAssertEqual(roomProxyMock.getMemberUserIDReceivedUserID, "bob")
|
||||
}
|
||||
|
||||
func testGoToUserDetailsSuccessWithDelay() async {
|
||||
// Setup
|
||||
let timelineController = MockRoomTimelineController()
|
||||
let roomProxyMock = RoomProxyMock(with: .init(displayName: ""))
|
||||
let roomMemberMock = RoomMemberProxyMock()
|
||||
roomMemberMock.userID = "bob"
|
||||
let expectation = XCTestExpectation(description: "Go to user details")
|
||||
|
||||
roomProxyMock.getMemberUserIDClosure = { _ in
|
||||
.success(roomMemberMock)
|
||||
}
|
||||
|
||||
let viewModel = RoomScreenViewModel(roomProxy: roomProxyMock,
|
||||
timelineController: timelineController,
|
||||
mediaProvider: MockMediaProvider(),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock(),
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
notificationCenter: NotificationCenterMock())
|
||||
|
||||
viewModel.actions
|
||||
.sink { action in
|
||||
switch action {
|
||||
case .displayRoomMemberDetails(let member):
|
||||
XCTAssert(member === roomMemberMock)
|
||||
expectation.fulfill()
|
||||
default:
|
||||
XCTFail("Did not received the expected action")
|
||||
}
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
// Test
|
||||
viewModel.context.send(viewAction: .tappedOnUser(userID: "bob"))
|
||||
await fulfillment(of: [expectation])
|
||||
|
||||
XCTAssert(userIndicatorControllerMock.submitIndicatorDelayCallsCount == 1)
|
||||
XCTAssert(userIndicatorControllerMock.retractIndicatorWithIdCallsCount == 1)
|
||||
XCTAssert(roomProxyMock.getMemberUserIDCallsCount == 1)
|
||||
XCTAssertEqual(roomProxyMock.getMemberUserIDReceivedUserID, "bob")
|
||||
}
|
||||
|
||||
func testGoToUserDetailsFailure() async throws {
|
||||
// Setup
|
||||
let timelineController = MockRoomTimelineController()
|
||||
let roomProxyMock = RoomProxyMock(with: .init(displayName: ""))
|
||||
let roomMemberMock = RoomMemberProxyMock()
|
||||
roomMemberMock.userID = "bob"
|
||||
roomProxyMock.getMemberUserIDClosure = { _ in
|
||||
.failure(.failedRetrievingMember)
|
||||
}
|
||||
|
||||
let viewModel = RoomScreenViewModel(roomProxy: roomProxyMock,
|
||||
timelineController: timelineController,
|
||||
mediaProvider: MockMediaProvider(),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
voiceMessageMediaManager: VoiceMessageMediaManagerMock(),
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
notificationCenter: NotificationCenterMock())
|
||||
viewModel.actions
|
||||
.sink { _ in
|
||||
XCTFail("Should not receive any action")
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
let deferred = deferFulfillment(viewModel.context.$viewState) { value in
|
||||
value.bindings.alertInfo != nil
|
||||
}
|
||||
|
||||
viewModel.context.send(viewAction: .tappedOnUser(userID: "bob"))
|
||||
|
||||
try await deferred.fulfill()
|
||||
|
||||
XCTAssertFalse(viewModel.state.bindings.alertInfo.isNil)
|
||||
XCTAssert(roomProxyMock.getMemberUserIDCallsCount == 1)
|
||||
XCTAssertEqual(roomProxyMock.getMemberUserIDReceivedUserID, "bob")
|
||||
}
|
||||
|
||||
// MARK: - Sending
|
||||
|
||||
func testRetrySend() async throws {
|
||||
|
||||
Reference in New Issue
Block a user