mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Make AnalyticsService mockable via `AnalyticsServiceProtocol (#5599)
* Create AnalyticsServiceProtocol and conform AnalyticsService * Replace AnalyticsService properties and arguments with AnalyticsServiceProtocol * Inline AnalyticsServiceMock replacing old mock * handle more complex AnalyticsServiceMock callsites * move documentation from AnalyticsService to AnalyticsServiceProtocol
This commit is contained in:
@@ -20,7 +20,7 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
|
||||
private let wysiwygViewModel: WysiwygComposerViewModel
|
||||
private let completionSuggestionService: CompletionSuggestionServiceProtocol
|
||||
private let roomProxy: JoinedRoomProxyProtocol
|
||||
private let analyticsService: AnalyticsService
|
||||
private let analyticsService: AnalyticsServiceProtocol
|
||||
private let draftService: ComposerDraftServiceProtocol
|
||||
private var identityPinningViolations = [String: RoomMemberProxyProtocol]()
|
||||
|
||||
@@ -52,7 +52,7 @@ final class ComposerToolbarViewModel: ComposerToolbarViewModelType, ComposerTool
|
||||
mediaProvider: MediaProviderProtocol,
|
||||
mentionDisplayHelper: MentionDisplayHelper,
|
||||
appSettings: AppSettings,
|
||||
analyticsService: AnalyticsService,
|
||||
analyticsService: AnalyticsServiceProtocol,
|
||||
composerDraftService: ComposerDraftServiceProtocol) {
|
||||
self.initialText = initialText
|
||||
self.wysiwygViewModel = wysiwygViewModel
|
||||
@@ -820,17 +820,14 @@ 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: appSettings,
|
||||
analyticsService: analytics,
|
||||
appSettings: AppSettings(),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
composerDraftService: ComposerDraftServiceMock(.init()))
|
||||
viewModel.state.bindings.composerFocused = focused
|
||||
viewModel.state.bindings.plainComposerText = NSAttributedString(string: message)
|
||||
|
||||
@@ -89,7 +89,7 @@ struct RoomAttachmentPicker_Previews: PreviewProvider, TestablePreview {
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper.mock,
|
||||
appSettings: appSettings,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
composerDraftService: ComposerDraftServiceMock(.init()))
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ struct RoomScreenCoordinatorParameters {
|
||||
let appMediator: AppMediatorProtocol
|
||||
let appSettings: AppSettings
|
||||
let appHooks: AppHooks
|
||||
let analytics: AnalyticsService
|
||||
let analytics: AnalyticsServiceProtocol
|
||||
let composerDraftService: ComposerDraftServiceProtocol
|
||||
let timelineControllerFactory: TimelineControllerFactoryProtocol
|
||||
let userIndicatorController: UserIndicatorControllerProtocol
|
||||
|
||||
@@ -18,7 +18,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
private let clientProxy: ClientProxyProtocol
|
||||
private let roomProxy: JoinedRoomProxyProtocol
|
||||
private let appSettings: AppSettings
|
||||
private let analyticsService: AnalyticsService
|
||||
private let analyticsService: AnalyticsServiceProtocol
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
|
||||
private var initialSelectedPinnedEventID: String?
|
||||
@@ -56,7 +56,7 @@ class RoomScreenViewModel: RoomScreenViewModelType, RoomScreenViewModelProtocol
|
||||
ongoingCallRoomIDPublisher: CurrentValuePublisher<String?, Never>,
|
||||
appSettings: AppSettings,
|
||||
appHooks: AppHooks,
|
||||
analyticsService: AnalyticsService,
|
||||
analyticsService: AnalyticsServiceProtocol,
|
||||
userIndicatorController: UserIndicatorControllerProtocol) {
|
||||
clientProxy = userSession.clientProxy
|
||||
self.roomProxy = roomProxy
|
||||
@@ -457,17 +457,14 @@ extension RoomScreenViewModel {
|
||||
static func mock(roomProxyMock: JoinedRoomProxyMock,
|
||||
clientProxyMock: ClientProxyMock = ClientProxyMock(.init()),
|
||||
appHooks: AppHooks = AppHooks()) -> RoomScreenViewModel {
|
||||
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: appSettings,
|
||||
appHooks: appHooks,
|
||||
analyticsService: analytics,
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
RoomScreenViewModel(userSession: UserSessionMock(.init(clientProxy: clientProxyMock)),
|
||||
roomProxy: roomProxyMock,
|
||||
initialSelectedPinnedEventID: nil,
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: AppSettings(),
|
||||
appHooks: appHooks,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -258,8 +258,6 @@ struct RoomScreen_Previews: PreviewProvider, TestablePreview {
|
||||
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()),
|
||||
@@ -267,7 +265,7 @@ struct RoomScreen_Previews: PreviewProvider, TestablePreview {
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
|
||||
Reference in New Issue
Block a user