Updated on 2026-08-14

This commit is contained in:
Tangem 2025-09-11 14:46:14 +05:00
parent 1755406d31
commit 410253dc5a
6 changed files with 225 additions and 25 deletions

View file

@ -4,10 +4,6 @@ import com.tangem.common.BaseTestCase
import com.tangem.common.extensions.clickWithAssertion
import com.tangem.domain.models.scan.ProductType
import com.tangem.screens.*
import com.tangem.screens.onDisclaimerScreen
import com.tangem.screens.onMainScreen
import com.tangem.screens.onMarketsTooltipScreen
import com.tangem.screens.onStoriesScreen
import com.tangem.tap.domain.sdk.mocks.MockContent
import com.tangem.tap.domain.sdk.mocks.MockProvider
import io.qameta.allure.kotlin.Allure.step
@ -47,7 +43,7 @@ fun BaseTestCase.synchronizeAddresses(balance: String) {
onMainScreen { synchronizeAddressesButton.clickWithAssertion() }
}
step("Assert wallet balance = '$balance'") {
onMainScreen { walletBalance().assertTextContains(balance) }
onMainScreen { totalBalanceText.assertTextContains(balance) }
}
}

View file

@ -3,11 +3,12 @@ package com.tangem.screens
import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.SemanticsMatcher
import androidx.compose.ui.test.SemanticsNodeInteractionsProvider
import androidx.compose.ui.test.hasAnyAncestor
import com.tangem.common.BaseTestCase
import com.tangem.common.extensions.hasLazyListItemPosition
import com.tangem.common.utils.LazyListItemNode
import com.tangem.core.ui.test.TokenElementsTestTags
import com.tangem.core.ui.test.MainScreenTestTags
import com.tangem.core.ui.test.TokenElementsTestTags
import com.tangem.core.ui.test.NotificationTestTags
import com.tangem.core.ui.utils.LazyListItemPositionSemantics
import com.tangem.feature.wallet.impl.R
@ -72,6 +73,24 @@ class MainScreenPageObject(semanticsProvider: SemanticsNodeInteractionsProvider)
useUnmergedTree = true
}
val totalBalanceContainer: KNode = child {
hasTestTag(MainScreenTestTags.WALLET_LIST_ITEM)
}
val totalBalanceMenuRenameWallet: KNode = child {
hasTestTag(MainScreenTestTags.TOTAL_BALANCE_MENU_ITEM)
hasText(getResourceString(R.string.common_rename))
}
val totalBalanceMenuDeleteWallet: KNode = child {
hasTestTag(MainScreenTestTags.TOTAL_BALANCE_MENU_ITEM)
hasText(getResourceString(R.string.common_delete))
}
val totalBalanceText: KNode = child {
hasParent(withTestTag(MainScreenTestTags.WALLET_BALANCE))
}
/**
* Find token list item with title and address
*/
@ -86,19 +105,6 @@ class MainScreenPageObject(semanticsProvider: SemanticsNodeInteractionsProvider)
}
}
/**
* Find node with wallet balance using lazyList. This construction doesn't affect next step with lazyList.
*/
@OptIn(ExperimentalTestApi::class)
fun walletBalance(): KNode {
return lazyList.childWith<LazyListItemNode> {
hasAnyDescendant(withTestTag(MainScreenTestTags.WALLET_LIST_ITEM))
}.child<KNode> {
hasTestTag(MainScreenTestTags.WALLET_BALANCE)
useUnmergedTree = true
}
}
@OptIn(ExperimentalTestApi::class)
fun organizeTokensButton(): KNode {
return lazyList.childWith<LazyListItemNode> {
@ -129,6 +135,12 @@ class MainScreenPageObject(semanticsProvider: SemanticsNodeInteractionsProvider)
}
}
fun KNode.assertIsUnreachable() {
this {
hasAnyAncestor(withText(getResourceString(R.string.common_unreachable)))
assertIsDisplayed()
}
}
/**
* This assertion is required to properly verify the token's absence in the semantic tree.

View file

@ -0,0 +1,43 @@
package com.tangem.tests.balance
import androidx.compose.ui.test.longClick
import com.tangem.common.BaseTestCase
import com.tangem.common.constants.TestConstants.TOTAL_BALANCE
import com.tangem.scenarios.openMainScreen
import com.tangem.scenarios.synchronizeAddresses
import com.tangem.screens.onMainScreen
import dagger.hilt.android.testing.HiltAndroidTest
import io.qameta.allure.kotlin.AllureId
import io.qameta.allure.kotlin.junit4.DisplayName
import org.junit.Test
@HiltAndroidTest
class TotalBalanceLongTapTest : BaseTestCase() {
@Test
@AllureId("3965")
@DisplayName("Total balance: check long tap on block without biometry")
fun whenBiometryIsOffTest() {
setupHooks().run {
step("Open 'Main Screen'") {
openMainScreen()
}
step("Synchronize addresses") {
synchronizeAddresses(TOTAL_BALANCE)
}
step("Long tap on total balance block") {
onMainScreen {
totalBalanceContainer.performTouchInput {
longClick()
}
}
}
step("Assert 'Rename' button is not displayed") {
onMainScreen { totalBalanceMenuRenameWallet.assertIsNotDisplayed() }
}
step("Assert 'Delete' button is not displayed") {
onMainScreen { totalBalanceMenuDeleteWallet.assertIsNotDisplayed() }
}
}
}
}

View file

@ -0,0 +1,145 @@
package com.tangem.tests.balance
import com.tangem.common.BaseTestCase
import com.tangem.common.utils.resetWireMockScenarioState
import com.tangem.common.utils.setWireMockScenarioState
import com.tangem.scenarios.openMainScreen
import com.tangem.scenarios.synchronizeAddresses
import com.tangem.screens.onMainScreen
import com.tangem.utils.StringsSigns.DASH_SIGN
import dagger.hilt.android.testing.HiltAndroidTest
import io.qameta.allure.kotlin.AllureId
import io.qameta.allure.kotlin.junit4.DisplayName
import org.junit.Test
@HiltAndroidTest
class TotalBalanceUnavailableTest : BaseTestCase() {
@Test
@AllureId("148")
@DisplayName("Total balance: check dash sign when addresses are not derived")
fun whenDerivationsDoesNotSyncedTest() {
setupHooks().run {
step("Open 'Main Screen'") {
openMainScreen()
}
step("Do not synchronize addresses") {
onMainScreen { synchronizeAddressesButton.assertIsDisplayed() }
}
step("Assert dash sign is displayed in total balance") {
onMainScreen { totalBalanceText.assertTextContains(DASH_SIGN) }
}
}
}
@Test
@AllureId("3993")
@DisplayName("Total balance: check dash sign when network is unreachable")
fun whenNetworkIsUnreachableTest() {
val scenarioName = "eth_network_balance"
val scenarioState = "Unreachable"
val tokenTitle = "Ethereum"
setupHooks(
additionalAfterSection = {
resetWireMockScenarioState(scenarioName)
}
).run {
step("Set WireMock scenario: '$scenarioName' to state: '$scenarioState'") {
setWireMockScenarioState(scenarioName = scenarioName, state = scenarioState)
}
step("Open 'Main Screen'") {
openMainScreen()
}
step("Synchronize addresses") {
synchronizeAddresses(DASH_SIGN)
}
step("Assert 'Synchronize addresses' button does not exist") {
onMainScreen {
flakySafely {
synchronizeAddressesButton.assertDoesNotExist()
}
}
}
step("Assert dash sign is displayed in total balance") {
onMainScreen { totalBalanceText.assertTextContains(DASH_SIGN) }
}
step("Assert $tokenTitle is unreachable") {
onMainScreen { tokenWithTitleAndPosition(tokenTitle, 1).assertIsUnreachable() }
}
}
}
@Test
@AllureId("3994")
@DisplayName("Total balance: check dash sign when quotes are failed")
fun whenQuotesAreFailedTest() {
val scenarioName = "quotes_api"
val scenarioState = "Error"
val tokenTitle = "Ethereum"
setupHooks(
additionalAfterSection = {
resetWireMockScenarioState(scenarioName)
}
).run {
step("Set WireMock scenario: '$scenarioName' to state: '$scenarioState'") {
setWireMockScenarioState(scenarioName = scenarioName, state = scenarioState)
}
step("Open 'Main Screen'") {
openMainScreen()
}
step("Synchronize addresses") {
synchronizeAddresses(DASH_SIGN)
}
step("Assert 'Synchronize addresses' button does not exist") {
onMainScreen {
flakySafely {
synchronizeAddressesButton.assertDoesNotExist()
}
}
}
step("Assert dash sign is displayed in total balance") {
onMainScreen { totalBalanceText.assertTextContains(DASH_SIGN) }
}
step("Assert $tokenTitle is unreachable") {
onMainScreen { tokenWithTitleAndPosition(tokenTitle, 1).assertIsUnreachable() }
}
}
}
@Test
@AllureId("3995")
@DisplayName("Total balance: check dash sign when added custom token without rate")
fun whenCustomTokenWithoutRateAddedTest() {
val scenarioName = "user_tokens_api"
val scenarioState = "CustomTokenAdded"
val tokenTitle = "Myria"
setupHooks(
additionalAfterSection = {
resetWireMockScenarioState(scenarioName)
}
).run {
step("Set WireMock scenario: '$scenarioName' to state: '$scenarioState'") {
setWireMockScenarioState(scenarioName = scenarioName, state = scenarioState)
}
step("Open 'Main Screen'") {
openMainScreen()
}
step("Synchronize addresses") {
synchronizeAddresses(DASH_SIGN)
}
step("Assert 'Synchronize addresses' button does not exist") {
onMainScreen {
flakySafely {
synchronizeAddressesButton.assertDoesNotExist()
}
}
}
step("Assert dash sign is displayed in total balance") {
onMainScreen { totalBalanceText.assertTextContains(DASH_SIGN) }
}
step("Assert $tokenTitle is unreachable") {
onMainScreen { tokenWithTitleAndPosition(tokenTitle, 4).assertIsUnreachable() }
}
}
}
}