Test hotfixes

This commit is contained in:
Milan Cerovsky 2024-12-18 13:59:58 +01:00 committed by Milan
parent 3d7c1c101f
commit 7ddd2e6b67
7 changed files with 116 additions and 26 deletions

View File

@ -5,7 +5,10 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.test.junit4.ComposeContentTestRule
import co.electriccoin.zcash.ui.common.model.WalletRestoringState
import co.electriccoin.zcash.ui.common.model.WalletSnapshot
import co.electriccoin.zcash.ui.design.R
import co.electriccoin.zcash.ui.design.component.IconButtonState
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import co.electriccoin.zcash.ui.design.util.stringRes
import co.electriccoin.zcash.ui.fixture.BalanceStateFixture
import co.electriccoin.zcash.ui.fixture.WalletSnapshotFixture
import co.electriccoin.zcash.ui.fixture.ZashiMainTopAppBarStateFixture
@ -60,7 +63,27 @@ class AccountTestSetup(
transactionsUiState = initialTransactionState,
walletRestoringState = WalletRestoringState.NONE,
walletSnapshot = WalletSnapshotFixture.new(),
zashiMainTopAppBarState = ZashiMainTopAppBarStateFixture.new()
zashiMainTopAppBarState =
ZashiMainTopAppBarStateFixture.new(
settingsButton =
IconButtonState(
icon = R.drawable.ic_app_bar_settings,
contentDescription =
stringRes(co.electriccoin.zcash.ui.R.string.settings_menu_content_description),
) {
onSettingsCount.incrementAndGet()
},
balanceVisibilityButton =
IconButtonState(
icon = R.drawable.ic_app_bar_balances_hide,
contentDescription =
stringRes(
co.electriccoin.zcash.ui.R.string.hide_balances_content_description
),
) {
onHideBalancesCount.incrementAndGet()
},
)
)
}

View File

@ -5,7 +5,10 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.test.junit4.ComposeContentTestRule
import co.electriccoin.zcash.ui.common.model.WalletRestoringState
import co.electriccoin.zcash.ui.common.model.WalletSnapshot
import co.electriccoin.zcash.ui.design.R
import co.electriccoin.zcash.ui.design.component.IconButtonState
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import co.electriccoin.zcash.ui.design.util.stringRes
import co.electriccoin.zcash.ui.fixture.BalanceStateFixture
import co.electriccoin.zcash.ui.fixture.ZashiMainTopAppBarStateFixture
import co.electriccoin.zcash.ui.screen.balances.model.ShieldState
@ -47,7 +50,16 @@ class BalancesTestSetup(
walletSnapshot = walletSnapshot,
walletRestoringState = WalletRestoringState.NONE,
zashiMainTopAppBarState =
ZashiMainTopAppBarStateFixture.new()
ZashiMainTopAppBarStateFixture.new(
settingsButton =
IconButtonState(
icon = R.drawable.ic_app_bar_settings,
contentDescription =
stringRes(co.electriccoin.zcash.ui.R.string.settings_menu_content_description),
) {
onSettingsCount.incrementAndGet()
}
)
)
}

View File

@ -5,10 +5,8 @@ import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.test.filters.MediumTest
import cash.z.ecc.android.sdk.fixture.WalletAddressesFixture
import cash.z.ecc.android.sdk.fixture.WalletAddressFixture
import co.electriccoin.zcash.ui.R
import co.electriccoin.zcash.ui.screen.send.ext.abbreviated
import co.electriccoin.zcash.ui.test.getAppContext
import co.electriccoin.zcash.ui.test.getStringResource
import kotlinx.coroutines.test.runTest
import org.junit.Assert.assertEquals
@ -31,16 +29,14 @@ class ReceiveViewTest {
@MediumTest
fun setup() =
runTest {
val walletAddresses = WalletAddressesFixture.new()
newTestSetup()
// Enable substring for ellipsizing
composeTestRule.onNodeWithText(
text = walletAddresses.unified.abbreviated(getAppContext()),
substring = true
).also {
it.assertExists()
}
text = "${WalletAddressFixture.UNIFIED_ADDRESS_STRING.take(20)}...",
substring = true,
useUnmergedTree = true
).assertExists()
}
@Test

View File

@ -1,8 +1,13 @@
package co.electriccoin.zcash.ui.screen.receive.view
import androidx.compose.ui.test.junit4.ComposeContentTestRule
import cash.z.ecc.android.sdk.fixture.WalletAddressFixture
import co.electriccoin.zcash.ui.R
import co.electriccoin.zcash.ui.design.component.IconButtonState
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import co.electriccoin.zcash.ui.design.util.stringRes
import co.electriccoin.zcash.ui.fixture.ZashiMainTopAppBarStateFixture
import co.electriccoin.zcash.ui.screen.receive.model.ReceiveAddressState
import co.electriccoin.zcash.ui.screen.receive.model.ReceiveState
import java.util.concurrent.atomic.AtomicInteger
@ -23,10 +28,36 @@ class ReceiveViewTestSetup(
ReceiveView(
state =
ReceiveState(
items = listOf(),
items =
listOf(
ReceiveAddressState(
icon = R.drawable.ic_zec_round_full,
title = stringRes("Zashi"),
subtitle =
stringRes(
"${WalletAddressFixture.UNIFIED_ADDRESS_STRING.take(20)}...",
),
isShielded = true,
onCopyClicked = {},
onQrClicked = { },
onRequestClicked = {},
isExpanded = true,
onClick = {}
)
),
isLoading = false,
),
zashiMainTopAppBarState = ZashiMainTopAppBarStateFixture.new()
zashiMainTopAppBarState =
ZashiMainTopAppBarStateFixture.new(
settingsButton =
IconButtonState(
icon = co.electriccoin.zcash.ui.design.R.drawable.ic_app_bar_settings,
contentDescription =
stringRes(R.string.settings_menu_content_description),
) {
onSettingsCount.incrementAndGet()
}
)
)
}
}

View File

@ -12,7 +12,10 @@ import cash.z.ecc.android.sdk.model.Zatoshi
import cash.z.ecc.android.sdk.model.ZecSend
import cash.z.ecc.android.sdk.type.AddressType
import co.electriccoin.zcash.ui.common.wallet.ExchangeRateState
import co.electriccoin.zcash.ui.design.R
import co.electriccoin.zcash.ui.design.component.IconButtonState
import co.electriccoin.zcash.ui.design.theme.ZcashTheme
import co.electriccoin.zcash.ui.design.util.stringRes
import co.electriccoin.zcash.ui.fixture.BalanceStateFixture
import co.electriccoin.zcash.ui.fixture.WalletSnapshotFixture
import co.electriccoin.zcash.ui.fixture.ZashiMainTopAppBarStateFixture
@ -148,7 +151,17 @@ class SendViewTestSetup(
isHintVisible = false,
onButtonClick = {}
),
zashiMainTopAppBarState = ZashiMainTopAppBarStateFixture.new()
zashiMainTopAppBarState =
ZashiMainTopAppBarStateFixture.new(
settingsButton =
IconButtonState(
icon = R.drawable.ic_app_bar_settings,
contentDescription =
stringRes(co.electriccoin.zcash.ui.R.string.settings_menu_content_description),
) {
onSettingsCount.incrementAndGet()
}
)
)
}
}

View File

@ -15,6 +15,7 @@ import co.electriccoin.zcash.ui.design.R
import co.electriccoin.zcash.ui.design.component.AccountSwitchState
import co.electriccoin.zcash.ui.design.component.IconButtonState
import co.electriccoin.zcash.ui.design.component.ZashiMainTopAppBarState
import co.electriccoin.zcash.ui.design.util.stringRes
import co.electriccoin.zcash.ui.preference.StandardPreferenceKeys
import co.electriccoin.zcash.ui.screen.accountlist.AccountList
import kotlinx.coroutines.flow.SharingStarted
@ -65,12 +66,14 @@ class ZashiMainTopAppBarViewModel(
} else {
R.drawable.ic_app_bar_balances_hide
},
onClick = ::onShowOrHideBalancesClicked
onClick = ::onShowOrHideBalancesClicked,
contentDescription = stringRes(co.electriccoin.zcash.ui.R.string.hide_balances_content_description)
),
settingsButton =
IconButtonState(
icon = R.drawable.ic_app_bar_settings,
onClick = ::onSettingsClicked
onClick = ::onSettingsClicked,
contentDescription = stringRes(co.electriccoin.zcash.ui.R.string.settings_menu_content_description)
)
)

View File

@ -4,16 +4,28 @@ import co.electriccoin.zcash.ui.design.R
import co.electriccoin.zcash.ui.design.component.AccountSwitchState
import co.electriccoin.zcash.ui.design.component.IconButtonState
import co.electriccoin.zcash.ui.design.component.ZashiMainTopAppBarState
import co.electriccoin.zcash.ui.design.util.stringRes
object ZashiMainTopAppBarStateFixture {
fun new() =
ZashiMainTopAppBarState(
accountSwitchState =
AccountSwitchState(
accountType = ZashiMainTopAppBarState.AccountType.ZASHI,
onAccountTypeClick = {}
),
balanceVisibilityButton = IconButtonState(R.drawable.ic_app_bar_balances_hide) {},
settingsButton = IconButtonState(R.drawable.ic_app_bar_settings) {},
)
fun new(
accountSwitchState: AccountSwitchState =
AccountSwitchState(
accountType = ZashiMainTopAppBarState.AccountType.ZASHI,
onAccountTypeClick = {}
),
balanceVisibilityButton: IconButtonState =
IconButtonState(
icon = R.drawable.ic_app_bar_balances_hide,
contentDescription = stringRes(co.electriccoin.zcash.ui.R.string.hide_balances_content_description)
) {},
settingsButton: IconButtonState =
IconButtonState(
icon = R.drawable.ic_app_bar_settings,
contentDescription = stringRes(co.electriccoin.zcash.ui.R.string.settings_menu_content_description)
) {},
) = ZashiMainTopAppBarState(
accountSwitchState = accountSwitchState,
balanceVisibilityButton = balanceVisibilityButton,
settingsButton = settingsButton,
)
}