fixed existing tests and added tests for all the threaded flows

This commit is contained in:
Mauro Romito
2025-10-01 19:12:57 +02:00
committed by Mauro
parent a42cb77368
commit 8f31671e10
4 changed files with 106 additions and 5 deletions
@@ -173,8 +173,9 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
if case .thread(threadRootEventID: threadRootEventID, _) = stateMachine.state, let threadCoordinator = childThreads.last {
threadCoordinator.focusOnEvent(eventID: eventID)
} else {
// If we are showing the room timeline, we want to focus the thread root
if childThreads.isEmpty {
roomScreenCoordinator?.focusOnEvent(.init(eventID: eventID, shouldSetPin: false))
roomScreenCoordinator?.focusOnEvent(.init(eventID: threadRootEventID, shouldSetPin: false))
}
stateMachine.tryEvent(.presentThread(threadRootEventID: threadRootEventID, focusEventID: eventID))
}
+7 -3
View File
@@ -96,11 +96,15 @@ extension ClientProxyMock {
roomForIdentifierClosure = { [weak self] identifier in
if let room = self?.roomSummaryProvider.roomListPublisher.value.first(where: { $0.id == identifier }) {
await .joined(JoinedRoomProxyMock(.init(id: room.id, name: room.name)))
let roomProxy = await JoinedRoomProxyMock(.init(id: room.id, name: room.name))
roomProxy.loadOrFetchEventForReturnValue = .success(TimelineEventSDKMock())
return .joined(roomProxy)
} else if let spaceRoomProxy = configuration.joinedSpaceRooms.first(where: { $0.id == identifier }) {
await .joined(JoinedRoomProxyMock(.init(id: spaceRoomProxy.id, name: spaceRoomProxy.name)))
let roomProxy = await JoinedRoomProxyMock(.init(id: spaceRoomProxy.id, name: spaceRoomProxy.name))
roomProxy.loadOrFetchEventForReturnValue = .success(TimelineEventSDKMock())
return .joined(roomProxy)
} else {
nil
return nil
}
}
@@ -10,6 +10,7 @@ import Foundation
extension TimelineControllerFactoryMock {
struct Configuration {
var timelineController: TimelineControllerProtocol?
var threadTimelineController: TimelineControllerProtocol?
}
convenience init(_ configuration: Configuration) {
@@ -20,5 +21,15 @@ extension TimelineControllerFactoryMock {
timelineController.timelineItems = RoomTimelineItemFixtures.largeChunk
return timelineController
}()
buildThreadTimelineControllerEventIDRoomProxyTimelineItemFactoryMediaProviderClosure = { threadRootEventID, _, _, _ in
if let threadTimelineController = configuration.threadTimelineController {
return .success(threadTimelineController)
} else {
let timelineController = MockTimelineController(timelineKind: .thread(rootEventID: threadRootEventID))
timelineController.timelineItems = RoomTimelineItemFixtures.largeChunk
return .success(timelineController)
}
}
}
}