Skip to content

Commit cb84239

Browse files
committed
test: paykit ui flag test ids
1 parent 6fd27d8 commit cb84239

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

app/src/main/java/to/bitkit/ui/components/settings/SettingsSwitchRow.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import androidx.compose.runtime.Composable
1515
import androidx.compose.ui.Alignment
1616
import androidx.compose.ui.Modifier
1717
import androidx.compose.ui.graphics.Color
18+
import androidx.compose.ui.platform.testTag
1819
import androidx.compose.ui.res.painterResource
1920
import androidx.compose.ui.text.style.TextOverflow
2021
import androidx.compose.ui.tooling.preview.Preview
@@ -38,6 +39,7 @@ fun SettingsSwitchRow(
3839
subtitle: String? = null,
3940
iconRes: Int? = null,
4041
iconTint: Color = Color.Unspecified,
42+
switchTestTag: String? = null,
4143
colors: SwitchColors = AppSwitchDefaults.colors
4244
) {
4345
SettingsSwitchRowCore(
@@ -47,6 +49,7 @@ fun SettingsSwitchRow(
4749
enabled = enabled,
4850
subtitle = subtitle,
4951
colors = colors,
52+
switchTestTag = switchTestTag,
5053
icon = if (iconRes != null) {
5154
{
5255
Icon(
@@ -73,6 +76,7 @@ fun SettingsSwitchRow(
7376
modifier: Modifier = Modifier,
7477
enabled: Boolean = true,
7578
subtitle: String? = null,
79+
switchTestTag: String? = null,
7680
colors: SwitchColors = AppSwitchDefaults.colors
7781
) {
7882
SettingsSwitchRowCore(
@@ -82,6 +86,7 @@ fun SettingsSwitchRow(
8286
enabled = enabled,
8387
subtitle = subtitle,
8488
colors = colors,
89+
switchTestTag = switchTestTag,
8590
icon = {
8691
icon()
8792
HorizontalSpacer(8.dp)
@@ -99,6 +104,7 @@ private fun SettingsSwitchRowCore(
99104
enabled: Boolean = true,
100105
subtitle: String? = null,
101106
icon: (@Composable () -> Unit)? = null,
107+
switchTestTag: String? = null,
102108
colors: SwitchColors = AppSwitchDefaults.colors
103109
) {
104110
Column(modifier = modifier) {
@@ -131,6 +137,7 @@ private fun SettingsSwitchRowCore(
131137
onCheckedChange = null, // handled by parent
132138
enabled = enabled,
133139
colors = colors,
140+
modifier = switchTestTag?.let { Modifier.testTag(it) } ?: Modifier
134141
)
135142
}
136143
HorizontalDivider(color = Colors.White10)

app/src/main/java/to/bitkit/ui/screens/settings/DevSettingsScreen.kt

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,16 @@ fun DevSettingsScreen(
7676
onClick = {
7777
if (isPaykitEnabled) {
7878
settings.setIsPaykitEnabled(false)
79-
app.toast(type = Toast.ToastType.SUCCESS, title = "Paykit UI disabled")
79+
app.toast(
80+
type = Toast.ToastType.SUCCESS,
81+
title = "Paykit UI disabled",
82+
testTag = "PaykitUiDisabledToast",
83+
)
8084
} else {
8185
showPaykitWarning = true
8286
}
8387
},
88+
switchTestTag = "PaykitUiToggle",
8489
)
8590
}
8691

@@ -228,7 +233,11 @@ fun DevSettingsScreen(
228233
onClick = {
229234
settings.setIsPaykitEnabled(true)
230235
showPaykitWarning = false
231-
app.toast(type = Toast.ToastType.SUCCESS, title = "Paykit UI enabled")
236+
app.toast(
237+
type = Toast.ToastType.SUCCESS,
238+
title = "Paykit UI enabled",
239+
testTag = "PaykitUiEnabledToast",
240+
)
232241
},
233242
) {
234243
Text("Enable")

0 commit comments

Comments
 (0)