@ -41,7 +41,6 @@ class NotificationSettingsPresenterTests {
assertThat ( initialState . appSettings . appNotificationsEnabled ) . isFalse ( )
assertThat ( initialState . appSettings . appNotificationsEnabled ) . isFalse ( )
assertThat ( initialState . appSettings . systemNotificationsEnabled ) . isTrue ( )
assertThat ( initialState . appSettings . systemNotificationsEnabled ) . isTrue ( )
assertThat ( initialState . matrixSettings ) . isEqualTo ( NotificationSettingsState . MatrixSettings . Uninitialized )
assertThat ( initialState . matrixSettings ) . isEqualTo ( NotificationSettingsState . MatrixSettings . Uninitialized )
val loadedState = consumeItemsUntilPredicate {
val loadedState = consumeItemsUntilPredicate {
it . matrixSettings is NotificationSettingsState . MatrixSettings . Valid
it . matrixSettings is NotificationSettingsState . MatrixSettings . Valid
} . last ( )
} . last ( )
@ -50,6 +49,7 @@ class NotificationSettingsPresenterTests {
val valid = loadedState . matrixSettings as ? NotificationSettingsState . MatrixSettings . Valid
val valid = loadedState . matrixSettings as ? NotificationSettingsState . MatrixSettings . Valid
assertThat ( valid ?. atRoomNotificationsEnabled ) . isFalse ( )
assertThat ( valid ?. atRoomNotificationsEnabled ) . isFalse ( )
assertThat ( valid ?. callNotificationsEnabled ) . isFalse ( )
assertThat ( valid ?. callNotificationsEnabled ) . isFalse ( )
assertThat ( valid ?. inviteForMeNotificationsEnabled ) . isFalse ( )
assertThat ( valid ?. defaultGroupNotificationMode ) . isEqualTo ( RoomNotificationMode . MENTIONS _AND _KEYWORDS _ONLY )
assertThat ( valid ?. defaultGroupNotificationMode ) . isEqualTo ( RoomNotificationMode . MENTIONS _AND _KEYWORDS _ONLY )
assertThat ( valid ?. defaultOneToOneNotificationMode ) . isEqualTo ( RoomNotificationMode . ALL _MESSAGES )
assertThat ( valid ?. defaultOneToOneNotificationMode ) . isEqualTo ( RoomNotificationMode . ALL _MESSAGES )
cancelAndIgnoreRemainingEvents ( )
cancelAndIgnoreRemainingEvents ( )
@ -63,7 +63,6 @@ class NotificationSettingsPresenterTests {
moleculeFlow ( RecompositionMode . Immediate ) {
moleculeFlow ( RecompositionMode . Immediate ) {
presenter . present ( )
presenter . present ( )
} . test {
} . test {
notificationSettingsService . setDefaultRoomNotificationMode ( isEncrypted = true , isOneToOne = false , mode = RoomNotificationMode . ALL _MESSAGES )
notificationSettingsService . setDefaultRoomNotificationMode ( isEncrypted = true , isOneToOne = false , mode = RoomNotificationMode . ALL _MESSAGES )
notificationSettingsService . setDefaultRoomNotificationMode ( isEncrypted = false , isOneToOne = false , mode = RoomNotificationMode . ALL _MESSAGES )
notificationSettingsService . setDefaultRoomNotificationMode ( isEncrypted = false , isOneToOne = false , mode = RoomNotificationMode . ALL _MESSAGES )
val updatedState = consumeItemsUntilPredicate {
val updatedState = consumeItemsUntilPredicate {
@ -82,7 +81,6 @@ class NotificationSettingsPresenterTests {
moleculeFlow ( RecompositionMode . Immediate ) {
moleculeFlow ( RecompositionMode . Immediate ) {
presenter . present ( )
presenter . present ( )
} . test {
} . test {
notificationSettingsService . setDefaultRoomNotificationMode (
notificationSettingsService . setDefaultRoomNotificationMode (
isEncrypted = true ,
isEncrypted = true ,
isOneToOne = false ,
isOneToOne = false ,
@ -118,7 +116,6 @@ class NotificationSettingsPresenterTests {
val fixedState = consumeItemsUntilPredicate ( timeout = 2000. milliseconds ) {
val fixedState = consumeItemsUntilPredicate ( timeout = 2000. milliseconds ) {
it . matrixSettings is NotificationSettingsState . MatrixSettings . Valid
it . matrixSettings is NotificationSettingsState . MatrixSettings . Valid
} . last ( )
} . last ( )
val fixedMatrixState = fixedState . matrixSettings as ? NotificationSettingsState . MatrixSettings . Valid
val fixedMatrixState = fixedState . matrixSettings as ? NotificationSettingsState . MatrixSettings . Valid
assertThat ( fixedMatrixState ?. defaultGroupNotificationMode ) . isEqualTo ( RoomNotificationMode . ALL _MESSAGES )
assertThat ( fixedMatrixState ?. defaultGroupNotificationMode ) . isEqualTo ( RoomNotificationMode . ALL _MESSAGES )
}
}
@ -134,7 +131,6 @@ class NotificationSettingsPresenterTests {
it . matrixSettings is NotificationSettingsState . MatrixSettings . Valid
it . matrixSettings is NotificationSettingsState . MatrixSettings . Valid
} . last ( )
} . last ( )
assertThat ( loadedState . appSettings . appNotificationsEnabled ) . isTrue ( )
assertThat ( loadedState . appSettings . appNotificationsEnabled ) . isTrue ( )
loadedState . eventSink ( NotificationSettingsEvents . SetNotificationsEnabled ( false ) )
loadedState . eventSink ( NotificationSettingsEvents . SetNotificationsEnabled ( false ) )
val updatedState = consumeItemsUntilPredicate {
val updatedState = consumeItemsUntilPredicate {
! it . appSettings . appNotificationsEnabled
! it . appSettings . appNotificationsEnabled
@ -155,7 +151,6 @@ class NotificationSettingsPresenterTests {
} . last ( )
} . last ( )
val validMatrixState = loadedState . matrixSettings as ? NotificationSettingsState . MatrixSettings . Valid
val validMatrixState = loadedState . matrixSettings as ? NotificationSettingsState . MatrixSettings . Valid
assertThat ( validMatrixState ?. callNotificationsEnabled ) . isFalse ( )
assertThat ( validMatrixState ?. callNotificationsEnabled ) . isFalse ( )
loadedState . eventSink ( NotificationSettingsEvents . SetCallNotificationsEnabled ( true ) )
loadedState . eventSink ( NotificationSettingsEvents . SetCallNotificationsEnabled ( true ) )
val updatedState = consumeItemsUntilPredicate {
val updatedState = consumeItemsUntilPredicate {
( it . matrixSettings as ? NotificationSettingsState . MatrixSettings . Valid ) ?. callNotificationsEnabled == true
( it . matrixSettings as ? NotificationSettingsState . MatrixSettings . Valid ) ?. callNotificationsEnabled == true
@ -166,6 +161,27 @@ class NotificationSettingsPresenterTests {
}
}
}
}
@Test
fun `present - set invite for me notifications enabled` ( ) = runTest {
val presenter = createNotificationSettingsPresenter ( )
moleculeFlow ( RecompositionMode . Immediate ) {
presenter . present ( )
} . test {
val loadedState = consumeItemsUntilPredicate {
( it . matrixSettings as ? NotificationSettingsState . MatrixSettings . Valid ) ?. inviteForMeNotificationsEnabled == false
} . last ( )
val validMatrixState = loadedState . matrixSettings as ? NotificationSettingsState . MatrixSettings . Valid
assertThat ( validMatrixState ?. inviteForMeNotificationsEnabled ) . isFalse ( )
loadedState . eventSink ( NotificationSettingsEvents . SetInviteForMeNotificationsEnabled ( true ) )
val updatedState = consumeItemsUntilPredicate {
( it . matrixSettings as ? NotificationSettingsState . MatrixSettings . Valid ) ?. inviteForMeNotificationsEnabled == true
} . last ( )
val updatedMatrixState = updatedState . matrixSettings as ? NotificationSettingsState . MatrixSettings . Valid
assertThat ( updatedMatrixState ?. inviteForMeNotificationsEnabled ) . isTrue ( )
cancelAndIgnoreRemainingEvents ( )
}
}
@Test
@Test
fun `present - set atRoom notifications enabled` ( ) = runTest {
fun `present - set atRoom notifications enabled` ( ) = runTest {
val presenter = createNotificationSettingsPresenter ( )
val presenter = createNotificationSettingsPresenter ( )
@ -177,7 +193,6 @@ class NotificationSettingsPresenterTests {
} . last ( )
} . last ( )
val validMatrixState = loadedState . matrixSettings as ? NotificationSettingsState . MatrixSettings . Valid
val validMatrixState = loadedState . matrixSettings as ? NotificationSettingsState . MatrixSettings . Valid
assertThat ( validMatrixState ?. atRoomNotificationsEnabled ) . isFalse ( )
assertThat ( validMatrixState ?. atRoomNotificationsEnabled ) . isFalse ( )
loadedState . eventSink ( NotificationSettingsEvents . SetAtRoomNotificationsEnabled ( true ) )
loadedState . eventSink ( NotificationSettingsEvents . SetAtRoomNotificationsEnabled ( true ) )
val updatedState = consumeItemsUntilPredicate {
val updatedState = consumeItemsUntilPredicate {
( it . matrixSettings as ? NotificationSettingsState . MatrixSettings . Valid ) ?. atRoomNotificationsEnabled == true
( it . matrixSettings as ? NotificationSettingsState . MatrixSettings . Valid ) ?. atRoomNotificationsEnabled == true
@ -201,14 +216,12 @@ class NotificationSettingsPresenterTests {
} . last ( )
} . last ( )
val validMatrixState = loadedState . matrixSettings as ? NotificationSettingsState . MatrixSettings . Valid
val validMatrixState = loadedState . matrixSettings as ? NotificationSettingsState . MatrixSettings . Valid
assertThat ( validMatrixState ?. atRoomNotificationsEnabled ) . isFalse ( )
assertThat ( validMatrixState ?. atRoomNotificationsEnabled ) . isFalse ( )
loadedState . eventSink ( NotificationSettingsEvents . SetAtRoomNotificationsEnabled ( true ) )
loadedState . eventSink ( NotificationSettingsEvents . SetAtRoomNotificationsEnabled ( true ) )
val errorState = consumeItemsUntilPredicate {
val errorState = consumeItemsUntilPredicate {
it . changeNotificationSettingAction . isFailure ( )
it . changeNotificationSettingAction . isFailure ( )
} . last ( )
} . last ( )
assertThat ( errorState . changeNotificationSettingAction . isFailure ( ) ) . isTrue ( )
assertThat ( errorState . changeNotificationSettingAction . isFailure ( ) ) . isTrue ( )
errorState . eventSink ( NotificationSettingsEvents . ClearNotificationChangeError )
errorState . eventSink ( NotificationSettingsEvents . ClearNotificationChangeError )
val clearErrorState = consumeItemsUntilPredicate {
val clearErrorState = consumeItemsUntilPredicate {
it . changeNotificationSettingAction . isUninitialized ( )
it . changeNotificationSettingAction . isUninitialized ( )
} . last ( )
} . last ( )