mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 16:24:11 +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,9 @@ final class AnalyticsSettingsScreenViewModelTests {
|
||||
init() {
|
||||
AppSettings.resetAllSettings()
|
||||
appSettings = AppSettings()
|
||||
analytics = .mock(settings: appSettings)
|
||||
let client = AnalyticsClientMock()
|
||||
client.isRunning = false
|
||||
analytics = AnalyticsService(client: client, appSettings: appSettings)
|
||||
|
||||
viewModel = AnalyticsSettingsScreenViewModel(appSettings: appSettings,
|
||||
analytics: analytics)
|
||||
|
||||
@@ -13,7 +13,7 @@ import Testing
|
||||
|
||||
final class AnalyticsTests {
|
||||
private let appSettings: AppSettings
|
||||
private let analytics: AnalyticsService
|
||||
private let analytics: AnalyticsServiceProtocol
|
||||
private let analyticsClient: AnalyticsClientMock
|
||||
private var posthogMock: PHGPostHogMock
|
||||
|
||||
@@ -24,7 +24,7 @@ final class AnalyticsTests {
|
||||
|
||||
analyticsClient = AnalyticsClientMock()
|
||||
analyticsClient.isRunning = false
|
||||
analytics = .mock(analyticsClient, settings: appSettings)
|
||||
analytics = AnalyticsService(client: analyticsClient, appSettings: appSettings)
|
||||
|
||||
posthogMock = PHGPostHogMock()
|
||||
posthogMock.configureMockBehavior()
|
||||
|
||||
@@ -32,8 +32,6 @@ 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())
|
||||
|
||||
@@ -50,7 +48,7 @@ struct ChatsTabFlowCoordinatorTests {
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: analytics,
|
||||
analytics: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
notificationManager: notificationManager,
|
||||
stateMachineFactory: stateMachineFactory)
|
||||
|
||||
@@ -97,7 +97,7 @@ final class ComposerToolbarViewModelTests {
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper.mock,
|
||||
appSettings: appSettings,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
composerDraftService: draftServiceMock)
|
||||
|
||||
#expect(viewModel.state.suggestions == suggestions)
|
||||
@@ -716,7 +716,7 @@ final class ComposerToolbarViewModelTests {
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper.mock,
|
||||
appSettings: appSettings,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
composerDraftService: draftServiceMock)
|
||||
|
||||
var fulfillment = deferFulfillment(viewModel.context.$viewState, message: "Composer is disabled") { $0.canSend == false }
|
||||
@@ -763,7 +763,7 @@ final class ComposerToolbarViewModelTests {
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper.mock,
|
||||
appSettings: appSettings,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
composerDraftService: draftServiceMock)
|
||||
|
||||
var fulfillment = deferFulfillment(viewModel.context.$viewState, message: "Composer is disabled") { $0.canSend == false }
|
||||
@@ -799,7 +799,7 @@ final class ComposerToolbarViewModelTests {
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper.mock,
|
||||
appSettings: appSettings,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
composerDraftService: draftServiceMock)
|
||||
|
||||
let deferred = deferFulfillment(viewModel.context.$viewState, message: "Composer should be enabled") { $0.canSend == true }
|
||||
@@ -825,7 +825,7 @@ final class ComposerToolbarViewModelTests {
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
mentionDisplayHelper: ComposerMentionDisplayHelper.mock,
|
||||
appSettings: appSettings,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
composerDraftService: draftServiceMock)
|
||||
viewModel.context.composerFormattingEnabled = true
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ final class CreateRoomScreenViewModelTests {
|
||||
var userSession: UserSessionMock!
|
||||
|
||||
private let appSettings: AppSettings
|
||||
private let analytics: AnalyticsService
|
||||
|
||||
private let usersSubject = CurrentValueSubject<[UserProfileProxy], Never>([])
|
||||
|
||||
@@ -28,7 +27,6 @@ final class CreateRoomScreenViewModelTests {
|
||||
|
||||
init() {
|
||||
appSettings = AppSettings()
|
||||
analytics = .mock(settings: appSettings)
|
||||
}
|
||||
|
||||
deinit {
|
||||
@@ -95,7 +93,7 @@ final class CreateRoomScreenViewModelTests {
|
||||
spaceSelectionMode: .none,
|
||||
shouldShowCancelButton: false,
|
||||
userSession: userSession,
|
||||
analytics: analytics,
|
||||
analytics: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: appSettings)
|
||||
self.viewModel = viewModel
|
||||
@@ -345,7 +343,7 @@ final class CreateRoomScreenViewModelTests {
|
||||
spaceSelectionMode: spacesSelectionMode,
|
||||
shouldShowCancelButton: false,
|
||||
userSession: userSession,
|
||||
analytics: analytics,
|
||||
analytics: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: appSettings)
|
||||
self.viewModel = viewModel
|
||||
|
||||
@@ -21,16 +21,12 @@ final class HomeScreenViewModelTests {
|
||||
var roomSummaryProvider: RoomSummaryProviderMock!
|
||||
var notificationManager: NotificationManagerMock!
|
||||
private let appSettings: AppSettings
|
||||
private let analytics: AnalyticsService
|
||||
private let userIndicatorController: UserIndicatorControllerProtocol
|
||||
|
||||
var cancellables = Set<AnyCancellable>()
|
||||
|
||||
init() {
|
||||
AppSettings.resetAllSettings()
|
||||
appSettings = AppSettings()
|
||||
analytics = .mock(settings: appSettings)
|
||||
userIndicatorController = UserIndicatorControllerMock.default
|
||||
}
|
||||
|
||||
deinit {
|
||||
@@ -444,9 +440,9 @@ final class HomeScreenViewModelTests {
|
||||
viewModel = HomeScreenViewModel(userSession: userSession,
|
||||
selectedRoomPublisher: CurrentValueSubject<String?, Never>(nil).asCurrentValuePublisher(),
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
notificationManager: notificationManager,
|
||||
userIndicatorController: userIndicatorController)
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -401,7 +401,7 @@ struct LocationSharingScreenViewModelTests {
|
||||
roomProxy: roomProxyMock,
|
||||
timelineController: MockTimelineController(timelineProxy: TimelineProxyMock(.init())),
|
||||
liveLocationManager: LiveLocationManagerMock(.init()),
|
||||
analytics: .mock(settings: appSettings),
|
||||
analytics: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
mediaProvider: MediaProviderMock(configuration: .init()))
|
||||
|
||||
@@ -436,7 +436,7 @@ struct LocationSharingScreenViewModelTests {
|
||||
roomProxy: JoinedRoomProxyMock(.init(members: members)),
|
||||
timelineController: MockTimelineController(timelineProxy: timelineProxy),
|
||||
liveLocationManager: LiveLocationManagerMock(liveLocationManagerConfiguration),
|
||||
analytics: .mock(settings: appSettings),
|
||||
analytics: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
mediaProvider: MediaProviderMock(configuration: .init()))
|
||||
viewModel.state.bindings.isLocationAuthorized = true
|
||||
@@ -451,7 +451,7 @@ struct LocationSharingScreenViewModelTests {
|
||||
roomProxy: JoinedRoomProxyMock(.init(members: members)),
|
||||
timelineController: MockTimelineController(timelineProxy: timelineProxy),
|
||||
liveLocationManager: liveLocationManagerMock,
|
||||
analytics: .mock(settings: appSettings),
|
||||
analytics: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
mediaProvider: MediaProviderMock(configuration: .init()))
|
||||
viewModel.state.bindings.isLocationAuthorized = true
|
||||
@@ -473,7 +473,7 @@ struct LocationSharingScreenViewModelTests {
|
||||
roomProxy: roomProxyMock,
|
||||
timelineController: MockTimelineController(timelineProxy: TimelineProxyMock(.init())),
|
||||
liveLocationManager: LiveLocationManagerMock(.init()),
|
||||
analytics: .mock(settings: appSettings),
|
||||
analytics: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
mediaProvider: MediaProviderMock(configuration: .init()))
|
||||
}
|
||||
|
||||
@@ -247,6 +247,6 @@ struct LoginScreenViewModelTests {
|
||||
loginHint: loginHint,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
appSettings: appSettings,
|
||||
analytics: .mock(settings: appSettings))
|
||||
analytics: AnalyticsServiceMock.default())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ struct ManageRoomMemberSheetViewModelTests {
|
||||
permissions: .init(canKick: true, canBan: true, ownPowerLevel: RoomMemberProxyMock.mockAdmin.powerLevel),
|
||||
roomProxy: roomProxy,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
analyticsService: .mock(),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
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: .mock(),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
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: .mock(),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
mediaProvider: MediaProviderMock(configuration: .init()))
|
||||
|
||||
let deferredAction = deferFulfillment(viewModel.actions) { action in
|
||||
|
||||
@@ -16,7 +16,6 @@ struct PillContextTests {
|
||||
@Test
|
||||
func user() async {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let id = "@test:matrix.org"
|
||||
@@ -30,7 +29,7 @@ struct PillContextTests {
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -51,7 +50,6 @@ struct PillContextTests {
|
||||
@Test
|
||||
func ownUser() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let id = "@test:matrix.org"
|
||||
@@ -65,7 +63,7 @@ struct PillContextTests {
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -77,7 +75,6 @@ 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")
|
||||
@@ -93,7 +90,7 @@ struct PillContextTests {
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -106,7 +103,6 @@ struct PillContextTests {
|
||||
@Test
|
||||
func roomIDMention() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
@@ -121,7 +117,7 @@ struct PillContextTests {
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -135,7 +131,6 @@ struct PillContextTests {
|
||||
@Test
|
||||
func roomIDMentionMissingRoom() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
@@ -148,7 +143,7 @@ struct PillContextTests {
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -162,7 +157,6 @@ struct PillContextTests {
|
||||
@Test
|
||||
func roomAliasMention() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
@@ -179,7 +173,7 @@ struct PillContextTests {
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -193,7 +187,6 @@ struct PillContextTests {
|
||||
@Test
|
||||
func roomAliasMentionMissingRoom() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
@@ -206,7 +199,7 @@ struct PillContextTests {
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -220,7 +213,6 @@ struct PillContextTests {
|
||||
@Test
|
||||
func eventOnRoomIDMention() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
@@ -235,7 +227,7 @@ struct PillContextTests {
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -249,7 +241,6 @@ struct PillContextTests {
|
||||
@Test
|
||||
func eventOnRoomIDMentionMissingRoom() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
@@ -262,7 +253,7 @@ struct PillContextTests {
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -276,7 +267,6 @@ struct PillContextTests {
|
||||
@Test
|
||||
func eventOnRoomAliasMention() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
@@ -293,7 +283,7 @@ struct PillContextTests {
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -307,7 +297,6 @@ struct PillContextTests {
|
||||
@Test
|
||||
func eventOnRoomAliasMentionMissingRoom() {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let proxyMock = JoinedRoomProxyMock(.init())
|
||||
@@ -320,7 +309,7 @@ struct PillContextTests {
|
||||
userIndicatorController: userIndicatorController,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: analytics,
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
|
||||
@@ -179,7 +179,7 @@ struct PollFormScreenViewModelTests {
|
||||
private mutating func setupViewModel(mode: PollFormMode = .new) {
|
||||
viewModel = PollFormScreenViewModel(mode: mode,
|
||||
timelineController: MockTimelineController(timelineProxy: timelineProxy),
|
||||
analytics: .mock(),
|
||||
analytics: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,6 +125,6 @@ struct RoomChangePermissionsScreenViewModelTests {
|
||||
ownPowerLevel: ownPowerLevel,
|
||||
roomProxy: roomProxy,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
analytics: .mock())
|
||||
analytics: AnalyticsServiceMock.default())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,6 +197,6 @@ struct RoomChangeRolesScreenViewModelTests {
|
||||
roomProxy: roomProxy,
|
||||
mediaProvider: MediaProviderMock(configuration: .init()),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
analytics: .mock())
|
||||
analytics: AnalyticsServiceMock.default())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,33 +26,29 @@ 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: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: notificationSettingsProxyMock,
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: appSettings)
|
||||
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: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: appSettings)
|
||||
appSettings: AppSettings())
|
||||
let deferred = deferFulfillment(context.observe(\.viewState.bindings.leaveRoomAlertItem)) { $0 != nil }
|
||||
|
||||
context.send(viewAction: .processTapLeave)
|
||||
@@ -64,17 +60,15 @@ 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: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: appSettings)
|
||||
appSettings: AppSettings())
|
||||
let deferred = deferFulfillment(context.observe(\.viewState.bindings.leaveRoomAlertItem)) { $0 != nil }
|
||||
|
||||
context.send(viewAction: .processTapLeave)
|
||||
@@ -87,17 +81,15 @@ 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: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: appSettings)
|
||||
appSettings: AppSettings())
|
||||
|
||||
context.send(viewAction: .processTapLeave)
|
||||
#expect(context.leaveRoomAlertItem?.state == .empty)
|
||||
@@ -146,18 +138,16 @@ 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: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: appSettings)
|
||||
appSettings: AppSettings())
|
||||
|
||||
let deferred = deferFulfillment(viewModel.context.observe(\.viewState.dmRecipientInfo)) { $0 != nil }
|
||||
|
||||
@@ -168,19 +158,17 @@ 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: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: appSettings)
|
||||
appSettings: AppSettings())
|
||||
|
||||
let deferredRecipient = deferFulfillment(viewModel.context.observe(\.viewState.dmRecipientInfo)) { $0 != nil }
|
||||
|
||||
@@ -200,8 +188,6 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func ignoreFailure() async throws {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let recipient = RoomMemberProxyMock.mockDan
|
||||
let mockedMembers: [RoomMemberProxyMock] = [.mockMe, recipient]
|
||||
let clientProxy = ClientProxyMock(.init())
|
||||
@@ -209,11 +195,11 @@ struct RoomDetailsScreenViewModelTests {
|
||||
roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isDirect: true, isEncrypted: true, members: mockedMembers))
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: appSettings)
|
||||
appSettings: AppSettings())
|
||||
|
||||
let deferredRecipient = deferFulfillment(viewModel.context.observe(\.viewState.dmRecipientInfo)) { $0 != nil }
|
||||
|
||||
@@ -234,18 +220,16 @@ 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: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: appSettings)
|
||||
appSettings: AppSettings())
|
||||
|
||||
let deferredRecipient = deferFulfillment(viewModel.context.observe(\.viewState.dmRecipientInfo)) { $0 != nil }
|
||||
|
||||
@@ -265,8 +249,6 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func unignoreFailure() async throws {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let recipient = RoomMemberProxyMock.mockIgnored
|
||||
let mockedMembers: [RoomMemberProxyMock] = [.mockMe, recipient]
|
||||
let clientProxy = ClientProxyMock(.init())
|
||||
@@ -274,11 +256,11 @@ struct RoomDetailsScreenViewModelTests {
|
||||
roomProxyMock = JoinedRoomProxyMock(.init(name: "Test", isDirect: true, isEncrypted: true, members: mockedMembers))
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: appSettings)
|
||||
appSettings: AppSettings())
|
||||
|
||||
let deferredRecipient = deferFulfillment(viewModel.context.observe(\.viewState.dmRecipientInfo)) { $0 != nil }
|
||||
|
||||
@@ -299,8 +281,6 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func cannotInvitePeople() async {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let mockedMembers: [RoomMemberProxyMock] = [.mockMe, .mockAlice]
|
||||
roomProxyMock = JoinedRoomProxyMock(.init(name: "Test",
|
||||
members: mockedMembers,
|
||||
@@ -308,11 +288,11 @@ struct RoomDetailsScreenViewModelTests {
|
||||
powerLevelsConfiguration: .init(canUserInvite: false)))
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: appSettings)
|
||||
appSettings: AppSettings())
|
||||
|
||||
_ = await context.observe(\.viewState).debounce(for: .milliseconds(100)).first()
|
||||
|
||||
@@ -321,17 +301,15 @@ 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: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: appSettings)
|
||||
appSettings: AppSettings())
|
||||
|
||||
_ = await context.observe(\.viewState).debounce(for: .milliseconds(100)).first()
|
||||
|
||||
@@ -356,8 +334,6 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func canEditAvatar() async {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let mockedMembers: [RoomMemberProxyMock] = [.mockMe, .mockBob, .mockAlice]
|
||||
|
||||
let configuration = JoinedRoomProxyMockConfiguration(name: "Test",
|
||||
@@ -381,11 +357,11 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: appSettings)
|
||||
appSettings: AppSettings())
|
||||
|
||||
_ = await context.observe(\.viewState).debounce(for: .milliseconds(100)).first()
|
||||
|
||||
@@ -397,8 +373,6 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func canEditName() async {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let mockedMembers: [RoomMemberProxyMock] = [.mockMe, .mockBob, .mockAlice]
|
||||
|
||||
let configuration = JoinedRoomProxyMockConfiguration(name: "Test",
|
||||
@@ -422,11 +396,11 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: appSettings)
|
||||
appSettings: AppSettings())
|
||||
|
||||
_ = await context.observe(\.viewState).debounce(for: .milliseconds(100)).first()
|
||||
|
||||
@@ -438,8 +412,6 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func canEditTopic() async {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let mockedMembers: [RoomMemberProxyMock] = [.mockMe, .mockBob, .mockAlice]
|
||||
|
||||
let configuration = JoinedRoomProxyMockConfiguration(name: "Test",
|
||||
@@ -463,11 +435,11 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: appSettings)
|
||||
appSettings: AppSettings())
|
||||
|
||||
_ = await context.observe(\.viewState).debounce(for: .milliseconds(100)).first()
|
||||
|
||||
@@ -479,17 +451,15 @@ 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: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: appSettings)
|
||||
appSettings: AppSettings())
|
||||
|
||||
_ = await context.observe(\.viewState).debounce(for: .milliseconds(100)).first()
|
||||
|
||||
@@ -501,17 +471,15 @@ 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: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: NotificationSettingsProxyMock(with: NotificationSettingsProxyMockConfiguration()),
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: appSettings)
|
||||
appSettings: AppSettings())
|
||||
|
||||
_ = await context.observe(\.viewState).debounce(for: .milliseconds(100)).first()
|
||||
|
||||
@@ -522,16 +490,14 @@ 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: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: notificationSettingsProxyMock,
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: appSettings)
|
||||
appSettings: AppSettings())
|
||||
|
||||
var deferred = deferFulfillment(context.observe(\.viewState.notificationSettingsState)) { $0.isError }
|
||||
|
||||
@@ -731,17 +697,15 @@ 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: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: notificationSettingsProxyMock,
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: appSettings)
|
||||
appSettings: AppSettings())
|
||||
|
||||
let deferred = deferFulfillment(context.observe(\.viewState)) { state in
|
||||
state.knockRequestsCount == 2 && state.canSeeKnockingRequests
|
||||
@@ -755,16 +719,14 @@ 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: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: notificationSettingsProxyMock,
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: appSettings)
|
||||
appSettings: AppSettings())
|
||||
|
||||
let deferred = deferFulfillment(context.observe(\.viewState)) { state in
|
||||
state.knockRequestsCount == 0 && state.canSeeKnockingRequests
|
||||
@@ -775,8 +737,6 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
mutating func knockRequestsCounterIsNotShownIfNoPermissions() async throws {
|
||||
let appSettings = AppSettings()
|
||||
|
||||
let mockedRequests: [KnockRequestProxyMock] = [.init(), .init()]
|
||||
roomProxyMock = JoinedRoomProxyMock(.init(name: "Test",
|
||||
isDirect: false,
|
||||
@@ -785,11 +745,11 @@ struct RoomDetailsScreenViewModelTests {
|
||||
powerLevelsConfiguration: .init(canUserInvite: false)))
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: notificationSettingsProxyMock,
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: appSettings)
|
||||
appSettings: AppSettings())
|
||||
|
||||
let deferred = deferFulfillment(context.observe(\.viewState)) { state in
|
||||
state.knockRequestsCount == 2 &&
|
||||
@@ -803,18 +763,16 @@ 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: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: notificationSettingsProxyMock,
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: appSettings)
|
||||
appSettings: AppSettings())
|
||||
|
||||
let deferred = deferFulfillment(context.observe(\.viewState)) { state in
|
||||
state.knockRequestsCount == 2 &&
|
||||
@@ -830,8 +788,6 @@ 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)
|
||||
@@ -839,11 +795,11 @@ struct RoomDetailsScreenViewModelTests {
|
||||
|
||||
viewModel = RoomDetailsScreenViewModel(roomProxy: roomProxyMock,
|
||||
userSession: UserSessionMock(.init()),
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationSettingsProxy: notificationSettingsProxyMock,
|
||||
attributedStringBuilder: AttributedStringBuilder(mentionBuilder: MentionBuilder()),
|
||||
appSettings: appSettings)
|
||||
appSettings: AppSettings())
|
||||
|
||||
let deferredShared = deferFulfillment(context.observe(\.viewState),
|
||||
message: "The pill should be shown for rooms with shared history visibility") { state in
|
||||
|
||||
@@ -490,7 +490,7 @@ final class RoomFlowCoordinatorTests {
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: .mock(settings: appSettings),
|
||||
analytics: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
notificationManager: NotificationManagerMock(),
|
||||
stateMachineFactory: StateMachineFactory())
|
||||
|
||||
@@ -206,16 +206,13 @@ struct RoomMemberDetailsViewModelTests {
|
||||
.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: UserIndicatorControllerMock.default,
|
||||
analytics: analytics,
|
||||
appSettings: appSettings)
|
||||
analytics: AnalyticsServiceMock.default(),
|
||||
appSettings: AppSettings())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,6 @@ struct RoomMembersFlowCoordinatorTests {
|
||||
clientProxy.directRoomForUserIDReturnValue = .success(nil)
|
||||
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
|
||||
let flowParameters = CommonFlowParameters(userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||
bugReportService: BugReportServiceMock(.init()),
|
||||
@@ -63,7 +62,7 @@ struct RoomMembersFlowCoordinatorTests {
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: analytics,
|
||||
analytics: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
notificationManager: NotificationManagerMock(),
|
||||
stateMachineFactory: stateMachineFactory)
|
||||
|
||||
@@ -278,7 +278,7 @@ struct RoomMembersListScreenViewModelTests {
|
||||
viewModel = RoomMembersListScreenViewModel(userSession: UserSessionMock(.init()),
|
||||
roomProxy: roomProxy,
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
analytics: .mock())
|
||||
analytics: AnalyticsServiceMock.default())
|
||||
|
||||
let context = viewModel.context
|
||||
|
||||
@@ -298,6 +298,6 @@ struct RoomMembersListScreenViewModelTests {
|
||||
viewModel = RoomMembersListScreenViewModel(userSession: UserSessionMock(.init()),
|
||||
roomProxy: roomProxy,
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
analytics: .mock())
|
||||
analytics: AnalyticsServiceMock.default())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +84,6 @@ struct RoomRolesAndPermissionsScreenViewModelTests {
|
||||
roomProxy = JoinedRoomProxyMock(.init(members: members))
|
||||
viewModel = RoomRolesAndPermissionsScreenViewModel(roomProxy: roomProxy,
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
analytics: .mock())
|
||||
analytics: AnalyticsServiceMock.default())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ final class RoomScreenViewModelTests {
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
self.viewModel = viewModel
|
||||
|
||||
@@ -131,7 +131,7 @@ final class RoomScreenViewModelTests {
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
self.viewModel = viewModel
|
||||
|
||||
@@ -192,7 +192,7 @@ final class RoomScreenViewModelTests {
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
self.viewModel = viewModel
|
||||
|
||||
@@ -251,7 +251,7 @@ final class RoomScreenViewModelTests {
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
self.viewModel = viewModel
|
||||
|
||||
@@ -288,7 +288,7 @@ final class RoomScreenViewModelTests {
|
||||
ongoingCallRoomIDPublisher: ongoingCallRoomIDSubject.asCurrentValuePublisher(),
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
self.viewModel = viewModel
|
||||
#expect(viewModel.state.shouldShowCallButton)
|
||||
@@ -333,7 +333,7 @@ final class RoomScreenViewModelTests {
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
self.viewModel = viewModel
|
||||
viewModel.stop()
|
||||
@@ -354,7 +354,7 @@ final class RoomScreenViewModelTests {
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
self.viewModel = viewModel
|
||||
|
||||
@@ -388,7 +388,7 @@ final class RoomScreenViewModelTests {
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
self.viewModel = viewModel
|
||||
|
||||
@@ -417,7 +417,7 @@ final class RoomScreenViewModelTests {
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
self.viewModel = viewModel
|
||||
|
||||
@@ -437,7 +437,7 @@ final class RoomScreenViewModelTests {
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
self.viewModel = viewModel
|
||||
|
||||
@@ -464,7 +464,7 @@ final class RoomScreenViewModelTests {
|
||||
ongoingCallRoomIDPublisher: .init(.init(nil)),
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock.default)
|
||||
self.viewModel = viewModel
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ struct StartChatScreenViewModelTests {
|
||||
userDiscoveryService.searchProfilesWithReturnValue = .success([])
|
||||
let userSession = UserSessionMock(.init(clientProxy: clientProxy))
|
||||
viewModel = StartChatScreenViewModel(userSession: userSession,
|
||||
analytics: .mock(settings: appSettings),
|
||||
analytics: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: UserIndicatorControllerMock(),
|
||||
userDiscoveryService: userDiscoveryService,
|
||||
appSettings: appSettings)
|
||||
|
||||
@@ -316,7 +316,7 @@ final class TimelineViewModelTests {
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -345,7 +345,7 @@ final class TimelineViewModelTests {
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -372,7 +372,7 @@ final class TimelineViewModelTests {
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -411,7 +411,7 @@ final class TimelineViewModelTests {
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -450,7 +450,7 @@ final class TimelineViewModelTests {
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -495,7 +495,7 @@ final class TimelineViewModelTests {
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -526,7 +526,7 @@ final class TimelineViewModelTests {
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
@@ -598,7 +598,7 @@ final class TimelineViewModelTests {
|
||||
userIndicatorController: UserIndicatorControllerMock.default,
|
||||
appMediator: AppMediatorMock.default,
|
||||
appSettings: appSettings,
|
||||
analyticsService: .mock(settings: appSettings),
|
||||
analyticsService: AnalyticsServiceMock.default(),
|
||||
emojiProvider: EmojiProvider(appSettings: appSettings),
|
||||
linkMetadataProvider: LinkMetadataProvider(),
|
||||
timelineControllerFactory: TimelineControllerFactoryMock(.init()))
|
||||
|
||||
@@ -13,8 +13,6 @@ import Testing
|
||||
struct UserProfileScreenViewModelTests {
|
||||
@Test
|
||||
func initialState() async throws {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let profile = UserProfileProxy(userID: "@alice:matrix.org", displayName: "Alice", avatarURL: .mockMXCAvatar)
|
||||
@@ -25,8 +23,8 @@ struct UserProfileScreenViewModelTests {
|
||||
isPresentedModally: false,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||
userIndicatorController: userIndicatorController,
|
||||
analytics: analytics,
|
||||
appSettings: appSettings)
|
||||
analytics: AnalyticsServiceMock.default(),
|
||||
appSettings: AppSettings())
|
||||
let context = viewModel.context
|
||||
|
||||
let waitForMemberToLoad = deferFulfillment(context.observe(\.viewState.userProfile)) { $0 != nil }
|
||||
@@ -39,8 +37,6 @@ struct UserProfileScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
func initialStateAccountOwner() async throws {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let profile = UserProfileProxy(userID: RoomMemberProxyMock.mockMe.userID, displayName: "Me", avatarURL: .mockMXCAvatar)
|
||||
@@ -51,8 +47,8 @@ struct UserProfileScreenViewModelTests {
|
||||
isPresentedModally: false,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||
userIndicatorController: userIndicatorController,
|
||||
analytics: analytics,
|
||||
appSettings: appSettings)
|
||||
analytics: AnalyticsServiceMock.default(),
|
||||
appSettings: AppSettings())
|
||||
let context = viewModel.context
|
||||
|
||||
let waitForMemberToLoad = deferFulfillment(context.observe(\.viewState.userProfile)) { $0 != nil }
|
||||
@@ -65,8 +61,6 @@ struct UserProfileScreenViewModelTests {
|
||||
|
||||
@Test
|
||||
func startingDmWithUnknownUserFetchesIdentity() async throws {
|
||||
let appSettings = AppSettings()
|
||||
let analytics = AnalyticsService.mock(settings: appSettings)
|
||||
let userIndicatorController = UserIndicatorControllerMock.default
|
||||
|
||||
let profile = UserProfileProxy.mockAlice
|
||||
@@ -79,8 +73,8 @@ struct UserProfileScreenViewModelTests {
|
||||
isPresentedModally: false,
|
||||
userSession: UserSessionMock(.init(clientProxy: clientProxy)),
|
||||
userIndicatorController: userIndicatorController,
|
||||
analytics: analytics,
|
||||
appSettings: appSettings)
|
||||
analytics: AnalyticsServiceMock.default(),
|
||||
appSettings: AppSettings())
|
||||
|
||||
let context = viewModel.context
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ struct UserSessionFlowCoordinatorTests {
|
||||
appMediator: appMediator,
|
||||
appSettings: appSettings,
|
||||
appHooks: AppHooks(),
|
||||
analytics: .mock(settings: appSettings),
|
||||
analytics: AnalyticsServiceMock.default(),
|
||||
userIndicatorController: userIndicatorController,
|
||||
notificationManager: NotificationManagerMock(),
|
||||
stateMachineFactory: stateMachineFactory)
|
||||
|
||||
Reference in New Issue
Block a user