Skip to content

Commit 3eb5bcd

Browse files
committed
feat: e2e test tags wip
1 parent d900a2c commit 3eb5bcd

File tree

8 files changed

+93
-83
lines changed

8 files changed

+93
-83
lines changed

app/src/main/java/to/bitkit/ui/components/AmountInput.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import to.bitkit.ui.utils.withAccent
3434

3535
@Composable
3636
fun AmountInput(
37+
modifier: Modifier = Modifier,
3738
defaultValue: Long = 0,
3839
primaryDisplay: PrimaryDisplay,
3940
showConversion: Boolean = false,
@@ -191,7 +192,9 @@ fun AmountInput(
191192

192193
// Visible balance display
193194
currency.convert(sats)?.let { converted ->
194-
Column(modifier = Modifier.clickableAlpha { currency.togglePrimaryDisplay() }) {
195+
Column(
196+
modifier = modifier.clickableAlpha { currency.togglePrimaryDisplay() }
197+
) {
195198
if (showConversion) {
196199
val captionText = if (primaryDisplay == PrimaryDisplay.BITCOIN) {
197200
"${converted.symbol} ${converted.formatted}"

app/src/main/java/to/bitkit/ui/components/LightningChannel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ fun LightningChannel(
2626
capacity: Long,
2727
localBalance: Long,
2828
remoteBalance: Long,
29+
modifier: Modifier = Modifier,
2930
status: ChannelStatusUi = ChannelStatusUi.PENDING,
3031
showLabels: Boolean = false,
31-
modifier: Modifier = Modifier,
3232
) {
3333
val spendingColor = if (status == ChannelStatusUi.CLOSED) Colors.Gray5 else Colors.Purple50
3434
val spendingAvailableColor = if (status == ChannelStatusUi.CLOSED) Colors.Gray3 else Colors.Purple

app/src/main/java/to/bitkit/ui/screens/transfer/SpendingAdvancedScreen.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import androidx.compose.runtime.saveable.rememberSaveable
2424
import androidx.compose.runtime.setValue
2525
import androidx.compose.ui.Alignment
2626
import androidx.compose.ui.Modifier
27+
import androidx.compose.ui.platform.testTag
2728
import androidx.compose.ui.res.stringResource
2829
import androidx.compose.ui.unit.dp
2930
import androidx.lifecycle.compose.collectAsStateWithLifecycle
@@ -70,6 +71,7 @@ fun SpendingAdvancedScreen(
7071
.padding(horizontal = 16.dp)
7172
.fillMaxSize()
7273
.imePadding()
74+
.testTag("SpendingAdvanced")
7375
) {
7476
var receivingSatsAmount by rememberSaveable { mutableLongStateOf(0) }
7577
var overrideSats: Long? by remember { mutableStateOf(null) }
@@ -117,6 +119,7 @@ fun SpendingAdvancedScreen(
117119
receivingSatsAmount = sats
118120
overrideSats = null
119121
},
122+
modifier = Modifier.testTag("SpendingAdvancedNumberField")
120123
)
121124

122125
Spacer(modifier = Modifier.height(10.dp))
@@ -153,6 +156,7 @@ fun SpendingAdvancedScreen(
153156
onClick = {
154157
overrideSats = transferValues.minLspBalance.toLong()
155158
},
159+
modifier = Modifier.testTag("SpendingAdvancedMin")
156160
)
157161
// Default Button
158162
NumberPadActionButton(
@@ -161,6 +165,7 @@ fun SpendingAdvancedScreen(
161165
onClick = {
162166
overrideSats = transferValues.defaultLspBalance.toLong()
163167
},
168+
modifier = Modifier.testTag("SpendingAdvancedDefault")
164169
)
165170
// Max Button
166171
NumberPadActionButton(
@@ -169,6 +174,7 @@ fun SpendingAdvancedScreen(
169174
onClick = {
170175
overrideSats = transferValues.maxLspBalance.toLong()
171176
},
177+
modifier = Modifier.testTag("SpendingAdvancedMax")
172178
)
173179
}
174180
HorizontalDivider()
@@ -195,6 +201,7 @@ fun SpendingAdvancedScreen(
195201
},
196202
enabled = !isLoading && isValid,
197203
isLoading = isLoading,
204+
modifier = Modifier.testTag("SpendingAdvancedContinue")
198205
)
199206

200207
Spacer(modifier = Modifier.height(16.dp))

app/src/main/java/to/bitkit/ui/screens/transfer/SpendingAmountScreen.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ private fun Content(
102102
.padding(horizontal = 16.dp)
103103
.fillMaxSize()
104104
.imePadding()
105+
.testTag("SpendingAmount")
105106
) {
106107
VerticalSpacer(32.dp)
107108
Display(
@@ -139,12 +140,14 @@ private fun Content(
139140
text = stringResource(R.string.lightning__spending_amount__quarter),
140141
color = Colors.Purple,
141142
onClick = onClickQuarter,
143+
modifier = Modifier.testTag("SpendingAmountQuarter")
142144
)
143145
// Max Button
144146
NumberPadActionButton(
145147
text = stringResource(R.string.common__max),
146148
color = Colors.Purple,
147149
onClick = onClickMaxAmount,
150+
modifier = Modifier.testTag("SpendingAmountMax")
148151
)
149152
}
150153
HorizontalDivider()

app/src/main/java/to/bitkit/ui/screens/transfer/SpendingConfirmScreen.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ private fun Content(
172172
remoteBalance = lspBalance.toLong(),
173173
status = ChannelStatusUi.OPEN,
174174
showLabels = true,
175+
modifier = Modifier.testTag("SpendingConfirmChannel")
175176
)
176177
}
177178

@@ -182,6 +183,7 @@ private fun Content(
182183
size = ButtonSize.Small,
183184
fullWidth = false,
184185
onClick = onLearnMoreClick,
186+
modifier = Modifier.testTag("SpendingConfirmMore")
185187
)
186188
PrimaryButton(
187189
text = stringResource(
@@ -196,6 +198,9 @@ private fun Content(
196198
onAdvancedClick()
197199
}
198200
},
201+
modifier = Modifier.testTag(
202+
if (isAdvanced) "SpendingConfirmDefault" else "SpendingConfirmAdvanced"
203+
)
199204
)
200205
}
201206
VerticalSpacer(16.dp)
@@ -215,7 +220,6 @@ private fun Content(
215220
onConfirm()
216221
}
217222
},
218-
modifier = Modifier.testTag("SpendingConfirmAdvanced")
219223
)
220224
VerticalSpacer(16.dp)
221225
}

app/src/main/java/to/bitkit/ui/sheets/BoostTransactionSheet.kt

Lines changed: 26 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -151,22 +151,18 @@ fun BoostTransactionContent(
151151
)
152152

153153
VerticalSpacer(24.dp)
154-
155-
when {
156-
uiState.loading -> {
157-
LoadingState()
158-
}
159-
160-
uiState.isDefaultMode -> {
161-
DefaultModeContent(
154+
Column(
155+
modifier = Modifier.testTag(if (uiState.isRbf) "RBFBoost" else "CPFPBoost")
156+
) {
157+
when {
158+
uiState.loading -> LoadingState()
159+
uiState.isDefaultMode -> DefaultModeContent(
162160
uiState = uiState,
163161
onClickEdit = onClickEdit,
164162
onSwipe = onSwipe,
165163
)
166-
}
167164

168-
else -> {
169-
CustomModeContent(
165+
else -> CustomModeContent(
170166
uiState = uiState,
171167
onChangeAmount = onChangeAmount,
172168
onClickUseSuggestedFee = onClickUseSuggestedFee,
@@ -181,12 +177,10 @@ fun BoostTransactionContent(
181177
@Composable
182178
private fun LoadingState() {
183179
Column(
184-
horizontalAlignment = Alignment.CenterHorizontally,
185-
modifier = Modifier.padding(32.dp)
180+
horizontalAlignment = Alignment.CenterHorizontally, modifier = Modifier.padding(32.dp)
186181
) {
187182
CircularProgressIndicator(
188-
color = Colors.Yellow,
189-
modifier = Modifier
183+
color = Colors.Yellow, modifier = Modifier
190184
.size(32.dp)
191185
.testTag(BoostTransactionTestTags.LOADING_INDICATOR)
192186
)
@@ -206,8 +200,7 @@ private fun DefaultModeContent(
206200
modifier = Modifier
207201
.fillMaxWidth()
208202
.clickableAlpha { onClickEdit() }
209-
.testTag(BoostTransactionTestTags.EDIT_FEE_ROW)
210-
) {
203+
.testTag(BoostTransactionTestTags.EDIT_FEE_ROW)) {
211204
Image(
212205
painter = painterResource(R.drawable.ic_timer_alt_yellow),
213206
contentDescription = null,
@@ -235,13 +228,11 @@ private fun DefaultModeContent(
235228
horizontalAlignment = Alignment.End,
236229
) {
237230
Row(
238-
verticalAlignment = Alignment.CenterVertically,
239-
horizontalArrangement = Arrangement.spacedBy(4.dp)
231+
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(4.dp)
240232
) {
241-
val feeText = rememberMoneyText(sats = uiState.totalFeeSats.toLong())
242-
?.withAccent(defaultColor = Colors.White)
243-
?.toString()
244-
.orEmpty()
233+
val feeText =
234+
rememberMoneyText(sats = uiState.totalFeeSats.toLong())?.withAccent(defaultColor = Colors.White)
235+
?.toString().orEmpty()
245236

246237
BodyMSB(
247238
text = feeText,
@@ -259,11 +250,8 @@ private fun DefaultModeContent(
259250
}
260251

261252
val feeTextSecondary = rememberMoneyText(
262-
sats = uiState.totalFeeSats.toLong(),
263-
reversed = true
264-
)?.withAccent(defaultColor = Colors.White64)
265-
?.toString()
266-
.orEmpty()
253+
sats = uiState.totalFeeSats.toLong(), reversed = true
254+
)?.withAccent(defaultColor = Colors.White64)?.toString().orEmpty()
267255

268256
BodySSB(
269257
text = feeTextSecondary,
@@ -300,8 +288,7 @@ private fun CustomModeContent(
300288
modifier = Modifier.testTag(BoostTransactionTestTags.CUSTOM_MODE_CONTENT),
301289
) {
302290
Row(
303-
modifier = Modifier.fillMaxWidth(),
304-
verticalAlignment = Alignment.CenterVertically
291+
modifier = Modifier.fillMaxWidth(), verticalAlignment = Alignment.CenterVertically
305292
) {
306293
QuantityButton(
307294
icon = painterResource(R.drawable.ic_minus),
@@ -318,10 +305,9 @@ private fun CustomModeContent(
318305
horizontalAlignment = Alignment.CenterHorizontally,
319306
verticalArrangement = Arrangement.spacedBy(2.dp)
320307
) {
321-
val rateText = rememberMoneyText(sats = uiState.feeRate.toLong())
322-
?.withAccent(defaultColor = Colors.White)
323-
?.toString()
324-
.orEmpty()
308+
val rateText =
309+
rememberMoneyText(sats = uiState.feeRate.toLong())?.withAccent(defaultColor = Colors.White)
310+
?.toString().orEmpty()
325311

326312
BodyMSB(
327313
text = "$rateText/vbyte ($BITCOIN_SYMBOL ${uiState.totalFeeSats})",
@@ -333,11 +319,8 @@ private fun CustomModeContent(
333319
horizontalArrangement = Arrangement.spacedBy(8.dp)
334320
) {
335321
val feeTextSecondary = rememberMoneyText(
336-
sats = uiState.totalFeeSats.toLong(),
337-
reversed = true
338-
)?.withAccent(defaultColor = Colors.White64)
339-
?.toString()
340-
.orEmpty()
322+
sats = uiState.totalFeeSats.toLong(), reversed = true
323+
)?.withAccent(defaultColor = Colors.White64)?.toString().orEmpty()
341324

342325
BodySSB(
343326
text = feeTextSecondary,
@@ -407,15 +390,12 @@ fun QuantityButton(
407390
haptic.performHapticFeedback(HapticFeedbackType.TextHandleMove)
408391
onClick()
409392
}
410-
},
411-
enabled = enabled,
412-
colors = IconButtonDefaults.iconButtonColors(
393+
}, enabled = enabled, colors = IconButtonDefaults.iconButtonColors(
413394
containerColor = backgroundColor,
414395
contentColor = iconColor,
415396
disabledContainerColor = Colors.Gray3,
416397
disabledContentColor = Colors.Gray1
417-
),
418-
modifier = modifier
398+
), modifier = modifier
419399
.size(40.dp)
420400
.clip(CircleShape)
421401
) {
@@ -445,6 +425,8 @@ object BoostTransactionTestTags {
445425
const val DECREASE_FEE_BUTTON = "Minus"
446426
const val INCREASE_FEE_BUTTON = "Plus"
447427
const val FEE_RATE_TEXT = "fee_rate_text"
428+
429+
@Suppress("SpellCheckingInspection")
448430
const val USE_SUGGESTED_FEE_BUTTON = "RecomendedFeeButton"
449431
}
450432

app/src/main/java/to/bitkit/ui/sheets/BoostTransactionViewModel.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import kotlinx.coroutines.flow.update
1515
import kotlinx.coroutines.launch
1616
import org.lightningdevkit.ldknode.Txid
1717
import to.bitkit.data.dto.PendingBoostActivity
18+
import to.bitkit.ext.BoostType
19+
import to.bitkit.ext.boostType
1820
import to.bitkit.ext.nowTimestamp
1921
import to.bitkit.models.TransactionSpeed
2022
import to.bitkit.repositories.ActivityRepo
@@ -56,7 +58,12 @@ class BoostTransactionViewModel @Inject constructor(
5658
Logger.debug("Setup activity $activity", context = TAG)
5759
this.activity = activity
5860

59-
_uiState.update { it.copy(loading = true) }
61+
_uiState.update {
62+
it.copy(
63+
loading = true,
64+
isRbf = activity.boostType() == BoostType.RBF,
65+
)
66+
}
6067

6168
initializeFeeEstimates()
6269
}
@@ -437,4 +444,5 @@ data class BoostTransactionUiState(
437444
val boosting: Boolean = false,
438445
val loading: Boolean = false,
439446
val estimateTime: String = "±10-20 minutes", // TODO: Implement dynamic time estimation
447+
val isRbf: Boolean = false,
440448
)

0 commit comments

Comments
 (0)