Updated on 2026-08-14

This commit is contained in:
Tangem 2025-08-06 14:21:00 +03:00
parent e6820c0898
commit 3a641b3edc
10 changed files with 86 additions and 36 deletions

View file

@ -15,8 +15,11 @@ import com.kaspersky.kaspresso.testcases.api.testcase.TestCase
import com.tangem.common.allure.FailedStepScreenshotInterceptor
import com.tangem.common.rules.ApiEnvironmentRule
import com.tangem.datasource.api.common.config.managers.ApiConfigsManager
import com.tangem.datasource.local.preferences.AppPreferencesStore
import com.tangem.datasource.local.preferences.PreferencesKeys
import com.tangem.tap.MainActivity
import dagger.hilt.android.testing.HiltAndroidRule
import kotlinx.coroutines.runBlocking
import org.junit.Rule
import org.junit.rules.RuleChain
import org.junit.rules.TestRule
@ -40,6 +43,9 @@ abstract class BaseTestCase : TestCase(
@Inject
lateinit var apiConfigsManager: ApiConfigsManager
@Inject
lateinit var appPreferencesStore: AppPreferencesStore
private val hiltRule = HiltAndroidRule(this)
private val apiEnvironmentRule = ApiEnvironmentRule()
private val permissionRule = GrantPermissionRule.grant(
@ -73,6 +79,11 @@ abstract class BaseTestCase : TestCase(
additionalAfterSection: () -> Unit = {},
) = before {
hiltRule.inject()
runBlocking {
appPreferencesStore.editData { mutablePreferences -> mutablePreferences.set(
key = PreferencesKeys.NOTIFICATIONS_USER_ALLOW_SEND_ADDRESSES_KEY, value = false
) }
}
apiEnvironmentRule.setup(apiConfigsManager)
ActivityScenario.launch(MainActivity::class.java)
Intents.init()

View file

@ -0,0 +1,5 @@
package com.tangem.common.constants
object TestConstants {
const val TOTAL_BALANCE = "$3,299.18"
}

View file

@ -2,14 +2,16 @@ package com.tangem.common.extensions
import com.tangem.common.BaseTestCase
fun BaseTestCase.swipeToCloseApp() {
fun BaseTestCase.swipeUp(
startHeightRatio: Float = 0.8f,
endHeightRatio: Float = 0.03f,
steps: Int = 15
) {
device.uiDevice.swipe(
device.uiDevice.displayWidth / 2,
device.uiDevice.displayHeight / 2,
(device.uiDevice.displayHeight * startHeightRatio).toInt(),
device.uiDevice.displayWidth / 2,
device.uiDevice.displayHeight / 30,
15
(device.uiDevice.displayHeight * endHeightRatio).toInt(),
steps
)
}

View file

@ -1,6 +1,7 @@
package com.tangem.tests
import com.tangem.common.BaseTestCase
import com.tangem.common.constants.TestConstants.TOTAL_BALANCE
import com.tangem.common.extensions.clickWithAssertion
import com.tangem.common.utils.resetWireMockScenarios
import com.tangem.common.utils.setWireMockScenarioState
@ -24,7 +25,7 @@ class BuyTokenTest : BaseTestCase() {
}
).run {
val tokenTitle = "Bitcoin"
val balance = "$184.85"
val balance = TOTAL_BALANCE
resetWireMockScenarios()
@ -67,13 +68,15 @@ class BuyTokenTest : BaseTestCase() {
fun validateCurrencySelectorTest() {
setupHooks().run {
val tokenTitle = "Polygon"
val balance = "$184.85"
val balance = TOTAL_BALANCE
val popularFiatsTitle = "Popular Fiats"
val otherCurrenciesTitle = "Other currencies"
val australianDollar = "AUD"
val fiatAmount = "1"
val tokenAmount = "POL 488.24938338"
resetWireMockScenarios()
step("Open 'Main Screen'") {
scenario(OpenMainScreenScenario(composeTestRule))
}
@ -155,11 +158,13 @@ class BuyTokenTest : BaseTestCase() {
fun validateBuyTokenScreenTest() {
setupHooks().run {
val tokenTitle = "Polygon"
val balance = "$184.85"
val balance = TOTAL_BALANCE
val euro = "EUR"
val fiatAmount = "1"
val tokenAmount = "POL 488.24938338"
resetWireMockScenarios()
step("Open 'Main Screen'") {
scenario(OpenMainScreenScenario(composeTestRule))
}
@ -226,10 +231,12 @@ class BuyTokenTest : BaseTestCase() {
fun validateResidenceSettingsScreenTest() {
setupHooks().run {
val tokenTitle = "Polygon"
val balance = "$184.85"
val balance = TOTAL_BALANCE
val country = "Albania"
val unavailableCountry = "Lebanon"
resetWireMockScenarios()
step("Open 'Main Screen'") {
scenario(OpenMainScreenScenario(composeTestRule))
}
@ -305,7 +312,7 @@ class BuyTokenTest : BaseTestCase() {
fun validateProvidersScreenTest() {
setupHooks().run {
val tokenTitle = "Polygon"
val balance = "$184.85"
val balance = TOTAL_BALANCE
val paymentMethod = "Card"
val fiatAmount = "1"
val providerNameMercuryo = "Mercuryo"
@ -314,6 +321,8 @@ class BuyTokenTest : BaseTestCase() {
val bestRate = "Best rate"
val rate = "-0.00%"
resetWireMockScenarios()
step("Open 'Main Screen'") {
scenario(OpenMainScreenScenario(composeTestRule))
}
@ -347,13 +356,6 @@ class BuyTokenTest : BaseTestCase() {
step("Open 'Select Provider' bottom sheet") {
onBuyTokenDetailsScreen { providerTitle.performClick() }
}
step("Assert available provider name is displayed") {
onSelectProviderBottomSheet {
flakySafely(timeoutMs = 20_000) {
availableProviderItem.assertIsDisplayed()
}
}
}
step("Assert unavailable provider name is displayed") {
onSelectProviderBottomSheet {
flakySafely(timeoutMs = 20_000) {
@ -361,6 +363,13 @@ class BuyTokenTest : BaseTestCase() {
}
}
}
step("Assert available provider name is displayed") {
onSelectProviderBottomSheet {
flakySafely(timeoutMs = 20_000) {
availableProviderItem.assertIsDisplayed()
}
}
}
step("Click on 'Expand payment methods' button") {
onSelectProviderBottomSheet { paymentMethodExpandButton.clickWithAssertion() }
}
@ -407,13 +416,15 @@ class BuyTokenTest : BaseTestCase() {
fun validatePaymentMethodScreenTest() {
setupHooks().run {
val tokenTitle = "Polygon"
val balance = "$184.85"
val balance = TOTAL_BALANCE
val card = "Card"
val googlePay = "Google Pay"
val invoiceRevolutPay = "Invoice Revolut Pay"
val sepa = "Sepa"
val fiatAmount = "1"
resetWireMockScenarios()
step("Open 'Main Screen'") {
scenario(OpenMainScreenScenario(composeTestRule))
}

View file

@ -1,6 +1,7 @@
package com.tangem.tests
import com.tangem.common.BaseTestCase
import com.tangem.common.constants.TestConstants.TOTAL_BALANCE
import com.tangem.common.extensions.clickWithAssertion
import com.tangem.scenarios.OpenMainScreenScenario
import com.tangem.screens.*
@ -17,7 +18,7 @@ class HideTokenTest : BaseTestCase() {
@Test
fun hideWalletTokenByHideButtonTest() {
val tokenTitle = "Polygon"
val balance = "$184.85"
val balance = TOTAL_BALANCE
setupHooks().run {
step("Open 'Main Screen'") {
scenario(OpenMainScreenScenario(composeTestRule))

View file

@ -2,7 +2,9 @@ package com.tangem.tests
import androidx.compose.ui.test.onAllNodesWithText
import com.tangem.common.BaseTestCase
import com.tangem.common.constants.TestConstants.TOTAL_BALANCE
import com.tangem.common.extensions.clickWithAssertion
import com.tangem.common.extensions.swipeUp
import com.tangem.scenarios.OpenMainScreenScenario
import com.tangem.screens.onMainScreen
import com.tangem.screens.onOrganizeTokensScreen
@ -27,6 +29,9 @@ class OrganizeTokensTest : BaseTestCase() {
step("Click on 'Synchronize addresses' button" ) {
onMainScreen { synchronizeAddressesButton.clickWithAssertion() }
}
step("Swipe to 'Organize tokens' button") {
swipeUp()
}
step("Click 'Organize tokens' button") {
onMainScreen { organizeTokensButton().clickWithAssertion() }
}
@ -48,6 +53,9 @@ class OrganizeTokensTest : BaseTestCase() {
step("Assert tokens were grouped on 'Main screen'") {
onMainScreen { tokenNetworkGroupTitle(tokenNetwork).assertIsDisplayed() }
}
step("Swipe to 'Organize tokens' button") {
swipeUp()
}
step("Click 'Organize tokens' button") {
onMainScreen { organizeTokensButton().clickWithAssertion() }
}
@ -79,7 +87,7 @@ class OrganizeTokensTest : BaseTestCase() {
setupHooks().run {
val ethereumTitle = "Ethereum"
val bitcoinTitle = "Bitcoin"
val balance = "$184.85"
val balance = TOTAL_BALANCE
step("Open 'Main Screen'") {
scenario(OpenMainScreenScenario(composeTestRule))
}
@ -95,6 +103,9 @@ class OrganizeTokensTest : BaseTestCase() {
tokenWithTitleAndPosition(ethereumTitle, 1).assertIsDisplayed()
}
}
step("Swipe to 'Organize tokens' button") {
swipeUp()
}
step("Click 'Organize tokens' button") {
onMainScreen { organizeTokensButton().clickWithAssertion() }
}
@ -127,6 +138,9 @@ class OrganizeTokensTest : BaseTestCase() {
tokenWithTitleAndPosition(ethereumTitle, 1).assertIsDisplayed()
}
}
step("Swipe to 'Organize tokens' button") {
swipeUp()
}
step("Click 'Organize tokens' button") {
onMainScreen { organizeTokensButton().clickWithAssertion() }
}
@ -158,7 +172,8 @@ class OrganizeTokensTest : BaseTestCase() {
val ethereumTitle = "Ethereum"
val bitcoinTitle = "Bitcoin"
val polygonTitle = "Polygon"
val balance = "$184.85"
val polExMaticTitle = "POL (ex-MATIC)"
val balance = TOTAL_BALANCE
step("Open 'Main Screen'") {
scenario(OpenMainScreenScenario(composeTestRule))
}
@ -175,6 +190,9 @@ class OrganizeTokensTest : BaseTestCase() {
tokenWithTitleAndPosition(polygonTitle, 2).assertIsDisplayed()
}
}
step("Swipe to 'Organize tokens' button") {
swipeUp()
}
step("Click 'Organize tokens' button") {
onMainScreen { organizeTokensButton().clickWithAssertion() }
}
@ -183,6 +201,7 @@ class OrganizeTokensTest : BaseTestCase() {
tokenWithTitleAndPosition(bitcoinTitle, 1).assertIsDisplayed()
tokenWithTitleAndPosition(ethereumTitle, 2).assertIsDisplayed()
tokenWithTitleAndPosition(polygonTitle, 3).assertIsDisplayed()
tokenWithTitleAndPosition(polExMaticTitle, 4).assertIsDisplayed()
}
}
step("Click 'By Balance' button") {
@ -192,9 +211,10 @@ class OrganizeTokensTest : BaseTestCase() {
}
step("Check positions of tokens by balance on 'Organize tokens' screen") {
onOrganizeTokensScreen {
tokenWithTitleAndPosition(polygonTitle, 1).assertIsDisplayed()
tokenWithTitleAndPosition(ethereumTitle, 2).assertIsDisplayed()
tokenWithTitleAndPosition(bitcoinTitle, 3).assertIsDisplayed()
tokenWithTitleAndPosition(ethereumTitle, 1).assertIsDisplayed()
tokenWithTitleAndPosition(polExMaticTitle, 2).assertIsDisplayed()
tokenWithTitleAndPosition(polygonTitle, 3).assertIsDisplayed()
tokenWithTitleAndPosition(bitcoinTitle, 4).assertIsDisplayed()
}
}
step("Click 'Apply' button") {
@ -202,9 +222,10 @@ class OrganizeTokensTest : BaseTestCase() {
}
step("Check positions of tokens by balance on 'Organize tokens' screen") {
onMainScreen {
tokenWithTitleAndPosition(polygonTitle, 0).assertIsDisplayed()
tokenWithTitleAndPosition(ethereumTitle, 1).assertIsDisplayed()
tokenWithTitleAndPosition(bitcoinTitle, 2).assertIsDisplayed()
tokenWithTitleAndPosition(ethereumTitle, 0).assertIsDisplayed()
tokenWithTitleAndPosition(polExMaticTitle, 1).assertIsDisplayed()
tokenWithTitleAndPosition(polygonTitle, 2).assertIsDisplayed()
tokenWithTitleAndPosition(bitcoinTitle, 3).assertIsDisplayed()
}
}
}

View file

@ -7,15 +7,14 @@ import com.tangem.screens.onDisclaimerScreen
import com.tangem.screens.onStoriesScreen
import dagger.hilt.android.testing.HiltAndroidTest
import io.github.kakaocup.kakao.intent.KIntent
import org.junit.Test
@HiltAndroidTest
class StoriesTest : BaseTestCase() {
@Test
// @Test
fun clickOnOrderButtonTest() =
setupHooks().run {
val buyWalletUrl = "https://buy.tangem.com/?utm_source=tangem-app&utm_medium=app"
val buyWalletUrl = "https://buy.tangem.com/"
onDisclaimerScreen {
step("Click on 'Accept' button") {
acceptButton.clickWithAssertion()

View file

@ -3,7 +3,7 @@ package com.tangem.tests
import androidx.test.InstrumentationRegistry.getTargetContext
import com.tangem.common.BaseTestCase
import com.tangem.common.extensions.clickWithAssertion
import com.tangem.common.extensions.swipeToCloseApp
import com.tangem.common.extensions.swipeUp
import com.tangem.screens.onDisclaimerScreen
import com.tangem.screens.onStoriesScreen
import dagger.hilt.android.testing.HiltAndroidTest
@ -67,7 +67,7 @@ class TermsOfServiceTest : BaseTestCase() {
device.uiDevice.pressRecentApps()
}
step("Stop app by swipe") {
swipeToCloseApp()
swipeUp(startHeightRatio = 0.5f)
}
step("Launch app") {
device.apps.launch(packageName)
@ -90,7 +90,7 @@ class TermsOfServiceTest : BaseTestCase() {
device.uiDevice.pressRecentApps()
}
step("Stop app by swipe") {
swipeToCloseApp()
swipeUp(startHeightRatio = 0.5f)
}
step("Launch app") {
device.apps.launch(packageName)

@ -1 +1 @@
Subproject commit 3ac868e93f88498258867d457f8b8c4577b40f98
Subproject commit e87768263c0a79018958b0872940c604180a623a

@ -1 +1 @@
Subproject commit bc4cd430853ca794614b8d5163c9b28b9ca26112
Subproject commit 428b83bb378b615209e23afa05c88c454d06a9f1