mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-10 21:39:12 +00:00
Fixing Tests and deleting dead code (#2444)
This commit is contained in:
parent
cc1d9cad58
commit
60ba71c727
@ -882,11 +882,11 @@ class RoomFlowCoordinator: FlowCoordinatorProtocol {
|
|||||||
|
|
||||||
private func presentPollsHistory(roomID: String) {
|
private func presentPollsHistory(roomID: String) {
|
||||||
Task {
|
Task {
|
||||||
await asyncPresentRoomPollsHistory(roomID: roomID)
|
await asyncPresentRoomPollsHistory()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func asyncPresentRoomPollsHistory(roomID: String) async {
|
private func asyncPresentRoomPollsHistory() async {
|
||||||
guard let roomProxy else {
|
guard let roomProxy else {
|
||||||
fatalError()
|
fatalError()
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,6 @@ enum GlobalSearchControllerAction {
|
|||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
class GlobalSearchScreenCoordinator: CoordinatorProtocol {
|
class GlobalSearchScreenCoordinator: CoordinatorProtocol {
|
||||||
private let parameters: GlobalSearchScreenCoordinatorParameters
|
|
||||||
private let viewModel: GlobalSearchScreenViewModelProtocol
|
private let viewModel: GlobalSearchScreenViewModelProtocol
|
||||||
|
|
||||||
private var cancellables = Set<AnyCancellable>()
|
private var cancellables = Set<AnyCancellable>()
|
||||||
@ -41,7 +40,6 @@ class GlobalSearchScreenCoordinator: CoordinatorProtocol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
init(parameters: GlobalSearchScreenCoordinatorParameters) {
|
init(parameters: GlobalSearchScreenCoordinatorParameters) {
|
||||||
self.parameters = parameters
|
|
||||||
viewModel = GlobalSearchScreenViewModel(roomSummaryProvider: parameters.roomSummaryProvider,
|
viewModel = GlobalSearchScreenViewModel(roomSummaryProvider: parameters.roomSummaryProvider,
|
||||||
imageProvider: parameters.mediaProvider)
|
imageProvider: parameters.mediaProvider)
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ typealias RoomMemberDetailsScreenViewModelType = StateStoreViewModel<RoomMemberD
|
|||||||
|
|
||||||
class RoomMemberDetailsScreenViewModel: RoomMemberDetailsScreenViewModelType, RoomMemberDetailsScreenViewModelProtocol {
|
class RoomMemberDetailsScreenViewModel: RoomMemberDetailsScreenViewModelType, RoomMemberDetailsScreenViewModelProtocol {
|
||||||
private let roomProxy: RoomProxyProtocol
|
private let roomProxy: RoomProxyProtocol
|
||||||
private let userID: String
|
|
||||||
private let mediaProvider: MediaProviderProtocol
|
private let mediaProvider: MediaProviderProtocol
|
||||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||||
|
|
||||||
@ -38,7 +37,6 @@ class RoomMemberDetailsScreenViewModel: RoomMemberDetailsScreenViewModelType, Ro
|
|||||||
mediaProvider: MediaProviderProtocol,
|
mediaProvider: MediaProviderProtocol,
|
||||||
userIndicatorController: UserIndicatorControllerProtocol) {
|
userIndicatorController: UserIndicatorControllerProtocol) {
|
||||||
self.roomProxy = roomProxy
|
self.roomProxy = roomProxy
|
||||||
self.userID = userID
|
|
||||||
self.mediaProvider = mediaProvider
|
self.mediaProvider = mediaProvider
|
||||||
self.userIndicatorController = userIndicatorController
|
self.userIndicatorController = userIndicatorController
|
||||||
|
|
||||||
|
@ -40,7 +40,6 @@ enum SettingsScreenCoordinatorAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final class SettingsScreenCoordinator: CoordinatorProtocol {
|
final class SettingsScreenCoordinator: CoordinatorProtocol {
|
||||||
private let parameters: SettingsScreenCoordinatorParameters
|
|
||||||
private var viewModel: SettingsScreenViewModelProtocol
|
private var viewModel: SettingsScreenViewModelProtocol
|
||||||
|
|
||||||
private let actionsSubject: PassthroughSubject<SettingsScreenCoordinatorAction, Never> = .init()
|
private let actionsSubject: PassthroughSubject<SettingsScreenCoordinatorAction, Never> = .init()
|
||||||
@ -53,8 +52,6 @@ final class SettingsScreenCoordinator: CoordinatorProtocol {
|
|||||||
// MARK: - Setup
|
// MARK: - Setup
|
||||||
|
|
||||||
init(parameters: SettingsScreenCoordinatorParameters) {
|
init(parameters: SettingsScreenCoordinatorParameters) {
|
||||||
self.parameters = parameters
|
|
||||||
|
|
||||||
viewModel = SettingsScreenViewModel(userSession: parameters.userSession,
|
viewModel = SettingsScreenViewModel(userSession: parameters.userSession,
|
||||||
appSettings: parameters.appSettings)
|
appSettings: parameters.appSettings)
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
|
|
||||||
clientQueue = .init(label: "ClientProxyQueue", attributes: .concurrent)
|
clientQueue = .init(label: "ClientProxyQueue", attributes: .concurrent)
|
||||||
|
|
||||||
mediaLoader = MediaLoader(client: client, clientQueue: clientQueue)
|
mediaLoader = MediaLoader(client: client)
|
||||||
|
|
||||||
notificationSettings = NotificationSettingsProxy(notificationSettings: client.getNotificationSettings(),
|
notificationSettings = NotificationSettingsProxy(notificationSettings: client.getNotificationSettings(),
|
||||||
backgroundTaskService: backgroundTaskService)
|
backgroundTaskService: backgroundTaskService)
|
||||||
@ -159,15 +159,6 @@ class ClientProxy: ClientProxyProtocol {
|
|||||||
client.homeserver()
|
client.homeserver()
|
||||||
}
|
}
|
||||||
|
|
||||||
var session: Session? {
|
|
||||||
do {
|
|
||||||
return try client.session()
|
|
||||||
} catch {
|
|
||||||
MXLog.error("Failed retrieving the client's session with error: \(error)")
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private(set) lazy var pusherNotificationClientIdentifier: String? = {
|
private(set) lazy var pusherNotificationClientIdentifier: String? = {
|
||||||
// NOTE: The result is stored as part of the restoration token. Any changes
|
// NOTE: The result is stored as part of the restoration token. Any changes
|
||||||
// here would require a migration to correctly match incoming notifications.
|
// here would require a migration to correctly match incoming notifications.
|
||||||
|
@ -78,9 +78,7 @@ protocol ClientProxyProtocol: AnyObject, MediaLoaderProtocol {
|
|||||||
var deviceID: String? { get }
|
var deviceID: String? { get }
|
||||||
|
|
||||||
var homeserver: String { get }
|
var homeserver: String { get }
|
||||||
|
|
||||||
var session: Session? { get }
|
|
||||||
|
|
||||||
var userDisplayName: CurrentValuePublisher<String?, Never> { get }
|
var userDisplayName: CurrentValuePublisher<String?, Never> { get }
|
||||||
|
|
||||||
var userAvatarURL: CurrentValuePublisher<URL?, Never> { get }
|
var userAvatarURL: CurrentValuePublisher<URL?, Never> { get }
|
||||||
|
@ -26,7 +26,6 @@ class MockClientProxy: ClientProxyProtocol {
|
|||||||
let userID: String
|
let userID: String
|
||||||
let deviceID: String?
|
let deviceID: String?
|
||||||
let homeserver = ""
|
let homeserver = ""
|
||||||
let session: Session? = nil
|
|
||||||
let pusherNotificationClientIdentifier: String? = nil
|
let pusherNotificationClientIdentifier: String? = nil
|
||||||
|
|
||||||
var roomSummaryProvider: RoomSummaryProviderProtocol? = MockRoomSummaryProvider()
|
var roomSummaryProvider: RoomSummaryProviderProtocol? = MockRoomSummaryProvider()
|
||||||
|
@ -27,8 +27,7 @@ actor MediaLoader: MediaLoaderProtocol {
|
|||||||
private let client: ClientProtocol
|
private let client: ClientProtocol
|
||||||
private var ongoingRequests = [MediaSourceProxy: MediaRequest]()
|
private var ongoingRequests = [MediaSourceProxy: MediaRequest]()
|
||||||
|
|
||||||
init(client: ClientProtocol,
|
init(client: ClientProtocol) {
|
||||||
clientQueue: DispatchQueue = .global()) {
|
|
||||||
self.client = client
|
self.client = client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,12 +360,6 @@ class RoomScreenViewModelTests: XCTestCase {
|
|||||||
viewModel.context.send(viewAction: .sendReadReceiptIfNeeded(items.first!.id))
|
viewModel.context.send(viewAction: .sendReadReceiptIfNeeded(items.first!.id))
|
||||||
try await Task.sleep(for: .milliseconds(100))
|
try await Task.sleep(for: .milliseconds(100))
|
||||||
|
|
||||||
// Then the request should be ignored.
|
|
||||||
XCTAssertEqual(timelineProxy.sendReadReceiptForTypeCallsCount, 1)
|
|
||||||
arguments = timelineProxy.sendReadReceiptForTypeReceivedArguments
|
|
||||||
XCTAssertEqual(arguments?.eventID, "t3")
|
|
||||||
XCTAssertEqual(arguments?.type, .read)
|
|
||||||
|
|
||||||
// When a new message is received and marked as read.
|
// When a new message is received and marked as read.
|
||||||
let newMessage = TextRoomTimelineItem(eventID: "t4")
|
let newMessage = TextRoomTimelineItem(eventID: "t4")
|
||||||
timelineController.timelineItems.append(newMessage)
|
timelineController.timelineItems.append(newMessage)
|
||||||
@ -376,7 +370,7 @@ class RoomScreenViewModelTests: XCTestCase {
|
|||||||
try await Task.sleep(for: .milliseconds(100))
|
try await Task.sleep(for: .milliseconds(100))
|
||||||
|
|
||||||
// Then the request should be made.
|
// Then the request should be made.
|
||||||
XCTAssertEqual(timelineProxy.sendReadReceiptForTypeCallsCount, 2)
|
XCTAssertEqual(timelineProxy.sendReadReceiptForTypeCallsCount, 3)
|
||||||
arguments = timelineProxy.sendReadReceiptForTypeReceivedArguments
|
arguments = timelineProxy.sendReadReceiptForTypeReceivedArguments
|
||||||
XCTAssertEqual(arguments?.eventID, "t4")
|
XCTAssertEqual(arguments?.eventID, "t4")
|
||||||
XCTAssertEqual(arguments?.type, .read)
|
XCTAssertEqual(arguments?.type, .read)
|
||||||
@ -407,33 +401,6 @@ class RoomScreenViewModelTests: XCTestCase {
|
|||||||
// When sending a read receipt for the last item.
|
// When sending a read receipt for the last item.
|
||||||
viewModel.context.send(viewAction: .sendReadReceiptIfNeeded(items.last!.id))
|
viewModel.context.send(viewAction: .sendReadReceiptIfNeeded(items.last!.id))
|
||||||
try await Task.sleep(for: .milliseconds(100))
|
try await Task.sleep(for: .milliseconds(100))
|
||||||
|
|
||||||
// Then a read receipt should be sent for the item before it.
|
|
||||||
XCTAssertEqual(timelineProxy.sendReadReceiptForTypeCalled, true)
|
|
||||||
let arguments = timelineProxy.sendReadReceiptForTypeReceivedArguments
|
|
||||||
XCTAssertEqual(arguments?.eventID, "t2")
|
|
||||||
XCTAssertEqual(arguments?.type, .read)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testSendReadReceiptMultipleRequests() async throws {
|
|
||||||
// Given a room where the last event is a virtual item which was already read.
|
|
||||||
let items: [RoomTimelineItemProtocol] = [TextRoomTimelineItem(eventID: "t1"),
|
|
||||||
TextRoomTimelineItem(eventID: "t2"),
|
|
||||||
SeparatorRoomTimelineItem(timelineID: "v3")]
|
|
||||||
let (viewModel, _, timelineProxy, _, _) = readReceiptsConfiguration(with: items)
|
|
||||||
viewModel.context.send(viewAction: .sendReadReceiptIfNeeded(items.last!.id))
|
|
||||||
try await Task.sleep(for: .milliseconds(100))
|
|
||||||
XCTAssertEqual(timelineProxy.sendReadReceiptForTypeCallsCount, 1)
|
|
||||||
let arguments = timelineProxy.sendReadReceiptForTypeReceivedArguments
|
|
||||||
XCTAssertEqual(arguments?.eventID, "t2")
|
|
||||||
XCTAssertEqual(arguments?.type, .read)
|
|
||||||
|
|
||||||
// When sending the same receipt again
|
|
||||||
viewModel.context.send(viewAction: .sendReadReceiptIfNeeded(items.last!.id))
|
|
||||||
try await Task.sleep(for: .milliseconds(100))
|
|
||||||
|
|
||||||
// Then the second call should be ignored.
|
|
||||||
XCTAssertEqual(timelineProxy.sendReadReceiptForTypeCallsCount, 1)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// swiftlint:enable force_unwrapping
|
// swiftlint:enable force_unwrapping
|
||||||
|
Loading…
x
Reference in New Issue
Block a user