summaryrefslogtreecommitdiffhomepage
path: root/android/app/src
diff options
context:
space:
mode:
authorKalle Lindström <karl.lindstrom@mullvad.net>2025-04-23 11:26:52 +0200
committerAlbin <albin@mullvad.net>2025-04-28 11:20:54 +0200
commit3b9add3fca368d32f9a3dce4112853873251e53a (patch)
tree4e03c9ce91f3d1da685e4fcdf40a41c4767bd764 /android/app/src
parent30f142dd2ab096eeb80354690b754a452ba471cd (diff)
downloadmullvadvpn-3b9add3fca368d32f9a3dce4112853873251e53a.tar.xz
mullvadvpn-3b9add3fca368d32f9a3dce4112853873251e53a.zip
Add mock api test for manage devices screen
Diffstat (limited to 'android/app/src')
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AccountScreen.kt3
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/test/ComposeTestTagConstants.kt3
-rw-r--r--android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ManageDevicesViewModel.kt4
3 files changed, 8 insertions, 2 deletions
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AccountScreen.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AccountScreen.kt
index c077f72823..94f72b1b72 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AccountScreen.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/screen/AccountScreen.kt
@@ -18,6 +18,7 @@ import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalUriHandler
+import androidx.compose.ui.platform.testTag
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextDecoration
import androidx.compose.ui.tooling.preview.Preview
@@ -51,6 +52,7 @@ import net.mullvad.mullvadvpn.compose.component.ScaffoldWithMediumTopBar
import net.mullvad.mullvadvpn.compose.extensions.createOpenAccountPageHook
import net.mullvad.mullvadvpn.compose.extensions.dropUnlessResumed
import net.mullvad.mullvadvpn.compose.preview.AccountUiStatePreviewParameterProvider
+import net.mullvad.mullvadvpn.compose.test.MANAGE_DEVICES_BUTTON_TEST_TAG
import net.mullvad.mullvadvpn.compose.transitions.AccountTransition
import net.mullvad.mullvadvpn.compose.util.CollectSideEffectWithLifecycle
import net.mullvad.mullvadvpn.compose.util.SecureScreenWhileInView
@@ -232,6 +234,7 @@ private fun DeviceNameRow(deviceName: String, onManageDevicesClick: () -> Unit)
InformationView(content = deviceName, whenMissing = MissingPolicy.SHOW_SPINNER)
Spacer(modifier = Modifier.weight(1f))
PrimaryTextButton(
+ modifier = Modifier.testTag(MANAGE_DEVICES_BUTTON_TEST_TAG),
onClick = onManageDevicesClick,
text = stringResource(R.string.manage_devices),
textDecoration = TextDecoration.Underline,
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/test/ComposeTestTagConstants.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/test/ComposeTestTagConstants.kt
index 4b6a339f61..8c00afd227 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/test/ComposeTestTagConstants.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/compose/test/ComposeTestTagConstants.kt
@@ -33,6 +33,9 @@ const val WIREGUARD_OBFUSCATION_UDP_OVER_TCP_CELL =
"wireguard_obfuscation_udp_over_tcp_cell_test_tag"
const val QUANTUM_RESISTANCE_OFF_CELL = "quantum_resistance_off_cell_test_tag"
+// Account screen
+const val MANAGE_DEVICES_BUTTON_TEST_TAG = "manage_devices_button_test_tag"
+
// SelectLocationScreen, ConnectScreen, CustomListLocationsScreen
const val SELECT_LOCATION_SCREEN_TEST_TAG = "select_location_screen_test_tag"
const val CIRCULAR_PROGRESS_INDICATOR = "circular_progress_indicator"
diff --git a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ManageDevicesViewModel.kt b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ManageDevicesViewModel.kt
index 9e8dfde0a8..53533264f1 100644
--- a/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ManageDevicesViewModel.kt
+++ b/android/app/src/main/kotlin/net/mullvad/mullvadvpn/viewmodel/ManageDevicesViewModel.kt
@@ -62,7 +62,7 @@ class ManageDevicesViewModel(
// Put the current device first in the list, but otherwise keep the sort order.
val devices = toMutableList()
devices
- .indexOfFirst { it.device == currentDevice }
+ .indexOfFirst { it.device.id == currentDevice.id }
.let { index ->
if (index > 0) {
devices.add(0, devices.removeAt(index))
@@ -73,7 +73,7 @@ class ManageDevicesViewModel(
ManageDevicesItemUiState(
device = it.device,
isLoading = it.isLoading,
- isCurrentDevice = it.device == currentDevice,
+ isCurrentDevice = it.device.id == currentDevice.id,
)
}
}