[#770] Hide request ZEC button

This commit is contained in:
Carter Jernigan 2023-02-20 13:46:23 -05:00 committed by Carter Jernigan
parent 417fc4b8a5
commit ec7eb3804e
9 changed files with 57 additions and 19 deletions

View File

@ -108,7 +108,11 @@ Debug builds allow for manual override of feature toggle entries, which can be s
To set a configuration value manually, run the following shell command replacing `$SOME_KEY` and `$SOME_VALUE` with the key-value pair you'd like to set. The change will take effect immediately.
`adb shell am broadcast -n co.electriccoin.zcash/co.electriccoin.zcash.configuration.internal.intent.IntentConfigurationReceiver --es key "$SOME_KEY" --es value "$NEW_VALUE"`
`adb shell am broadcast -n co.electriccoin.zcash.debug/co.electriccoin.zcash.configuration.internal.intent.IntentConfigurationReceiver --es key "$SOME_KEY" --es value "$NEW_VALUE"`
As a specific example, the "Request ZEC" button on the home screen is currently disabled because the underlying functionality is not available yet. The button can be shown by running the command:
`adb shell am broadcast -n co.electriccoin.zcash.debug/co.electriccoin.zcash.configuration.internal.intent.IntentConfigurationReceiver --es key "is_request_zec_enabled" --es value "true"`
# Shared Resources
There are some app-wide resources that share a common namespace, and these should be documented here to make it easy to ensure there are no collisions.

View File

@ -9,7 +9,8 @@ import java.util.concurrent.atomic.AtomicInteger
class HomeTestSetup(
private val composeTestRule: ComposeContentTestRule,
private val walletSnapshot: WalletSnapshot
private val walletSnapshot: WalletSnapshot,
private val isRequestZecButtonEnabled: Boolean,
) {
private val onScanCount = AtomicInteger(0)
private val onProfileCount = AtomicInteger(0)
@ -46,7 +47,8 @@ class HomeTestSetup(
Home(
walletSnapshot,
isKeepScreenOnDuringSync = false,
emptyList(),
isRequestZecButtonEnabled = isRequestZecButtonEnabled,
transactionHistory = emptyList(),
goScan = {
onScanCount.incrementAndGet()
},

View File

@ -26,7 +26,8 @@ class HomeViewIntegrationTest : UiTestPrerequisites() {
private fun newTestSetup(walletSnapshot: WalletSnapshot) = HomeTestSetup(
composeTestRule,
walletSnapshot
walletSnapshot,
isRequestZecButtonEnabled = false
)
// This is just basic sanity check that we still have UI set up as expected after the state restore

View File

@ -49,6 +49,16 @@ class HomeViewTest : UiTestPrerequisites() {
}
}
@Test
@MediumTest
fun hide_request_zec() {
newTestSetup(isRequestZecButtonEnabled = false)
composeTestRule.onNodeWithText(getStringResource(R.string.home_button_request)).also {
it.assertDoesNotExist()
}
}
@Test
@MediumTest
fun click_scan_button() {
@ -97,9 +107,10 @@ class HomeViewTest : UiTestPrerequisites() {
assertEquals(1, testSetup.getOnRequestCount())
}
private fun newTestSetup() = HomeTestSetup(
private fun newTestSetup(isRequestZecButtonEnabled: Boolean = true) = HomeTestSetup(
composeTestRule,
WalletSnapshotFixture.new()
WalletSnapshotFixture.new(),
isRequestZecButtonEnabled = isRequestZecButtonEnabled
).apply {
setDefaultContent()
}

View File

@ -10,5 +10,5 @@ object ConfigurationEntries {
* Disabled because we don't have the URI parser support in the SDK yet.
*
*/
val IS_REQUEST_ZEC_ENABLED = BooleanConfigurationEntry(ConfigKey("is_update_check_enabled"), false)
val IS_REQUEST_ZEC_ENABLED = BooleanConfigurationEntry(ConfigKey("is_request_zec_enabled"), false)
}

View File

@ -11,6 +11,8 @@ import co.electriccoin.zcash.spackle.EmulatorWtfUtil
import co.electriccoin.zcash.spackle.FirebaseTestLabUtil
import co.electriccoin.zcash.ui.BuildConfig
import co.electriccoin.zcash.ui.MainActivity
import co.electriccoin.zcash.ui.configuration.ConfigurationEntries
import co.electriccoin.zcash.ui.configuration.RemoteConfig
import co.electriccoin.zcash.ui.screen.home.view.Home
import co.electriccoin.zcash.ui.screen.home.viewmodel.CheckUpdateViewModel
import co.electriccoin.zcash.ui.screen.home.viewmodel.WalletViewModel
@ -76,6 +78,7 @@ internal fun WrapHome(
Home(
walletSnapshot,
isKeepScreenOnDuringSync = isKeepScreenOnWhileSyncing,
isRequestZecButtonEnabled = ConfigurationEntries.IS_REQUEST_ZEC_ENABLED.getValue(RemoteConfig.current),
transactionSnapshot,
goScan = goScan,
goRequest = goRequest,

View File

@ -70,6 +70,7 @@ fun ComposablePreview() {
Home(
WalletSnapshotFixture.new(),
isKeepScreenOnDuringSync = false,
isRequestZecButtonEnabled = false,
emptyList(),
goScan = {},
goProfile = {},
@ -89,6 +90,7 @@ fun ComposablePreview() {
fun Home(
walletSnapshot: WalletSnapshot,
isKeepScreenOnDuringSync: Boolean?,
isRequestZecButtonEnabled: Boolean,
transactionHistory: List<CommonTransaction>,
goScan: () -> Unit,
goProfile: () -> Unit,
@ -105,6 +107,7 @@ fun Home(
paddingValues,
walletSnapshot,
isKeepScreenOnDuringSync = isKeepScreenOnDuringSync,
isRequestZecButtonEnabled = isRequestZecButtonEnabled,
transactionHistory,
goScan = goScan,
goProfile = goProfile,
@ -177,6 +180,7 @@ private fun HomeMainContent(
paddingValues: PaddingValues,
walletSnapshot: WalletSnapshot,
isKeepScreenOnDuringSync: Boolean?,
isRequestZecButtonEnabled: Boolean,
transactionHistory: List<CommonTransaction>,
goScan: () -> Unit,
goProfile: () -> Unit,
@ -215,7 +219,9 @@ private fun HomeMainContent(
PrimaryButton(onClick = goSend, text = stringResource(R.string.home_button_send))
TertiaryButton(onClick = goRequest, text = stringResource(R.string.home_button_request))
if (isRequestZecButtonEnabled) {
TertiaryButton(onClick = goRequest, text = stringResource(R.string.home_button_request))
}
History(transactionHistory)

View File

@ -55,10 +55,12 @@ android {
}
dependencies {
implementation(projects.uiLib)
implementation(projects.testLib)
implementation(projects.spackleAndroidLib)
implementation(projects.configurationApiLib)
implementation(projects.configurationImplAndroidLib)
implementation(projects.sdkExtLib)
implementation(projects.spackleAndroidLib)
implementation(projects.testLib)
implementation(projects.uiLib)
implementation(libs.bundles.androidx.test)
implementation(libs.bundles.androidx.compose.core)

View File

@ -29,16 +29,19 @@ import androidx.test.filters.SdkSuppress
import cash.z.ecc.android.sdk.fixture.WalletAddressFixture
import cash.z.ecc.android.sdk.model.MonetarySeparators
import cash.z.ecc.sdk.fixture.SeedPhraseFixture
import co.electriccoin.zcash.configuration.model.map.StringConfiguration
import co.electriccoin.zcash.spackle.FirebaseTestLabUtil
import co.electriccoin.zcash.test.UiTestPrerequisites
import co.electriccoin.zcash.ui.MainActivity
import co.electriccoin.zcash.ui.NavigationTargets
import co.electriccoin.zcash.ui.R
import co.electriccoin.zcash.ui.configuration.ConfigurationEntries
import co.electriccoin.zcash.ui.design.component.ConfigurationOverride
import co.electriccoin.zcash.ui.design.component.UiMode
import co.electriccoin.zcash.ui.screen.backup.BackupTag
import co.electriccoin.zcash.ui.screen.home.viewmodel.SecretState
import co.electriccoin.zcash.ui.screen.restore.RestoreTag
import kotlinx.collections.immutable.persistentMapOf
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
@ -76,6 +79,8 @@ class ScreenshotTest : UiTestPrerequisites() {
.captureToBitmap()
.writeToTestStorage("$screenshotName - $tag")
}
private val emptyConfiguration = StringConfiguration(persistentMapOf(), null)
}
@get:Rule
@ -300,15 +305,19 @@ class ScreenshotTest : UiTestPrerequisites() {
}
composeTestRule.waitUntil(DEFAULT_TIMEOUT_MILLISECONDS) { composeTestRule.activity.walletViewModel.secretState.value is SecretState.Ready }
composeTestRule.onNode(hasText(resContext.getString(R.string.home_button_request))).also {
it.assertExists()
it.performClick()
}
composeTestRule.waitUntil(DEFAULT_TIMEOUT_MILLISECONDS) { composeTestRule.activity.walletViewModel.walletSnapshot.value != null }
requestZecScreenshots(resContext, tag, composeTestRule)
navigateTo(NavigationTargets.HOME)
composeTestRule.waitUntil(DEFAULT_TIMEOUT_MILLISECONDS) { composeTestRule.activity.walletViewModel.secretState.value is SecretState.Ready }
if (ConfigurationEntries.IS_REQUEST_ZEC_ENABLED.getValue(emptyConfiguration)) {
composeTestRule.onNode(hasText(resContext.getString(R.string.home_button_request))).also {
it.assertExists()
it.performClick()
}
composeTestRule.waitUntil(DEFAULT_TIMEOUT_MILLISECONDS) { composeTestRule.activity.walletViewModel.walletSnapshot.value != null }
requestZecScreenshots(resContext, tag, composeTestRule)
navigateTo(NavigationTargets.HOME)
composeTestRule.waitUntil(DEFAULT_TIMEOUT_MILLISECONDS) { composeTestRule.activity.walletViewModel.secretState.value is SecretState.Ready }
}
composeTestRule.onNode(hasText(resContext.getString(R.string.home_button_send))).also {
it.assertExists()