change (preferences) : clean and fix tests
This commit is contained in:
parent
5725e328fe
commit
14681c56b7
5 changed files with 40 additions and 6 deletions
|
|
@ -48,5 +48,4 @@ dependencies {
|
|||
testImplementation(libs.androidx.compose.ui.test.junit)
|
||||
testImplementation(projects.libraries.preferences.test)
|
||||
testReleaseImplementation(libs.androidx.compose.ui.test.manifest)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,12 @@
|
|||
package io.element.android.features.messages.impl.timeline.protection
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import io.element.android.libraries.matrix.api.media.MediaPreviewValue
|
||||
import io.element.android.libraries.matrix.api.room.MatrixRoom
|
||||
import io.element.android.libraries.matrix.api.room.join.JoinRule
|
||||
import io.element.android.libraries.matrix.test.AN_EVENT_ID
|
||||
import io.element.android.libraries.matrix.test.room.FakeMatrixRoom
|
||||
import io.element.android.libraries.matrix.test.room.aRoomInfo
|
||||
import io.element.android.libraries.preferences.api.store.AppPreferencesStore
|
||||
import io.element.android.libraries.preferences.test.InMemoryAppPreferencesStore
|
||||
import io.element.android.tests.testutils.WarmUpRule
|
||||
|
|
@ -32,8 +37,8 @@ class TimelineProtectionPresenterTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `present - protected`() = runTest {
|
||||
val appPreferencesStore = InMemoryAppPreferencesStore(hideImagesAndVideos = true)
|
||||
fun `present - media preview value off`() = runTest {
|
||||
val appPreferencesStore = InMemoryAppPreferencesStore(timelineMediaPreviewValue = MediaPreviewValue.Off)
|
||||
val presenter = createPresenter(appPreferencesStore)
|
||||
presenter.test {
|
||||
skipItems(1)
|
||||
|
|
@ -47,9 +52,42 @@ class TimelineProtectionPresenterTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `present - media preview value private in public room`() = runTest {
|
||||
val appPreferencesStore = InMemoryAppPreferencesStore(timelineMediaPreviewValue = MediaPreviewValue.Private)
|
||||
val room = FakeMatrixRoom(initialRoomInfo = aRoomInfo(joinRule = JoinRule.Public))
|
||||
val presenter = createPresenter(appPreferencesStore, room)
|
||||
presenter.test {
|
||||
skipItems(1)
|
||||
val initialState = awaitItem()
|
||||
assertThat(initialState.protectionState).isEqualTo(ProtectionState.RenderOnly(persistentSetOf()))
|
||||
// ShowContent with null should have no effect.
|
||||
initialState.eventSink(TimelineProtectionEvent.ShowContent(eventId = null))
|
||||
initialState.eventSink(TimelineProtectionEvent.ShowContent(eventId = AN_EVENT_ID))
|
||||
val finalState = awaitItem()
|
||||
assertThat(finalState.protectionState).isEqualTo(ProtectionState.RenderOnly(persistentSetOf(AN_EVENT_ID)))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `present - media preview value private in non public room`() = runTest {
|
||||
val appPreferencesStore = InMemoryAppPreferencesStore(timelineMediaPreviewValue = MediaPreviewValue.Private)
|
||||
val room = FakeMatrixRoom(initialRoomInfo = aRoomInfo(joinRule = JoinRule.Invite))
|
||||
val presenter = createPresenter(appPreferencesStore, room)
|
||||
presenter.test {
|
||||
val initialState = awaitItem()
|
||||
assertThat(initialState.protectionState).isEqualTo(ProtectionState.RenderAll)
|
||||
// ShowContent with null should have no effect.
|
||||
initialState.eventSink(TimelineProtectionEvent.ShowContent(eventId = null))
|
||||
initialState.eventSink(TimelineProtectionEvent.ShowContent(eventId = AN_EVENT_ID))
|
||||
}
|
||||
}
|
||||
|
||||
private fun createPresenter(
|
||||
appPreferencesStore: AppPreferencesStore = InMemoryAppPreferencesStore(),
|
||||
room: MatrixRoom = FakeMatrixRoom(),
|
||||
) = TimelineProtectionPresenter(
|
||||
appPreferencesStore = appPreferencesStore,
|
||||
room = room,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ import io.element.android.libraries.designsystem.components.dialogs.ListOption
|
|||
import io.element.android.libraries.designsystem.components.dialogs.SingleSelectionDialog
|
||||
import io.element.android.libraries.designsystem.components.list.ListItemContent
|
||||
import io.element.android.libraries.designsystem.components.preferences.PreferenceCategory
|
||||
import io.element.android.libraries.designsystem.components.preferences.PreferenceDivider
|
||||
import io.element.android.libraries.designsystem.components.preferences.PreferencePage
|
||||
import io.element.android.libraries.designsystem.components.preferences.PreferenceSwitch
|
||||
import io.element.android.libraries.designsystem.preview.ElementPreview
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ class DeveloperSettingsPresenterTest {
|
|||
assertThat(state.cacheSize).isEqualTo(AsyncData.Uninitialized)
|
||||
assertThat(state.customElementCallBaseUrlState).isNotNull()
|
||||
assertThat(state.customElementCallBaseUrlState.baseUrl).isNull()
|
||||
assertThat(state.hideImagesAndVideos).isFalse()
|
||||
assertThat(state.rageshakeState.isEnabled).isFalse()
|
||||
assertThat(state.rageshakeState.isSupported).isTrue()
|
||||
assertThat(state.rageshakeState.sensitivity).isEqualTo(0.3f)
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@ internal fun RoomSummaryRow(
|
|||
eventSink: (RoomListEvents) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
|
||||
Box(modifier = modifier) {
|
||||
when (room.displayType) {
|
||||
RoomSummaryDisplayType.PLACEHOLDER -> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue