[#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(
|
class HomeTestSetup(
|
||||||
private val composeTestRule: ComposeContentTestRule,
|
private val composeTestRule: ComposeContentTestRule,
|
||||||
private val walletSnapshot: WalletSnapshot,
|
private val walletSnapshot: WalletSnapshot,
|
||||||
|
private val isShowFiatConversion: Boolean
|
||||||
) {
|
) {
|
||||||
private val onAboutCount = AtomicInteger(0)
|
private val onAboutCount = AtomicInteger(0)
|
||||||
private val onSeedCount = AtomicInteger(0)
|
private val onSeedCount = AtomicInteger(0)
|
||||||
|
@ -60,8 +61,10 @@ class HomeTestSetup(
|
||||||
Home(
|
Home(
|
||||||
walletSnapshot,
|
walletSnapshot,
|
||||||
transactionHistory = persistentListOf(),
|
transactionHistory = persistentListOf(),
|
||||||
isKeepScreenOnDuringSync = false,
|
|
||||||
isUpdateAvailable = false,
|
isUpdateAvailable = false,
|
||||||
|
isKeepScreenOnDuringSync = false,
|
||||||
|
isFiatConversionEnabled = isShowFiatConversion,
|
||||||
|
isDebugMenuEnabled = false,
|
||||||
goSettings = {
|
goSettings = {
|
||||||
onSettingsCount.incrementAndGet()
|
onSettingsCount.incrementAndGet()
|
||||||
},
|
},
|
||||||
|
@ -81,7 +84,6 @@ class HomeTestSetup(
|
||||||
onSendCount.incrementAndGet()
|
onSendCount.incrementAndGet()
|
||||||
},
|
},
|
||||||
resetSdk = {},
|
resetSdk = {},
|
||||||
isDebugMenuEnabled = false,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,8 @@ class HomeViewIntegrationTest : UiTestPrerequisites() {
|
||||||
|
|
||||||
private fun newTestSetup(walletSnapshot: WalletSnapshot) = HomeTestSetup(
|
private fun newTestSetup(walletSnapshot: WalletSnapshot) = HomeTestSetup(
|
||||||
composeTestRule,
|
composeTestRule,
|
||||||
walletSnapshot
|
walletSnapshot,
|
||||||
|
isShowFiatConversion = false
|
||||||
)
|
)
|
||||||
|
|
||||||
// This is just basic sanity check that we still have UI set up as expected after the state restore
|
// 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()
|
it.assertIsDisplayed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
composeTestRule.onNodeWithTag(HomeTag.FIAT_CONVERSION).also {
|
||||||
|
it.assertIsDisplayed()
|
||||||
|
}
|
||||||
|
|
||||||
composeTestRule.onNodeWithText(getStringResource(R.string.home_button_send)).also {
|
composeTestRule.onNodeWithText(getStringResource(R.string.home_button_send)).also {
|
||||||
it.assertIsDisplayed()
|
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
|
@Test
|
||||||
@MediumTest
|
@MediumTest
|
||||||
fun click_receive_button() {
|
fun click_receive_button() {
|
||||||
|
@ -133,9 +147,10 @@ class HomeViewTest : UiTestPrerequisites() {
|
||||||
assertEquals(1, testSetup.getOnAboutCount())
|
assertEquals(1, testSetup.getOnAboutCount())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun newTestSetup() = HomeTestSetup(
|
private fun newTestSetup(isShowFiatConversion: Boolean = true) = HomeTestSetup(
|
||||||
composeTestRule,
|
composeTestRule,
|
||||||
WalletSnapshotFixture.new()
|
WalletSnapshotFixture.new(),
|
||||||
|
isShowFiatConversion = isShowFiatConversion
|
||||||
).apply {
|
).apply {
|
||||||
setDefaultContent()
|
setDefaultContent()
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,11 @@ object ConfigurationEntries {
|
||||||
*/
|
*/
|
||||||
val IS_SHORT_NEW_WALLET_BACKUP_UX = BooleanConfigurationEntry(ConfigKey("is_short_new_wallet_backup_ux"), true)
|
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.
|
* 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.BuildConfig
|
||||||
import co.electriccoin.zcash.ui.MainActivity
|
import co.electriccoin.zcash.ui.MainActivity
|
||||||
import co.electriccoin.zcash.ui.common.closeDrawerMenu
|
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.view.Home
|
||||||
import co.electriccoin.zcash.ui.screen.home.viewmodel.CheckUpdateViewModel
|
import co.electriccoin.zcash.ui.screen.home.viewmodel.CheckUpdateViewModel
|
||||||
import co.electriccoin.zcash.ui.screen.home.viewmodel.WalletViewModel
|
import co.electriccoin.zcash.ui.screen.home.viewmodel.WalletViewModel
|
||||||
|
@ -72,6 +74,7 @@ internal fun WrapHome(
|
||||||
val settingsViewModel by activity.viewModels<SettingsViewModel>()
|
val settingsViewModel by activity.viewModels<SettingsViewModel>()
|
||||||
|
|
||||||
val isKeepScreenOnWhileSyncing = settingsViewModel.isKeepScreenOnWhileSyncing.collectAsStateWithLifecycle().value
|
val isKeepScreenOnWhileSyncing = settingsViewModel.isKeepScreenOnWhileSyncing.collectAsStateWithLifecycle().value
|
||||||
|
val isFiatConversionEnabled = ConfigurationEntries.IS_FIAT_CONVERSION_ENABLED.getValue(RemoteConfig.current)
|
||||||
|
|
||||||
if (null == walletSnapshot) {
|
if (null == walletSnapshot) {
|
||||||
// Display loading indicator
|
// Display loading indicator
|
||||||
|
@ -99,6 +102,7 @@ internal fun WrapHome(
|
||||||
transactionSnapshot,
|
transactionSnapshot,
|
||||||
isUpdateAvailable = updateAvailable,
|
isUpdateAvailable = updateAvailable,
|
||||||
isKeepScreenOnDuringSync = isKeepScreenOnWhileSyncing,
|
isKeepScreenOnDuringSync = isKeepScreenOnWhileSyncing,
|
||||||
|
isFiatConversionEnabled = isFiatConversionEnabled,
|
||||||
isDebugMenuEnabled = isDebugMenuEnabled,
|
isDebugMenuEnabled = isDebugMenuEnabled,
|
||||||
goSeedPhrase = goSeedPhrase,
|
goSeedPhrase = goSeedPhrase,
|
||||||
goSettings = goSettings,
|
goSettings = goSettings,
|
||||||
|
|
|
@ -7,4 +7,5 @@ object HomeTag {
|
||||||
const val STATUS_VIEWS = "status_views"
|
const val STATUS_VIEWS = "status_views"
|
||||||
const val PROGRESS = "progress_bar"
|
const val PROGRESS = "progress_bar"
|
||||||
const val SINGLE_LINE_TEXT = "single_line_text"
|
const val SINGLE_LINE_TEXT = "single_line_text"
|
||||||
|
const val FIAT_CONVERSION = "fiat_conversion"
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,6 +88,7 @@ fun ComposablePreview() {
|
||||||
isUpdateAvailable = false,
|
isUpdateAvailable = false,
|
||||||
isKeepScreenOnDuringSync = false,
|
isKeepScreenOnDuringSync = false,
|
||||||
isDebugMenuEnabled = false,
|
isDebugMenuEnabled = false,
|
||||||
|
isFiatConversionEnabled = false,
|
||||||
goSeedPhrase = {},
|
goSeedPhrase = {},
|
||||||
goSettings = {},
|
goSettings = {},
|
||||||
goSupport = {},
|
goSupport = {},
|
||||||
|
@ -108,6 +109,7 @@ fun Home(
|
||||||
transactionHistory: ImmutableList<CommonTransaction>,
|
transactionHistory: ImmutableList<CommonTransaction>,
|
||||||
isUpdateAvailable: Boolean,
|
isUpdateAvailable: Boolean,
|
||||||
isKeepScreenOnDuringSync: Boolean?,
|
isKeepScreenOnDuringSync: Boolean?,
|
||||||
|
isFiatConversionEnabled: Boolean,
|
||||||
isDebugMenuEnabled: Boolean,
|
isDebugMenuEnabled: Boolean,
|
||||||
goSeedPhrase: () -> Unit,
|
goSeedPhrase: () -> Unit,
|
||||||
goSettings: () -> Unit,
|
goSettings: () -> Unit,
|
||||||
|
@ -144,6 +146,7 @@ fun Home(
|
||||||
transactionHistory,
|
transactionHistory,
|
||||||
isUpdateAvailable = isUpdateAvailable,
|
isUpdateAvailable = isUpdateAvailable,
|
||||||
isKeepScreenOnDuringSync = isKeepScreenOnDuringSync,
|
isKeepScreenOnDuringSync = isKeepScreenOnDuringSync,
|
||||||
|
isFiatConversionEnabled = isFiatConversionEnabled,
|
||||||
goReceive = goReceive,
|
goReceive = goReceive,
|
||||||
goSend = goSend,
|
goSend = goSend,
|
||||||
)
|
)
|
||||||
|
@ -282,6 +285,7 @@ private fun HomeMainContent(
|
||||||
transactionHistory: ImmutableList<CommonTransaction>,
|
transactionHistory: ImmutableList<CommonTransaction>,
|
||||||
isUpdateAvailable: Boolean,
|
isUpdateAvailable: Boolean,
|
||||||
isKeepScreenOnDuringSync: Boolean?,
|
isKeepScreenOnDuringSync: Boolean?,
|
||||||
|
isFiatConversionEnabled: Boolean,
|
||||||
goReceive: () -> Unit,
|
goReceive: () -> Unit,
|
||||||
goSend: () -> Unit,
|
goSend: () -> Unit,
|
||||||
) {
|
) {
|
||||||
|
@ -290,7 +294,7 @@ private fun HomeMainContent(
|
||||||
.verticalScroll(rememberScrollState())
|
.verticalScroll(rememberScrollState())
|
||||||
.padding(top = paddingValues.calculateTopPadding())
|
.padding(top = paddingValues.calculateTopPadding())
|
||||||
) {
|
) {
|
||||||
Status(walletSnapshot, isUpdateAvailable)
|
Status(walletSnapshot, isUpdateAvailable, isFiatConversionEnabled)
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(24.dp))
|
Spacer(modifier = Modifier.height(24.dp))
|
||||||
|
|
||||||
|
@ -316,7 +320,8 @@ private fun isSyncing(status: Synchronizer.Status): Boolean {
|
||||||
@Suppress("LongMethod", "MagicNumber")
|
@Suppress("LongMethod", "MagicNumber")
|
||||||
private fun Status(
|
private fun Status(
|
||||||
walletSnapshot: WalletSnapshot,
|
walletSnapshot: WalletSnapshot,
|
||||||
updateAvailable: Boolean
|
updateAvailable: Boolean,
|
||||||
|
isFiatConversionEnabled: Boolean
|
||||||
) {
|
) {
|
||||||
val configuration = LocalConfiguration.current
|
val configuration = LocalConfiguration.current
|
||||||
val contentSizeRatioRatio = if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
val contentSizeRatioRatio = if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
|
@ -376,22 +381,26 @@ private fun Status(
|
||||||
HeaderWithZecIcon(amount = walletDisplayValues.zecAmountText)
|
HeaderWithZecIcon(amount = walletDisplayValues.zecAmountText)
|
||||||
}
|
}
|
||||||
|
|
||||||
Spacer(modifier = Modifier.height(8.dp))
|
if (isFiatConversionEnabled) {
|
||||||
|
Column(Modifier.testTag(HomeTag.FIAT_CONVERSION)) {
|
||||||
|
Spacer(modifier = Modifier.height(8.dp))
|
||||||
|
|
||||||
when (walletDisplayValues.fiatCurrencyAmountState) {
|
when (walletDisplayValues.fiatCurrencyAmountState) {
|
||||||
is FiatCurrencyConversionRateState.Current -> {
|
is FiatCurrencyConversionRateState.Current -> {
|
||||||
BodyWithFiatCurrencySymbol(
|
BodyWithFiatCurrencySymbol(
|
||||||
amount = walletDisplayValues.fiatCurrencyAmountText
|
amount = walletDisplayValues.fiatCurrencyAmountText
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is FiatCurrencyConversionRateState.Stale -> {
|
is FiatCurrencyConversionRateState.Stale -> {
|
||||||
// Note: we should show information about staleness too
|
// Note: we should show information about staleness too
|
||||||
BodyWithFiatCurrencySymbol(
|
BodyWithFiatCurrencySymbol(
|
||||||
amount = walletDisplayValues.fiatCurrencyAmountText
|
amount = walletDisplayValues.fiatCurrencyAmountText
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
is FiatCurrencyConversionRateState.Unavailable -> {
|
is FiatCurrencyConversionRateState.Unavailable -> {
|
||||||
Body(text = walletDisplayValues.fiatCurrencyAmountText)
|
Body(text = walletDisplayValues.fiatCurrencyAmountText)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue