[#1121] Available balance check on Send
* [#1121] Available balance check on Send Closes #1121 * Align UI tests * Changelog update
This commit is contained in:
parent
4e3bea2c2f
commit
c943fc58be
|
@ -13,6 +13,7 @@ directly impact users rather than highlighting other key architectural updates.*
|
|||
- Home screen navigation switched from the Side menu to the Bottom Navigation Tabs menu
|
||||
- Re-enabled the possibility of installing different Zashi application build types on the same device simultaneously
|
||||
(i.e., Mainnet, Testnet, Production, Debug)
|
||||
- Send screen form now validates a maximum amount for sending with respect to the available balance
|
||||
|
||||
## [0.2.0 (505)] - 2023-12-11
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import androidx.compose.ui.test.onNodeWithContentDescription
|
|||
import androidx.compose.ui.test.onNodeWithTag
|
||||
import androidx.compose.ui.test.onNodeWithText
|
||||
import androidx.compose.ui.test.performClick
|
||||
import androidx.compose.ui.test.performScrollTo
|
||||
import androidx.compose.ui.test.performTextClearance
|
||||
import androidx.compose.ui.test.performTextInput
|
||||
import cash.z.ecc.android.sdk.fixture.WalletAddressFixture
|
||||
|
@ -78,6 +79,7 @@ internal fun ComposeContentTestRule.setMemo(memo: String) {
|
|||
|
||||
internal fun ComposeContentTestRule.clickCreateAndSend() {
|
||||
onNodeWithTag(SendTag.SEND_FORM_BUTTON).also {
|
||||
it.performScrollTo()
|
||||
it.performClick()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.saveable.rememberSaveable
|
||||
import androidx.compose.ui.test.junit4.ComposeContentTestRule
|
||||
import cash.z.ecc.android.sdk.model.Zatoshi
|
||||
import cash.z.ecc.android.sdk.model.ZecSend
|
||||
import cash.z.ecc.sdk.fixture.ZatoshiFixture
|
||||
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
|
||||
|
@ -95,7 +96,7 @@ class SendViewTestSetup(
|
|||
|
||||
ZcashTheme {
|
||||
Send(
|
||||
mySpendableBalance = ZatoshiFixture.new(),
|
||||
mySpendableBalance = ZatoshiFixture.new(Zatoshi.MAX_INCLUSIVE),
|
||||
sendStage = sendStage,
|
||||
sendArgumentsWrapper = initialSendArgumentWrapper,
|
||||
onSendStageChange = setSendStage,
|
||||
|
|
|
@ -6,6 +6,7 @@ import androidx.compose.ui.test.junit4.createComposeRule
|
|||
import androidx.compose.ui.test.onNodeWithText
|
||||
import androidx.test.filters.MediumTest
|
||||
import cash.z.ecc.android.sdk.fixture.WalletFixture
|
||||
import cash.z.ecc.android.sdk.model.Zatoshi
|
||||
import cash.z.ecc.android.sdk.model.ZcashNetwork
|
||||
import cash.z.ecc.sdk.fixture.ZatoshiFixture
|
||||
import cash.z.ecc.sdk.fixture.ZecSendFixture
|
||||
|
@ -38,7 +39,7 @@ class SendViewIntegrationTest {
|
|||
)
|
||||
}
|
||||
private val synchronizer = MockSynchronizer.new()
|
||||
private val balance = ZatoshiFixture.new()
|
||||
private val balance = ZatoshiFixture.new(Zatoshi.MAX_INCLUSIVE)
|
||||
|
||||
@Test
|
||||
@MediumTest
|
||||
|
|
|
@ -172,8 +172,8 @@ class SendViewTest : UiTestPrerequisites() {
|
|||
composeTestRule.setAmount("123")
|
||||
composeTestRule.assertSendEnabled()
|
||||
|
||||
// e.g. 123,
|
||||
composeTestRule.setAmount("123${separators.grouping}")
|
||||
// e.g. 123,456
|
||||
composeTestRule.setAmount("123${separators.grouping}456")
|
||||
composeTestRule.assertSendEnabled()
|
||||
|
||||
// e.g. 123.
|
||||
|
|
|
@ -33,6 +33,7 @@ import androidx.compose.ui.res.stringResource
|
|||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import cash.z.ecc.android.sdk.ext.ZcashSdk
|
||||
import cash.z.ecc.android.sdk.fixture.WalletAddressFixture
|
||||
import cash.z.ecc.android.sdk.model.Memo
|
||||
import cash.z.ecc.android.sdk.model.MonetarySeparators
|
||||
|
@ -41,6 +42,7 @@ import cash.z.ecc.android.sdk.model.ZecSend
|
|||
import cash.z.ecc.android.sdk.model.ZecSendExt
|
||||
import cash.z.ecc.android.sdk.model.ZecString
|
||||
import cash.z.ecc.android.sdk.model.ZecStringExt
|
||||
import cash.z.ecc.android.sdk.model.fromZecString
|
||||
import cash.z.ecc.android.sdk.model.toZecString
|
||||
import cash.z.ecc.sdk.fixture.MemoFixture
|
||||
import cash.z.ecc.sdk.fixture.ZatoshiFixture
|
||||
|
@ -284,7 +286,7 @@ private fun SendMainContent(
|
|||
// TODO [#217]: Need to handle changing of Locale after user input, but before submitting the button.
|
||||
// TODO [#288]: TextField component can't do long-press backspace.
|
||||
// TODO [#294]: DetektAll failed LongMethod
|
||||
@Suppress("LongMethod", "LongParameterList")
|
||||
@Suppress("LongMethod", "LongParameterList", "CyclomaticComplexMethod")
|
||||
@Composable
|
||||
private fun SendForm(
|
||||
myBalance: Zatoshi,
|
||||
|
@ -416,6 +418,18 @@ private fun SendForm(
|
|||
|
||||
Spacer(modifier = Modifier.height(dimens.spacingDefault))
|
||||
|
||||
// Create a send amount that is continuously checked for validity
|
||||
val sendValueCheck = (Zatoshi.fromZecString(context, amountZecString, monetarySeparators))?.value ?: 0L
|
||||
|
||||
// Continuous amount check while user is typing into the amount field
|
||||
// Note: the check for ABBREVIATION_INDEX goes away once proper address validation is in place.
|
||||
// For now, it just prevents a crash on the confirmation screen.
|
||||
val sendButtonEnabled =
|
||||
amountZecString.isNotBlank() &&
|
||||
sendValueCheck > 0L &&
|
||||
myBalance.value >= (sendValueCheck + ZcashSdk.MINERS_FEE.value) &&
|
||||
recipientAddressString.length > ABBREVIATION_INDEX
|
||||
|
||||
PrimaryButton(
|
||||
onClick = {
|
||||
val zecSendValidation =
|
||||
|
@ -433,9 +447,7 @@ private fun SendForm(
|
|||
}
|
||||
},
|
||||
text = stringResource(id = R.string.send_create),
|
||||
// Check for ABBREVIATION_INDEX goes away once proper address validation is in place.
|
||||
// For now, it just prevents a crash on the confirmation screen.
|
||||
enabled = amountZecString.isNotBlank() && recipientAddressString.length > ABBREVIATION_INDEX,
|
||||
enabled = sendButtonEnabled,
|
||||
outerPaddingValues = PaddingValues(top = dimens.spacingNone),
|
||||
modifier = Modifier.testTag(SendTag.SEND_FORM_BUTTON)
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue