mirror of
https://github.com/bitwarden/android.git
synced 2025-12-10 09:56:45 -06:00
PM-28545: Remove the compatibility mode toggle from the Autofill screen (#6188)
This commit is contained in:
parent
ab305b2631
commit
663eb3641f
@ -93,7 +93,6 @@ class AutofillParserImpl(
|
||||
val urlBarWebsite = traversalDataList
|
||||
.flatMap { it.urlBarWebsites }
|
||||
.firstOrNull()
|
||||
?.takeIf { settingsRepository.isAutofillWebDomainCompatMode }
|
||||
|
||||
// Take only the autofill views from the node that currently has focus.
|
||||
// Then remove all the fields that cannot be filled with data.
|
||||
|
||||
@ -110,11 +110,6 @@ interface SettingsDiskSource {
|
||||
*/
|
||||
var browserAutofillDialogReshowTime: Instant?
|
||||
|
||||
/**
|
||||
* The current status of whether the web domain compatibility mode is enabled.
|
||||
*/
|
||||
var isAutofillWebDomainCompatMode: Boolean?
|
||||
|
||||
/**
|
||||
* Clears all the settings data for the given user.
|
||||
*/
|
||||
|
||||
@ -50,7 +50,6 @@ private const val RESUME_SCREEN = "resumeScreen"
|
||||
private const val FLIGHT_RECORDER_KEY = "flightRecorderData"
|
||||
private const val IS_DYNAMIC_COLORS_ENABLED = "isDynamicColorsEnabled"
|
||||
private const val BROWSER_AUTOFILL_DIALOG_RESHOW_TIME = "browserAutofillDialogReshowTime"
|
||||
private const val AUTOFILL_WEB_DOMAIN_COMPATIBILITY = "autofillWebDomainCompatibility"
|
||||
|
||||
/**
|
||||
* Primary implementation of [SettingsDiskSource].
|
||||
@ -235,12 +234,6 @@ class SettingsDiskSourceImpl(
|
||||
putLong(key = BROWSER_AUTOFILL_DIALOG_RESHOW_TIME, value = value?.toEpochMilli())
|
||||
}
|
||||
|
||||
override var isAutofillWebDomainCompatMode: Boolean?
|
||||
get() = getBoolean(key = AUTOFILL_WEB_DOMAIN_COMPATIBILITY)
|
||||
set(value) {
|
||||
putBoolean(key = AUTOFILL_WEB_DOMAIN_COMPATIBILITY, value = value)
|
||||
}
|
||||
|
||||
override fun clearData(userId: String) {
|
||||
storeVaultTimeoutInMinutes(userId = userId, vaultTimeoutInMinutes = null)
|
||||
storeVaultTimeoutAction(userId = userId, vaultTimeoutAction = null)
|
||||
|
||||
@ -155,11 +155,6 @@ interface SettingsRepository : FlightRecorderManager {
|
||||
*/
|
||||
var isAutofillSavePromptDisabled: Boolean
|
||||
|
||||
/**
|
||||
* Whether or not the autofill web domain parsing is enabled.
|
||||
*/
|
||||
var isAutofillWebDomainCompatMode: Boolean
|
||||
|
||||
/**
|
||||
* A list of blocked autofill URI's for the current user.
|
||||
*/
|
||||
|
||||
@ -338,12 +338,6 @@ class SettingsRepositoryImpl(
|
||||
)
|
||||
}
|
||||
|
||||
override var isAutofillWebDomainCompatMode: Boolean
|
||||
get() = settingsDiskSource.isAutofillWebDomainCompatMode ?: false
|
||||
set(value) {
|
||||
settingsDiskSource.isAutofillWebDomainCompatMode = value
|
||||
}
|
||||
|
||||
override var blockedAutofillUris: List<String>
|
||||
get() = activeUserId
|
||||
?.let { settingsDiskSource.getBlockedAutofillUris(userId = it) }
|
||||
|
||||
@ -32,9 +32,6 @@ import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.platform.LocalResources
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.CustomAccessibilityAction
|
||||
import androidx.compose.ui.semantics.customActions
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.net.toUri
|
||||
import androidx.hilt.lifecycle.viewmodel.compose.hiltViewModel
|
||||
@ -137,13 +134,6 @@ fun AutoFillScreen(
|
||||
intentManager.launchUri("https://bitwarden.com/help/uri-match-detection/".toUri())
|
||||
}
|
||||
|
||||
AutoFillEvent.NavigateToCompatibilityModeLearnMore -> {
|
||||
intentManager.launchUri(
|
||||
uri = "https://bitwarden.com/help/auto-fill-android/#compatibility-mode"
|
||||
.toUri(),
|
||||
)
|
||||
}
|
||||
|
||||
AutoFillEvent.NavigateToAutofillHelp -> {
|
||||
intentManager.launchUri(
|
||||
uri = "https://bitwarden.com/help/auto-fill-android-troubleshooting/".toUri(),
|
||||
@ -255,20 +245,6 @@ private fun AutoFillScreenContent(
|
||||
}
|
||||
}
|
||||
|
||||
AnimatedVisibility(visible = state.isAutoFillServicesEnabled) {
|
||||
Column {
|
||||
WebDomainCompatibilityModeRow(
|
||||
isChecked = state.isWebDomainCompatModeEnabled,
|
||||
onToggle = autoFillHandlers.onWebDomainCompatModeToggled,
|
||||
onLearnMoreClick = autoFillHandlers.onWebDomainModeCompatLearnMoreClick,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.standardHorizontalMargin(),
|
||||
)
|
||||
Spacer(modifier = Modifier.height(height = 8.dp))
|
||||
}
|
||||
}
|
||||
|
||||
if (state.showPasskeyManagementRow) {
|
||||
BitwardenExternalLinkRow(
|
||||
text = stringResource(id = BitwardenString.passkey_management),
|
||||
@ -370,76 +346,6 @@ private fun AutoFillScreenContent(
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("LongMethod")
|
||||
@Composable
|
||||
private fun WebDomainCompatibilityModeRow(
|
||||
isChecked: Boolean,
|
||||
onToggle: (isEnabled: Boolean) -> Unit,
|
||||
onLearnMoreClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
var showConfirmationDialog by rememberSaveable { mutableStateOf(false) }
|
||||
if (showConfirmationDialog) {
|
||||
BitwardenTwoButtonDialog(
|
||||
title = stringResource(id = BitwardenString.warning),
|
||||
message = stringResource(id = BitwardenString.compatibility_mode_warning),
|
||||
confirmButtonText = stringResource(id = BitwardenString.accept),
|
||||
dismissButtonText = stringResource(id = BitwardenString.cancel),
|
||||
onConfirmClick = {
|
||||
onToggle(true)
|
||||
showConfirmationDialog = false
|
||||
},
|
||||
onDismissClick = { showConfirmationDialog = false },
|
||||
onDismissRequest = { showConfirmationDialog = false },
|
||||
)
|
||||
}
|
||||
|
||||
BitwardenSwitch(
|
||||
label = stringResource(id = BitwardenString.use_compatibility_mode_for_browser_autofill),
|
||||
isChecked = isChecked,
|
||||
onCheckedChange = {
|
||||
if (isChecked) {
|
||||
onToggle(false)
|
||||
} else {
|
||||
showConfirmationDialog = true
|
||||
}
|
||||
},
|
||||
cardStyle = CardStyle.Full,
|
||||
modifier = modifier,
|
||||
supportingContent = {
|
||||
val learnMore = stringResource(id = BitwardenString.learn_more)
|
||||
Text(
|
||||
text = annotatedStringResource(
|
||||
id = BitwardenString
|
||||
.use_a_less_secure_autofill_method_compatible_with_more_browsers,
|
||||
style = spanStyleOf(
|
||||
textStyle = BitwardenTheme.typography.bodyMedium,
|
||||
color = BitwardenTheme.colorScheme.text.secondary,
|
||||
),
|
||||
onAnnotationClick = {
|
||||
when (it) {
|
||||
"learnMore" -> onLearnMoreClick()
|
||||
}
|
||||
},
|
||||
),
|
||||
style = BitwardenTheme.typography.bodyMedium,
|
||||
color = BitwardenTheme.colorScheme.text.secondary,
|
||||
modifier = Modifier.semantics {
|
||||
customActions = listOf(
|
||||
CustomAccessibilityAction(
|
||||
label = learnMore,
|
||||
action = {
|
||||
onLearnMoreClick()
|
||||
true
|
||||
},
|
||||
),
|
||||
)
|
||||
},
|
||||
)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun AutofillCallToActionCard(
|
||||
state: AutoFillState,
|
||||
|
||||
@ -69,7 +69,6 @@ class AutoFillViewModel @Inject constructor(
|
||||
browserAutofillSettingsOptions = browserThirdPartyAutofillEnabledManager
|
||||
.browserThirdPartyAutofillStatus
|
||||
.toBrowserAutoFillSettingsOptions(),
|
||||
isWebDomainCompatModeEnabled = settingsRepository.isAutofillWebDomainCompatMode,
|
||||
)
|
||||
},
|
||||
) {
|
||||
@ -135,10 +134,6 @@ class AutoFillViewModel @Inject constructor(
|
||||
AutoFillAction.PrivilegedAppsClick -> handlePrivilegedAppsClick()
|
||||
AutoFillAction.LearnMoreClick -> handleLearnMoreClick()
|
||||
AutoFillAction.HelpCardClick -> handleHelpCardClick()
|
||||
is AutoFillAction.WebDomainModeCompatToggle -> handleWebDomainModeCompatToggle(action)
|
||||
AutoFillAction.WebDomainModeCompatLearnMoreClick -> {
|
||||
handleNavigateToCompatibilityModeLearnMore()
|
||||
}
|
||||
}
|
||||
|
||||
private fun handlePrivilegedAppsClick() {
|
||||
@ -153,15 +148,6 @@ class AutoFillViewModel @Inject constructor(
|
||||
sendEvent(AutoFillEvent.NavigateToAutofillHelp)
|
||||
}
|
||||
|
||||
private fun handleNavigateToCompatibilityModeLearnMore() {
|
||||
sendEvent(AutoFillEvent.NavigateToCompatibilityModeLearnMore)
|
||||
}
|
||||
|
||||
private fun handleWebDomainModeCompatToggle(action: AutoFillAction.WebDomainModeCompatToggle) {
|
||||
settingsRepository.isAutofillWebDomainCompatMode = action.isEnabled
|
||||
mutableStateFlow.update { it.copy(isWebDomainCompatModeEnabled = action.isEnabled) }
|
||||
}
|
||||
|
||||
private fun handleInternalAction(action: AutoFillAction.Internal) {
|
||||
when (action) {
|
||||
is AutoFillAction.Internal.AccessibilityEnabledUpdateReceive -> {
|
||||
@ -319,7 +305,6 @@ data class AutoFillState(
|
||||
val showBrowserAutofillActionCard: Boolean,
|
||||
val activeUserId: String,
|
||||
val browserAutofillSettingsOptions: ImmutableList<BrowserAutofillSettingsOption>,
|
||||
val isWebDomainCompatModeEnabled: Boolean,
|
||||
) : Parcelable {
|
||||
/**
|
||||
* Indicates which call-to-action that should be displayed.
|
||||
@ -433,11 +418,6 @@ sealed class AutoFillEvent {
|
||||
*/
|
||||
data object NavigateToLearnMore : AutoFillEvent()
|
||||
|
||||
/**
|
||||
* Navigate to the web domain learn more site.
|
||||
*/
|
||||
data object NavigateToCompatibilityModeLearnMore : AutoFillEvent()
|
||||
|
||||
/**
|
||||
* Navigate to the autofill help page.
|
||||
*/
|
||||
@ -548,16 +528,6 @@ sealed class AutoFillAction {
|
||||
*/
|
||||
data object HelpCardClick : AutoFillAction()
|
||||
|
||||
/**
|
||||
* User has clicked to learn more about compatibility mode.
|
||||
*/
|
||||
data object WebDomainModeCompatLearnMoreClick : AutoFillAction()
|
||||
|
||||
/**
|
||||
* User has changed their compatibility setting.
|
||||
*/
|
||||
data class WebDomainModeCompatToggle(val isEnabled: Boolean) : AutoFillAction()
|
||||
|
||||
/**
|
||||
* Internal actions.
|
||||
*/
|
||||
|
||||
@ -29,8 +29,6 @@ class AutoFillHandlers(
|
||||
val onBlockAutoFillClick: () -> Unit,
|
||||
val onLearnMoreClick: () -> Unit,
|
||||
val onHelpCardClick: () -> Unit,
|
||||
val onWebDomainCompatModeToggled: (isEnabled: Boolean) -> Unit,
|
||||
val onWebDomainModeCompatLearnMoreClick: () -> Unit,
|
||||
) {
|
||||
@Suppress("UndocumentedPublicClass")
|
||||
companion object {
|
||||
@ -86,12 +84,6 @@ class AutoFillHandlers(
|
||||
onBlockAutoFillClick = { viewModel.trySendAction(AutoFillAction.BlockAutoFillClick) },
|
||||
onLearnMoreClick = { viewModel.trySendAction(AutoFillAction.LearnMoreClick) },
|
||||
onHelpCardClick = { viewModel.trySendAction(AutoFillAction.HelpCardClick) },
|
||||
onWebDomainCompatModeToggled = {
|
||||
viewModel.trySendAction(AutoFillAction.WebDomainModeCompatToggle(it))
|
||||
},
|
||||
onWebDomainModeCompatLearnMoreClick = {
|
||||
viewModel.trySendAction(AutoFillAction.WebDomainModeCompatLearnMoreClick)
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,7 +69,6 @@ class AutofillParserTests {
|
||||
private val settingsRepository: SettingsRepository = mockk {
|
||||
every { isInlineAutofillEnabled } answers { mockIsInlineAutofillEnabled }
|
||||
every { blockedAutofillUris } returns emptyList()
|
||||
every { isAutofillWebDomainCompatMode } returns false
|
||||
}
|
||||
|
||||
private var mockIsInlineAutofillEnabled = true
|
||||
@ -177,86 +176,13 @@ class AutofillParserTests {
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `parse should return Fillable without website in AutofillView from url bar but compatibility mode is off`() {
|
||||
// Setup
|
||||
val packageName = "com.microsoft.emmx"
|
||||
every {
|
||||
any<List<ViewNodeTraversalData>>().buildPackageNameOrNull(assistStructure)
|
||||
} returns packageName
|
||||
every { settingsRepository.isAutofillWebDomainCompatMode } returns false
|
||||
every { assistStructure.windowNodeCount } returns 2
|
||||
// Override the idPackage to be Edge's package name.
|
||||
every { loginViewNode.idPackage } returns packageName
|
||||
every { assistStructure.getWindowNodeAt(0) } returns loginWindowNode
|
||||
val urlBarNode: AssistStructure.ViewNode = mockk {
|
||||
every { autofillHints } returns emptyArray()
|
||||
every { autofillId } returns null
|
||||
every { childCount } returns 0
|
||||
every { idEntry } returns "url_bar"
|
||||
every { idPackage } returns packageName
|
||||
every { webDomain } returns "m.facebook.com"
|
||||
every { webScheme } returns null
|
||||
}
|
||||
val urlBarWindowNode: AssistStructure.WindowNode = mockk {
|
||||
every { this@mockk.rootViewNode } returns urlBarNode
|
||||
}
|
||||
every { assistStructure.getWindowNodeAt(1) } returns urlBarWindowNode
|
||||
val loginAutofillView: AutofillView.Login = AutofillView.Login.Username(
|
||||
data = AutofillView.Data(
|
||||
autofillId = loginAutofillId,
|
||||
autofillOptions = emptyList(),
|
||||
autofillType = AUTOFILL_TYPE,
|
||||
isFocused = true,
|
||||
textValue = null,
|
||||
hasPasswordTerms = false,
|
||||
website = null,
|
||||
),
|
||||
)
|
||||
every { loginViewNode.toAutofillView(parentWebsite = any()) } returns loginAutofillView
|
||||
val autofillPartition = AutofillPartition.Login(
|
||||
views = listOf(loginAutofillView),
|
||||
)
|
||||
val expected = AutofillRequest.Fillable(
|
||||
ignoreAutofillIds = emptyList(),
|
||||
inlinePresentationSpecs = inlinePresentationSpecs,
|
||||
maxInlineSuggestionsCount = MAX_INLINE_SUGGESTION_COUNT,
|
||||
packageName = packageName,
|
||||
partition = autofillPartition,
|
||||
uri = "androidapp://$packageName",
|
||||
)
|
||||
|
||||
// Test
|
||||
val actual = parser.parse(
|
||||
autofillAppInfo = autofillAppInfo,
|
||||
fillRequest = fillRequest,
|
||||
)
|
||||
|
||||
// Verify
|
||||
assertEquals(expected, actual)
|
||||
verify(exactly = 1) {
|
||||
fillRequest.getInlinePresentationSpecs(
|
||||
autofillAppInfo = autofillAppInfo,
|
||||
isInlineAutofillEnabled = true,
|
||||
)
|
||||
fillRequest.getMaxInlineSuggestionsCount(
|
||||
autofillAppInfo = autofillAppInfo,
|
||||
isInlineAutofillEnabled = true,
|
||||
)
|
||||
any<List<ViewNodeTraversalData>>().buildPackageNameOrNull(assistStructure)
|
||||
any<AutofillView>().buildUriOrNull(packageName)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `parse should return Fillable with website in AutofillView from url bar but compatibility mode is on`() {
|
||||
fun `parse should return Fillable with website in AutofillView from url bar for compatible browser`() {
|
||||
// Setup
|
||||
val website = "https://m.facebook.com"
|
||||
val packageName = "com.microsoft.emmx"
|
||||
every {
|
||||
any<List<ViewNodeTraversalData>>().buildPackageNameOrNull(assistStructure)
|
||||
} returns packageName
|
||||
every { settingsRepository.isAutofillWebDomainCompatMode } returns true
|
||||
every { assistStructure.windowNodeCount } returns 2
|
||||
// Override the idPackage to be Edge's package name.
|
||||
every { loginViewNode.idPackage } returns packageName
|
||||
|
||||
@ -1257,23 +1257,6 @@ class SettingsDiskSourceTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `isAutofillWebDomainCompatMode should update SharedPreferences`() {
|
||||
val autofillWebDomainCompatKey = "bwPreferencesStorage:autofillWebDomainCompatibility"
|
||||
settingsDiskSource.isAutofillWebDomainCompatMode = true
|
||||
assertTrue(fakeSharedPreferences.getBoolean(autofillWebDomainCompatKey, false))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `isAutofillWebDomainCompatMode should pull value from shared preferences`() {
|
||||
val autofillWebDomainCompatKey = "bwPreferencesStorage:autofillWebDomainCompatibility"
|
||||
fakeSharedPreferences.edit {
|
||||
putBoolean(autofillWebDomainCompatKey, true)
|
||||
}
|
||||
|
||||
assertTrue(settingsDiskSource.isAutofillWebDomainCompatMode!!)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `storeShowUnlockSettingBadge should update SharedPreferences`() {
|
||||
val mockUserId = "mockUserId"
|
||||
|
||||
@ -89,7 +89,6 @@ class FakeSettingsDiskSource : SettingsDiskSource {
|
||||
private var storedFlightRecorderData: FlightRecorderDataSet? = null
|
||||
private var storedIsDynamicColorsEnabled: Boolean? = null
|
||||
private var storedBrowserAutofillDialogReshowTime: Instant? = null
|
||||
private var storedIsAutofillWebDomainCompatMode: Boolean? = null
|
||||
|
||||
private val mutableShowAutoFillSettingBadgeFlowMap =
|
||||
mutableMapOf<String, MutableSharedFlow<Boolean?>>()
|
||||
@ -218,12 +217,6 @@ class FakeSettingsDiskSource : SettingsDiskSource {
|
||||
storedBrowserAutofillDialogReshowTime = value
|
||||
}
|
||||
|
||||
override var isAutofillWebDomainCompatMode: Boolean?
|
||||
get() = storedIsAutofillWebDomainCompatMode
|
||||
set(value) {
|
||||
storedIsAutofillWebDomainCompatMode = value
|
||||
}
|
||||
|
||||
override fun getAccountBiometricIntegrityValidity(
|
||||
userId: String,
|
||||
systemBioIntegrityState: String,
|
||||
|
||||
@ -713,19 +713,6 @@ class SettingsRepositoryTest {
|
||||
assertFalse(fakeSettingsDiskSource.getAutofillSavePromptDisabled(userId = USER_ID)!!)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `isAutofillWebDomainCompatMode should pull from and update SettingsDiskSource`() {
|
||||
assertFalse(settingsRepository.isAutofillWebDomainCompatMode)
|
||||
|
||||
// Updates to the disk source change the repository value.
|
||||
fakeSettingsDiskSource.isAutofillWebDomainCompatMode = true
|
||||
assertTrue(settingsRepository.isAutofillWebDomainCompatMode)
|
||||
|
||||
// Updates to the repository change the disk source value
|
||||
settingsRepository.isAutofillWebDomainCompatMode = false
|
||||
assertFalse(fakeSettingsDiskSource.isAutofillWebDomainCompatMode!!)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `blockedAutofillUris should pull from and update SettingsDiskSource`() {
|
||||
fakeAuthDiskSource.userState = MOCK_USER_STATE
|
||||
|
||||
@ -18,7 +18,6 @@ import com.bitwarden.ui.platform.manager.IntentManager
|
||||
import com.bitwarden.ui.platform.manager.util.startSystemAccessibilitySettingsActivity
|
||||
import com.bitwarden.ui.platform.manager.util.startSystemAutofillSettingsActivity
|
||||
import com.bitwarden.ui.util.assertNoDialogExists
|
||||
import com.bitwarden.ui.util.performCustomAccessibilityAction
|
||||
import com.x8bit.bitwarden.data.autofill.model.browser.BrowserPackage
|
||||
import com.x8bit.bitwarden.data.platform.repository.model.UriMatchType
|
||||
import com.x8bit.bitwarden.ui.platform.base.BitwardenComposeTest
|
||||
@ -867,86 +866,6 @@ class AutoFillScreenTest : BitwardenComposeTest() {
|
||||
intentManager.launchUri("https://bitwarden.com/help/uri-match-detection/".toUri())
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `on NavigateToCompatibilityModeLearnMore should launch the browser to the autofill help page`() {
|
||||
mutableEventFlow.tryEmit(AutoFillEvent.NavigateToCompatibilityModeLearnMore)
|
||||
verify(exactly = 1) {
|
||||
intentManager.launchUri(
|
||||
uri = "https://bitwarden.com/help/auto-fill-android/#compatibility-mode".toUri(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on web domain compatibility mode click should display confirmation dialog`() {
|
||||
mutableStateFlow.update { it.copy(isAutoFillServicesEnabled = true) }
|
||||
composeTestRule.assertNoDialogExists()
|
||||
composeTestRule
|
||||
.onNodeWithText(text = "Use compatibility mode for browser autofill")
|
||||
.performScrollTo()
|
||||
.performClick()
|
||||
|
||||
composeTestRule
|
||||
.onNodeWithText(text = "Warning")
|
||||
.assert(hasAnyAncestor(isDialog()))
|
||||
.assertIsDisplayed()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on web domain compatibility mode dialog Cancel click should close dialog`() {
|
||||
mutableStateFlow.update { it.copy(isAutoFillServicesEnabled = true) }
|
||||
composeTestRule.assertNoDialogExists()
|
||||
composeTestRule
|
||||
.onNodeWithText(text = "Use compatibility mode for browser autofill")
|
||||
.performScrollTo()
|
||||
.performClick()
|
||||
|
||||
composeTestRule
|
||||
.onNodeWithText(text = "Cancel")
|
||||
.assert(hasAnyAncestor(isDialog()))
|
||||
.performClick()
|
||||
|
||||
composeTestRule.assertNoDialogExists()
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `on web domain compatibility mode dialog Accept click should close dialog and send event`() {
|
||||
mutableStateFlow.update { it.copy(isAutoFillServicesEnabled = true) }
|
||||
composeTestRule.assertNoDialogExists()
|
||||
composeTestRule
|
||||
.onNodeWithText(text = "Use compatibility mode for browser autofill")
|
||||
.performScrollTo()
|
||||
.performClick()
|
||||
|
||||
composeTestRule
|
||||
.onNodeWithText(text = "Accept")
|
||||
.assert(hasAnyAncestor(isDialog()))
|
||||
.performClick()
|
||||
|
||||
verify(exactly = 1) {
|
||||
viewModel.trySendAction(AutoFillAction.WebDomainModeCompatToggle(true))
|
||||
}
|
||||
composeTestRule.assertNoDialogExists()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `on learn more about compatibility mode should send WebDomainModeLearnMoreClick`() {
|
||||
mutableStateFlow.update { it.copy(isAutoFillServicesEnabled = true) }
|
||||
composeTestRule
|
||||
.onNodeWithText(
|
||||
text = "Uses a less secure autofill method compatible with more " +
|
||||
"browsers.\nLearn more about compatibility mode",
|
||||
)
|
||||
.performScrollTo()
|
||||
.performCustomAccessibilityAction(label = "Learn more")
|
||||
|
||||
verify(exactly = 1) {
|
||||
viewModel.trySendAction(AutoFillAction.WebDomainModeCompatLearnMoreClick)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val DEFAULT_STATE: AutoFillState = AutoFillState(
|
||||
@ -962,5 +881,4 @@ private val DEFAULT_STATE: AutoFillState = AutoFillState(
|
||||
showBrowserAutofillActionCard = false,
|
||||
activeUserId = "activeUserId",
|
||||
browserAutofillSettingsOptions = persistentListOf(),
|
||||
isWebDomainCompatModeEnabled = false,
|
||||
)
|
||||
|
||||
@ -67,8 +67,6 @@ class AutoFillViewModelTest : BaseViewModelTest() {
|
||||
every { isAccessibilityEnabledStateFlow } returns mutableIsAccessibilityEnabledStateFlow
|
||||
every { isAutofillEnabledStateFlow } returns mutableIsAutofillEnabledStateFlow
|
||||
every { disableAutofill() } just runs
|
||||
every { isAutofillWebDomainCompatMode = any() } just runs
|
||||
every { isAutofillWebDomainCompatMode } returns false
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
@ -514,43 +512,6 @@ class AutoFillViewModelTest : BaseViewModelTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("MaxLineLength")
|
||||
@Test
|
||||
fun `when WebDomainModeLearnMoreClick action is handled NavigateToCompatibilityModeLearnMore event is sent`() =
|
||||
runTest {
|
||||
val viewModel = createViewModel()
|
||||
viewModel.eventFlow.test {
|
||||
viewModel.trySendAction(AutoFillAction.WebDomainModeCompatLearnMoreClick)
|
||||
assertEquals(
|
||||
AutoFillEvent.NavigateToCompatibilityModeLearnMore,
|
||||
awaitItem(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `when WebDomainModeToggle action is handled settings repo and state is updated`() {
|
||||
val viewModel = createViewModel()
|
||||
|
||||
viewModel.trySendAction(AutoFillAction.WebDomainModeCompatToggle(isEnabled = true))
|
||||
assertEquals(
|
||||
DEFAULT_STATE.copy(isWebDomainCompatModeEnabled = true),
|
||||
viewModel.stateFlow.value,
|
||||
)
|
||||
verify(exactly = 1) {
|
||||
settingsRepository.isAutofillWebDomainCompatMode = true
|
||||
}
|
||||
|
||||
viewModel.trySendAction(AutoFillAction.WebDomainModeCompatToggle(isEnabled = false))
|
||||
assertEquals(
|
||||
DEFAULT_STATE.copy(isWebDomainCompatModeEnabled = false),
|
||||
viewModel.stateFlow.value,
|
||||
)
|
||||
verify(exactly = 1) {
|
||||
settingsRepository.isAutofillWebDomainCompatMode = false
|
||||
}
|
||||
}
|
||||
|
||||
private fun createViewModel(
|
||||
state: AutoFillState? = DEFAULT_STATE,
|
||||
): AutoFillViewModel = AutoFillViewModel(
|
||||
@ -575,7 +536,6 @@ private val DEFAULT_STATE: AutoFillState = AutoFillState(
|
||||
showBrowserAutofillActionCard = false,
|
||||
activeUserId = "activeUserId",
|
||||
browserAutofillSettingsOptions = persistentListOf(),
|
||||
isWebDomainCompatModeEnabled = false,
|
||||
)
|
||||
|
||||
private val DEFAULT_BROWSER_AUTOFILL_DATA = BrowserThirdPartyAutoFillData(
|
||||
|
||||
@ -1156,7 +1156,4 @@ Do you want to switch to this account?</string>
|
||||
<string name="lock_app">Lock app</string>
|
||||
<string name="use_your_devices_lock_method_to_unlock_the_app">Use your device’s lock method to unlock the app</string>
|
||||
<string name="loading_vault_data">Loading vault data…</string>
|
||||
<string name="compatibility_mode_warning">Compatibility mode should only be enabled if autofill doesn’t work in your browser. This setting reduces security and could allow malicious sites to capture your passwords. Only enable it if you accept this risk.</string>
|
||||
<string name="use_compatibility_mode_for_browser_autofill">Use compatibility mode for browser autofill</string>
|
||||
<string name="use_a_less_secure_autofill_method_compatible_with_more_browsers">Uses a less secure autofill method compatible with more browsers.\n<annotation link="learnMore">Learn more about compatibility mode</annotation></string>
|
||||
</resources>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user