[#783] Hide fiat currency conversion
* [#783] Hide fiat currency conversion * Add test
This commit is contained in:
parent
6e77a6f981
commit
5e3c1f1768
|
@ -11,6 +11,7 @@ import java.util.concurrent.atomic.AtomicInteger
|
|||
class HomeTestSetup(
|
||||
private val composeTestRule: ComposeContentTestRule,
|
||||
private val walletSnapshot: WalletSnapshot,
|
||||
private val isShowFiatConversion: Boolean
|
||||
) {
|
||||
private val onAboutCount = AtomicInteger(0)
|
||||
private val onSeedCount = AtomicInteger(0)
|
||||
|
@ -60,8 +61,10 @@ class HomeTestSetup(
|
|||
Home(
|
||||
walletSnapshot,
|
||||
transactionHistory = persistentListOf(),
|
||||
isKeepScreenOnDuringSync = false,
|
||||
isUpdateAvailable = false,
|
||||
isKeepScreenOnDuringSync = false,
|
||||
isFiatConversionEnabled = isShowFiatConversion,
|
||||
isDebugMenuEnabled = false,
|
||||
goSettings = {
|
||||
onSettingsCount.incrementAndGet()
|
||||
},
|
||||
|
@ -81,7 +84,6 @@ class HomeTestSetup(
|
|||
onSendCount.incrementAndGet()
|
||||
},
|
||||
resetSdk = {},
|
||||
isDebugMenuEnabled = false,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,8 @@ class HomeViewIntegrationTest : UiTestPrerequisites() {
|
|||
|
||||
private fun newTestSetup(walletSnapshot: WalletSnapshot) = HomeTestSetup(
|
||||
composeTestRule,
|
||||
walletSnapshot
|
||||
walletSnapshot,
|
||||
isShowFiatConversion = false
|
||||
)
|
||||
|
||||
// This is just basic sanity check that we still have UI set up as expected after the state restore
|
||||
|
|
|
@ -36,6 +36,10 @@ class HomeViewTest : UiTestPrerequisites() {
|
|||
it.assertIsDisplayed()
|
||||
}
|
||||
|
||||
composeTestRule.onNodeWithTag(HomeTag.FIAT_CONVERSION).also {
|
||||
it.assertIsDisplayed()
|
||||
}
|
||||
|
||||
composeTestRule.onNodeWithText(getStringResource(R.string.home_button_send)).also {
|
||||
it.assertIsDisplayed()
|
||||
}
|
||||
|
@ -45,6 +49,16 @@ class HomeViewTest : UiTestPrerequisites() {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@MediumTest
|
||||
fun hide_fiat_conversion() {
|
||||
newTestSetup(isShowFiatConversion = false)
|
||||
|
||||
composeTestRule.onNodeWithTag(HomeTag.FIAT_CONVERSION).also {
|
||||
it.assertDoesNotExist()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
@MediumTest
|
||||
fun click_receive_button() {
|
||||
|
@ -133,9 +147,10 @@ class HomeViewTest : UiTestPrerequisites() {
|
|||
assertEquals(1, testSetup.getOnAboutCount())
|
||||
}
|
||||
|
||||
private fun newTestSetup() = HomeTestSetup(
|
||||
private fun newTestSetup(isShowFiatConversion: Boolean = true) = HomeTestSetup(
|
||||
composeTestRule,
|
||||
WalletSnapshotFixture.new()
|
||||
WalletSnapshotFixture.new(),
|
||||
isShowFiatConversion = isShowFiatConversion
|
||||
).apply {
|
||||
setDefaultContent()
|
||||
}
|
||||
|
|
|
@ -16,6 +16,11 @@ object ConfigurationEntries {
|
|||
*/
|
||||
val IS_SHORT_NEW_WALLET_BACKUP_UX = BooleanConfigurationEntry(ConfigKey("is_short_new_wallet_backup_ux"), true)
|
||||
|
||||
/*
|
||||
* This isn't fully implemented yet, so it is disabled from being shown.
|
||||
*/
|
||||
val IS_FIAT_CONVERSION_ENABLED = BooleanConfigurationEntry(ConfigKey("is_fiat_conversion_enabled"), false)
|
||||
|
||||
/*
|
||||
* A troubleshooting step. If we fix our bugs, this should be unnecessary.
|
||||
*/
|
||||
|
|
|
@ -16,6 +16,8 @@ import co.electriccoin.zcash.spackle.FirebaseTestLabUtil
|
|||
import co.electriccoin.zcash.ui.BuildConfig
|
||||
import co.electriccoin.zcash.ui.MainActivity
|
||||
import co.electriccoin.zcash.ui.common.closeDrawerMenu
|
||||
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
|
||||
|
@ -72,6 +74,7 @@ internal fun WrapHome(
|
|||
val settingsViewModel by activity.viewModels<SettingsViewModel>()
|
||||
|
||||
val isKeepScreenOnWhileSyncing = settingsViewModel.isKeepScreenOnWhileSyncing.collectAsStateWithLifecycle().value
|
||||
val isFiatConversionEnabled = ConfigurationEntries.IS_FIAT_CONVERSION_ENABLED.getValue(RemoteConfig.current)
|
||||
|
||||
if (null == walletSnapshot) {
|
||||
// Display loading indicator
|
||||
|
@ -99,6 +102,7 @@ internal fun WrapHome(
|
|||
transactionSnapshot,
|
||||
isUpdateAvailable = updateAvailable,
|
||||
isKeepScreenOnDuringSync = isKeepScreenOnWhileSyncing,
|
||||
isFiatConversionEnabled = isFiatConversionEnabled,
|
||||
isDebugMenuEnabled = isDebugMenuEnabled,
|
||||
goSeedPhrase = goSeedPhrase,
|
||||
goSettings = goSettings,
|
||||
|
|
|
@ -7,4 +7,5 @@ object HomeTag {
|
|||
const val STATUS_VIEWS = "status_views"
|
||||
const val PROGRESS = "progress_bar"
|
||||
const val SINGLE_LINE_TEXT = "single_line_text"
|
||||
const val FIAT_CONVERSION = "fiat_conversion"
|
||||
}
|
||||
|
|
|
@ -88,6 +88,7 @@ fun ComposablePreview() {
|
|||
isUpdateAvailable = false,
|
||||
isKeepScreenOnDuringSync = false,
|
||||
isDebugMenuEnabled = false,
|
||||
isFiatConversionEnabled = false,
|
||||
goSeedPhrase = {},
|
||||
goSettings = {},
|
||||
goSupport = {},
|
||||
|
@ -108,6 +109,7 @@ fun Home(
|
|||
transactionHistory: ImmutableList<CommonTransaction>,
|
||||
isUpdateAvailable: Boolean,
|
||||
isKeepScreenOnDuringSync: Boolean?,
|
||||
isFiatConversionEnabled: Boolean,
|
||||
isDebugMenuEnabled: Boolean,
|
||||
goSeedPhrase: () -> Unit,
|
||||
goSettings: () -> Unit,
|
||||
|
@ -144,6 +146,7 @@ fun Home(
|
|||
transactionHistory,
|
||||
isUpdateAvailable = isUpdateAvailable,
|
||||
isKeepScreenOnDuringSync = isKeepScreenOnDuringSync,
|
||||
isFiatConversionEnabled = isFiatConversionEnabled,
|
||||
goReceive = goReceive,
|
||||
goSend = goSend,
|
||||
)
|
||||
|
@ -282,6 +285,7 @@ private fun HomeMainContent(
|
|||
transactionHistory: ImmutableList<CommonTransaction>,
|
||||
isUpdateAvailable: Boolean,
|
||||
isKeepScreenOnDuringSync: Boolean?,
|
||||
isFiatConversionEnabled: Boolean,
|
||||
goReceive: () -> Unit,
|
||||
goSend: () -> Unit,
|
||||
) {
|
||||
|
@ -290,7 +294,7 @@ private fun HomeMainContent(
|
|||
.verticalScroll(rememberScrollState())
|
||||
.padding(top = paddingValues.calculateTopPadding())
|
||||
) {
|
||||
Status(walletSnapshot, isUpdateAvailable)
|
||||
Status(walletSnapshot, isUpdateAvailable, isFiatConversionEnabled)
|
||||
|
||||
Spacer(modifier = Modifier.height(24.dp))
|
||||
|
||||
|
@ -316,7 +320,8 @@ private fun isSyncing(status: Synchronizer.Status): Boolean {
|
|||
@Suppress("LongMethod", "MagicNumber")
|
||||
private fun Status(
|
||||
walletSnapshot: WalletSnapshot,
|
||||
updateAvailable: Boolean
|
||||
updateAvailable: Boolean,
|
||||
isFiatConversionEnabled: Boolean
|
||||
) {
|
||||
val configuration = LocalConfiguration.current
|
||||
val contentSizeRatioRatio = if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||
|
@ -376,6 +381,8 @@ private fun Status(
|
|||
HeaderWithZecIcon(amount = walletDisplayValues.zecAmountText)
|
||||
}
|
||||
|
||||
if (isFiatConversionEnabled) {
|
||||
Column(Modifier.testTag(HomeTag.FIAT_CONVERSION)) {
|
||||
Spacer(modifier = Modifier.height(8.dp))
|
||||
|
||||
when (walletDisplayValues.fiatCurrencyAmountState) {
|
||||
|
@ -394,6 +401,8 @@ private fun Status(
|
|||
Body(text = walletDisplayValues.fiatCurrencyAmountText)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(24.dp))
|
||||
|
||||
|
|
Loading…
Reference in New Issue