mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
Check Application state before sending RR (#1960)
* check the state * better handling * protocol to mock the application state * test improvement
This commit is contained in:
@@ -55,7 +55,8 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
roomProxy: RoomProxyMock(with: .init(displayName: "")),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: userIndicatorControllerMock)
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default)
|
||||
|
||||
// Then the messages should be grouped together.
|
||||
XCTAssertEqual(viewModel.state.timelineViewState.itemViewStates[0].groupStyle, .first, "Nothing should prevent the first message from being grouped.")
|
||||
@@ -89,7 +90,8 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
roomProxy: RoomProxyMock(with: .init(displayName: "")),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: userIndicatorControllerMock)
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default)
|
||||
|
||||
// Then the messages should be grouped by sender.
|
||||
XCTAssertEqual(viewModel.state.timelineViewState.itemViewStates[0].groupStyle, .single, "A message should not be grouped when the sender changes.")
|
||||
@@ -121,7 +123,8 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
roomProxy: RoomProxyMock(with: .init(displayName: "")),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: userIndicatorControllerMock)
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default)
|
||||
|
||||
// Then the first message should not be grouped but the other two should.
|
||||
XCTAssertEqual(viewModel.state.timelineViewState.itemViewStates[0].groupStyle, .single, "When the first message has reactions it should not be grouped.")
|
||||
@@ -150,7 +153,8 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
roomProxy: RoomProxyMock(with: .init(displayName: "")),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: userIndicatorControllerMock)
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default)
|
||||
|
||||
// Then the first and second messages should be grouped and the last one should not.
|
||||
XCTAssertEqual(viewModel.state.timelineViewState.itemViewStates[0].groupStyle, .first, "Nothing should prevent the first message from being grouped.")
|
||||
@@ -179,7 +183,8 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
roomProxy: RoomProxyMock(with: .init(displayName: "")),
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: userIndicatorControllerMock)
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default)
|
||||
|
||||
// Then the messages should be grouped together.
|
||||
XCTAssertEqual(viewModel.state.timelineViewState.itemViewStates[0].groupStyle, .first, "Nothing should prevent the first message from being grouped.")
|
||||
@@ -204,7 +209,8 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
roomProxy: roomProxyMock,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: userIndicatorControllerMock)
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default)
|
||||
viewModel.actions
|
||||
.sink { action in
|
||||
switch action {
|
||||
@@ -243,7 +249,8 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
roomProxy: roomProxyMock,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: userIndicatorControllerMock)
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default)
|
||||
|
||||
viewModel.actions
|
||||
.sink { action in
|
||||
@@ -283,7 +290,8 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
roomProxy: roomProxyMock,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: userIndicatorControllerMock)
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default)
|
||||
viewModel.actions
|
||||
.sink { _ in
|
||||
XCTFail("Should not receive any action")
|
||||
@@ -315,7 +323,8 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
roomProxy: roomProxyMock,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: userIndicatorControllerMock)
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default)
|
||||
|
||||
viewModel.context.send(viewAction: .retrySend(itemID: .init(timelineID: UUID().uuidString, transactionID: "test retry send id")))
|
||||
|
||||
@@ -335,7 +344,8 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
roomProxy: roomProxyMock,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: userIndicatorControllerMock)
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default)
|
||||
|
||||
viewModel.context.send(viewAction: .retrySend(itemID: .random))
|
||||
|
||||
@@ -354,7 +364,8 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
roomProxy: roomProxyMock,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: userIndicatorControllerMock)
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default)
|
||||
|
||||
viewModel.context.send(viewAction: .cancelSend(itemID: .init(timelineID: UUID().uuidString, transactionID: "test cancel send id")))
|
||||
|
||||
@@ -374,7 +385,8 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
roomProxy: roomProxyMock,
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: userIndicatorControllerMock)
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default)
|
||||
|
||||
viewModel.context.send(viewAction: .cancelSend(itemID: .random))
|
||||
|
||||
@@ -512,6 +524,7 @@ class RoomScreenViewModelTests: XCTestCase {
|
||||
appSettings: ServiceLocator.shared.settings,
|
||||
analytics: ServiceLocator.shared.analytics,
|
||||
userIndicatorController: userIndicatorControllerMock,
|
||||
application: ApplicationMock.default,
|
||||
notificationCenterProtocol: notificationCenter)
|
||||
|
||||
return (viewModel, roomProxy, timelineController, notificationCenter)
|
||||
|
||||
Reference in New Issue
Block a user