mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-08 14:20:37 +00:00
Replace the ServiceLocator with direct dependency injection (#5548)
Removes the ServiceLocator singleton and instead directly injects the dependencies it was holding for more control over instantiation of the various component subtrees and better visibility over how they're being used.
This commit is contained in:
@@ -426,6 +426,7 @@
|
||||
484202C5D50983442D24D061 /* AttributedString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52BD6ED18E2EB61E28C340AD /* AttributedString.swift */; };
|
||||
4870F7F72CEBEFDAD1C973A6 /* VoiceMessageMediaEventsTimelineView.swift in Sources */ = {isa = PBXBuildFile; fileRef = AD3521DF92391551E02004D8 /* VoiceMessageMediaEventsTimelineView.swift */; };
|
||||
489BB6A733D3DA0FE7062650 /* IdentityConfirmationScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C71B9802433F1B4252291BB /* IdentityConfirmationScreenViewModelProtocol.swift */; };
|
||||
48F2D00593F6D73434D3F893 /* AnalyticsService+Mock.swift in Sources */ = {isa = PBXBuildFile; fileRef = A384A5A9F8472A0DA76FDB27 /* AnalyticsService+Mock.swift */; };
|
||||
491D62ACD19E6F134B1766AF /* RoomNotificationSettingsUserDefinedScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3203C6566DC17B7AECC1B7FD /* RoomNotificationSettingsUserDefinedScreen.swift */; };
|
||||
492274DA6691EE985C2FCCAA /* SnapshotTesting in Frameworks */ = {isa = PBXBuildFile; productRef = 21C83087604B154AA30E9A8F /* SnapshotTesting */; };
|
||||
4940B439681767BE9D78CFDB /* AppLockSetupBiometricsScreenViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52F5EE5DE3B55D59299DB5BC /* AppLockSetupBiometricsScreenViewModelTests.swift */; };
|
||||
@@ -1120,7 +1121,6 @@
|
||||
BCC864190651B3A3CF51E4DF /* MediaFileHandleProxy.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEC1D382565A4E9CAC2F14EA /* MediaFileHandleProxy.swift */; };
|
||||
BD0BE20DBCE31253AE4490A1 /* RoomListFiltersEmptyStateView.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC1DDB2293A51EA4C2739351 /* RoomListFiltersEmptyStateView.swift */; };
|
||||
BD6685592716CA957D7BAAC4 /* RoomChangeRolesScreenSelectedItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D9B45D584D232CB9E5C7734 /* RoomChangeRolesScreenSelectedItem.swift */; };
|
||||
BD782053BE4C3D2F0BDE5699 /* ServiceLocator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57F95CADD0A5DBD76B990FCB /* ServiceLocator.swift */; };
|
||||
BDA68E8D95B2B24B28825B8B /* LoginScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3C368CAB3063EF275357ECD4 /* LoginScreenViewModel.swift */; };
|
||||
BDC4EB54CC3036730475CB8B /* QRCodeLoginScreenViewModelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25E7E9B7FEAB6169D960C206 /* QRCodeLoginScreenViewModelTests.swift */; };
|
||||
BDCF42966007770A33D90E15 /* PreviewScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5DB56ABD78E60920ACE43087 /* PreviewScrollView.swift */; };
|
||||
@@ -2115,7 +2115,6 @@
|
||||
57916A1578D8043BB0795441 /* GeneratedMocks.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GeneratedMocks.swift; sourceTree = "<group>"; };
|
||||
57AD14D3ADADE8F6A10F9E88 /* EncryptionSettingsTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncryptionSettingsTests.swift; sourceTree = "<group>"; };
|
||||
57EAAF82432B0B53881CF826 /* AudioRoomTimelineItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AudioRoomTimelineItem.swift; sourceTree = "<group>"; };
|
||||
57F95CADD0A5DBD76B990FCB /* ServiceLocator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ServiceLocator.swift; sourceTree = "<group>"; };
|
||||
580BDCD23DD02481AB5FFB47 /* LeaveSpaceHandleSDKMock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LeaveSpaceHandleSDKMock.swift; sourceTree = "<group>"; };
|
||||
584A61D9C459FAFEF038A7C0 /* Section.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Section.swift; sourceTree = "<group>"; };
|
||||
5875F7C0A2398E9F134B1284 /* EncryptionResetScreenViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = EncryptionResetScreenViewModel.swift; sourceTree = "<group>"; };
|
||||
@@ -2527,6 +2526,7 @@
|
||||
A232D9156D225BD9FD1D0C43 /* PhotoLibraryPicker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PhotoLibraryPicker.swift; sourceTree = "<group>"; };
|
||||
A243A6E6207297123E60DE48 /* TimelineItemMacContextMenu.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimelineItemMacContextMenu.swift; sourceTree = "<group>"; };
|
||||
A2723A4AF3AB9F5E18D26E49 /* hr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = hr; path = hr.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
A384A5A9F8472A0DA76FDB27 /* AnalyticsService+Mock.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AnalyticsService+Mock.swift"; sourceTree = "<group>"; };
|
||||
A3A4F56855188DAD23E59031 /* ja */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ja; path = ja.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
A3B4B58B79A6FA250B24A1EC /* HomeScreenContent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeScreenContent.swift; sourceTree = "<group>"; };
|
||||
A3E3DE6616DCA81AD5F4791B /* vi */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = vi; path = vi.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
@@ -3766,6 +3766,7 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
69CB8242D69B7E4D0B32E18D /* AggregatedReactionMock.swift */,
|
||||
A384A5A9F8472A0DA76FDB27 /* AnalyticsService+Mock.swift */,
|
||||
3BAC027034248429A438886B /* AppMediatorMock.swift */,
|
||||
0554FEA301486A8CFA475D5A /* AuthenticationClientBuilderFactoryMock.swift */,
|
||||
9FD7E851E2BA8C5A8D284B2A /* BannedRoomProxyMock.swift */,
|
||||
@@ -5911,7 +5912,6 @@
|
||||
05AF58372CA884A789EB9C5A /* AppMediatorProtocol.swift */,
|
||||
B251F5B4511D1CA0BA8361FE /* CoordinatorProtocol.swift */,
|
||||
7B9FCA1CFD07B8CF9BD21266 /* FlowCoordinatorProtocol.swift */,
|
||||
57F95CADD0A5DBD76B990FCB /* ServiceLocator.swift */,
|
||||
B5D829FD8958376614504B18 /* TargetConfiguration.swift */,
|
||||
780F74C73E826685A9DB289B /* Navigation */,
|
||||
D64E20C9E4C486D5C764D7F3 /* Settings */,
|
||||
@@ -8079,6 +8079,7 @@
|
||||
6DC8E43BA04AC2AC4EB2EB97 /* AnalyticsPromptScreenModels.swift in Sources */,
|
||||
DB65401349C143DFF883E2B0 /* AnalyticsPromptScreenViewModel.swift in Sources */,
|
||||
05BAB510CBC2ED35C154ADD0 /* AnalyticsPromptScreenViewModelProtocol.swift in Sources */,
|
||||
48F2D00593F6D73434D3F893 /* AnalyticsService+Mock.swift in Sources */,
|
||||
3C73442084BF8A6939F0F80B /* AnalyticsService.swift in Sources */,
|
||||
020F7E70167FB2833266F2F0 /* AnalyticsSettingsScreen.swift in Sources */,
|
||||
95690DDD9D547D3D842ACBE3 /* AnalyticsSettingsScreenCoordinator.swift in Sources */,
|
||||
@@ -8880,7 +8881,6 @@
|
||||
6530865EB9A8C0F0AF0216DA /* ServerSelectionScreenModels.swift in Sources */,
|
||||
85F89F3F320F4FADCFFFE68B /* ServerSelectionScreenViewModel.swift in Sources */,
|
||||
0C47AE2CA7929CB3B0E2D793 /* ServerSelectionScreenViewModelProtocol.swift in Sources */,
|
||||
BD782053BE4C3D2F0BDE5699 /* ServiceLocator.swift in Sources */,
|
||||
914BDF61447C723F104BCE33 /* SessionDirectories.swift in Sources */,
|
||||
237FC70AA257B935F53316BA /* SessionVerificationControllerProxy.swift in Sources */,
|
||||
AE1A73B24D63DA3D63DC4EE3 /* SessionVerificationControllerProxyMock.swift in Sources */,
|
||||
|
||||
@@ -40,16 +40,8 @@ class AccessibilityTestsAppCoordinator: AppCoordinatorProtocol {
|
||||
|
||||
MXLog.configure(currentTarget: "accessibility-tests")
|
||||
|
||||
ServiceLocator.shared.register(userIndicatorController: UserIndicatorController())
|
||||
|
||||
AppSettings.configureWithSuiteName("io.element.elementx.accessibilitytests")
|
||||
AppSettings.resetAllSettings()
|
||||
ServiceLocator.shared.register(appSettings: AppSettings())
|
||||
|
||||
let analyticsClient = AnalyticsClientMock()
|
||||
analyticsClient.isRunning = false
|
||||
ServiceLocator.shared.register(analytics: AnalyticsService(client: analyticsClient,
|
||||
appSettings: ServiceLocator.shared.settings))
|
||||
|
||||
guard let name = ProcessInfo.accessibilityViewID,
|
||||
let previewType = TestablePreviewsDictionary.dictionary[name] else {
|
||||
|
||||
@@ -22,6 +22,9 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
private let targetConfiguration: Target.ConfigurationResult
|
||||
private let appMediator: AppMediator
|
||||
private let appSettings: AppSettings
|
||||
private let analyticsService: AnalyticsService
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
|
||||
private let appDelegate: AppDelegate
|
||||
private let appHooks: AppHooks
|
||||
private let bugReportService: BugReportServiceProtocol
|
||||
@@ -76,7 +79,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
appMediator = AppMediator(windowManager: windowManager, networkMonitor: networkMonitor)
|
||||
|
||||
let appSettings = appHooks.appSettingsHook.configure(AppSettings())
|
||||
ServiceLocator.shared.register(appSettings: appSettings)
|
||||
self.appSettings = appSettings
|
||||
|
||||
targetConfiguration = Target.mainApp.configure(logLevel: appSettings.logLevel,
|
||||
traceLogPacks: appSettings.traceLogPacks,
|
||||
@@ -94,17 +97,15 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
}
|
||||
|
||||
self.appDelegate = appDelegate
|
||||
self.appSettings = appSettings
|
||||
self.appHooks = appHooks
|
||||
|
||||
appRouteURLParser = AppRouteURLParser(appSettings: appSettings)
|
||||
|
||||
ServiceLocator.shared.register(userIndicatorController: UserIndicatorController())
|
||||
|
||||
let posthogAnalyticsClient = PostHogAnalyticsClient()
|
||||
posthogAnalyticsClient.updateSuperProperties(AnalyticsEvent.SuperProperties(appPlatform: .EXI, cryptoSDK: .Rust, cryptoSDKVersion: sdkGitSha()))
|
||||
let analyticsService = AnalyticsService(client: posthogAnalyticsClient, appSettings: appSettings)
|
||||
ServiceLocator.shared.register(analytics: analyticsService)
|
||||
analyticsService = AnalyticsService(client: posthogAnalyticsClient, appSettings: appSettings)
|
||||
|
||||
userIndicatorController = UserIndicatorController()
|
||||
|
||||
elementCallService = ElementCallService()
|
||||
|
||||
@@ -136,7 +137,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
sdkGitSHA: sdkGitSha(),
|
||||
appHooks: appHooks)
|
||||
|
||||
Self.setupSentry(bugReportService: bugReportService, appSettings: appSettings)
|
||||
Self.setupSentry(bugReportService: bugReportService, appSettings: appSettings, analytics: analyticsService)
|
||||
|
||||
analyticsService.startIfEnabled()
|
||||
|
||||
@@ -165,9 +166,9 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
registerBackgroundAppRefresh()
|
||||
|
||||
appSettings.$analyticsConsentState
|
||||
.dropFirst() // Called above before configuring the ServiceLocator
|
||||
.sink { [bugReportService] _ in
|
||||
Self.setupSentry(bugReportService: bugReportService, appSettings: appSettings)
|
||||
.dropFirst() // Sentry is configured during init; only reconfigure when consent state actually changes
|
||||
.sink { [bugReportService, analyticsService, appSettings] _ in
|
||||
Self.setupSentry(bugReportService: bugReportService, appSettings: appSettings, analytics: analyticsService)
|
||||
}
|
||||
.store(in: &cancellables)
|
||||
|
||||
@@ -216,7 +217,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
|
||||
func toPresentable() -> AnyView {
|
||||
AnyView(navigationRootCoordinator.toPresentable()
|
||||
.environment(\.analyticsService, ServiceLocator.shared.analytics)
|
||||
.environment(\.analyticsService, analyticsService)
|
||||
.onReceive(appSettings.$appAppearance) { [weak self] appAppearance in
|
||||
guard let self else { return }
|
||||
|
||||
@@ -370,7 +371,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
|
||||
func windowManagerDidConfigureWindows(_ windowManager: SecureWindowManagerProtocol) {
|
||||
windowManager.alternateWindow.rootViewController = UIHostingController(rootView: appLockFlowCoordinator.toPresentable())
|
||||
ServiceLocator.shared.userIndicatorController.window = windowManager.overlayWindow
|
||||
userIndicatorController.window = windowManager.overlayWindow
|
||||
}
|
||||
|
||||
// MARK: - NotificationManagerDelegate
|
||||
@@ -414,7 +415,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
handleAppRoute(.thread(roomID: roomID, threadRootEventID: threadRootEventID, focusEventID: eventID), windowType: nil)
|
||||
} else if let eventID {
|
||||
// Only track main timeline event deeplinking
|
||||
ServiceLocator.shared.analytics.signpost.startTransaction(.notificationToMessage)
|
||||
analyticsService.signpost.startTransaction(.notificationToMessage)
|
||||
handleAppRoute(.event(eventID: eventID, roomID: roomID, via: []), windowType: nil)
|
||||
} else {
|
||||
handleAppRoute(.room(roomID: roomID, via: []), windowType: nil)
|
||||
@@ -665,8 +666,8 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
appMediator: appMediator,
|
||||
appSettings: appSettings,
|
||||
appHooks: appHooks,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
analytics: analyticsService,
|
||||
userIndicatorController: userIndicatorController)
|
||||
coordinator.delegate = self
|
||||
|
||||
authenticationFlowCoordinator = coordinator
|
||||
@@ -721,7 +722,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
appMediator: appMediator,
|
||||
appSettings: appSettings,
|
||||
appHooks: appHooks,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
userIndicatorController: userIndicatorController)
|
||||
let coordinator = SoftLogoutScreenCoordinator(parameters: parameters)
|
||||
self.softLogoutCoordinator = coordinator
|
||||
coordinator.actions
|
||||
@@ -750,24 +751,24 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
}
|
||||
|
||||
if let serverName = userSession.clientProxy.userIDServerName {
|
||||
ServiceLocator.shared.analytics.signpost.addGlobalTag(.homeserver, value: serverName)
|
||||
analyticsService.signpost.addGlobalTag(.homeserver, value: serverName)
|
||||
}
|
||||
|
||||
if !isNewLogin {
|
||||
ServiceLocator.shared.analytics.signpost.startTransaction(.cachedRoomList)
|
||||
analyticsService.signpost.startTransaction(.cachedRoomList)
|
||||
}
|
||||
|
||||
let flowParameters = CommonFlowParameters(userSession: userSession,
|
||||
bugReportService: bugReportService,
|
||||
elementCallService: elementCallService,
|
||||
timelineControllerFactory: TimelineControllerFactory(),
|
||||
timelineControllerFactory: TimelineControllerFactory(appSettings: appSettings),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
appMediator: appMediator,
|
||||
appSettings: appSettings,
|
||||
appHooks: appHooks,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analytics: analyticsService,
|
||||
userIndicatorController: userIndicatorController,
|
||||
notificationManager: notificationManager,
|
||||
stateMachineFactory: StateMachineFactory())
|
||||
|
||||
@@ -837,8 +838,8 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
appHooks.remoteSettingsHook.reset(appSettings)
|
||||
|
||||
// Reset analytics
|
||||
ServiceLocator.shared.analytics.optOut()
|
||||
ServiceLocator.shared.analytics.resetConsentState()
|
||||
analyticsService.optOut()
|
||||
analyticsService.resetConsentState()
|
||||
|
||||
stateMachine.processEvent(.completedSigningOut)
|
||||
|
||||
@@ -847,7 +848,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
}
|
||||
|
||||
private func tearDownUserSession() {
|
||||
ServiceLocator.shared.userIndicatorController.retractAllIndicators()
|
||||
userIndicatorController.retractAllIndicators()
|
||||
|
||||
userSession = nil
|
||||
|
||||
@@ -949,7 +950,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
}
|
||||
}
|
||||
|
||||
private static func setupSentry(bugReportService: BugReportServiceProtocol, appSettings: AppSettings) {
|
||||
private static func setupSentry(bugReportService: BugReportServiceProtocol, appSettings: AppSettings, analytics: AnalyticsService) {
|
||||
guard let bugReportSentryURL = appSettings.bugReportSentryURL else { return }
|
||||
|
||||
let options: Options = .init()
|
||||
@@ -1008,7 +1009,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
|
||||
// Any ongoing transactions will no longer be valid after calling SentrySDK.start so lets
|
||||
// remove them and start over, otherwise the app will crash if finishTransaction is used.
|
||||
ServiceLocator.shared.analytics.signpost.resetTransactions()
|
||||
analytics.signpost.resetTransactions()
|
||||
|
||||
SentrySDK.start(options: options) // Swift
|
||||
enableSentryLogging(enabled: options.enabled) // Rust
|
||||
@@ -1043,18 +1044,18 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
private static let loadingIndicatorIdentifier = "\(AppCoordinator.self)-Loading"
|
||||
|
||||
private func showLoadingIndicator() {
|
||||
ServiceLocator.shared.userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier,
|
||||
userIndicatorController.submitIndicator(UserIndicator(id: Self.loadingIndicatorIdentifier,
|
||||
type: .modal,
|
||||
title: L10n.commonLoading,
|
||||
persistent: true))
|
||||
}
|
||||
|
||||
private func hideLoadingIndicator() {
|
||||
ServiceLocator.shared.userIndicatorController.retractIndicatorWithId(Self.loadingIndicatorIdentifier)
|
||||
userIndicatorController.retractIndicatorWithId(Self.loadingIndicatorIdentifier)
|
||||
}
|
||||
|
||||
private func showLoginErrorToast() {
|
||||
ServiceLocator.shared.userIndicatorController.submitIndicator(UserIndicator(title: "Failed logging in"))
|
||||
userIndicatorController.submitIndicator(UserIndicator(title: "Failed logging in"))
|
||||
}
|
||||
|
||||
// MARK: - Application State
|
||||
@@ -1074,7 +1075,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
private func startSync() {
|
||||
guard let userSession else { return }
|
||||
|
||||
ServiceLocator.shared.analytics.signpost.startTransaction(.upToDateRoomList)
|
||||
analyticsService.signpost.startTransaction(.upToDateRoomList)
|
||||
|
||||
userSession.clientProxy.startSync()
|
||||
|
||||
@@ -1089,16 +1090,17 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] state in
|
||||
let toastIdentifier = "StaleDataIndicator"
|
||||
guard let self else { return }
|
||||
|
||||
switch state {
|
||||
case .loading:
|
||||
if self?.userSession?.clientProxy.homeserverReachabilityPublisher.value == .reachable,
|
||||
self?.appMediator.networkMonitor.reachabilityPublisher.value == .reachable {
|
||||
ServiceLocator.shared.userIndicatorController.submitIndicator(.init(id: toastIdentifier, type: .toast(progress: .indeterminate), title: L10n.commonSyncing, persistent: true))
|
||||
if self.userSession?.clientProxy.homeserverReachabilityPublisher.value == .reachable,
|
||||
self.appMediator.networkMonitor.reachabilityPublisher.value == .reachable {
|
||||
self.userIndicatorController.submitIndicator(.init(id: toastIdentifier, type: .toast(progress: .indeterminate), title: L10n.commonSyncing, persistent: true))
|
||||
}
|
||||
case .notLoading:
|
||||
ServiceLocator.shared.analytics.signpost.finishTransaction(.upToDateRoomList)
|
||||
ServiceLocator.shared.userIndicatorController.retractIndicatorWithId(toastIdentifier)
|
||||
self.analyticsService.signpost.finishTransaction(.upToDateRoomList)
|
||||
self.userIndicatorController.retractIndicatorWithId(toastIdentifier)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
//
|
||||
// Copyright 2025 Element Creations Ltd.
|
||||
// Copyright 2022-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 Foundation
|
||||
|
||||
class ServiceLocator {
|
||||
private(set) static var shared = ServiceLocator()
|
||||
|
||||
private init() { }
|
||||
|
||||
private(set) var userIndicatorController: UserIndicatorControllerProtocol!
|
||||
|
||||
func register(userIndicatorController: UserIndicatorControllerProtocol) {
|
||||
self.userIndicatorController = userIndicatorController
|
||||
}
|
||||
|
||||
private(set) var settings: AppSettings!
|
||||
|
||||
func register(appSettings: AppSettings) {
|
||||
settings = appSettings
|
||||
}
|
||||
|
||||
private(set) var analytics: AnalyticsService!
|
||||
|
||||
func register(analytics: AnalyticsService) {
|
||||
self.analytics = analytics
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Copyright 2026 Element Creations Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
extension AnalyticsService {
|
||||
static func mock(_ clientOverride: AnalyticsClientProtocol? = nil, settings: AppSettings? = nil) -> AnalyticsService {
|
||||
let client: AnalyticsClientProtocol
|
||||
if let clientOverride {
|
||||
client = clientOverride
|
||||
} else {
|
||||
let mockClient = AnalyticsClientMock()
|
||||
mockClient.isRunning = false
|
||||
client = mockClient
|
||||
}
|
||||
|
||||
return .init(client: client, appSettings: settings ?? AppSettings())
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ struct ScreenTrackerViewModifier: ViewModifier {
|
||||
func body(content: Content) -> some View {
|
||||
content
|
||||
.onAppear {
|
||||
analyticsService.track(screen: screen)
|
||||
analyticsService?.track(screen: screen)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ private struct VisualListItemLabelStyle: LabelStyle {
|
||||
// MARK: - Previews
|
||||
|
||||
struct VisualListItem_Previews: PreviewProvider, TestablePreview {
|
||||
static let strings = AnalyticsPromptScreenStrings(termsURL: ServiceLocator.shared.settings.analyticsTermsURL)
|
||||
static let strings = AnalyticsPromptScreenStrings(termsURL: AppSettings().analyticsTermsURL)
|
||||
|
||||
static var testImage1: some View {
|
||||
Image(systemName: "circle")
|
||||
|
||||
@@ -158,11 +158,14 @@ struct LoginScreen_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
Task { await authenticationService.configure(for: homeserverAddress, flow: .login) }
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
let viewModel = LoginScreenViewModel(authenticationService: authenticationService,
|
||||
loginHint: nil,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analytics: ServiceLocator.shared.analytics)
|
||||
appSettings: appSettings,
|
||||
analytics: analytics)
|
||||
|
||||
if withCredentials {
|
||||
viewModel.context.username = "alice"
|
||||
|
||||
+2
-2
@@ -163,7 +163,7 @@ struct ServerConfirmationScreen_Previews: PreviewProvider, TestablePreview {
|
||||
ServerConfirmationScreenViewModel(authenticationService: AuthenticationService.mock,
|
||||
mode: mode,
|
||||
authenticationFlow: flow,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
appSettings: AppSettings(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -116,8 +116,8 @@ struct ServerSelection_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
let viewModel = ServerSelectionScreenViewModel(authenticationService: authenticationService,
|
||||
authenticationFlow: .login,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
appSettings: AppSettings(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
viewModel.context.homeserverAddress = homeserverAddress
|
||||
if homeserverAddress == "thisisbad" {
|
||||
viewModel.context.send(viewAction: .confirm)
|
||||
|
||||
+1
-1
@@ -151,7 +151,7 @@ struct AuthenticationClassicAppAccountView_Previews: PreviewProvider { // Not Te
|
||||
provisioningParameters: nil,
|
||||
isBugReportServiceEnabled: false,
|
||||
appMediator: AppMediatorMock(),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: AppSettings(),
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
}
|
||||
|
||||
+1
-1
@@ -195,7 +195,7 @@ struct AuthenticationStartScreen_Previews: PreviewProvider, TestablePreview {
|
||||
provisioningParameters: provisionedServerName.map { .init(accountProvider: $0, loginHint: nil) },
|
||||
isBugReportServiceEnabled: true,
|
||||
appMediator: AppMediatorMock(),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: AppSettings(),
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
}
|
||||
|
||||
@@ -364,6 +364,9 @@ struct CallScreen_Previews: PreviewProvider {
|
||||
|
||||
roomProxy.elementCallWidgetDriverDeviceIDReturnValue = widgetDriver
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return CallScreenViewModel(elementCallService: ElementCallServiceMock(.init()),
|
||||
configuration: .init(roomProxy: roomProxy,
|
||||
clientProxy: clientProxy,
|
||||
@@ -374,8 +377,8 @@ struct CallScreen_Previews: PreviewProvider {
|
||||
colorScheme: .light),
|
||||
allowPictureInPicture: false,
|
||||
appHooks: AppHooks(),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics)
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics)
|
||||
}()
|
||||
|
||||
static var previews: some View {
|
||||
|
||||
@@ -227,8 +227,8 @@ struct PollFormScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static func makeViewModel(mode: PollFormMode) -> PollFormScreenViewModel {
|
||||
PollFormScreenViewModel(mode: mode,
|
||||
timelineController: MockTimelineController(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
analytics: .mock(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -461,8 +461,8 @@ struct CreateRoom_Previews: PreviewProvider, TestablePreview {
|
||||
spaceSelectionMode: selectionMode,
|
||||
shouldShowCancelButton: isSpace,
|
||||
userSession: userSession,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
analytics: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
appSettings: appSettings)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,13 +67,16 @@ struct CreateRoomSpaceSelectionSheet_Previews: PreviewProvider, TestablePreview
|
||||
clientProxy.spaceService = SpaceServiceProxyMock(.init(editableSpaces: .mockJoinedSpaces2))
|
||||
let userSession = UserSessionMock(.init(clientProxy: clientProxy))
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return CreateRoomScreenViewModel(isSpace: false,
|
||||
spaceSelectionMode: .editableSpacesList(preSelectedSpace: nil),
|
||||
shouldShowCancelButton: false,
|
||||
userSession: userSession,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
analytics: analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
appSettings: appSettings)
|
||||
}()
|
||||
|
||||
static var previews: some View {
|
||||
|
||||
@@ -103,7 +103,7 @@ struct EmojiPickerScreen: View {
|
||||
struct EmojiPickerScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel = EmojiPickerScreenViewModel(itemID: .randomEvent,
|
||||
selectedEmojis: ["😀", "😄"],
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
emojiProvider: EmojiProvider(appSettings: AppSettings()),
|
||||
timelineController: MockTimelineController())
|
||||
|
||||
static var previews: some View {
|
||||
@@ -116,7 +116,7 @@ struct EmojiPickerScreen_Previews: PreviewProvider, TestablePreview {
|
||||
struct EmojiPickerScreenSheet_Previews: PreviewProvider {
|
||||
static let viewModel = EmojiPickerScreenViewModel(itemID: .randomEvent,
|
||||
selectedEmojis: ["😀", "😄"],
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
emojiProvider: EmojiProvider(appSettings: AppSettings()),
|
||||
timelineController: MockTimelineController())
|
||||
|
||||
static var previews: some View {
|
||||
|
||||
+2
-2
@@ -59,10 +59,10 @@ struct RoomListFiltersEmptyStateView_Previews: PreviewProvider, TestablePreview
|
||||
VStack(spacing: 24) {
|
||||
ForEach(RoomListFilter.allCases) { filter in
|
||||
RoomListFiltersEmptyStateView(state: .init(activeFilters: [filter],
|
||||
appSettings: ServiceLocator.shared.settings))
|
||||
appSettings: AppSettings()))
|
||||
}
|
||||
RoomListFiltersEmptyStateView(state: .init(activeFilters: [.people, .favourites],
|
||||
appSettings: ServiceLocator.shared.settings))
|
||||
appSettings: AppSettings()))
|
||||
}
|
||||
.padding(.bottom)
|
||||
.previewLayout(.sizeThatFits)
|
||||
|
||||
@@ -90,10 +90,10 @@ struct RoomListFiltersView: View {
|
||||
|
||||
struct RoomListFiltersView_Previews: PreviewProvider, TestablePreview {
|
||||
static var previews: some View {
|
||||
RoomListFiltersView(state: .constant(.init(appSettings: ServiceLocator.shared.settings)))
|
||||
RoomListFiltersView(state: .constant(.init(appSettings: AppSettings())))
|
||||
RoomListFiltersView(state: .constant(.init(activeFilters: [.rooms, .favourites],
|
||||
appSettings: ServiceLocator.shared.settings)))
|
||||
appSettings: AppSettings())))
|
||||
RoomListFiltersView(state: .constant(.init(activeFilters: [.lowPriority],
|
||||
appSettings: ServiceLocator.shared.settings)))
|
||||
appSettings: AppSettings())))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,11 +222,14 @@ struct HomeScreen_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
let userSession = UserSessionMock(.init(clientProxy: clientProxy))
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
notificationManager: NotificationManagerMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,12 +143,14 @@ struct HomeScreenEmptyStateView_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel = {
|
||||
let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "@user:example.com",
|
||||
roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded([])))))))
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
notificationManager: NotificationManagerMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -200,12 +200,15 @@ struct HomeScreenInviteCell_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
let userSession = UserSessionMock(.init(clientProxy: clientProxy))
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
notificationManager: NotificationManagerMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -132,12 +132,15 @@ struct HomeScreenKnockedCell_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
let userSession = UserSessionMock(.init(clientProxy: clientProxy))
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
notificationManager: NotificationManagerMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
-3
@@ -121,11 +121,14 @@ struct HomeScreenRecoveryKeyConfirmationBanner_Previews: PreviewProvider, Testab
|
||||
|
||||
let userSession = UserSessionMock(.init(clientProxy: clientProxy))
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
notificationManager: NotificationManagerMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,12 +253,15 @@ struct HomeScreenRoomCell_Previews: PreviewProvider, TestablePreview {
|
||||
static func makeViewModel(roomSummaryProvider: RoomSummaryProviderProtocol) -> HomeScreenViewModel {
|
||||
let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "John Doe", roomSummaryProvider: roomSummaryProvider))))
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return HomeScreenViewModel(userSession: userSession,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
notificationManager: NotificationManagerMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
}
|
||||
|
||||
static func makeRoom(lastMessageState: RoomSummary.LastMessageState) -> HomeScreenRoom {
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ struct InviteUsersConfirmationSheetView_Previews: PreviewProvider, TestablePrevi
|
||||
isSkippable: true,
|
||||
userDiscoveryService: UserDiscoveryServiceMock(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: AppSettings())
|
||||
|
||||
viewModel.state.usersToConfirm = [.mockAlice, .mockCharlie, .mockBob, .mockDan]
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@ struct InviteUsersScreen_Previews: PreviewProvider, TestablePreview {
|
||||
isSkippable: true,
|
||||
userDiscoveryService: userDiscoveryService,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: AppSettings())
|
||||
|
||||
if let searchQuery {
|
||||
viewModel.context.searchQuery = searchQuery
|
||||
|
||||
@@ -458,7 +458,7 @@ struct JoinRoomScreenPreviewWrapper: Identifiable {
|
||||
viewModel = JoinRoomScreenViewModel(source: source,
|
||||
appSettings: appSettings,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
}
|
||||
|
||||
var previewDisplayName: String {
|
||||
|
||||
@@ -389,12 +389,15 @@ extension LocationSharingScreenViewModel {
|
||||
let roomProxy = JoinedRoomProxyMock(.init(members: .allMembers, ownUserID: RoomMemberProxyMock.mockMe.userID))
|
||||
roomProxy.makeLiveLocationServiceReturnValue = liveLocationServiceMock
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return LocationSharingScreenViewModel(interactionMode: interactionMode,
|
||||
mapURLBuilder: ServiceLocator.shared.settings.mapTilerConfiguration,
|
||||
mapURLBuilder: appSettings.mapTilerConfiguration,
|
||||
roomProxy: roomProxy,
|
||||
timelineController: MockTimelineController(),
|
||||
liveLocationManager: LiveLocationManagerMock(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
mediaProvider: MediaProviderMock(configuration: .init()))
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ private extension ManageRoomMemberSheetViewModel {
|
||||
ownPowerLevel: powerLevel),
|
||||
roomProxy: JoinedRoomProxyMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
analyticsService: .mock(),
|
||||
mediaProvider: MediaProviderMock(configuration: .init()))
|
||||
}
|
||||
}
|
||||
|
||||
+6
-3
@@ -310,15 +310,18 @@ struct MediaEventsTimelineScreen_Previews: PreviewProvider, TestablePreview {
|
||||
MockTimelineController.mediaGallery
|
||||
}
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return TimelineViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "Preview room")),
|
||||
timelineController: timelineController,
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
}
|
||||
|
||||
+1
-1
@@ -370,7 +370,7 @@ struct MediaUploadPreviewScreen_Previews: PreviewProvider, TestablePreview {
|
||||
title: "App Icon.png",
|
||||
isRoomEncrypted: true,
|
||||
shouldShowCaptionWarning: true,
|
||||
mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: ServiceLocator.shared.settings),
|
||||
mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: AppSettings()),
|
||||
timelineController: MockTimelineController(),
|
||||
clientProxy: ClientProxyMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
|
||||
+1
-1
@@ -102,6 +102,6 @@ struct AnalyticsPromptScreen_Previews: PreviewProvider, TestablePreview {
|
||||
}
|
||||
|
||||
static func makeViewModel(showTerms: Bool = true) -> AnalyticsPromptScreenViewModel {
|
||||
AnalyticsPromptScreenViewModel(termsURL: showTerms ? ServiceLocator.shared.settings.analyticsTermsURL : nil)
|
||||
AnalyticsPromptScreenViewModel(termsURL: showTerms ? AppSettings().analyticsTermsURL : nil)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -140,7 +140,7 @@ struct IdentityConfirmationScreen_Previews: PreviewProvider, TestablePreview {
|
||||
userSession.sessionSecurityStatePublisher = CurrentValuePublisher<SessionSecurityState, Never>(.init(verificationState: .unverified, recoveryState: recoveryState))
|
||||
|
||||
return IdentityConfirmationScreenViewModel(userSession: userSession,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
appSettings: AppSettings(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
}
|
||||
}
|
||||
|
||||
+8
-4
@@ -69,20 +69,24 @@ struct PinnedEventsTimelineScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel = PinnedEventsTimelineScreenViewModel(roomProxy: JoinedRoomProxyMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: AppSettings(),
|
||||
analyticsService: ServiceLocator.shared.analytics)
|
||||
analyticsService: .mock())
|
||||
|
||||
static let emptyTimelineViewModel: TimelineViewModel = {
|
||||
let timelineController = MockTimelineController(timelineKind: .pinned)
|
||||
timelineController.timelineItems = []
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return TimelineViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "Preview room")),
|
||||
timelineController: timelineController,
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
}()
|
||||
|
||||
+1
-1
@@ -91,6 +91,6 @@ struct RoomChangePermissionsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
ownPowerLevel: ownPowerLevel,
|
||||
roomProxy: JoinedRoomProxyMock(.init(isSpace: isSpace)),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
analytics: ServiceLocator.shared.analytics)
|
||||
analytics: .mock())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,6 +151,6 @@ struct RoomChangeRolesScreen_Previews: PreviewProvider, TestablePreview {
|
||||
roomProxy: JoinedRoomProxyMock(.init(members: members)),
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
analytics: ServiceLocator.shared.analytics)
|
||||
analytics: .mock())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ struct RoomDetailsEditScreen_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
return RoomDetailsEditScreenViewModel(roomProxy: roomProxy,
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: ServiceLocator.shared.settings),
|
||||
mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: AppSettings()),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,13 +406,16 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
let notificationSettingsProxy = NotificationSettingsProxyMock(with: notificationSettingsProxyMockConfiguration)
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return .init(roomProxy: roomProxy,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: notificationSettingsProxy,
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
}
|
||||
|
||||
private static func makeSimpleRoomViewModel() -> RoomDetailsScreenViewModel {
|
||||
@@ -434,13 +437,16 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init())
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return .init(roomProxy: roomProxy,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: notificationSettingsProxy,
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
}
|
||||
|
||||
private static func makeDMViewModel(verificationState: UserIdentityVerificationState) -> RoomDetailsScreenViewModel {
|
||||
@@ -472,12 +478,15 @@ struct RoomDetailsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
let notificationSettingsProxy = NotificationSettingsProxyMock(with: .init())
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return .init(roomProxy: roomProxy,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxyMock)),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: notificationSettingsProxy,
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,11 +236,14 @@ struct RoomMemberDetailsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
clientProxyMock.directRoomForUserIDReturnValue = .success("roomID")
|
||||
}
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return RoomMemberDetailsScreenViewModel(userID: member.userID,
|
||||
roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxyMock)),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
analytics: analytics,
|
||||
appSettings: appSettings)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,7 +261,7 @@ struct RoomMembersListScreen_Previews: PreviewProvider, TestablePreview {
|
||||
members: members,
|
||||
ownUserID: ownUserID,
|
||||
powerLevelsConfiguration: .init(canUserInvite: false))),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analytics: ServiceLocator.shared.analytics)
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
analytics: .mock())
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -131,8 +131,8 @@ struct RoomMembersListMemberCell_Previews: PreviewProvider, TestablePreview {
|
||||
|
||||
static let viewModel = RoomMembersListScreenViewModel(userSession: UserSessionMock(.init()),
|
||||
roomProxy: JoinedRoomProxyMock(.init(name: "Some room", members: [])),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analytics: ServiceLocator.shared.analytics)
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
analytics: .mock())
|
||||
static var previews: some View {
|
||||
VStack(spacing: 0) {
|
||||
Section("Invited/Joined") {
|
||||
|
||||
+2
-2
@@ -121,12 +121,12 @@ struct RoomRolesAndPermissionsScreen_Previews: PreviewProvider, TestablePreview
|
||||
static let viewModel = RoomRolesAndPermissionsScreenViewModel(initialPermissions: RoomPermissions(powerLevels: .mock),
|
||||
roomProxy: JoinedRoomProxyMock(.init(members: .allMembersAsAdmin)),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
analytics: ServiceLocator.shared.analytics)
|
||||
analytics: .mock())
|
||||
|
||||
static let creatorViewModel = RoomRolesAndPermissionsScreenViewModel(initialPermissions: RoomPermissions(powerLevels: .mock),
|
||||
roomProxy: JoinedRoomProxyMock(.init(members: .allMembersAsCreator)),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
analytics: ServiceLocator.shared.analytics)
|
||||
analytics: .mock())
|
||||
static var previews: some View {
|
||||
ElementNavigationStack {
|
||||
RoomRolesAndPermissionsScreen(context: viewModel.context)
|
||||
|
||||
@@ -820,14 +820,17 @@ extension ComposerToolbarViewModel {
|
||||
roomProxy.identityStatusChangesPublisher = .init([.init(userId: RoomMemberProxyMock.mockAlice.userID, changedTo: .verificationViolation)])
|
||||
}
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
let wysiwygViewModel = WysiwygComposerViewModel()
|
||||
let viewModel = ComposerToolbarViewModel(roomProxy: roomProxy,
|
||||
wysiwygViewModel: wysiwygViewModel,
|
||||
completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init(suggestions: suggestions)),
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper.mock,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
composerDraftService: ComposerDraftServiceMock(.init()))
|
||||
viewModel.state.bindings.composerFocused = focused
|
||||
viewModel.state.bindings.plainComposerText = NSAttributedString(string: message)
|
||||
|
||||
@@ -78,14 +78,20 @@ struct RoomAttachmentPicker: View {
|
||||
}
|
||||
|
||||
struct RoomAttachmentPicker_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel = ComposerToolbarViewModel(roomProxy: JoinedRoomProxyMock(.init()),
|
||||
static let viewModel = makeViewModel()
|
||||
|
||||
static func makeViewModel() -> ComposerToolbarViewModel {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
return ComposerToolbarViewModel(roomProxy: JoinedRoomProxyMock(.init()),
|
||||
wysiwygViewModel: WysiwygComposerViewModel(),
|
||||
completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()),
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper.mock,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
appSettings: appSettings,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
composerDraftService: ComposerDraftServiceMock(.init()))
|
||||
}
|
||||
|
||||
static var previews: some View {
|
||||
RoomAttachmentPicker(context: viewModel.context)
|
||||
|
||||
@@ -456,14 +456,17 @@ extension RoomScreenViewModel {
|
||||
static func mock(roomProxyMock: JoinedRoomProxyMock,
|
||||
clientProxyMock: ClientProxyMock = ClientProxyMock(.init()),
|
||||
appHooks: AppHooks = AppHooks()) -> RoomScreenViewModel {
|
||||
RoomScreenViewModel(userSession: UserSessionMock(.init(clientProxy: clientProxyMock)),
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return RoomScreenViewModel(userSession: UserSessionMock(.init(clientProxy: clientProxyMock)),
|
||||
roomProxy: roomProxyMock,
|
||||
initialSelectedPinnedEventID: nil,
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: appHooks,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
analyticsService: analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -256,15 +256,19 @@ struct RoomScreen_Previews: PreviewProvider, TestablePreview {
|
||||
successor: hasSuccessor ? .init(roomId: UUID().uuidString, reason: nil) : nil,
|
||||
powerLevelsConfiguration: .init(canUserSendMessage: canSendMessage)))
|
||||
let roomViewModel = RoomScreenViewModel.mock(roomProxyMock: roomProxyMock)
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
let timelineViewModel = TimelineViewModel(roomProxy: roomProxyMock,
|
||||
timelineController: MockTimelineController(),
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
|
||||
|
||||
+4
-3
@@ -162,10 +162,11 @@ private extension AppAppearance {
|
||||
struct AdvancedSettingsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static let viewModel = {
|
||||
AppSettings.resetAllSettings()
|
||||
return AdvancedSettingsScreenViewModel(advancedSettings: AppSettings(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
let appSettings = AppSettings()
|
||||
return AdvancedSettingsScreenViewModel(advancedSettings: appSettings,
|
||||
analytics: .mock(settings: appSettings),
|
||||
clientProxy: ClientProxyMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
}()
|
||||
|
||||
static var previews: some View {
|
||||
|
||||
+2
-1
@@ -40,8 +40,9 @@ struct AnalyticsSettingsScreen: View {
|
||||
struct AnalyticsSettingsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static var previews: some View {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let viewModel = AnalyticsSettingsScreenViewModel(appSettings: appSettings,
|
||||
analytics: ServiceLocator.shared.analytics)
|
||||
analytics: analytics)
|
||||
AnalyticsSettingsScreen(context: viewModel.context)
|
||||
}
|
||||
}
|
||||
|
||||
+3
-2
@@ -244,10 +244,11 @@ private extension Set<TraceLogPack> {
|
||||
// MARK: - Previews
|
||||
|
||||
struct DeveloperOptionsScreen_Previews: PreviewProvider {
|
||||
static let viewModel = DeveloperOptionsScreenViewModel(developerOptions: ServiceLocator.shared.settings,
|
||||
elementCallBaseURL: ServiceLocator.shared.settings.elementCallBaseURL,
|
||||
static let viewModel = DeveloperOptionsScreenViewModel(developerOptions: AppSettings(),
|
||||
elementCallBaseURL: AppSettings().elementCallBaseURL,
|
||||
appHooks: AppHooks(),
|
||||
clientProxy: ClientProxyMock(.init()))
|
||||
|
||||
static var previews: some View {
|
||||
ElementNavigationStack {
|
||||
DeveloperOptionsScreen(context: viewModel.context)
|
||||
|
||||
@@ -277,7 +277,7 @@ struct SettingsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "@userid:example.com",
|
||||
deviceID: "AAAAAAAAAAA"))))
|
||||
return SettingsScreenViewModel(userSession: userSession,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: AppSettings(),
|
||||
isBugReportServiceEnabled: isBugReportServiceEnabled,
|
||||
isInSecondaryWindow: false)
|
||||
}
|
||||
|
||||
+1
-1
@@ -141,7 +141,7 @@ struct UserDetailsEditScreen_Previews: PreviewProvider, TestablePreview {
|
||||
UserDetailsEditScreenViewModel(userSession: UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "@stefan:matrix.org",
|
||||
canChangeAvatar: canChangeProfile,
|
||||
canChangeDisplayName: canChangeProfile)))),
|
||||
mediaUploadingPreprocessor: .init(appSettings: ServiceLocator.shared.settings),
|
||||
mediaUploadingPreprocessor: .init(appSettings: AppSettings()),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
}
|
||||
}
|
||||
|
||||
+13
-16
@@ -121,29 +121,26 @@ struct SpaceSettingsScreen: View {
|
||||
// MARK: - Previews
|
||||
|
||||
struct SpaceSettingsScreen_Previews: PreviewProvider, TestablePreview {
|
||||
static let ownerViewModel = RoomDetailsScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "Space",
|
||||
avatarURL: .mockMXCAvatar,
|
||||
isSpace: true,
|
||||
canonicalAlias: "#space:matrix.org",
|
||||
members: .allMembersAsCreator)),
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
static let ownerViewModel = makeViewModel(members: .allMembersAsCreator)
|
||||
|
||||
static let userViewModel = RoomDetailsScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "Space",
|
||||
static let userViewModel = makeViewModel(members: .allMembers)
|
||||
|
||||
static func makeViewModel(members: [RoomMemberProxyMock]) -> RoomDetailsScreenViewModel {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return RoomDetailsScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "Space",
|
||||
avatarURL: .mockMXCAvatar,
|
||||
isSpace: true,
|
||||
canonicalAlias: "#space:matrix.org",
|
||||
members: .allMembers)),
|
||||
members: members)),
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
}
|
||||
|
||||
static var previews: some View {
|
||||
ElementNavigationStack {
|
||||
|
||||
@@ -82,11 +82,15 @@ struct JoinRoomByAddressView_Previews: PreviewProvider, TestablePreview {
|
||||
let userSession = UserSessionMock(.init(clientProxy: ClientProxyMock(.init(userID: "@userid:example.com"))))
|
||||
let userDiscoveryService = UserDiscoveryServiceMock()
|
||||
userDiscoveryService.searchProfilesWithReturnValue = .success([.mockAlice])
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return StartChatScreenViewModel(userSession: userSession,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
userDiscoveryService: userDiscoveryService,
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
}()
|
||||
|
||||
static var previews: some View {
|
||||
|
||||
@@ -159,7 +159,7 @@ struct StartChatScreen_Previews: PreviewProvider, TestablePreview {
|
||||
let userDiscoveryService = UserDiscoveryServiceMock()
|
||||
userDiscoveryService.searchProfilesWithReturnValue = .success([.mockAlice])
|
||||
return StartChatScreenViewModel(userSession: userSession,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
userDiscoveryService: userDiscoveryService,
|
||||
appSettings: appSettings)
|
||||
|
||||
@@ -1056,16 +1056,20 @@ extension TimelineViewModel {
|
||||
clientProxyMock.roomSummaryForAliasReturnValue = .mock(id: "!room:matrix.org", name: "Room")
|
||||
clientProxyMock.roomSummaryForIdentifierReturnValue = .mock(id: "!room:matrix.org", name: "Room", canonicalAlias: "#room:matrix.org")
|
||||
let roomProxy = JoinedRoomProxyMock(.init(name: "Preview room", predecessor: hasPredecessor ? .init(roomId: UUID().uuidString) : nil))
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return TimelineViewModel(roomProxy: roomProxy,
|
||||
focussedEventID: nil,
|
||||
timelineController: timelineController ?? MockTimelineController(timelineKind: timelineKind),
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxyMock)),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ struct TimelineItemMenu_Previews: PreviewProvider, TestablePreview {
|
||||
isViewSourceEnabled: true,
|
||||
areThreadsEnabled: true,
|
||||
timelineKind: .live,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings))
|
||||
emojiProvider: EmojiProvider(appSettings: AppSettings()))
|
||||
guard let actions = provider.makeActions() else { return nil }
|
||||
|
||||
if var textItem = item as? TextRoomTimelineItem {
|
||||
|
||||
@@ -44,15 +44,19 @@ struct ReadReceiptsSummaryView_Previews: PreviewProvider, TestablePreview {
|
||||
.mockDan
|
||||
]
|
||||
let roomProxyMock = JoinedRoomProxyMock(.init(name: "Room", members: members))
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return TimelineViewModel(roomProxy: roomProxyMock,
|
||||
timelineController: MockTimelineController(),
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
}()
|
||||
|
||||
@@ -343,11 +343,11 @@ struct TimelineItemBubbledStylerView_Previews: PreviewProvider, TestablePreview
|
||||
timelineController: MockTimelineController(),
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
}()
|
||||
@@ -362,11 +362,11 @@ struct TimelineItemBubbledStylerView_Previews: PreviewProvider, TestablePreview
|
||||
timelineController: MockTimelineController(),
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
}()
|
||||
|
||||
+10
-5
@@ -79,17 +79,22 @@ struct TimelineReadReceiptsView_Previews: PreviewProvider, TestablePreview {
|
||||
.mockMe
|
||||
]
|
||||
|
||||
static let viewModel = TimelineViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "Test", members: members)),
|
||||
static let viewModel = {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return TimelineViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "Test", members: members)),
|
||||
timelineController: MockTimelineController(),
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
}()
|
||||
|
||||
static let singleReceipt = [ReadReceipt(userID: RoomMemberProxyMock.mockAlice.userID, formattedTimestamp: "Now")]
|
||||
static let doubleReceipt = [ReadReceipt(userID: RoomMemberProxyMock.mockAlice.userID, formattedTimestamp: "Now"),
|
||||
|
||||
+10
-5
@@ -89,18 +89,23 @@ struct HighlightedTimelineItemTimeline_Previews: PreviewProvider {
|
||||
static let roomViewModel = RoomScreenViewModel.mock(roomProxyMock: roomProxyMock)
|
||||
static let focussedEventID = "RoomTimelineItemFixtures.default.5"
|
||||
static let composerViewModel = ComposerToolbarViewModel.mock()
|
||||
static let timelineViewModel = TimelineViewModel(roomProxy: roomProxyMock,
|
||||
static let timelineViewModel = {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return TimelineViewModel(roomProxy: roomProxyMock,
|
||||
focussedEventID: focussedEventID,
|
||||
timelineController: MockTimelineController(),
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
}()
|
||||
|
||||
static var previews: some View {
|
||||
ElementNavigationStack {
|
||||
|
||||
@@ -146,17 +146,22 @@ struct TimelineView_Previews: PreviewProvider { // Not testable as this preview
|
||||
name: "Preview room"))
|
||||
static let roomViewModel = RoomScreenViewModel.mock(roomProxyMock: roomProxyMock)
|
||||
static let composerViewModel = ComposerToolbarViewModel.mock()
|
||||
static let timelineViewModel = TimelineViewModel(roomProxy: roomProxyMock,
|
||||
static let timelineViewModel = {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return TimelineViewModel(roomProxy: roomProxyMock,
|
||||
timelineController: MockTimelineController(),
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
}()
|
||||
|
||||
static var previews: some View {
|
||||
ElementNavigationStack {
|
||||
|
||||
@@ -143,11 +143,14 @@ struct UserProfileScreen_Previews: PreviewProvider, TestablePreview {
|
||||
clientProxyMock.directRoomForUserIDReturnValue = .success("roomID")
|
||||
}
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
return UserProfileScreenViewModel(userID: userID,
|
||||
isPresentedModally: false,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxyMock)),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
analytics: analytics,
|
||||
appSettings: appSettings)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,5 +9,5 @@
|
||||
import SwiftUI
|
||||
|
||||
extension EnvironmentValues {
|
||||
@Entry var analyticsService: AnalyticsService = ServiceLocator.shared.analytics
|
||||
@Entry var analyticsService: AnalyticsService?
|
||||
}
|
||||
|
||||
@@ -388,7 +388,7 @@ extension AuthenticationService {
|
||||
encryptionKeyProvider: EncryptionKeyProvider(),
|
||||
classicAppManager: classicAppManager,
|
||||
clientFactory: AuthenticationClientFactoryMock(configuration: .init()),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: AppSettings(),
|
||||
appHooks: AppHooks())
|
||||
}
|
||||
}
|
||||
|
||||
+6
-4
@@ -10,6 +10,8 @@ import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
struct TimelineControllerFactory: TimelineControllerFactoryProtocol {
|
||||
let appSettings: AppSettings
|
||||
|
||||
func buildTimelineController(roomProxy: JoinedRoomProxyProtocol,
|
||||
initialFocussedEventID: String?,
|
||||
timelineItemFactory: RoomTimelineItemFactoryProtocol,
|
||||
@@ -19,7 +21,7 @@ struct TimelineControllerFactory: TimelineControllerFactoryProtocol {
|
||||
initialFocussedEventID: initialFocussedEventID,
|
||||
timelineItemFactory: timelineItemFactory,
|
||||
mediaProvider: mediaProvider,
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
}
|
||||
|
||||
func buildThreadTimelineController(threadRootEventID: String,
|
||||
@@ -34,7 +36,7 @@ struct TimelineControllerFactory: TimelineControllerFactoryProtocol {
|
||||
initialFocussedEventID: initialFocussedEventID,
|
||||
timelineItemFactory: timelineItemFactory,
|
||||
mediaProvider: mediaProvider,
|
||||
appSettings: ServiceLocator.shared.settings))
|
||||
appSettings: appSettings))
|
||||
case .failure(let error):
|
||||
return .failure(.roomProxyError(error))
|
||||
}
|
||||
@@ -50,7 +52,7 @@ struct TimelineControllerFactory: TimelineControllerFactoryProtocol {
|
||||
initialFocussedEventID: nil,
|
||||
timelineItemFactory: timelineItemFactory,
|
||||
mediaProvider: mediaProvider,
|
||||
appSettings: ServiceLocator.shared.settings))
|
||||
appSettings: appSettings))
|
||||
case .failure(let error):
|
||||
return .failure(.roomProxyError(error))
|
||||
}
|
||||
@@ -69,7 +71,7 @@ struct TimelineControllerFactory: TimelineControllerFactoryProtocol {
|
||||
initialFocussedEventID: nil,
|
||||
timelineItemFactory: timelineItemFactory,
|
||||
mediaProvider: mediaProvider,
|
||||
appSettings: ServiceLocator.shared.settings))
|
||||
appSettings: appSettings))
|
||||
case .failure(let error):
|
||||
return .failure(.roomProxyError(error))
|
||||
}
|
||||
|
||||
@@ -12,6 +12,10 @@ import SwiftUI
|
||||
import UIKit
|
||||
|
||||
class UITestsAppCoordinator: AppCoordinatorProtocol, SecureWindowManagerDelegate {
|
||||
private let appSettings: AppSettings
|
||||
private let analytics: AnalyticsService
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
|
||||
private let navigationRootCoordinator: NavigationRootCoordinator
|
||||
|
||||
// periphery:ignore - retaining purpose
|
||||
@@ -29,26 +33,30 @@ class UITestsAppCoordinator: AppCoordinatorProtocol, SecureWindowManagerDelegate
|
||||
|
||||
navigationRootCoordinator = NavigationRootCoordinator()
|
||||
|
||||
windowManager.delegate = self
|
||||
|
||||
MXLog.configure(currentTarget: "uitests")
|
||||
|
||||
ServiceLocator.shared.register(userIndicatorController: UserIndicatorController())
|
||||
|
||||
AppSettings.configureWithSuiteName("io.element.elementx.uitests")
|
||||
AppSettings.resetAllSettings()
|
||||
ServiceLocator.shared.register(appSettings: AppSettings())
|
||||
appSettings = AppSettings()
|
||||
|
||||
let analyticsClient = AnalyticsClientMock()
|
||||
analyticsClient.isRunning = false
|
||||
ServiceLocator.shared.register(analytics: AnalyticsService(client: analyticsClient,
|
||||
appSettings: ServiceLocator.shared.settings))
|
||||
|
||||
analytics = .mock(analyticsClient, settings: appSettings)
|
||||
userIndicatorController = UserIndicatorController()
|
||||
|
||||
windowManager.delegate = self
|
||||
}
|
||||
|
||||
func start() {
|
||||
guard let screenID = ProcessInfo.testScreenID else { fatalError("Unable to launch with unknown screen.") }
|
||||
|
||||
let mockScreen = MockScreen(id: screenID, windowManager: windowManager, navigationRootCoordinator: navigationRootCoordinator)
|
||||
let mockScreen = MockScreen(id: screenID,
|
||||
windowManager: windowManager,
|
||||
navigationRootCoordinator: navigationRootCoordinator,
|
||||
appSettings: appSettings,
|
||||
analytics: analytics,
|
||||
userIndicatorController: userIndicatorController)
|
||||
|
||||
if let coordinator = mockScreen.coordinator {
|
||||
navigationRootCoordinator.setRootCoordinator(coordinator)
|
||||
@@ -58,7 +66,8 @@ class UITestsAppCoordinator: AppCoordinatorProtocol, SecureWindowManagerDelegate
|
||||
}
|
||||
|
||||
func toPresentable() -> AnyView {
|
||||
navigationRootCoordinator.toPresentable()
|
||||
AnyView(navigationRootCoordinator.toPresentable()
|
||||
.environment(\.analyticsService, analytics))
|
||||
}
|
||||
|
||||
func handlePotentialPhishingAttempt(url: URL, openURLAction: @escaping (URL) -> Void) -> Bool {
|
||||
@@ -78,13 +87,16 @@ class UITestsAppCoordinator: AppCoordinatorProtocol, SecureWindowManagerDelegate
|
||||
}
|
||||
|
||||
func windowManagerDidConfigureWindows(_ windowManager: SecureWindowManagerProtocol) {
|
||||
ServiceLocator.shared.userIndicatorController.window = windowManager.overlayWindow
|
||||
userIndicatorController.window = windowManager.overlayWindow
|
||||
|
||||
// Set up the alternate window for the App Lock flow coordinator tests.
|
||||
guard let screenID = ProcessInfo.testScreenID, screenID == .appLockFlow || screenID == .appLockFlowDisabled else { return }
|
||||
let screen = MockScreen(id: screenID == .appLockFlow ? .appLockFlowAlternateWindow : .appLockFlowDisabledAlternateWindow,
|
||||
windowManager: windowManager,
|
||||
navigationRootCoordinator: navigationRootCoordinator)
|
||||
navigationRootCoordinator: navigationRootCoordinator,
|
||||
appSettings: appSettings,
|
||||
analytics: analytics,
|
||||
userIndicatorController: userIndicatorController)
|
||||
|
||||
guard let coordinator = screen.coordinator else {
|
||||
fatalError()
|
||||
@@ -102,6 +114,10 @@ class MockScreen: Identifiable {
|
||||
let windowManager: SecureWindowManagerProtocol
|
||||
let navigationRootCoordinator: NavigationRootCoordinator
|
||||
|
||||
private let appSettings: AppSettings
|
||||
private let analytics: AnalyticsService
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
|
||||
private var client: UITestsSignalling.Client?
|
||||
|
||||
private var retainedState = [Any]()
|
||||
@@ -109,10 +125,16 @@ class MockScreen: Identifiable {
|
||||
|
||||
init(id: UITestsScreenIdentifier,
|
||||
windowManager: SecureWindowManagerProtocol,
|
||||
navigationRootCoordinator: NavigationRootCoordinator) {
|
||||
navigationRootCoordinator: NavigationRootCoordinator,
|
||||
appSettings: AppSettings,
|
||||
analytics: AnalyticsService,
|
||||
userIndicatorController: UserIndicatorControllerProtocol) {
|
||||
self.id = id
|
||||
self.windowManager = windowManager
|
||||
self.navigationRootCoordinator = navigationRootCoordinator
|
||||
self.appSettings = appSettings
|
||||
self.analytics = analytics
|
||||
self.userIndicatorController = userIndicatorController
|
||||
}
|
||||
|
||||
lazy var coordinator: CoordinatorProtocol? = {
|
||||
@@ -121,12 +143,12 @@ class MockScreen: Identifiable {
|
||||
let navigationStackCoordinator = NavigationStackCoordinator()
|
||||
let coordinator = ServerSelectionScreenCoordinator(parameters: .init(authenticationService: AuthenticationService.mock,
|
||||
authenticationFlow: .login,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController))
|
||||
appSettings: appSettings,
|
||||
userIndicatorController: userIndicatorController))
|
||||
navigationStackCoordinator.setRootCoordinator(coordinator)
|
||||
return navigationStackCoordinator
|
||||
case .authenticationFlow, .provisionedAuthenticationFlow, .singleProviderAuthenticationFlow, .multipleProvidersAuthenticationFlow:
|
||||
let appSettings: AppSettings! = ServiceLocator.shared.settings
|
||||
let appSettings: AppSettings! = appSettings
|
||||
|
||||
if id == .singleProviderAuthenticationFlow || id == .multipleProvidersAuthenticationFlow {
|
||||
let accountProviders = id == .singleProviderAuthenticationFlow ? ["example.com"] : ["guest.example.com", "example.com"]
|
||||
@@ -158,8 +180,8 @@ class MockScreen: Identifiable {
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
analytics: analytics,
|
||||
userIndicatorController: userIndicatorController)
|
||||
flowCoordinator.start()
|
||||
retainedState.append(flowCoordinator)
|
||||
|
||||
@@ -184,7 +206,7 @@ class MockScreen: Identifiable {
|
||||
context.evaluatedPolicyDomainStateValue = Data("😎".utf8)
|
||||
|
||||
let appLockService = AppLockService(keychainController: keychainController,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
context: context)
|
||||
|
||||
if id == .appLockFlowAlternateWindow {
|
||||
@@ -206,7 +228,7 @@ class MockScreen: Identifiable {
|
||||
appLockService: appLockService,
|
||||
navigationCoordinator: navigationCoordinator,
|
||||
notificationCenter: notificationCenter,
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
|
||||
flowCoordinator.actions
|
||||
.sink { [weak self] action in
|
||||
@@ -240,7 +262,7 @@ class MockScreen: Identifiable {
|
||||
context.evaluatedPolicyDomainStateValue = Data("😎".utf8)
|
||||
|
||||
let appLockService = AppLockService(keychainController: keychainController,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
context: context)
|
||||
if id == .appLockSetupFlowUnlock, case .failure = appLockService.setupPINCode("2023") {
|
||||
fatalError("Failed to pre-set the PIN code")
|
||||
@@ -272,14 +294,14 @@ class MockScreen: Identifiable {
|
||||
roomProxy: JoinedRoomProxyMock(.init(name: "Some room name", avatarURL: nil)),
|
||||
timelineController: MockTimelineController(),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()),
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
composerDraftService: ComposerDraftServiceMock(.init()),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
@@ -294,14 +316,14 @@ class MockScreen: Identifiable {
|
||||
roomProxy: JoinedRoomProxyMock(.init(name: "New room", avatarURL: .mockMXCAvatar)),
|
||||
timelineController: timelineController,
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()),
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
composerDraftService: ComposerDraftServiceMock(.init()),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
@@ -316,14 +338,14 @@ class MockScreen: Identifiable {
|
||||
roomProxy: JoinedRoomProxyMock(.init(name: "New room", avatarURL: .mockMXCAvatar)),
|
||||
timelineController: timelineController,
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()),
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
composerDraftService: ComposerDraftServiceMock(.init()),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()), userIndicatorController: UserIndicatorControllerMock())
|
||||
let coordinator = RoomScreenCoordinator(parameters: parameters)
|
||||
@@ -337,14 +359,14 @@ class MockScreen: Identifiable {
|
||||
roomProxy: JoinedRoomProxyMock(.init(name: "New room", avatarURL: .mockMXCAvatar)),
|
||||
timelineController: timelineController,
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()),
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
composerDraftService: ComposerDraftServiceMock(.init()),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()), userIndicatorController: UserIndicatorControllerMock())
|
||||
let coordinator = RoomScreenCoordinator(parameters: parameters)
|
||||
@@ -361,14 +383,14 @@ class MockScreen: Identifiable {
|
||||
roomProxy: JoinedRoomProxyMock(.init(name: "Small timeline", avatarURL: .mockMXCAvatar)),
|
||||
timelineController: timelineController,
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()),
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
composerDraftService: ComposerDraftServiceMock(.init()),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()), userIndicatorController: UserIndicatorControllerMock())
|
||||
let coordinator = RoomScreenCoordinator(parameters: parameters)
|
||||
@@ -385,14 +407,14 @@ class MockScreen: Identifiable {
|
||||
roomProxy: JoinedRoomProxyMock(.init(name: "Small timeline, paginating", avatarURL: .mockMXCAvatar)),
|
||||
timelineController: timelineController,
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()),
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
composerDraftService: ComposerDraftServiceMock(.init()), timelineControllerFactory: TimelineControllerFactoryMock(.init()), userIndicatorController: UserIndicatorControllerMock())
|
||||
let coordinator = RoomScreenCoordinator(parameters: parameters)
|
||||
|
||||
@@ -408,14 +430,14 @@ class MockScreen: Identifiable {
|
||||
roomProxy: JoinedRoomProxyMock(.init(name: "Large timeline", avatarURL: .mockMXCAvatar)),
|
||||
timelineController: timelineController,
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()),
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
composerDraftService: ComposerDraftServiceMock(.init()),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()), userIndicatorController: UserIndicatorControllerMock())
|
||||
let coordinator = RoomScreenCoordinator(parameters: parameters)
|
||||
@@ -433,14 +455,14 @@ class MockScreen: Identifiable {
|
||||
roomProxy: JoinedRoomProxyMock(.init(name: "Large timeline", avatarURL: .mockMXCAvatar)),
|
||||
timelineController: timelineController,
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()),
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
composerDraftService: ComposerDraftServiceMock(.init()),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()), userIndicatorController: UserIndicatorControllerMock())
|
||||
let coordinator = RoomScreenCoordinator(parameters: parameters)
|
||||
@@ -457,14 +479,14 @@ class MockScreen: Identifiable {
|
||||
roomProxy: JoinedRoomProxyMock(.init(name: "Large timeline", avatarURL: .mockMXCAvatar)),
|
||||
timelineController: timelineController,
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()),
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
composerDraftService: ComposerDraftServiceMock(.init()),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()), userIndicatorController: UserIndicatorControllerMock())
|
||||
let coordinator = RoomScreenCoordinator(parameters: parameters)
|
||||
@@ -480,14 +502,14 @@ class MockScreen: Identifiable {
|
||||
roomProxy: JoinedRoomProxyMock(.init(name: "Timeline highlight", avatarURL: .mockMXCAvatar)),
|
||||
timelineController: timelineController,
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()),
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
composerDraftService: ComposerDraftServiceMock(.init()),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()), userIndicatorController: UserIndicatorControllerMock())
|
||||
let coordinator = RoomScreenCoordinator(parameters: parameters)
|
||||
@@ -517,14 +539,14 @@ class MockScreen: Identifiable {
|
||||
roomProxy: JoinedRoomProxyMock(.init(name: "Polls timeline", avatarURL: .mockMXCAvatar)),
|
||||
timelineController: timelineController,
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()),
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
composerDraftService: ComposerDraftServiceMock(.init()),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()), userIndicatorController: UserIndicatorControllerMock())
|
||||
let coordinator = RoomScreenCoordinator(parameters: parameters)
|
||||
@@ -541,14 +563,14 @@ class MockScreen: Identifiable {
|
||||
roomProxy: JoinedRoomProxyMock(.init(name: "Polls timeline", avatarURL: .mockMXCAvatar)),
|
||||
timelineController: timelineController,
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()),
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
composerDraftService: ComposerDraftServiceMock(.init()),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()), userIndicatorController: UserIndicatorControllerMock())
|
||||
let coordinator = RoomScreenCoordinator(parameters: parameters)
|
||||
@@ -565,14 +587,14 @@ class MockScreen: Identifiable {
|
||||
roomProxy: JoinedRoomProxyMock(.init(name: "Polls timeline", avatarURL: .mockMXCAvatar)),
|
||||
timelineController: timelineController,
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
completionSuggestionService: CompletionSuggestionServiceMock(configuration: .init()),
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
composerDraftService: ComposerDraftServiceMock(.init()),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()), userIndicatorController: UserIndicatorControllerMock())
|
||||
let coordinator = RoomScreenCoordinator(parameters: parameters)
|
||||
@@ -584,11 +606,11 @@ class MockScreen: Identifiable {
|
||||
requestDelay: .seconds(5))
|
||||
let parameters = SessionVerificationScreenCoordinatorParameters(sessionVerificationControllerProxy: sessionVerificationControllerProxy,
|
||||
flow: .deviceInitiator,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
mediaProvider: MediaProviderMock(configuration: .init()))
|
||||
return SessionVerificationScreenCoordinator(parameters: parameters)
|
||||
case .userSessionScreen, .userSessionScreenReply, .userSessionSpacesFlow:
|
||||
let appSettings: AppSettings = ServiceLocator.shared.settings
|
||||
let appSettings: AppSettings = appSettings
|
||||
appSettings.hasRunIdentityConfirmationOnboarding = true
|
||||
appSettings.hasRunNotificationPermissionsOnboarding = true
|
||||
appSettings.analyticsConsentState = .optedOut
|
||||
@@ -616,7 +638,7 @@ class MockScreen: Identifiable {
|
||||
let flowCoordinator = UserSessionFlowCoordinator(isNewLogin: false,
|
||||
navigationRootCoordinator: navigationRootCoordinator,
|
||||
appLockService: AppLockService(keychainController: KeychainControllerMock(),
|
||||
appSettings: ServiceLocator.shared.settings),
|
||||
appSettings: appSettings),
|
||||
flowParameters: CommonFlowParameters(userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||
bugReportService: BugReportServiceMock(.init()),
|
||||
elementCallService: ElementCallServiceMock(.init()),
|
||||
@@ -626,7 +648,7 @@ class MockScreen: Identifiable {
|
||||
appMediator: appMediator,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
notificationManager: NotificationManagerMock(),
|
||||
stateMachineFactory: StateMachineFactory()))
|
||||
@@ -641,8 +663,8 @@ class MockScreen: Identifiable {
|
||||
let members: [RoomMemberProxyMock] = [.mockInvitedAlice, .mockBob, .mockCharlie]
|
||||
let coordinator = RoomMembersListScreenCoordinator(parameters: .init(userSession: UserSessionMock(.init()),
|
||||
roomProxy: JoinedRoomProxyMock(.init(name: "test", members: members)),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analytics: ServiceLocator.shared.analytics))
|
||||
userIndicatorController: userIndicatorController,
|
||||
analytics: analytics))
|
||||
navigationStackCoordinator.setRootCoordinator(coordinator)
|
||||
return navigationStackCoordinator
|
||||
case .roomRolesAndPermissionsFlow:
|
||||
@@ -651,8 +673,8 @@ class MockScreen: Identifiable {
|
||||
let coordinator = RoomRolesAndPermissionsFlowCoordinator(parameters: .init(roomProxy: JoinedRoomProxyMock(.init(members: .allMembersAsAdmin)),
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
navigationStackCoordinator: navigationStackCoordinator,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analytics: ServiceLocator.shared.analytics))
|
||||
userIndicatorController: userIndicatorController,
|
||||
analytics: analytics))
|
||||
retainedState.append(coordinator)
|
||||
coordinator.start()
|
||||
return navigationStackCoordinator
|
||||
@@ -673,12 +695,12 @@ class MockScreen: Identifiable {
|
||||
bugReportService: BugReportServiceMock(.init()),
|
||||
elementCallService: ElementCallServiceMock(.init()),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()),
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
notificationManager: NotificationManagerMock(),
|
||||
stateMachineFactory: StateMachineFactory()))
|
||||
@@ -705,7 +727,7 @@ class MockScreen: Identifiable {
|
||||
let coordinator = PollFormScreenCoordinator(parameters: .init(mode: .new,
|
||||
maxNumberOfOptions: 10,
|
||||
timelineController: MockTimelineController(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock()))
|
||||
navigationStackCoordinator.setRootCoordinator(coordinator)
|
||||
return navigationStackCoordinator
|
||||
@@ -718,7 +740,7 @@ class MockScreen: Identifiable {
|
||||
navigationStackCoordinator.setRootCoordinator(BlankFormCoordinator())
|
||||
|
||||
let coordinator = EncryptionSettingsFlowCoordinator(parameters: .init(userSession: userSession,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
navigationStackCoordinator: navigationStackCoordinator))
|
||||
retainedState.append(coordinator)
|
||||
@@ -736,7 +758,7 @@ class MockScreen: Identifiable {
|
||||
|
||||
let coordinator = EncryptionResetFlowCoordinator(parameters: .init(userSession: userSession,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
userIndicatorController: userIndicatorController,
|
||||
navigationStackCoordinator: navigationStackCoordinator,
|
||||
@@ -759,12 +781,12 @@ class MockScreen: Identifiable {
|
||||
bugReportService: BugReportServiceMock(.init()),
|
||||
elementCallService: ElementCallServiceMock(.init()),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()),
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
notificationManager: NotificationManagerMock(),
|
||||
stateMachineFactory: StateMachineFactory()))
|
||||
@@ -787,7 +809,7 @@ class MockScreen: Identifiable {
|
||||
navigationRootCoordinator.setSheetCoordinator(navigationStackCoordinator)
|
||||
return PlaceholderScreenCoordinator(hideBrandChrome: false)
|
||||
case .autoUpdatingTimeline:
|
||||
let appSettings: AppSettings = ServiceLocator.shared.settings
|
||||
let appSettings: AppSettings = appSettings
|
||||
appSettings.hasRunIdentityConfirmationOnboarding = true
|
||||
appSettings.hasRunNotificationPermissionsOnboarding = true
|
||||
appSettings.analyticsConsentState = .optedOut
|
||||
@@ -807,7 +829,7 @@ class MockScreen: Identifiable {
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
stateEventStringBuilder: RoomStateEventStringBuilder(userID: "@alice:matrix.org")),
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
|
||||
let flowCoordinator = ChatsTabFlowCoordinator(isNewLogin: false,
|
||||
navigationSplitCoordinator: navigationSplitCoordinator,
|
||||
@@ -820,7 +842,7 @@ class MockScreen: Identifiable {
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
notificationManager: NotificationManagerMock(),
|
||||
stateMachineFactory: StateMachineFactory()))
|
||||
|
||||
@@ -17,16 +17,9 @@ class UnitTestsAppCoordinator: AppCoordinatorProtocol {
|
||||
|
||||
init(appDelegate: AppDelegate) {
|
||||
windowManager = WindowManager(appDelegate: appDelegate)
|
||||
ServiceLocator.shared.register(userIndicatorController: UserIndicatorControllerMock.default)
|
||||
|
||||
AppSettings.configureWithSuiteName("io.element.elementx.unittests")
|
||||
AppSettings.resetAllSettings()
|
||||
ServiceLocator.shared.register(appSettings: AppSettings())
|
||||
|
||||
let analyticsClient = AnalyticsClientMock()
|
||||
analyticsClient.isRunning = false
|
||||
ServiceLocator.shared.register(analytics: AnalyticsService(client: analyticsClient,
|
||||
appSettings: ServiceLocator.shared.settings))
|
||||
|
||||
// As the tests take advantage of Rust's ability to redirect the log files, there is
|
||||
// often some debris left from the previous run, so we wipe the entire directory.
|
||||
|
||||
@@ -11,20 +11,19 @@ import Testing
|
||||
|
||||
@MainActor
|
||||
final class AnalyticsSettingsScreenViewModelTests {
|
||||
private var appSettings: AppSettings!
|
||||
private let appSettings: AppSettings
|
||||
private let analytics: AnalyticsService
|
||||
|
||||
private var viewModel: AnalyticsSettingsScreenViewModelProtocol!
|
||||
private var context: AnalyticsSettingsScreenViewModelType.Context!
|
||||
|
||||
init() {
|
||||
AppSettings.resetAllSettings()
|
||||
appSettings = AppSettings()
|
||||
let analyticsClient = AnalyticsClientMock()
|
||||
analyticsClient.isRunning = false
|
||||
ServiceLocator.shared.register(analytics: AnalyticsService(client: analyticsClient,
|
||||
appSettings: appSettings))
|
||||
analytics = .mock(settings: appSettings)
|
||||
|
||||
viewModel = AnalyticsSettingsScreenViewModel(appSettings: appSettings,
|
||||
analytics: ServiceLocator.shared.analytics)
|
||||
analytics: analytics)
|
||||
context = viewModel.context
|
||||
}
|
||||
|
||||
|
||||
@@ -12,18 +12,19 @@ import PostHog
|
||||
import Testing
|
||||
|
||||
final class AnalyticsTests {
|
||||
private var appSettings: AppSettings
|
||||
private var analyticsClient: AnalyticsClientMock
|
||||
private let appSettings: AppSettings
|
||||
private let analytics: AnalyticsService
|
||||
private let analyticsClient: AnalyticsClientMock
|
||||
private var posthogMock: PHGPostHogMock
|
||||
|
||||
@MainActor
|
||||
init() {
|
||||
AppSettings.resetAllSettings()
|
||||
appSettings = AppSettings()
|
||||
|
||||
analyticsClient = AnalyticsClientMock()
|
||||
analyticsClient.isRunning = false
|
||||
ServiceLocator.shared.register(analytics: AnalyticsService(client: analyticsClient,
|
||||
appSettings: appSettings))
|
||||
analytics = .mock(analyticsClient, settings: appSettings)
|
||||
|
||||
posthogMock = PHGPostHogMock()
|
||||
posthogMock.configureMockBehavior()
|
||||
@@ -37,7 +38,7 @@ final class AnalyticsTests {
|
||||
func analyticsPromptNewUser() {
|
||||
// Given a fresh install of the app (without PostHog analytics having been set).
|
||||
// When the user is prompted for analytics.
|
||||
let showPrompt = ServiceLocator.shared.analytics.shouldShowAnalyticsPrompt
|
||||
let showPrompt = analytics.shouldShowAnalyticsPrompt
|
||||
|
||||
// Then the prompt should be shown.
|
||||
#expect(showPrompt, "A prompt should be shown for a new user.")
|
||||
@@ -49,7 +50,7 @@ final class AnalyticsTests {
|
||||
appSettings.analyticsConsentState = .optedOut
|
||||
|
||||
// When the user is prompted for analytics
|
||||
let showPrompt = ServiceLocator.shared.analytics.shouldShowAnalyticsPrompt
|
||||
let showPrompt = analytics.shouldShowAnalyticsPrompt
|
||||
|
||||
// Then no prompt should be shown.
|
||||
#expect(!showPrompt, "A prompt should not be shown any more.")
|
||||
@@ -61,7 +62,7 @@ final class AnalyticsTests {
|
||||
appSettings.analyticsConsentState = .optedIn
|
||||
|
||||
// When the user is prompted for analytics
|
||||
let showPrompt = ServiceLocator.shared.analytics.shouldShowAnalyticsPrompt
|
||||
let showPrompt = analytics.shouldShowAnalyticsPrompt
|
||||
|
||||
// Then no prompt should be shown.
|
||||
#expect(!showPrompt, "A prompt should not be shown any more.")
|
||||
@@ -71,7 +72,7 @@ final class AnalyticsTests {
|
||||
func analyticsPromptNotDisplayed() {
|
||||
// Given a fresh install of the app Analytics should be disabled
|
||||
#expect(appSettings.analyticsConsentState == .unknown)
|
||||
#expect(!ServiceLocator.shared.analytics.isEnabled)
|
||||
#expect(!analytics.isEnabled)
|
||||
#expect(!analyticsClient.startAnalyticsConfigurationCalled)
|
||||
}
|
||||
|
||||
@@ -79,10 +80,10 @@ final class AnalyticsTests {
|
||||
func analyticsOptOut() {
|
||||
// Given a fresh install of the app (without PostHog analytics having been set).
|
||||
// When analytics is opt-out
|
||||
ServiceLocator.shared.analytics.optOut()
|
||||
analytics.optOut()
|
||||
// Then analytics should be disabled
|
||||
#expect(appSettings.analyticsConsentState == .optedOut)
|
||||
#expect(!ServiceLocator.shared.analytics.isEnabled)
|
||||
#expect(!analytics.isEnabled)
|
||||
#expect(!analyticsClient.isRunning)
|
||||
// Analytics client should have been stopped
|
||||
#expect(analyticsClient.stopCalled)
|
||||
@@ -92,10 +93,10 @@ final class AnalyticsTests {
|
||||
func analyticsOptIn() {
|
||||
// Given a fresh install of the app (without PostHog analytics having been set).
|
||||
// When analytics is opt-in
|
||||
ServiceLocator.shared.analytics.optIn()
|
||||
analytics.optIn()
|
||||
// The analytics should be enabled
|
||||
#expect(appSettings.analyticsConsentState == .optedIn)
|
||||
#expect(ServiceLocator.shared.analytics.isEnabled)
|
||||
#expect(analytics.isEnabled)
|
||||
// Analytics client should have been started
|
||||
#expect(analyticsClient.startAnalyticsConfigurationCalled)
|
||||
}
|
||||
@@ -105,8 +106,8 @@ final class AnalyticsTests {
|
||||
// Given an existing install of the app where the user previously declined the tracking
|
||||
appSettings.analyticsConsentState = .optedOut
|
||||
// Analytics should not start
|
||||
#expect(!ServiceLocator.shared.analytics.isEnabled)
|
||||
ServiceLocator.shared.analytics.startIfEnabled()
|
||||
#expect(!analytics.isEnabled)
|
||||
analytics.startIfEnabled()
|
||||
#expect(!analyticsClient.startAnalyticsConfigurationCalled)
|
||||
}
|
||||
|
||||
@@ -115,8 +116,8 @@ final class AnalyticsTests {
|
||||
// Given an existing install of the app where the user previously accepted the tracking
|
||||
appSettings.analyticsConsentState = .optedIn
|
||||
// Analytics should start
|
||||
#expect(ServiceLocator.shared.analytics.isEnabled)
|
||||
ServiceLocator.shared.analytics.startIfEnabled()
|
||||
#expect(analytics.isEnabled)
|
||||
analytics.startIfEnabled()
|
||||
#expect(analyticsClient.startAnalyticsConfigurationCalled)
|
||||
}
|
||||
|
||||
@@ -214,14 +215,14 @@ final class AnalyticsTests {
|
||||
func resetConsentState() {
|
||||
// Given an existing install of the app where the user previously accpeted the tracking
|
||||
appSettings.analyticsConsentState = .optedIn
|
||||
#expect(!ServiceLocator.shared.analytics.shouldShowAnalyticsPrompt)
|
||||
#expect(!analytics.shouldShowAnalyticsPrompt)
|
||||
|
||||
// When forgetting analytics consents
|
||||
ServiceLocator.shared.analytics.resetConsentState()
|
||||
analytics.resetConsentState()
|
||||
|
||||
// Then the analytics prompt should be presented again
|
||||
#expect(appSettings.analyticsConsentState == .unknown)
|
||||
#expect(ServiceLocator.shared.analytics.shouldShowAnalyticsPrompt)
|
||||
#expect(analytics.shouldShowAnalyticsPrompt)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -153,7 +153,7 @@ struct AuthenticationServiceTests {
|
||||
encryptionKeyProvider: encryptionKeyProvider,
|
||||
classicAppManager: classicAppManager,
|
||||
clientFactory: clientFactory,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: AppSettings(),
|
||||
appHooks: AppHooks())
|
||||
|
||||
if let classicAppAccount = service.classicAppAccount {
|
||||
|
||||
@@ -28,8 +28,6 @@ final class AuthenticationStartScreenViewModelTests {
|
||||
init() {
|
||||
AppSettings.resetAllSettings()
|
||||
appSettings = AppSettings()
|
||||
// These app settings are kept local to the tests on purpose as if they are registered in the
|
||||
// ServiceLocator, the providers override that we apply will break other tests in the suite.
|
||||
}
|
||||
|
||||
deinit {
|
||||
|
||||
@@ -19,7 +19,7 @@ struct BlockedUsersScreenViewModelTests {
|
||||
|
||||
let viewModel = BlockedUsersScreenViewModel(hideProfiles: true,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
|
||||
let deferred = deferFailure(viewModel.context.observe(\.viewState.blockedUsers), timeout: .seconds(1)) { $0.contains { $0.displayName != nil } }
|
||||
try await deferred.fulfill()
|
||||
@@ -34,7 +34,7 @@ struct BlockedUsersScreenViewModelTests {
|
||||
|
||||
let viewModel = BlockedUsersScreenViewModel(hideProfiles: false,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
|
||||
let deferred = deferFulfillment(viewModel.context.observe(\.viewState.blockedUsers)) { $0.contains { $0.displayName != nil } }
|
||||
try await deferred.fulfill()
|
||||
|
||||
@@ -31,6 +31,9 @@ struct ChatsTabFlowCoordinatorTests {
|
||||
}
|
||||
|
||||
init() async throws {
|
||||
let appSettings = AppSettings()
|
||||
let analytics: AnalyticsService = .mock(settings: appSettings)
|
||||
|
||||
clientProxy = ClientProxyMock(.init(userID: "hi@bob", roomSummaryProvider: RoomSummaryProviderMock(.init(state: .loaded(.mockRooms)))))
|
||||
timelineControllerFactory = TimelineControllerFactoryMock(.init())
|
||||
|
||||
@@ -42,12 +45,12 @@ struct ChatsTabFlowCoordinatorTests {
|
||||
bugReportService: BugReportServiceMock(.init()),
|
||||
elementCallService: ElementCallServiceMock(.init()),
|
||||
timelineControllerFactory: timelineControllerFactory,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
notificationManager: notificationManager,
|
||||
stateMachineFactory: stateMachineFactory)
|
||||
|
||||
@@ -15,7 +15,6 @@ import WysiwygComposer
|
||||
|
||||
@MainActor
|
||||
final class ComposerToolbarViewModelTests {
|
||||
private var appSettings: AppSettings!
|
||||
private var wysiwygViewModel: WysiwygComposerViewModel!
|
||||
private var viewModel: ComposerToolbarViewModel!
|
||||
private var completionSuggestionServiceMock: CompletionSuggestionServiceMock!
|
||||
@@ -23,8 +22,7 @@ final class ComposerToolbarViewModelTests {
|
||||
|
||||
init() {
|
||||
AppSettings.resetAllSettings()
|
||||
appSettings = AppSettings()
|
||||
ServiceLocator.shared.register(appSettings: appSettings)
|
||||
|
||||
setUpViewModel()
|
||||
}
|
||||
|
||||
@@ -91,13 +89,15 @@ final class ComposerToolbarViewModelTests {
|
||||
.init(suggestionType: .user(.init(id: "@user_mention_2:matrix.org", displayName: "User 2", avatarURL: nil)), range: .init(), rawSuggestionText: "")]
|
||||
let mockCompletionSuggestionService = CompletionSuggestionServiceMock(configuration: .init(suggestions: suggestions))
|
||||
|
||||
let appSettings = AppSettings()
|
||||
|
||||
viewModel = ComposerToolbarViewModel(roomProxy: JoinedRoomProxyMock(.init()),
|
||||
wysiwygViewModel: wysiwygViewModel,
|
||||
completionSuggestionService: mockCompletionSuggestionService,
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper.mock,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
appSettings: appSettings,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
composerDraftService: draftServiceMock)
|
||||
|
||||
#expect(viewModel.state.suggestions == suggestions)
|
||||
@@ -708,13 +708,15 @@ final class ComposerToolbarViewModelTests {
|
||||
let mockSubject = CurrentValueSubject<[IdentityStatusChange], Never>([])
|
||||
roomProxyMock.underlyingIdentityStatusChangesPublisher = mockSubject.asCurrentValuePublisher()
|
||||
|
||||
let appSettings = AppSettings()
|
||||
|
||||
viewModel = ComposerToolbarViewModel(roomProxy: roomProxyMock,
|
||||
wysiwygViewModel: wysiwygViewModel,
|
||||
completionSuggestionService: mockCompletionSuggestionService,
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper.mock,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
appSettings: appSettings,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
composerDraftService: draftServiceMock)
|
||||
|
||||
var fulfillment = deferFulfillment(viewModel.context.$viewState, message: "Composer is disabled") { $0.canSend == false }
|
||||
@@ -753,13 +755,15 @@ final class ComposerToolbarViewModelTests {
|
||||
|
||||
roomProxyMock.underlyingIdentityStatusChangesPublisher = mockSubject.asCurrentValuePublisher()
|
||||
|
||||
let appSettings = AppSettings()
|
||||
|
||||
viewModel = ComposerToolbarViewModel(roomProxy: roomProxyMock,
|
||||
wysiwygViewModel: wysiwygViewModel,
|
||||
completionSuggestionService: mockCompletionSuggestionService,
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper.mock,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
appSettings: appSettings,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
composerDraftService: draftServiceMock)
|
||||
|
||||
var fulfillment = deferFulfillment(viewModel.context.$viewState, message: "Composer is disabled") { $0.canSend == false }
|
||||
@@ -787,14 +791,15 @@ final class ComposerToolbarViewModelTests {
|
||||
}
|
||||
|
||||
roomProxyMock.underlyingIdentityStatusChangesPublisher = CurrentValueSubject([IdentityStatusChange(userId: "@alice:localhost", changedTo: .pinViolation)]).asCurrentValuePublisher()
|
||||
let appSettings = AppSettings()
|
||||
|
||||
viewModel = ComposerToolbarViewModel(roomProxy: roomProxyMock,
|
||||
wysiwygViewModel: wysiwygViewModel,
|
||||
completionSuggestionService: mockCompletionSuggestionService,
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper.mock,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
appSettings: appSettings,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
composerDraftService: draftServiceMock)
|
||||
|
||||
let deferred = deferFulfillment(viewModel.context.$viewState, message: "Composer should be enabled") { $0.canSend == true }
|
||||
@@ -811,14 +816,16 @@ final class ComposerToolbarViewModelTests {
|
||||
draftServiceMock.loadDraftClosure = loadDraftClosure
|
||||
}
|
||||
|
||||
let appSettings = AppSettings()
|
||||
|
||||
viewModel = ComposerToolbarViewModel(initialText: initialText,
|
||||
roomProxy: JoinedRoomProxyMock(.init()),
|
||||
wysiwygViewModel: wysiwygViewModel,
|
||||
completionSuggestionService: completionSuggestionServiceMock,
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper.mock,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
appSettings: appSettings,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
composerDraftService: draftServiceMock)
|
||||
viewModel.context.composerFormattingEnabled = true
|
||||
}
|
||||
|
||||
@@ -17,12 +17,20 @@ final class CreateRoomScreenViewModelTests {
|
||||
var spaceService: SpaceServiceProxyMock!
|
||||
var userSession: UserSessionMock!
|
||||
|
||||
private let appSettings: AppSettings
|
||||
private let analytics: AnalyticsService
|
||||
|
||||
private let usersSubject = CurrentValueSubject<[UserProfileProxy], Never>([])
|
||||
|
||||
var context: CreateRoomScreenViewModel.Context {
|
||||
viewModel.context
|
||||
}
|
||||
|
||||
init() {
|
||||
appSettings = AppSettings()
|
||||
analytics = .mock(settings: appSettings)
|
||||
}
|
||||
|
||||
deinit {
|
||||
AppSettings.resetAllSettings()
|
||||
viewModel = nil
|
||||
@@ -82,14 +90,14 @@ final class CreateRoomScreenViewModelTests {
|
||||
spaceServiceConfiguration: .init(spaceRoomLists: ["1": .init()])))
|
||||
clientProxy.roomForIdentifierClosure = { roomID in .joined(JoinedRoomProxyMock(.init(id: roomID))) }
|
||||
userSession = UserSessionMock(.init(clientProxy: clientProxy))
|
||||
ServiceLocator.shared.settings.knockingEnabled = true
|
||||
appSettings.knockingEnabled = true
|
||||
let viewModel = CreateRoomScreenViewModel(isSpace: true,
|
||||
spaceSelectionMode: .none,
|
||||
shouldShowCancelButton: false,
|
||||
userSession: userSession,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
self.viewModel = viewModel
|
||||
|
||||
// Given a form with a blank topic.
|
||||
@@ -332,14 +340,14 @@ final class CreateRoomScreenViewModelTests {
|
||||
clientProxy.spaceService = spaceService
|
||||
clientProxy.roomForIdentifierClosure = { roomID in .joined(JoinedRoomProxyMock(.init(id: roomID))) }
|
||||
userSession = UserSessionMock(.init(clientProxy: clientProxy))
|
||||
ServiceLocator.shared.settings.knockingEnabled = true
|
||||
appSettings.knockingEnabled = true
|
||||
let viewModel = CreateRoomScreenViewModel(isSpace: isSpace,
|
||||
spaceSelectionMode: spacesSelectionMode,
|
||||
shouldShowCancelButton: false,
|
||||
userSession: userSession,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
self.viewModel = viewModel
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ struct EmojiPickerScreenViewModelTests {
|
||||
|
||||
viewModel = EmojiPickerScreenViewModel(itemID: .randomEvent,
|
||||
selectedEmojis: selectedEmojis,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
emojiProvider: EmojiProvider(appSettings: AppSettings()),
|
||||
timelineController: MockTimelineController(timelineProxy: timelineProxy))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ struct EmojiProviderTests {
|
||||
let emojiLoaderMock = EmojiLoaderMock()
|
||||
emojiLoaderMock.categories = [category]
|
||||
|
||||
let emojiProvider = EmojiProvider(loader: emojiLoaderMock, appSettings: ServiceLocator.shared.settings)
|
||||
let emojiProvider = EmojiProvider(loader: emojiLoaderMock, appSettings: AppSettings())
|
||||
|
||||
let categories = await emojiProvider.categories()
|
||||
#expect(emojiLoaderMock.categories == categories)
|
||||
@@ -33,7 +33,7 @@ struct EmojiProviderTests {
|
||||
let emojiLoaderMock = EmojiLoaderMock()
|
||||
emojiLoaderMock.categories = [category]
|
||||
|
||||
let emojiProvider = EmojiProvider(loader: emojiLoaderMock, appSettings: ServiceLocator.shared.settings)
|
||||
let emojiProvider = EmojiProvider(loader: emojiLoaderMock, appSettings: AppSettings())
|
||||
|
||||
let categories = await emojiProvider.categories(searchString: "")
|
||||
#expect(emojiLoaderMock.categories == categories)
|
||||
@@ -51,7 +51,7 @@ struct EmojiProviderTests {
|
||||
let emojiLoaderMock = EmojiLoaderMock()
|
||||
emojiLoaderMock.categories = categoriesForFirstLoad
|
||||
|
||||
let emojiProvider = EmojiProvider(loader: emojiLoaderMock, appSettings: ServiceLocator.shared.settings)
|
||||
let emojiProvider = EmojiProvider(loader: emojiLoaderMock, appSettings: AppSettings())
|
||||
|
||||
_ = await emojiProvider.categories()
|
||||
emojiLoaderMock.categories = categoriesForSecondLoad
|
||||
@@ -82,7 +82,7 @@ struct EmojiProviderTests {
|
||||
let emojiLoaderMock = EmojiLoaderMock()
|
||||
emojiLoaderMock.categories = categories
|
||||
|
||||
let emojiProvider = EmojiProvider(loader: emojiLoaderMock, appSettings: ServiceLocator.shared.settings)
|
||||
let emojiProvider = EmojiProvider(loader: emojiLoaderMock, appSettings: AppSettings())
|
||||
|
||||
_ = await emojiProvider.categories()
|
||||
let result = await emojiProvider.categories(searchString: searchString)
|
||||
|
||||
@@ -19,15 +19,18 @@ final class HomeScreenViewModelTests {
|
||||
|
||||
var clientProxy: ClientProxyMock!
|
||||
var roomSummaryProvider: RoomSummaryProviderMock!
|
||||
var appSettings: AppSettings!
|
||||
var notificationManager: NotificationManagerMock!
|
||||
private let appSettings: AppSettings
|
||||
private let analytics: AnalyticsService
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
|
||||
var cancellables = Set<AnyCancellable>()
|
||||
|
||||
init() {
|
||||
AppSettings.resetAllSettings()
|
||||
appSettings = AppSettings()
|
||||
ServiceLocator.shared.register(appSettings: appSettings)
|
||||
analytics = .mock(settings: appSettings)
|
||||
userIndicatorController = UserIndicatorControllerMock.default
|
||||
}
|
||||
|
||||
deinit {
|
||||
@@ -441,9 +444,9 @@ final class HomeScreenViewModelTests {
|
||||
viewModel = HomeScreenViewModel(userSession: userSession,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
appSettings: appSettings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
analyticsService: analytics,
|
||||
notificationManager: notificationManager,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
userIndicatorController: userIndicatorController)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,12 +15,9 @@ final class InviteUsersScreenViewModelTests {
|
||||
var viewModel: InviteUsersScreenViewModelProtocol!
|
||||
var userDiscoveryService: UserDiscoveryServiceMock!
|
||||
var clientProxy: ClientProxyMock!
|
||||
var appSettings: AppSettings!
|
||||
|
||||
init() {
|
||||
AppSettings.resetAllSettings()
|
||||
appSettings = AppSettings()
|
||||
ServiceLocator.shared.register(appSettings: appSettings)
|
||||
}
|
||||
|
||||
deinit {
|
||||
@@ -175,7 +172,7 @@ final class InviteUsersScreenViewModelTests {
|
||||
isSkippable: isSkippable,
|
||||
userDiscoveryService: userDiscoveryService,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: AppSettings())
|
||||
viewModel.state.usersSection = .init(type: .suggestions, users: [.mockAlice, .mockBob, .mockCharlie])
|
||||
self.viewModel = viewModel
|
||||
}
|
||||
|
||||
@@ -21,16 +21,16 @@ final class JoinRoomScreenViewModelTests {
|
||||
var viewModel: JoinRoomScreenViewModelProtocol!
|
||||
|
||||
var clientProxy: ClientProxyMock!
|
||||
var appSettings: AppSettings!
|
||||
|
||||
var context: JoinRoomScreenViewModelType.Context {
|
||||
viewModel.context
|
||||
}
|
||||
|
||||
private let appSettings: AppSettings
|
||||
|
||||
init() {
|
||||
AppSettings.resetAllSettings()
|
||||
appSettings = AppSettings()
|
||||
ServiceLocator.shared.register(appSettings: appSettings)
|
||||
}
|
||||
|
||||
deinit {
|
||||
@@ -205,7 +205,7 @@ final class JoinRoomScreenViewModelTests {
|
||||
viewModel = JoinRoomScreenViewModel(source: .generic(roomID: "1", via: []),
|
||||
appSettings: appSettings,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -394,12 +394,14 @@ struct LocationSharingScreenViewModelTests {
|
||||
let roomProxyMock = JoinedRoomProxyMock(.init(members: .allMembers))
|
||||
roomProxyMock.makeLiveLocationServiceReturnValue = liveLocationServiceMock
|
||||
|
||||
let appSettings = AppSettings()
|
||||
|
||||
viewModel = LocationSharingScreenViewModel(interactionMode: .viewLive(sender: nil, initialLiveLocationShare: nil),
|
||||
mapURLBuilder: ServiceLocator.shared.settings.mapTilerConfiguration,
|
||||
mapURLBuilder: appSettings.mapTilerConfiguration,
|
||||
roomProxy: roomProxyMock,
|
||||
timelineController: MockTimelineController(timelineProxy: TimelineProxyMock(.init())),
|
||||
liveLocationManager: LiveLocationManagerMock(.init()),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
mediaProvider: MediaProviderMock(configuration: .init()))
|
||||
|
||||
@@ -427,13 +429,14 @@ struct LocationSharingScreenViewModelTests {
|
||||
|
||||
private mutating func setupViewModel(liveLocationManagerConfiguration: LiveLocationManagerMock.Configuration = .init(),
|
||||
members: [RoomMemberProxyMock] = .allMembersAsAdmin) {
|
||||
let appSettings = AppSettings()
|
||||
timelineProxy = TimelineProxyMock(.init())
|
||||
viewModel = LocationSharingScreenViewModel(interactionMode: .picker(shouldShowLiveLocationOption: true),
|
||||
mapURLBuilder: ServiceLocator.shared.settings.mapTilerConfiguration,
|
||||
mapURLBuilder: appSettings.mapTilerConfiguration,
|
||||
roomProxy: JoinedRoomProxyMock(.init(members: members)),
|
||||
timelineController: MockTimelineController(timelineProxy: timelineProxy),
|
||||
liveLocationManager: LiveLocationManagerMock(liveLocationManagerConfiguration),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
mediaProvider: MediaProviderMock(configuration: .init()))
|
||||
viewModel.state.bindings.isLocationAuthorized = true
|
||||
@@ -441,13 +444,14 @@ struct LocationSharingScreenViewModelTests {
|
||||
|
||||
private mutating func setupViewModel(liveLocationManagerMock: LiveLocationManagerMock,
|
||||
members: [RoomMemberProxyMock] = .allMembersAsAdmin) {
|
||||
let appSettings = AppSettings()
|
||||
timelineProxy = TimelineProxyMock(.init())
|
||||
viewModel = LocationSharingScreenViewModel(interactionMode: .picker(shouldShowLiveLocationOption: true),
|
||||
mapURLBuilder: ServiceLocator.shared.settings.mapTilerConfiguration,
|
||||
mapURLBuilder: appSettings.mapTilerConfiguration,
|
||||
roomProxy: JoinedRoomProxyMock(.init(members: members)),
|
||||
timelineController: MockTimelineController(timelineProxy: timelineProxy),
|
||||
liveLocationManager: liveLocationManagerMock,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
mediaProvider: MediaProviderMock(configuration: .init()))
|
||||
viewModel.state.bindings.isLocationAuthorized = true
|
||||
@@ -457,6 +461,7 @@ struct LocationSharingScreenViewModelTests {
|
||||
initialShare: LiveLocationShare,
|
||||
liveLocationsSubject: CurrentValueSubject<[LiveLocationShare], Never>,
|
||||
members: [RoomMemberProxyMock] = .allMembers) {
|
||||
let appSettings = AppSettings()
|
||||
let liveLocationServiceMock = RoomLiveLocationServiceMock()
|
||||
liveLocationServiceMock.liveLocationsPublisher = liveLocationsSubject.asCurrentValuePublisher()
|
||||
|
||||
@@ -464,11 +469,11 @@ struct LocationSharingScreenViewModelTests {
|
||||
roomProxyMock.makeLiveLocationServiceReturnValue = liveLocationServiceMock
|
||||
|
||||
viewModel = LocationSharingScreenViewModel(interactionMode: .viewLive(sender: sender, initialLiveLocationShare: initialShare),
|
||||
mapURLBuilder: ServiceLocator.shared.settings.mapTilerConfiguration,
|
||||
mapURLBuilder: appSettings.mapTilerConfiguration,
|
||||
roomProxy: roomProxyMock,
|
||||
timelineController: MockTimelineController(timelineProxy: TimelineProxyMock(.init())),
|
||||
liveLocationManager: LiveLocationManagerMock(.init()),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
mediaProvider: MediaProviderMock(configuration: .init()))
|
||||
}
|
||||
|
||||
@@ -227,12 +227,14 @@ struct LoginScreenViewModelTests {
|
||||
// MARK: - Helpers
|
||||
|
||||
private mutating func setupViewModel(homeserverAddress: String = "example.com", loginHint: String? = nil) async {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
clientFactory = AuthenticationClientFactoryMock(configuration: .init())
|
||||
service = AuthenticationService(userSessionStore: UserSessionStoreMock(configuration: .init()),
|
||||
encryptionKeyProvider: EncryptionKeyProvider(),
|
||||
classicAppManager: nil,
|
||||
clientFactory: clientFactory,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks())
|
||||
|
||||
guard case .success = await service
|
||||
@@ -244,7 +246,7 @@ struct LoginScreenViewModelTests {
|
||||
viewModel = LoginScreenViewModel(authenticationService: service,
|
||||
loginHint: loginHint,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analytics: ServiceLocator.shared.analytics)
|
||||
appSettings: appSettings,
|
||||
analytics: .mock(settings: appSettings))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ struct ManageRoomMemberSheetViewModelTests {
|
||||
permissions: .init(canKick: true, canBan: true, ownPowerLevel: RoomMemberProxyMock.mockAdmin.powerLevel),
|
||||
roomProxy: roomProxy,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
analyticsService: .mock(),
|
||||
mediaProvider: MediaProviderMock(configuration: .init()))
|
||||
|
||||
let deferred = deferFulfillment(context.observe(\.viewState.bindings.alertInfo)) { $0 != nil }
|
||||
@@ -64,7 +64,7 @@ struct ManageRoomMemberSheetViewModelTests {
|
||||
permissions: .init(canKick: true, canBan: true, ownPowerLevel: RoomMemberProxyMock.mockAdmin.powerLevel),
|
||||
roomProxy: roomProxy,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
analyticsService: .mock(),
|
||||
mediaProvider: MediaProviderMock(configuration: .init()))
|
||||
|
||||
let deferred = deferFulfillment(context.observe(\.viewState.bindings.alertInfo)) { $0 != nil }
|
||||
@@ -87,7 +87,7 @@ struct ManageRoomMemberSheetViewModelTests {
|
||||
permissions: .init(canKick: true, canBan: true, ownPowerLevel: RoomMemberProxyMock.mockAdmin.powerLevel),
|
||||
roomProxy: roomProxy,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
analyticsService: .mock(),
|
||||
mediaProvider: MediaProviderMock(configuration: .init()))
|
||||
|
||||
let deferredAction = deferFulfillment(viewModel.actions) { action in
|
||||
|
||||
@@ -14,7 +14,8 @@ import Testing
|
||||
final class MediaUploadPreviewScreenViewModelTests {
|
||||
var timelineProxy: TimelineProxyMock!
|
||||
var clientProxy: ClientProxyMock!
|
||||
var userIndicatorController: UserIndicatorControllerMock!
|
||||
var userIndicatorController: UserIndicatorControllerMock
|
||||
private let appSettings: AppSettings
|
||||
|
||||
var viewModel: MediaUploadPreviewScreenViewModel!
|
||||
var context: MediaUploadPreviewScreenViewModel.Context {
|
||||
@@ -28,9 +29,10 @@ final class MediaUploadPreviewScreenViewModelTests {
|
||||
|
||||
init() {
|
||||
AppSettings.resetAllSettings()
|
||||
let appSettings = AppSettings()
|
||||
appSettings = AppSettings()
|
||||
appSettings.optimizeMediaUploads = false
|
||||
ServiceLocator.shared.register(appSettings: appSettings)
|
||||
|
||||
userIndicatorController = UserIndicatorControllerMock.default
|
||||
}
|
||||
|
||||
deinit {
|
||||
@@ -290,13 +292,11 @@ final class MediaUploadPreviewScreenViewModelTests {
|
||||
clientProxy.underlyingMaxMediaUploadSize = maxUploadSizeResult
|
||||
}
|
||||
|
||||
userIndicatorController = UserIndicatorControllerMock()
|
||||
|
||||
viewModel = MediaUploadPreviewScreenViewModel(mediaURLs: urls,
|
||||
title: "Some File",
|
||||
isRoomEncrypted: true,
|
||||
shouldShowCaptionWarning: true,
|
||||
mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: ServiceLocator.shared.settings),
|
||||
mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: appSettings),
|
||||
timelineController: MockTimelineController(timelineProxy: timelineProxy),
|
||||
clientProxy: clientProxy,
|
||||
userIndicatorController: userIndicatorController)
|
||||
|
||||
@@ -20,7 +20,6 @@ final class MediaUploadingPreprocessorTests {
|
||||
AppSettings.resetAllSettings()
|
||||
appSettings = AppSettings()
|
||||
appSettings.optimizeMediaUploads = false
|
||||
ServiceLocator.shared.register(appSettings: appSettings)
|
||||
mediaUploadingPreprocessor = MediaUploadingPreprocessor(appSettings: appSettings)
|
||||
}
|
||||
|
||||
|
||||
@@ -22,13 +22,11 @@ final class NotificationManagerTests {
|
||||
private var handleInlineReplyDelegateCalled = false
|
||||
private var notificationTappedDelegateCalled = false
|
||||
private var registerForRemoteNotificationsDelegateCalled: (() -> Void)?
|
||||
|
||||
private var appSettings: AppSettings {
|
||||
ServiceLocator.shared.settings
|
||||
}
|
||||
private let appSettings: AppSettings
|
||||
|
||||
init() {
|
||||
AppSettings.resetAllSettings()
|
||||
appSettings = AppSettings()
|
||||
notificationCenter = UserNotificationCenterMock()
|
||||
notificationCenter.requestAuthorizationOptionsReturnValue = true
|
||||
notificationCenter.authorizationStatusReturnValue = .authorized
|
||||
|
||||
@@ -15,6 +15,10 @@ import Testing
|
||||
struct PillContextTests {
|
||||
@Test
|
||||
func user() async {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let id = "@test:matrix.org"
|
||||
let proxyMock = JoinedRoomProxyMock(.init(name: "Test"))
|
||||
let subject = CurrentValueSubject<[RoomMemberProxyProtocol], Never>([])
|
||||
@@ -23,11 +27,11 @@ struct PillContextTests {
|
||||
timelineController: MockTimelineController(),
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
let context = PillContext(timelineContext: mock.context, data: PillTextAttachmentData(type: .user(userID: id), font: .preferredFont(forTextStyle: .body)))
|
||||
@@ -46,6 +50,10 @@ struct PillContextTests {
|
||||
|
||||
@Test
|
||||
func ownUser() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let id = "@test:matrix.org"
|
||||
let proxyMock = JoinedRoomProxyMock(.init(name: "Test", ownUserID: id))
|
||||
let subject = CurrentValueSubject<[RoomMemberProxyProtocol], Never>([])
|
||||
@@ -54,11 +62,11 @@ struct PillContextTests {
|
||||
timelineController: MockTimelineController(),
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
let context = PillContext(timelineContext: mock.context, data: PillTextAttachmentData(type: .user(userID: id), font: .preferredFont(forTextStyle: .body)))
|
||||
@@ -68,6 +76,10 @@ struct PillContextTests {
|
||||
|
||||
@Test
|
||||
func allUsers() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let avatarURL = URL(string: "https://matrix.jpg")
|
||||
let id = "test_room"
|
||||
let displayName = "Test"
|
||||
@@ -78,11 +90,11 @@ struct PillContextTests {
|
||||
timelineController: mockController,
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
let context = PillContext(timelineContext: mock.context, data: PillTextAttachmentData(type: .allUsers, font: .preferredFont(forTextStyle: .body)))
|
||||
@@ -93,6 +105,10 @@ struct PillContextTests {
|
||||
|
||||
@Test
|
||||
func roomIDMention() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
let mockController = MockTimelineController()
|
||||
let clientMock = ClientProxyMock(.init())
|
||||
@@ -102,11 +118,11 @@ struct PillContextTests {
|
||||
timelineController: mockController,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientMock)),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
let context = PillContext(timelineContext: mock.context, data: PillTextAttachmentData(type: .roomID("1"), font: .preferredFont(forTextStyle: .body)))
|
||||
@@ -118,6 +134,10 @@ struct PillContextTests {
|
||||
|
||||
@Test
|
||||
func roomIDMentionMissingRoom() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
let mockController = MockTimelineController()
|
||||
mockController.roomProxy = proxyMock
|
||||
@@ -125,11 +145,11 @@ struct PillContextTests {
|
||||
timelineController: mockController,
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
let context = PillContext(timelineContext: mock.context, data: PillTextAttachmentData(type: .roomID("1"), font: .preferredFont(forTextStyle: .body)))
|
||||
@@ -141,6 +161,10 @@ struct PillContextTests {
|
||||
|
||||
@Test
|
||||
func roomAliasMention() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
let mockController = MockTimelineController()
|
||||
mockController.roomProxy = proxyMock
|
||||
@@ -152,11 +176,11 @@ struct PillContextTests {
|
||||
timelineController: mockController,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientMock)),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
let context = PillContext(timelineContext: mock.context, data: PillTextAttachmentData(type: .roomAlias("#foundation-and-empire:matrix.org"), font: .preferredFont(forTextStyle: .body)))
|
||||
@@ -168,6 +192,10 @@ struct PillContextTests {
|
||||
|
||||
@Test
|
||||
func roomAliasMentionMissingRoom() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
let mockController = MockTimelineController()
|
||||
mockController.roomProxy = proxyMock
|
||||
@@ -175,11 +203,11 @@ struct PillContextTests {
|
||||
timelineController: mockController,
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
let context = PillContext(timelineContext: mock.context, data: PillTextAttachmentData(type: .roomAlias("#foundation-and-empire:matrix.org"), font: .preferredFont(forTextStyle: .body)))
|
||||
@@ -191,6 +219,10 @@ struct PillContextTests {
|
||||
|
||||
@Test
|
||||
func eventOnRoomIDMention() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
let mockController = MockTimelineController()
|
||||
mockController.roomProxy = proxyMock
|
||||
@@ -200,11 +232,11 @@ struct PillContextTests {
|
||||
timelineController: mockController,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientMock)),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
let context = PillContext(timelineContext: mock.context, data: PillTextAttachmentData(type: .event(room: .roomID("1")), font: .preferredFont(forTextStyle: .body)))
|
||||
@@ -216,6 +248,10 @@ struct PillContextTests {
|
||||
|
||||
@Test
|
||||
func eventOnRoomIDMentionMissingRoom() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
let mockController = MockTimelineController()
|
||||
mockController.roomProxy = proxyMock
|
||||
@@ -223,11 +259,11 @@ struct PillContextTests {
|
||||
timelineController: mockController,
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
let context = PillContext(timelineContext: mock.context, data: PillTextAttachmentData(type: .event(room: .roomID("1")), font: .preferredFont(forTextStyle: .body)))
|
||||
@@ -239,6 +275,10 @@ struct PillContextTests {
|
||||
|
||||
@Test
|
||||
func eventOnRoomAliasMention() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
let mockController = MockTimelineController()
|
||||
mockController.roomProxy = proxyMock
|
||||
@@ -250,11 +290,11 @@ struct PillContextTests {
|
||||
timelineController: mockController,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientMock)),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
let context = PillContext(timelineContext: mock.context, data: PillTextAttachmentData(type: .event(room: .roomAlias("#foundation-and-empire:matrix.org")), font: .preferredFont(forTextStyle: .body)))
|
||||
@@ -266,6 +306,10 @@ struct PillContextTests {
|
||||
|
||||
@Test
|
||||
func eventOnRoomAliasMentionMissingRoom() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
let mockController = MockTimelineController()
|
||||
mockController.roomProxy = proxyMock
|
||||
@@ -273,11 +317,11 @@ struct PillContextTests {
|
||||
timelineController: mockController,
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaPlayerProvider: MediaPlayerProviderMock(),
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
let context = PillContext(timelineContext: mock.context, data: PillTextAttachmentData(type: .event(room: .roomAlias("#foundation-and-empire:matrix.org")), font: .preferredFont(forTextStyle: .body)))
|
||||
|
||||
@@ -179,7 +179,7 @@ struct PollFormScreenViewModelTests {
|
||||
private mutating func setupViewModel(mode: PollFormMode = .new) {
|
||||
viewModel = PollFormScreenViewModel(mode: mode,
|
||||
timelineController: MockTimelineController(timelineProxy: timelineProxy),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: .mock(),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,6 +125,6 @@ struct RoomChangePermissionsScreenViewModelTests {
|
||||
ownPowerLevel: ownPowerLevel,
|
||||
roomProxy: roomProxy,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
analytics: ServiceLocator.shared.analytics)
|
||||
analytics: .mock())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,6 +197,6 @@ struct RoomChangeRolesScreenViewModelTests {
|
||||
roomProxy: roomProxy,
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
analytics: ServiceLocator.shared.analytics)
|
||||
analytics: .mock())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ struct RoomDetailsEditScreenViewModelTests {
|
||||
userIndicatorController = UserIndicatorControllerMock.default
|
||||
viewModel = .init(roomProxy: JoinedRoomProxyMock(roomProxyConfiguration),
|
||||
userSession: UserSessionMock(.init()),
|
||||
mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: ServiceLocator.shared.settings),
|
||||
mediaUploadingPreprocessor: MediaUploadingPreprocessor(appSettings: AppSettings()),
|
||||
userIndicatorController: userIndicatorController)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,29 +26,33 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
init() {
|
||||
AppSettings.resetAllSettings()
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
cancellables.removeAll()
|
||||
roomProxyMock = JoinedRoomProxyMock(.init(name: "Test"))
|
||||
notificationSettingsProxyMock = NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration())
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: notificationSettingsProxyMock,
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
}
|
||||
|
||||
@Test
|
||||
mutating func leaveRoomTappedWhenPublic() async throws {
|
||||
let appSettings = AppSettings()
|
||||
let mockedMembers: [RoomMemberProxyMock] = [.mockBob, .mockAlice]
|
||||
roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", members: mockedMembers, joinRule: .public))
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
let deferred = deferFulfillment(context.observe(\.viewState.bindings.leaveRoomAlertItem)) { $0 != nil }
|
||||
|
||||
context.send(viewAction: .processTapLeave)
|
||||
@@ -60,15 +64,17 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func leaveRoomTappedWhenRoomNotPublic() async throws {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let mockedMembers: [RoomMemberProxyMock] = [.mockBob, .mockAlice]
|
||||
roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", members: mockedMembers))
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
let deferred = deferFulfillment(context.observe(\.viewState.bindings.leaveRoomAlertItem)) { $0 != nil }
|
||||
|
||||
context.send(viewAction: .processTapLeave)
|
||||
@@ -81,15 +87,17 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func leaveRoomTappedWithLessThanTwoMembers() {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let mockedMembers: [RoomMemberProxyMock] = [.mockAlice]
|
||||
roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", members: mockedMembers))
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
|
||||
context.send(viewAction: .processTapLeave)
|
||||
#expect(context.leaveRoomAlertItem?.state == .empty)
|
||||
@@ -138,16 +146,18 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func initialDMDetailsState() async throws {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let recipient = RoomMemberProxyMock.mockDan
|
||||
let mockedMembers: [RoomMemberProxyMock] = [.mockMe, recipient]
|
||||
roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isDirect: true, isEncrypted: true, members: mockedMembers))
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
|
||||
let deferred = deferFulfillment(viewModel.context.observe(\.viewState.dmRecipientInfo)) { $0 != nil }
|
||||
|
||||
@@ -158,17 +168,19 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func ignoreSuccess() async throws {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let recipient = RoomMemberProxyMock.mockDan
|
||||
|
||||
let mockedMembers: [RoomMemberProxyMock] = [.mockMe, recipient]
|
||||
roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isDirect: true, isEncrypted: true, members: mockedMembers))
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
|
||||
let deferredRecipient = deferFulfillment(viewModel.context.observe(\.viewState.dmRecipientInfo)) { $0 != nil }
|
||||
|
||||
@@ -188,6 +200,8 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func ignoreFailure() async throws {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let recipient = RoomMemberProxyMock.mockDan
|
||||
let mockedMembers: [RoomMemberProxyMock] = [.mockMe, recipient]
|
||||
let clientProxy = ClientProxyMock(.init())
|
||||
@@ -195,11 +209,11 @@ struct RoomDetailsScreenViewModelTests {
|
||||
roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isDirect: true, isEncrypted: true, members: mockedMembers))
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
|
||||
let deferredRecipient = deferFulfillment(viewModel.context.observe(\.viewState.dmRecipientInfo)) { $0 != nil }
|
||||
|
||||
@@ -220,16 +234,18 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func unignoreSuccess() async throws {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let recipient = RoomMemberProxyMock.mockIgnored
|
||||
let mockedMembers: [RoomMemberProxyMock] = [.mockMe, recipient]
|
||||
roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isDirect: true, isEncrypted: true, members: mockedMembers))
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
|
||||
let deferredRecipient = deferFulfillment(viewModel.context.observe(\.viewState.dmRecipientInfo)) { $0 != nil }
|
||||
|
||||
@@ -249,6 +265,8 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func unignoreFailure() async throws {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let recipient = RoomMemberProxyMock.mockIgnored
|
||||
let mockedMembers: [RoomMemberProxyMock] = [.mockMe, recipient]
|
||||
let clientProxy = ClientProxyMock(.init())
|
||||
@@ -256,11 +274,11 @@ struct RoomDetailsScreenViewModelTests {
|
||||
roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isDirect: true, isEncrypted: true, members: mockedMembers))
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
|
||||
let deferredRecipient = deferFulfillment(viewModel.context.observe(\.viewState.dmRecipientInfo)) { $0 != nil }
|
||||
|
||||
@@ -281,6 +299,8 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func cannotInvitePeople() async {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let mockedMembers: [RoomMemberProxyMock] = [.mockMe, .mockAlice]
|
||||
roomProxyMock = JoinedRoomProxyMock(.init(name: "Test",
|
||||
members: mockedMembers,
|
||||
@@ -288,11 +308,11 @@ struct RoomDetailsScreenViewModelTests {
|
||||
powerLevelsConfiguration: .init(canUserInvite: false)))
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
|
||||
_ = await context.observe(\.viewState).debounce(for: .milliseconds(100)).first()
|
||||
|
||||
@@ -301,15 +321,17 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func invitePeople() async {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let mockedMembers: [RoomMemberProxyMock] = [.mockMe, .mockBob, .mockAlice]
|
||||
roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", members: mockedMembers, joinRule: .public))
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
|
||||
_ = await context.observe(\.viewState).debounce(for: .milliseconds(100)).first()
|
||||
|
||||
@@ -334,6 +356,8 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func canEditAvatar() async {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let mockedMembers: [RoomMemberProxyMock] = [.mockMe, .mockBob, .mockAlice]
|
||||
|
||||
let configuration = JoinedRoomProxyMockConfiguration(name: "Test",
|
||||
@@ -357,11 +381,11 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
|
||||
_ = await context.observe(\.viewState).debounce(for: .milliseconds(100)).first()
|
||||
|
||||
@@ -373,6 +397,8 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func canEditName() async {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let mockedMembers: [RoomMemberProxyMock] = [.mockMe, .mockBob, .mockAlice]
|
||||
|
||||
let configuration = JoinedRoomProxyMockConfiguration(name: "Test",
|
||||
@@ -396,11 +422,11 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
|
||||
_ = await context.observe(\.viewState).debounce(for: .milliseconds(100)).first()
|
||||
|
||||
@@ -412,6 +438,8 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func canEditTopic() async {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let mockedMembers: [RoomMemberProxyMock] = [.mockMe, .mockBob, .mockAlice]
|
||||
|
||||
let configuration = JoinedRoomProxyMockConfiguration(name: "Test",
|
||||
@@ -435,11 +463,11 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
|
||||
_ = await context.observe(\.viewState).debounce(for: .milliseconds(100)).first()
|
||||
|
||||
@@ -451,15 +479,17 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func cannotEditRoom() async {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let mockedMembers: [RoomMemberProxyMock] = [.mockMe, .mockBob, .mockAlice]
|
||||
roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isDirect: false, members: mockedMembers))
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
|
||||
_ = await context.observe(\.viewState).debounce(for: .milliseconds(100)).first()
|
||||
|
||||
@@ -471,15 +501,17 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func cannotEditDirectRoom() async {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let mockedMembers: [RoomMemberProxyMock] = [.mockMeAdmin, .mockBob, .mockAlice]
|
||||
roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isDirect: true, members: mockedMembers))
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
|
||||
_ = await context.observe(\.viewState).debounce(for: .milliseconds(100)).first()
|
||||
|
||||
@@ -490,14 +522,16 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func notificationLoadingSettingsFailure() async throws {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
notificationSettingsProxyMock.getNotificationSettingsRoomIdIsEncryptedIsOneToOneThrowableError = NotificationSettingsError.Generic(msg: "error")
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: notificationSettingsProxyMock,
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
|
||||
var deferred = deferFulfillment(context.observe(\.viewState.notificationSettingsState)) { $0.isError }
|
||||
|
||||
@@ -697,15 +731,17 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func knockRequestsCounter() async throws {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let mockedRequests: [KnockRequestProxyMock] = [.init(), .init()]
|
||||
roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isDirect: false, knockRequestsState: .loaded(mockedRequests), joinRule: .knock))
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: notificationSettingsProxyMock,
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
|
||||
let deferred = deferFulfillment(context.observe(\.viewState)) { state in
|
||||
state.knockRequestsCount == 2 && state.canSeeKnockingRequests
|
||||
@@ -719,14 +755,16 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func knockRequestsCounterIsLoading() async throws {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isDirect: false, knockRequestsState: .loading, joinRule: .knock))
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: notificationSettingsProxyMock,
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
|
||||
let deferred = deferFulfillment(context.observe(\.viewState)) { state in
|
||||
state.knockRequestsCount == 0 && state.canSeeKnockingRequests
|
||||
@@ -737,6 +775,8 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func knockRequestsCounterIsNotShownIfNoPermissions() async throws {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let mockedRequests: [KnockRequestProxyMock] = [.init(), .init()]
|
||||
roomProxyMock = JoinedRoomProxyMock(.init(name: "Test",
|
||||
isDirect: false,
|
||||
@@ -745,11 +785,11 @@ struct RoomDetailsScreenViewModelTests {
|
||||
powerLevelsConfiguration: .init(canUserInvite: false)))
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: notificationSettingsProxyMock,
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
|
||||
let deferred = deferFulfillment(context.observe(\.viewState)) { state in
|
||||
state.knockRequestsCount == 2 &&
|
||||
@@ -763,16 +803,18 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func knockRequestsCounterIsNotShownIfDM() async throws {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let mockedRequests: [KnockRequestProxyMock] = [.init(), .init()]
|
||||
let mockedMembers: [RoomMemberProxyMock] = [.mockMe, .mockAlice]
|
||||
roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isDirect: true, members: mockedMembers, knockRequestsState: .loaded(mockedRequests), joinRule: .knock))
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: notificationSettingsProxyMock,
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
|
||||
let deferred = deferFulfillment(context.observe(\.viewState)) { state in
|
||||
state.knockRequestsCount == 2 &&
|
||||
@@ -788,6 +830,8 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func historySharingPillDisplayed() async throws {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let configuration = JoinedRoomProxyMockConfiguration(historyVisibility: .shared)
|
||||
let infoSubject = CurrentValueSubject<RoomInfoProxyProtocol, Never>(RoomInfoProxyMock(configuration))
|
||||
let roomProxyMock = JoinedRoomProxyMock(configuration)
|
||||
@@ -795,11 +839,11 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: notificationSettingsProxyMock,
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
appSettings: appSettings)
|
||||
|
||||
let deferredShared = deferFulfillment(context.observe(\.viewState),
|
||||
message: "The pill should be shown for rooms with shared history visibility") { state in
|
||||
|
||||
@@ -19,6 +19,12 @@ final class RoomFlowCoordinatorTests {
|
||||
var navigationStackCoordinator: NavigationStackCoordinator!
|
||||
var cancellables = Set<AnyCancellable>()
|
||||
|
||||
private let appSettings: AppSettings
|
||||
|
||||
init() {
|
||||
appSettings = AppSettings()
|
||||
}
|
||||
|
||||
deinit {
|
||||
AppSettings.resetAllSettings()
|
||||
}
|
||||
@@ -236,7 +242,7 @@ final class RoomFlowCoordinatorTests {
|
||||
|
||||
@Test
|
||||
func threadedEventRoutes() async throws {
|
||||
ServiceLocator.shared.settings.threadsEnabled = true
|
||||
appSettings.threadsEnabled = true
|
||||
setupRoomFlowCoordinator()
|
||||
|
||||
// Navigate directly to the threaded event
|
||||
@@ -479,13 +485,13 @@ final class RoomFlowCoordinatorTests {
|
||||
bugReportService: BugReportServiceMock(.init()),
|
||||
elementCallService: ElementCallServiceMock(.init()),
|
||||
timelineControllerFactory: timelineControllerFactory,
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analytics: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationManager: NotificationManagerMock(),
|
||||
stateMachineFactory: StateMachineFactory())
|
||||
|
||||
|
||||
@@ -205,13 +205,17 @@ struct RoomMemberDetailsViewModelTests {
|
||||
roomProxyMock.getMemberUserIDClosure = { _ in
|
||||
.success(roomMemberProxyMock)
|
||||
}
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
// swiftlint:disable:next force_unwrapping
|
||||
let userSession = clientProxy != nil ? UserSessionMock(.init(clientProxy: clientProxy!)) : UserSessionMock(.init())
|
||||
viewModel = RoomMemberDetailsScreenViewModel(userID: roomMemberProxyMock.userID,
|
||||
roomProxy: roomProxyMock,
|
||||
userSession: userSession,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
appSettings: ServiceLocator.shared.settings)
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
analytics: analytics,
|
||||
appSettings: appSettings)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,16 +51,19 @@ struct RoomMembersFlowCoordinatorTests {
|
||||
let clientProxy = ClientProxyMock(.init())
|
||||
clientProxy.directRoomForUserIDReturnValue = .success(nil)
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
let flowParameters = CommonFlowParameters(userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||
bugReportService: BugReportServiceMock(.init()),
|
||||
elementCallService: ElementCallServiceMock(.init()),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()),
|
||||
emojiProvider: EmojiProvider(appSettings: ServiceLocator.shared.settings),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
analytics: analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
notificationManager: NotificationManagerMock(),
|
||||
stateMachineFactory: stateMachineFactory)
|
||||
|
||||
@@ -277,8 +277,8 @@ struct RoomMembersListScreenViewModelTests {
|
||||
|
||||
viewModel = RoomMembersListScreenViewModel(userSession: UserSessionMock(.init()),
|
||||
roomProxy: roomProxy,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analytics: ServiceLocator.shared.analytics)
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
analytics: .mock())
|
||||
|
||||
let context = viewModel.context
|
||||
|
||||
@@ -297,7 +297,7 @@ struct RoomMembersListScreenViewModelTests {
|
||||
roomProxy = JoinedRoomProxyMock(.init(name: "test", members: members))
|
||||
viewModel = RoomMembersListScreenViewModel(userSession: UserSessionMock(.init()),
|
||||
roomProxy: roomProxy,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController,
|
||||
analytics: ServiceLocator.shared.analytics)
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
analytics: .mock())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +84,6 @@ struct RoomRolesAndPermissionsScreenViewModelTests {
|
||||
roomProxy = JoinedRoomProxyMock(.init(members: members))
|
||||
viewModel = RoomRolesAndPermissionsScreenViewModel(roomProxy: roomProxy,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
analytics: ServiceLocator.shared.analytics)
|
||||
analytics: .mock())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,11 @@ import Testing
|
||||
final class RoomScreenViewModelTests {
|
||||
private var viewModel: RoomScreenViewModel!
|
||||
|
||||
private let appSettings: AppSettings
|
||||
|
||||
init() async throws {
|
||||
AppSettings.resetAllSettings()
|
||||
appSettings = AppSettings()
|
||||
}
|
||||
|
||||
deinit {
|
||||
@@ -45,10 +48,10 @@ final class RoomScreenViewModelTests {
|
||||
roomProxy: roomProxyMock,
|
||||
initialSelectedPinnedEventID: nil,
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
self.viewModel = viewModel
|
||||
|
||||
// check if in the default state is not showing but is indeed loading
|
||||
@@ -126,10 +129,10 @@ final class RoomScreenViewModelTests {
|
||||
roomProxy: roomProxyMock,
|
||||
initialSelectedPinnedEventID: "test1",
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
self.viewModel = viewModel
|
||||
|
||||
// check if the banner is now in a loaded state and is showing the counter
|
||||
@@ -166,7 +169,7 @@ final class RoomScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
func pinnedEventsBannerThreadedSelection() async throws {
|
||||
ServiceLocator.shared.settings.threadsEnabled = true
|
||||
appSettings.threadsEnabled = true
|
||||
|
||||
let roomProxyMock = JoinedRoomProxyMock(.init())
|
||||
let eventMock = TimelineEventSDKMock()
|
||||
@@ -187,10 +190,10 @@ final class RoomScreenViewModelTests {
|
||||
roomProxy: roomProxyMock,
|
||||
initialSelectedPinnedEventID: "test1",
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
self.viewModel = viewModel
|
||||
|
||||
// check if the banner is now in a loaded state and is showing the counter
|
||||
@@ -246,10 +249,10 @@ final class RoomScreenViewModelTests {
|
||||
roomProxy: roomProxyMock,
|
||||
initialSelectedPinnedEventID: nil,
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
self.viewModel = viewModel
|
||||
|
||||
#expect(viewModel.state.roomTitle == "StartingName")
|
||||
@@ -283,10 +286,10 @@ final class RoomScreenViewModelTests {
|
||||
roomProxy: roomProxyMock,
|
||||
initialSelectedPinnedEventID: nil,
|
||||
ongoingCallRoomIDPublisher: ongoingCallRoomIDSubject.asCurrentValuePublisher(),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
self.viewModel = viewModel
|
||||
#expect(viewModel.state.shouldShowCallButton)
|
||||
|
||||
@@ -328,10 +331,10 @@ final class RoomScreenViewModelTests {
|
||||
roomProxy: roomProxyMock,
|
||||
initialSelectedPinnedEventID: nil,
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
self.viewModel = viewModel
|
||||
viewModel.stop()
|
||||
}
|
||||
@@ -349,10 +352,10 @@ final class RoomScreenViewModelTests {
|
||||
roomProxy: roomProxyMock,
|
||||
initialSelectedPinnedEventID: nil,
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
self.viewModel = viewModel
|
||||
|
||||
var deferred = deferFulfillment(viewModel.context.$viewState) { state in
|
||||
@@ -383,10 +386,10 @@ final class RoomScreenViewModelTests {
|
||||
roomProxy: roomProxyMock,
|
||||
initialSelectedPinnedEventID: nil,
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
self.viewModel = viewModel
|
||||
|
||||
var deferred = deferFulfillment(viewModel.context.$viewState) { state in
|
||||
@@ -412,10 +415,10 @@ final class RoomScreenViewModelTests {
|
||||
roomProxy: roomProxyMock,
|
||||
initialSelectedPinnedEventID: nil,
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
self.viewModel = viewModel
|
||||
|
||||
// Loading state just does not appear at all
|
||||
@@ -432,10 +435,10 @@ final class RoomScreenViewModelTests {
|
||||
roomProxy: roomProxyMock,
|
||||
initialSelectedPinnedEventID: nil,
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
self.viewModel = viewModel
|
||||
|
||||
let deferred = deferFulfillment(viewModel.context.$viewState) { state in
|
||||
@@ -459,10 +462,10 @@ final class RoomScreenViewModelTests {
|
||||
roomProxy: roomProxyMock,
|
||||
initialSelectedPinnedEventID: nil,
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: ServiceLocator.shared.userIndicatorController)
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
self.viewModel = viewModel
|
||||
|
||||
let deferredInvisible = deferFailure(viewModel.context.$viewState,
|
||||
|
||||
@@ -16,18 +16,17 @@ final class ServerConfirmationScreenViewModelTests {
|
||||
var clientFactory: AuthenticationClientFactoryMock!
|
||||
var client: ClientSDKMock!
|
||||
var service: AuthenticationServiceProtocol!
|
||||
var appSettings: AppSettings!
|
||||
|
||||
var viewModel: ServerConfirmationScreenViewModel!
|
||||
var context: ServerConfirmationScreenViewModel.Context {
|
||||
viewModel.context
|
||||
}
|
||||
|
||||
private let appSettings: AppSettings
|
||||
|
||||
init() {
|
||||
AppSettings.resetAllSettings()
|
||||
appSettings = AppSettings()
|
||||
// These app settings are kept local to the tests on purpose as if they are registered in the
|
||||
// ServiceLocator, the providers override that we apply will break other tests in the suite.
|
||||
}
|
||||
|
||||
deinit {
|
||||
@@ -367,7 +366,7 @@ final class ServerConfirmationScreenViewModelTests {
|
||||
viewModel = ServerConfirmationScreenViewModel(authenticationService: service,
|
||||
mode: mode,
|
||||
authenticationFlow: authenticationFlow,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
appSettings: appSettings,
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
|
||||
// Add a fake window in order for the OAuth flow to continue
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user