quality: fix formatting and test
This commit is contained in:
@@ -11,7 +11,7 @@ package io.element.android.features.securityandprivacy.impl.root
|
||||
sealed interface SecurityAndPrivacyEvents {
|
||||
data object EditRoomAddress : SecurityAndPrivacyEvents
|
||||
data object Save : SecurityAndPrivacyEvents
|
||||
data object Exit: SecurityAndPrivacyEvents
|
||||
data object Exit : SecurityAndPrivacyEvents
|
||||
data object DismissExitConfirmation : SecurityAndPrivacyEvents
|
||||
data class ChangeRoomAccess(val roomAccess: SecurityAndPrivacyRoomAccess) : SecurityAndPrivacyEvents
|
||||
data object ToggleEncryptionState : SecurityAndPrivacyEvents
|
||||
|
||||
@@ -21,9 +21,9 @@ import androidx.compose.runtime.setValue
|
||||
import dev.zacsweers.metro.Assisted
|
||||
import dev.zacsweers.metro.AssistedFactory
|
||||
import dev.zacsweers.metro.AssistedInject
|
||||
import io.element.android.features.securityandprivacy.api.securityAndPrivacyPermissionsAsState
|
||||
import io.element.android.features.securityandprivacy.impl.SecurityAndPrivacyNavigator
|
||||
import io.element.android.features.securityandprivacy.impl.editroomaddress.matchesServer
|
||||
import io.element.android.features.securityandprivacy.api.securityAndPrivacyPermissionsAsState
|
||||
import io.element.android.libraries.architecture.AsyncAction
|
||||
import io.element.android.libraries.architecture.AsyncData
|
||||
import io.element.android.libraries.architecture.AsyncData.*
|
||||
@@ -65,7 +65,7 @@ class SecurityAndPrivacyPresenter(
|
||||
featureFlagService.isFeatureEnabledFlow(FeatureFlags.Knock)
|
||||
}.collectAsState(false)
|
||||
val saveAction = remember { mutableStateOf<AsyncAction<Unit>>(AsyncAction.Uninitialized) }
|
||||
var confirmExitAction by remember { mutableStateOf<AsyncAction<Unit>>(AsyncAction.Uninitialized)}
|
||||
var confirmExitAction by remember { mutableStateOf<AsyncAction<Unit>>(AsyncAction.Uninitialized) }
|
||||
val homeserverName = remember { matrixClient.userIdServerName() }
|
||||
val syncUpdateFlow = room.syncUpdateFlow.collectAsState()
|
||||
val roomInfo by room.roomInfoFlow.collectAsState()
|
||||
|
||||
@@ -117,7 +117,7 @@ fun aSecurityAndPrivacyState(
|
||||
canChangeRoomVisibility = true
|
||||
),
|
||||
isKnockEnabled: Boolean = true,
|
||||
isSpace: Boolean,
|
||||
isSpace: Boolean = false,
|
||||
eventSink: (SecurityAndPrivacyEvents) -> Unit = {}
|
||||
) = SecurityAndPrivacyState(
|
||||
editedSettings = editedSettings,
|
||||
|
||||
@@ -218,7 +218,7 @@ private fun RoomAccessSection(
|
||||
ListItem(
|
||||
headlineContent = { Text(text = stringResource(R.string.screen_security_and_privacy_room_access_space_members_option_title)) },
|
||||
supportingContent = { Text(text = stringResource(R.string.screen_security_and_privacy_room_access_space_members_option_description)) },
|
||||
trailingContent = ListItemContent.RadioButton(selected = edited == SecurityAndPrivacyRoomAccess.SpaceMember, enabled = false),
|
||||
trailingContent = ListItemContent.RadioButton(selected = edited == SecurityAndPrivacyRoomAccess.SpaceMember, enabled = false),
|
||||
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.Workspace())),
|
||||
enabled = false,
|
||||
)
|
||||
@@ -243,7 +243,6 @@ private fun RoomAccessSection(
|
||||
leadingContent = ListItemContent.Icon(IconSource.Vector(CompoundIcons.Lock())),
|
||||
onClick = { onSelectOption(SecurityAndPrivacyRoomAccess.InviteOnly) },
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,12 +21,12 @@ import io.element.android.features.securityandprivacy.impl.root.SecurityAndPriva
|
||||
import io.element.android.features.securityandprivacy.impl.root.SecurityAndPrivacyView
|
||||
import io.element.android.features.securityandprivacy.impl.root.aSecurityAndPrivacySettings
|
||||
import io.element.android.features.securityandprivacy.impl.root.aSecurityAndPrivacyState
|
||||
import io.element.android.libraries.architecture.AsyncAction
|
||||
import io.element.android.libraries.architecture.AsyncData
|
||||
import io.element.android.libraries.ui.strings.CommonStrings
|
||||
import io.element.android.tests.testutils.EnsureNeverCalled
|
||||
import io.element.android.tests.testutils.EventsRecorder
|
||||
import io.element.android.tests.testutils.clickOn
|
||||
import io.element.android.tests.testutils.ensureCalledOnce
|
||||
import io.element.android.tests.testutils.pressBack
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
@@ -39,15 +39,41 @@ class SecurityAndPrivacyViewTest {
|
||||
@get:Rule val rule = createAndroidComposeRule<ComponentActivity>()
|
||||
|
||||
@Test
|
||||
fun `click on back invokes expected callback`() {
|
||||
ensureCalledOnce { callback ->
|
||||
rule.setSecurityAndPrivacyView(
|
||||
onBackClick = callback,
|
||||
)
|
||||
rule.pressBack()
|
||||
}
|
||||
fun `click on back invokes emits the expected event`() {
|
||||
val recorder = EventsRecorder<SecurityAndPrivacyEvents>()
|
||||
val state = aSecurityAndPrivacyState(
|
||||
eventSink = recorder,
|
||||
)
|
||||
rule.setSecurityAndPrivacyView(state)
|
||||
rule.pressBack()
|
||||
recorder.assertSingle(SecurityAndPrivacyEvents.Exit)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `confirm cancellation emits the expected event`() {
|
||||
val recorder = EventsRecorder<SecurityAndPrivacyEvents>()
|
||||
val state = aSecurityAndPrivacyState(
|
||||
confirmExitAction = AsyncAction.ConfirmingCancellation,
|
||||
eventSink = recorder,
|
||||
)
|
||||
rule.setSecurityAndPrivacyView(state)
|
||||
rule.clickOn(CommonStrings.action_ok)
|
||||
recorder.assertSingle(SecurityAndPrivacyEvents.Exit)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `dismiss cancellation confirmation emits the expected event`() {
|
||||
val recorder = EventsRecorder<SecurityAndPrivacyEvents>()
|
||||
val state = aSecurityAndPrivacyState(
|
||||
confirmExitAction = AsyncAction.ConfirmingCancellation,
|
||||
eventSink = recorder,
|
||||
)
|
||||
rule.setSecurityAndPrivacyView(state)
|
||||
rule.clickOn(CommonStrings.action_cancel)
|
||||
recorder.assertSingle(SecurityAndPrivacyEvents.DismissExitConfirmation)
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun `click on room access item emits the expected event`() {
|
||||
val recorder = EventsRecorder<SecurityAndPrivacyEvents>()
|
||||
|
||||
Reference in New Issue
Block a user