Updated on 2026-08-14
This commit is contained in:
parent
e94298dd23
commit
9625042e8d
24 changed files with 317 additions and 467 deletions
|
|
@ -1,78 +1,66 @@
|
|||
package com.tangem.common
|
||||
|
||||
import android.Manifest
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import androidx.compose.ui.test.junit4.createAndroidComposeRule
|
||||
import androidx.test.espresso.intent.Intents
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.rule.GrantPermissionRule
|
||||
import com.kaspersky.components.composesupport.config.withComposeSupport
|
||||
import com.kaspersky.kaspresso.kaspresso.Kaspresso
|
||||
import com.kaspersky.kaspresso.testcases.api.testcase.TestCase
|
||||
import com.atiurin.ultron.core.compose.config.UltronComposeConfig
|
||||
import com.atiurin.ultron.core.compose.createUltronComposeRule
|
||||
import com.atiurin.ultron.core.compose.listeners.ComposDebugListener
|
||||
import com.atiurin.ultron.core.config.UltronCommonConfig
|
||||
import com.atiurin.ultron.core.config.UltronConfig
|
||||
import com.atiurin.ultron.core.test.UltronTest
|
||||
import com.tangem.datasource.local.preferences.AppPreferencesStore
|
||||
import com.tangem.sdk.api.TangemSdkManager
|
||||
import com.tangem.tap.MainActivity
|
||||
import com.tangem.tap.domain.sdk.TangemSdkManager
|
||||
import dagger.hilt.android.testing.HiltAndroidRule
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import org.junit.BeforeClass
|
||||
import org.junit.Rule
|
||||
import org.junit.rules.RuleChain
|
||||
import org.junit.runner.RunWith
|
||||
import javax.inject.Inject
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
abstract class BaseTestCase : TestCase(
|
||||
kaspressoBuilder = Kaspresso.Builder.withComposeSupport()
|
||||
) {
|
||||
|
||||
abstract class BaseTestCase : UltronTest() {
|
||||
@Inject
|
||||
lateinit var tangemSdkManager: TangemSdkManager
|
||||
|
||||
@Inject
|
||||
lateinit var appPreferencesStore: AppPreferencesStore
|
||||
|
||||
@get:Rule
|
||||
open val composeTestRule = createAndroidComposeRule<MainActivity>()
|
||||
|
||||
@get:Rule
|
||||
@get:Rule(order = 0)
|
||||
val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||
Manifest.permission.POST_NOTIFICATIONS,
|
||||
Manifest.permission.CAMERA
|
||||
)
|
||||
@get:Rule(order = 1)
|
||||
val hiltRule = HiltAndroidRule(this)
|
||||
|
||||
private val hiltRule = HiltAndroidRule(this)
|
||||
@get:Rule (order = 2)
|
||||
val injectionRule = ApplicationInjectionExecutionRule()
|
||||
|
||||
@Rule
|
||||
@JvmField
|
||||
val ruleChain = RuleChain
|
||||
.outerRule(hiltRule)
|
||||
.around(ApplicationInjectionExecutionRule())
|
||||
@get:Rule(order = 3)
|
||||
val composeRule = createUltronComposeRule<MainActivity>()
|
||||
|
||||
protected fun setupHooks(
|
||||
additionalBeforeSection: () -> Unit = {},
|
||||
additionalAfterSection: () -> Unit = {},
|
||||
) = before {
|
||||
override val beforeTest: () -> Unit = {
|
||||
hiltRule.inject()
|
||||
Intents.init()
|
||||
additionalBeforeSection()
|
||||
|
||||
runBlocking {
|
||||
delay(INIT_DELAY)
|
||||
}
|
||||
}
|
||||
|
||||
}.after {
|
||||
override val afterTest: () -> Unit = {
|
||||
runBlocking {
|
||||
appPreferencesStore.editData { prefs -> prefs.clear() }
|
||||
}
|
||||
|
||||
additionalAfterSection()
|
||||
Intents.release()
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val INIT_DELAY = 1000L
|
||||
}
|
||||
@BeforeClass
|
||||
@JvmStatic
|
||||
fun config() {
|
||||
UltronConfig.applyRecommended()
|
||||
UltronComposeConfig.applyRecommended()
|
||||
UltronCommonConfig.addListener(ComposDebugListener())
|
||||
}
|
||||
|
||||
private const val INIT_DELAY = 2000L
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package com.tangem.common.di
|
||||
|
||||
import android.content.Context
|
||||
import com.tangem.sdk.api.TangemSdkManager
|
||||
import com.tangem.tap.di.TangemSdkManagerModule
|
||||
import com.tangem.tap.domain.sdk.impl.MockTangemSdkManager
|
||||
import com.tangem.tap.domain.sdk.TangemSdkManager
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
package com.tangem.common.extensions
|
||||
|
||||
import io.github.kakaocup.compose.node.element.KNode
|
||||
|
||||
fun KNode.clickWithAssertion() {
|
||||
assertIsDisplayed()
|
||||
performClick()
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.tangem.common.extensions
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
|
||||
object TestDataUtils {
|
||||
fun getResourceString(resourceId: Int): String {
|
||||
return InstrumentationRegistry.getInstrumentation().targetContext.resources.getString(resourceId)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
package com.tangem.scenarios
|
||||
|
||||
import com.atiurin.ultron.allure.step.step
|
||||
import com.atiurin.ultron.extensions.assertIsDisplayed
|
||||
import com.atiurin.ultron.extensions.click
|
||||
import com.tangem.domain.models.scan.ProductType
|
||||
import com.tangem.screens.DisclaimerPage
|
||||
import com.tangem.screens.MainPage
|
||||
import com.tangem.screens.StoriesPage
|
||||
import com.tangem.tap.domain.sdk.mocks.MockProvider
|
||||
|
||||
object MainPageScenario {
|
||||
fun open(productType: ProductType? = null) {
|
||||
if (productType != null) {
|
||||
MockProvider.setMocks(productType)
|
||||
}
|
||||
step("Click on \"Accept\" button") {
|
||||
DisclaimerPage.acceptButton.click()
|
||||
}
|
||||
step("Click on \"Scan\" button emulating scan error") {
|
||||
StoriesPage.scanButton.click()
|
||||
}
|
||||
step("Assert: main is displayed") {
|
||||
MainPage.container.assertIsDisplayed()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,44 +0,0 @@
|
|||
package com.tangem.scenarios
|
||||
|
||||
import androidx.compose.ui.test.junit4.ComposeTestRule
|
||||
import com.kaspersky.kaspresso.testcases.api.scenario.Scenario
|
||||
import com.kaspersky.kaspresso.testcases.core.testcontext.TestContext
|
||||
import com.tangem.common.extensions.clickWithAssertion
|
||||
import com.tangem.domain.models.scan.ProductType
|
||||
import com.tangem.screens.DisclaimerTestScreen
|
||||
import com.tangem.screens.MainTestScreen
|
||||
import com.tangem.screens.StoriesTestScreen
|
||||
import com.tangem.screens.TestTopBar
|
||||
import com.tangem.tap.domain.sdk.mocks.MockProvider
|
||||
import io.github.kakaocup.compose.node.element.ComposeScreen
|
||||
|
||||
class OpenMainScreenScenario(
|
||||
private val testRule: ComposeTestRule,
|
||||
private val productType: ProductType? = null,
|
||||
) : Scenario() {
|
||||
override val steps: TestContext<Unit>.() -> Unit = {
|
||||
if (productType != null) {
|
||||
MockProvider.setMocks(productType)
|
||||
}
|
||||
ComposeScreen.onComposeScreen<DisclaimerTestScreen>(testRule) {
|
||||
step("Click on \"Accept\" button") {
|
||||
acceptButton.clickWithAssertion()
|
||||
}
|
||||
}
|
||||
ComposeScreen.onComposeScreen<StoriesTestScreen>(testRule) {
|
||||
step("Click on \"Scan\" button") {
|
||||
scanButton.clickWithAssertion()
|
||||
}
|
||||
}
|
||||
ComposeScreen.onComposeScreen<MainTestScreen>(testRule) {
|
||||
step("Make sure wallet screen is visible") {
|
||||
assertIsDisplayed()
|
||||
}
|
||||
}
|
||||
ComposeScreen.onComposeScreen<TestTopBar>(testRule) {
|
||||
step("Close Markets tooltip"){
|
||||
performClick()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
16
app/src/androidTest/kotlin/com/tangem/screens/DetailsPage.kt
Normal file
16
app/src/androidTest/kotlin/com/tangem/screens/DetailsPage.kt
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
package com.tangem.screens
|
||||
|
||||
import androidx.compose.ui.test.hasText
|
||||
import com.atiurin.ultron.page.Page
|
||||
import com.tangem.common.extensions.TestDataUtils.getResourceString
|
||||
import com.tangem.wallet.R
|
||||
|
||||
object DetailsPage : Page<DetailsPage>() {
|
||||
val walletConnectButton = hasText(getResourceString(R.string.wallet_connect_title))
|
||||
val walletNameButton = hasText(getResourceString(R.string.manage_tokens_network_selector_wallet))
|
||||
val scanCardButton = hasText(getResourceString(R.string.scan_card_settings_button))
|
||||
val buyTangemButton = hasText(getResourceString(R.string.details_buy_wallet))
|
||||
val appSettingsButton = hasText(getResourceString(R.string.app_settings_title))
|
||||
val contactSupportButton = hasText(getResourceString(R.string.details_row_title_contact_to_support))
|
||||
val toSButton = hasText(getResourceString(R.string.disclaimer_title))
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
package com.tangem.screens
|
||||
|
||||
import androidx.compose.ui.test.SemanticsNodeInteractionsProvider
|
||||
import com.tangem.core.ui.test.TestTags
|
||||
import com.tangem.wallet.R
|
||||
import io.github.kakaocup.compose.node.element.ComposeScreen
|
||||
import io.github.kakaocup.compose.node.element.KNode
|
||||
import io.github.kakaocup.kakao.common.utilities.getResourceString
|
||||
|
||||
class DetailsTestScreen(semanticsProvider: SemanticsNodeInteractionsProvider) :
|
||||
ComposeScreen<DetailsTestScreen>(
|
||||
semanticsProvider = semanticsProvider,
|
||||
viewBuilderAction = { hasTestTag(TestTags.DETAILS_SCREEN) }
|
||||
) {
|
||||
|
||||
val walletConnectButton: KNode = child {
|
||||
hasTestTag(TestTags.DETAILS_SCREEN_ITEM)
|
||||
hasText(getResourceString(R.string.wallet_connect_title))
|
||||
}
|
||||
|
||||
private val walletBlock: KNode = child {
|
||||
hasTestTag(TestTags.DETAILS_SCREEN_ITEM)
|
||||
}
|
||||
|
||||
val walletNameButton: KNode = walletBlock.child {
|
||||
hasClickAction()
|
||||
hasPosition(0)
|
||||
}
|
||||
|
||||
val scanCardButton: KNode = walletBlock.child {
|
||||
hasText(getResourceString(R.string.scan_card_settings_button))
|
||||
}
|
||||
|
||||
val buyTangemButton: KNode = child {
|
||||
hasTestTag(TestTags.DETAILS_SCREEN_ITEM)
|
||||
hasText(getResourceString(R.string.details_buy_wallet))
|
||||
}
|
||||
|
||||
val appSettingsButton: KNode = child {
|
||||
hasTestTag(TestTags.DETAILS_SCREEN_ITEM)
|
||||
hasText(getResourceString(R.string.app_settings_title))
|
||||
}
|
||||
val contactSupportButton: KNode = child {
|
||||
hasTestTag(TestTags.DETAILS_SCREEN_ITEM)
|
||||
hasText(getResourceString(R.string.details_row_title_contact_to_support))
|
||||
}
|
||||
val toSButton: KNode = child {
|
||||
hasTestTag(TestTags.DETAILS_SCREEN_ITEM)
|
||||
hasText(getResourceString(R.string.disclaimer_title))
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.tangem.screens
|
||||
|
||||
import androidx.compose.ui.test.hasTestTag
|
||||
import com.atiurin.ultron.page.Page
|
||||
import com.tangem.core.ui.test.TestTags
|
||||
|
||||
object DisclaimerPage : Page<DisclaimerPage>() {
|
||||
val acceptButton = hasTestTag(TestTags.DISCLAIMER_SCREEN_ACCEPT_BUTTON)
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
package com.tangem.screens
|
||||
|
||||
import androidx.compose.ui.test.SemanticsNodeInteractionsProvider
|
||||
import com.tangem.core.ui.test.TestTags
|
||||
import io.github.kakaocup.compose.node.element.ComposeScreen
|
||||
import io.github.kakaocup.compose.node.element.KNode
|
||||
|
||||
class DisclaimerTestScreen(semanticsProvider: SemanticsNodeInteractionsProvider) :
|
||||
ComposeScreen<DisclaimerTestScreen>(
|
||||
semanticsProvider = semanticsProvider,
|
||||
viewBuilderAction = { hasTestTag(TestTags.DISCLAIMER_SCREEN_CONTAINER) }
|
||||
) {
|
||||
|
||||
val acceptButton: KNode = child {
|
||||
hasTestTag(TestTags.DISCLAIMER_SCREEN_ACCEPT_BUTTON)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.tangem.screens
|
||||
|
||||
import androidx.compose.ui.test.hasTestTag
|
||||
import com.atiurin.ultron.page.Page
|
||||
import com.tangem.core.ui.test.TestTags
|
||||
|
||||
object MainPage : Page<MainPage>() {
|
||||
val container = hasTestTag(TestTags.MAIN_SCREEN)
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
package com.tangem.screens
|
||||
|
||||
import androidx.compose.ui.test.SemanticsNodeInteractionsProvider
|
||||
import com.tangem.core.ui.test.TestTags
|
||||
import io.github.kakaocup.compose.node.element.ComposeScreen
|
||||
|
||||
class MainTestScreen(semanticsProvider: SemanticsNodeInteractionsProvider) :
|
||||
ComposeScreen<MainTestScreen>(
|
||||
semanticsProvider = semanticsProvider,
|
||||
viewBuilderAction = { hasTestTag(TestTags.MAIN_SCREEN) }
|
||||
)
|
||||
10
app/src/androidTest/kotlin/com/tangem/screens/StoriesPage.kt
Normal file
10
app/src/androidTest/kotlin/com/tangem/screens/StoriesPage.kt
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
package com.tangem.screens
|
||||
|
||||
import androidx.compose.ui.test.hasTestTag
|
||||
import com.atiurin.ultron.page.Page
|
||||
import com.tangem.core.ui.test.TestTags
|
||||
|
||||
object StoriesPage : Page<StoriesPage>() {
|
||||
val scanButton = hasTestTag(TestTags.STORIES_SCREEN_SCAN_BUTTON)
|
||||
val orderButton = hasTestTag(TestTags.STORIES_SCREEN_ORDER_BUTTON)
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
package com.tangem.screens
|
||||
|
||||
import androidx.compose.ui.test.SemanticsNodeInteractionsProvider
|
||||
import com.tangem.core.ui.test.TestTags
|
||||
import com.tangem.wallet.R
|
||||
import io.github.kakaocup.compose.node.element.ComposeScreen
|
||||
import io.github.kakaocup.compose.node.element.KNode
|
||||
import io.github.kakaocup.kakao.common.views.KView
|
||||
import io.github.kakaocup.kakao.text.KButton
|
||||
|
||||
class StoriesTestScreen(semanticsProvider: SemanticsNodeInteractionsProvider) :
|
||||
ComposeScreen<StoriesTestScreen>(
|
||||
semanticsProvider = semanticsProvider,
|
||||
viewBuilderAction = { hasTestTag(TestTags.STORIES_SCREEN) }
|
||||
) {
|
||||
|
||||
val scanButton: KNode = child {
|
||||
hasTestTag(TestTags.STORIES_SCREEN_SCAN_BUTTON)
|
||||
}
|
||||
|
||||
val orderButton: KNode = child {
|
||||
hasTestTag(TestTags.STORIES_SCREEN_ORDER_BUTTON)
|
||||
}
|
||||
|
||||
val enableNFCAlert: KView = KView {
|
||||
withId(R.id.alertTitle)
|
||||
}
|
||||
|
||||
val cancelButton: KButton = KButton {
|
||||
withId(android.R.id.button2)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
package com.tangem.screens
|
||||
|
||||
import androidx.compose.ui.test.SemanticsNodeInteractionsProvider
|
||||
import com.tangem.core.ui.test.TestTags
|
||||
import io.github.kakaocup.compose.node.element.ComposeScreen
|
||||
import io.github.kakaocup.compose.node.element.KNode
|
||||
|
||||
class TestTopBar(semanticsProvider: SemanticsNodeInteractionsProvider) :
|
||||
ComposeScreen<TestTopBar>(
|
||||
semanticsProvider = semanticsProvider,
|
||||
viewBuilderAction = { hasTestTag(TestTags.MAIN_SCREEN_TOP_BAR) }
|
||||
) {
|
||||
val moreButton: KNode = child {
|
||||
hasTestTag(TestTags.MAIN_SCREEN_MORE_BUTTON)
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
package com.tangem.screens
|
||||
|
||||
import androidx.compose.ui.test.hasTestTag
|
||||
import com.atiurin.ultron.page.Page
|
||||
import com.tangem.core.ui.test.TestTags
|
||||
|
||||
object TopBarPage : Page<TopBarPage>() {
|
||||
val moreButton = hasTestTag(TestTags.MAIN_SCREEN_MORE_BUTTON)
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.tangem.screens
|
||||
|
||||
import androidx.compose.ui.test.hasText
|
||||
import com.atiurin.ultron.page.Page
|
||||
import com.tangem.common.extensions.TestDataUtils.getResourceString
|
||||
import com.tangem.wallet.R
|
||||
|
||||
object WalletSettingsPage : Page<WalletSettingsPage>() {
|
||||
val linkMoreCardsButton = hasText(getResourceString(R.string.details_row_title_create_backup))
|
||||
val cardSettingsButton = hasText(getResourceString(R.string.card_settings_title))
|
||||
val referralProgramButton = hasText(getResourceString(R.string.details_referral_title))
|
||||
val forgetWalletButton = hasText(getResourceString(R.string.settings_forget_wallet))
|
||||
}
|
||||
|
|
@ -1,31 +0,0 @@
|
|||
package com.tangem.screens
|
||||
|
||||
import androidx.compose.ui.test.SemanticsNodeInteractionsProvider
|
||||
import com.tangem.core.ui.test.TestTags
|
||||
import com.tangem.wallet.R
|
||||
import io.github.kakaocup.compose.node.element.ComposeScreen
|
||||
import io.github.kakaocup.compose.node.element.KNode
|
||||
import io.github.kakaocup.kakao.common.utilities.getResourceString
|
||||
|
||||
class WalletSettingsTestScreen(semanticsProvider: SemanticsNodeInteractionsProvider) :
|
||||
ComposeScreen<WalletSettingsTestScreen>(
|
||||
semanticsProvider = semanticsProvider,
|
||||
viewBuilderAction = { hasTestTag(TestTags.WALLET_SETTINGS_SCREEN) }
|
||||
) {
|
||||
private val walletSettingsItem: KNode = child {
|
||||
hasTestTag(TestTags.WALLET_SETTINGS_SCREEN_ITEM)
|
||||
}
|
||||
|
||||
val linkMoreCardsButton: KNode = walletSettingsItem.child {
|
||||
hasText(getResourceString(R.string.details_row_title_create_backup))
|
||||
}
|
||||
val cardSettingsButton: KNode = walletSettingsItem.child {
|
||||
hasText(getResourceString(R.string.card_settings_title))
|
||||
}
|
||||
val referralProgramButton: KNode = walletSettingsItem.child {
|
||||
hasText(getResourceString(R.string.details_referral_title))
|
||||
}
|
||||
val forgetWalletButton: KNode = walletSettingsItem.child {
|
||||
hasText(getResourceString(R.string.settings_forget_wallet))
|
||||
}
|
||||
}
|
||||
|
|
@ -1,157 +1,138 @@
|
|||
package com.tangem.tests
|
||||
|
||||
import com.atiurin.ultron.allure.step.step
|
||||
import com.atiurin.ultron.extensions.assertIsDisplayed
|
||||
import com.atiurin.ultron.extensions.assertIsNotDisplayed
|
||||
import com.atiurin.ultron.extensions.click
|
||||
import com.tangem.common.BaseTestCase
|
||||
import com.tangem.common.extensions.clickWithAssertion
|
||||
import com.tangem.domain.models.scan.ProductType
|
||||
import com.tangem.scenarios.OpenMainScreenScenario
|
||||
import com.tangem.screens.DetailsTestScreen
|
||||
import com.tangem.screens.TestTopBar
|
||||
import com.tangem.screens.WalletSettingsTestScreen
|
||||
import com.tangem.scenarios.MainPageScenario
|
||||
import com.tangem.screens.DetailsPage
|
||||
import com.tangem.screens.TopBarPage
|
||||
import com.tangem.screens.WalletSettingsPage
|
||||
import dagger.hilt.android.testing.HiltAndroidTest
|
||||
import io.github.kakaocup.compose.node.element.ComposeScreen
|
||||
import org.junit.Test
|
||||
|
||||
@HiltAndroidTest
|
||||
class DetailsScreenTest : BaseTestCase() {
|
||||
|
||||
@Test
|
||||
fun walletWithoutBackupDetails() =
|
||||
setupHooks().run {
|
||||
scenario(OpenMainScreenScenario(composeTestRule))
|
||||
ComposeScreen.onComposeScreen<TestTopBar>(composeTestRule) {
|
||||
step("Open wallet details") {
|
||||
moreButton.clickWithAssertion()
|
||||
}
|
||||
}
|
||||
ComposeScreen.onComposeScreen<DetailsTestScreen>(composeTestRule) {
|
||||
step("Assert wallet connect button is visible") {
|
||||
walletConnectButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert scan card button is visible") {
|
||||
scanCardButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert buy Tangem card button is visible") {
|
||||
buyTangemButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert app settings button is visible") {
|
||||
appSettingsButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert contact support button is visible") {
|
||||
contactSupportButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert terms or service button is visible") {
|
||||
toSButton.assertIsDisplayed()
|
||||
}
|
||||
step("Open wallet settings screen") {
|
||||
walletNameButton.clickWithAssertion()
|
||||
}
|
||||
}
|
||||
ComposeScreen.onComposeScreen<WalletSettingsTestScreen>(composeTestRule) {
|
||||
step("Assert Link more cards button is visible") {
|
||||
linkMoreCardsButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert Card Settings button is visible") {
|
||||
cardSettingsButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert Referral program button is visible") {
|
||||
referralProgramButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert Forget wallet button is visible") {
|
||||
forgetWalletButton.assertIsDisplayed()
|
||||
}
|
||||
}
|
||||
fun walletWithoutBackupDetails() {
|
||||
MainPageScenario.open()
|
||||
step("Open wallet details") {
|
||||
TopBarPage.moreButton.click()
|
||||
}
|
||||
step("Assert wallet connect button is visible") {
|
||||
DetailsPage.walletConnectButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert scan card button is visible") {
|
||||
DetailsPage.scanCardButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert buy Tangem card button is visible") {
|
||||
DetailsPage.buyTangemButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert app settings button is visible") {
|
||||
DetailsPage.appSettingsButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert contact support button is visible") {
|
||||
DetailsPage.contactSupportButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert terms or service button is visible") {
|
||||
DetailsPage.toSButton.assertIsDisplayed()
|
||||
}
|
||||
step("Open wallet settings screen") {
|
||||
DetailsPage.walletNameButton.click()
|
||||
}
|
||||
step("Assert Link more cards button is visible") {
|
||||
WalletSettingsPage.linkMoreCardsButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert Card Settings button is visible") {
|
||||
WalletSettingsPage.cardSettingsButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert Referral program button is visible") {
|
||||
WalletSettingsPage.referralProgramButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert Forget wallet button is visible") {
|
||||
WalletSettingsPage.forgetWalletButton.assertIsDisplayed()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun wallet2Details() =
|
||||
setupHooks().run {
|
||||
scenario(OpenMainScreenScenario(composeTestRule, ProductType.Wallet2))
|
||||
ComposeScreen.onComposeScreen<TestTopBar>(composeTestRule) {
|
||||
step("Open wallet details") {
|
||||
moreButton.clickWithAssertion()
|
||||
}
|
||||
}
|
||||
ComposeScreen.onComposeScreen<DetailsTestScreen>(composeTestRule) {
|
||||
step("Assert wallet connect button is visible") {
|
||||
walletConnectButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert scan card button is visible") {
|
||||
scanCardButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert buy Tangem card button is visible") {
|
||||
buyTangemButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert app settings button is visible") {
|
||||
appSettingsButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert contact support button is visible") {
|
||||
contactSupportButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert terms or service button is visible") {
|
||||
toSButton.assertIsDisplayed()
|
||||
}
|
||||
step("Open wallet settings screen") {
|
||||
walletNameButton.clickWithAssertion()
|
||||
}
|
||||
}
|
||||
ComposeScreen.onComposeScreen<WalletSettingsTestScreen>(composeTestRule) {
|
||||
step("Assert Link more cards button does not exist") {
|
||||
linkMoreCardsButton.assertIsNotDisplayed()
|
||||
}
|
||||
step("Assert Card Settings button is visible") {
|
||||
cardSettingsButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert Referral program button is visible") {
|
||||
referralProgramButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert Forget wallet button is visible") {
|
||||
forgetWalletButton.assertIsDisplayed()
|
||||
}
|
||||
}
|
||||
fun wallet2Details() {
|
||||
MainPageScenario.open(ProductType.Wallet2)
|
||||
step("Open wallet details") {
|
||||
TopBarPage.moreButton.click()
|
||||
}
|
||||
step("Assert wallet connect button is visible") {
|
||||
DetailsPage.walletConnectButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert scan card button is visible") {
|
||||
DetailsPage.scanCardButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert buy Tangem card button is visible") {
|
||||
DetailsPage.buyTangemButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert app settings button is visible") {
|
||||
DetailsPage.appSettingsButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert contact support button is visible") {
|
||||
DetailsPage.contactSupportButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert terms or service button is visible") {
|
||||
DetailsPage.toSButton.assertIsDisplayed()
|
||||
}
|
||||
step("Open wallet settings screen") {
|
||||
DetailsPage.walletNameButton.click()
|
||||
}
|
||||
step("Assert Link more cards button does not exist") {
|
||||
WalletSettingsPage.linkMoreCardsButton.assertIsNotDisplayed()
|
||||
}
|
||||
step("Assert Card Settings button is visible") {
|
||||
WalletSettingsPage.cardSettingsButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert Referral program button is visible") {
|
||||
WalletSettingsPage.referralProgramButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert Forget wallet button is visible") {
|
||||
WalletSettingsPage.forgetWalletButton.assertIsDisplayed()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun noteDetails() =
|
||||
setupHooks().run {
|
||||
scenario(OpenMainScreenScenario(composeTestRule, ProductType.Note))
|
||||
ComposeScreen.onComposeScreen<TestTopBar>(composeTestRule) {
|
||||
step("Open wallet details") {
|
||||
moreButton.clickWithAssertion()
|
||||
}
|
||||
}
|
||||
ComposeScreen.onComposeScreen<DetailsTestScreen>(composeTestRule) {
|
||||
step("Assert wallet connect button does not exist") {
|
||||
walletConnectButton.assertIsNotDisplayed()
|
||||
}
|
||||
step("Assert scan card button is visible") {
|
||||
scanCardButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert buy Tangem card button is visible") {
|
||||
buyTangemButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert app settings button is visible") {
|
||||
appSettingsButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert contact support button is visible") {
|
||||
contactSupportButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert terms or service button is visible") {
|
||||
toSButton.assertIsDisplayed()
|
||||
}
|
||||
step("Open wallet settings screen") {
|
||||
walletNameButton.clickWithAssertion()
|
||||
}
|
||||
}
|
||||
ComposeScreen.onComposeScreen<WalletSettingsTestScreen>(composeTestRule) {
|
||||
step("Assert Card Settings button is visible") {
|
||||
cardSettingsButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert Referral program button does not exist") {
|
||||
referralProgramButton.assertIsNotDisplayed()
|
||||
}
|
||||
step("Assert Forget wallet button is visible") {
|
||||
forgetWalletButton.assertIsDisplayed()
|
||||
}
|
||||
}
|
||||
fun noteDetails() {
|
||||
MainPageScenario.open(ProductType.Note)
|
||||
step("Open wallet details") {
|
||||
TopBarPage.moreButton.click()
|
||||
}
|
||||
}
|
||||
step("Assert wallet connect button does not exist") {
|
||||
DetailsPage.walletConnectButton.assertIsNotDisplayed()
|
||||
}
|
||||
step("Assert scan card button is visible") {
|
||||
DetailsPage.scanCardButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert buy Tangem card button is visible") {
|
||||
DetailsPage.buyTangemButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert app settings button is visible") {
|
||||
DetailsPage.appSettingsButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert contact support button is visible") {
|
||||
DetailsPage.contactSupportButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert terms or service button is visible") {
|
||||
DetailsPage.toSButton.assertIsDisplayed()
|
||||
}
|
||||
step("Open wallet settings screen") {
|
||||
DetailsPage.walletNameButton.click()
|
||||
}
|
||||
step("Assert Card Settings button is visible") {
|
||||
WalletSettingsPage.cardSettingsButton.assertIsDisplayed()
|
||||
}
|
||||
step("Assert Referral program button does not exist") {
|
||||
WalletSettingsPage.referralProgramButton.assertIsNotDisplayed()
|
||||
}
|
||||
step("Assert Forget wallet button is visible") {
|
||||
WalletSettingsPage.forgetWalletButton.assertIsDisplayed()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
package com.tangem.tests
|
||||
|
||||
import com.tangem.common.BaseTestCase
|
||||
import com.tangem.scenarios.OpenMainScreenScenario
|
||||
import dagger.hilt.android.testing.HiltAndroidTest
|
||||
import org.junit.Test
|
||||
|
||||
@HiltAndroidTest
|
||||
class MainScreenTest : BaseTestCase() {
|
||||
|
||||
@Test
|
||||
fun goToMain() =
|
||||
setupHooks().run {
|
||||
scenario(OpenMainScreenScenario(composeTestRule))
|
||||
}
|
||||
}
|
||||
|
|
@ -1,40 +1,42 @@
|
|||
package com.tangem.tests
|
||||
|
||||
import com.atiurin.ultron.allure.step.step
|
||||
import com.atiurin.ultron.extensions.assertIsDisplayed
|
||||
import com.atiurin.ultron.extensions.assertIsNotDisplayed
|
||||
import com.atiurin.ultron.extensions.click
|
||||
import com.tangem.common.BaseTestCase
|
||||
import com.tangem.common.extensions.clickWithAssertion
|
||||
import com.tangem.screens.DisclaimerTestScreen
|
||||
import com.tangem.screens.MainTestScreen
|
||||
import com.tangem.screens.StoriesTestScreen
|
||||
import com.tangem.screens.DisclaimerPage
|
||||
import com.tangem.screens.MainPage
|
||||
import com.tangem.screens.StoriesPage
|
||||
import com.tangem.tap.domain.sdk.mocks.MockProvider
|
||||
import dagger.hilt.android.testing.HiltAndroidTest
|
||||
import io.github.kakaocup.compose.node.element.ComposeScreen
|
||||
import org.junit.Test
|
||||
|
||||
@HiltAndroidTest
|
||||
class ScanErrorTest : BaseTestCase() {
|
||||
|
||||
@Test
|
||||
fun goToMain() =
|
||||
setupHooks().run {
|
||||
ComposeScreen.onComposeScreen<DisclaimerTestScreen>(composeTestRule) {
|
||||
step("Click on \"Accept\" button") {
|
||||
acceptButton.clickWithAssertion()
|
||||
}
|
||||
}
|
||||
ComposeScreen.onComposeScreen<StoriesTestScreen>(composeTestRule) {
|
||||
step("Click on \"Scan\" button emulating scan error") {
|
||||
MockProvider.setEmulateError()
|
||||
scanButton.clickWithAssertion()
|
||||
}
|
||||
step("Click on \"Scan\" button again without emulating error") {
|
||||
MockProvider.resetEmulateError()
|
||||
scanButton.clickWithAssertion()
|
||||
}
|
||||
}
|
||||
ComposeScreen.onComposeScreen<MainTestScreen>(composeTestRule) {
|
||||
step("Make sure wallet screen is visible") {
|
||||
assertIsDisplayed()
|
||||
}
|
||||
}
|
||||
fun goToMain() {
|
||||
step("Click on \"Accept\" button") {
|
||||
DisclaimerPage.acceptButton.click()
|
||||
}
|
||||
step("Emulate scan error") {
|
||||
MockProvider.setEmulateError()
|
||||
}
|
||||
step("Click on \"Scan\" button emulating scan error") {
|
||||
StoriesPage.scanButton.click()
|
||||
}
|
||||
step("Assert: Error is displayed") {
|
||||
MainPage.container.assertIsNotDisplayed()
|
||||
}
|
||||
step("Emulate success scan") {
|
||||
MockProvider.resetEmulateError()
|
||||
}
|
||||
step("Click on \"Scan\" button") {
|
||||
StoriesPage.scanButton.click()
|
||||
}
|
||||
step("Assert: wallet screen is displayed") {
|
||||
MainPage.container.assertIsDisplayed()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,41 +1,36 @@
|
|||
package com.tangem.tests
|
||||
|
||||
import android.content.Intent.ACTION_VIEW
|
||||
import androidx.test.espresso.intent.matcher.UriMatchers
|
||||
import androidx.test.espresso.intent.Intents
|
||||
import androidx.test.espresso.intent.matcher.IntentMatchers.hasAction
|
||||
import androidx.test.espresso.intent.matcher.IntentMatchers.hasData
|
||||
import com.atiurin.ultron.allure.step.step
|
||||
import com.atiurin.ultron.core.config.UltronConfig.UiAutomator.Companion.uiDevice
|
||||
import com.atiurin.ultron.extensions.click
|
||||
import com.tangem.common.BaseTestCase
|
||||
import com.tangem.common.extensions.clickWithAssertion
|
||||
import com.tangem.screens.DisclaimerTestScreen
|
||||
import com.tangem.screens.StoriesTestScreen
|
||||
import com.tangem.screens.DisclaimerPage
|
||||
import com.tangem.screens.StoriesPage
|
||||
import com.tangem.tap.features.home.redux.HomeMiddleware.NEW_BUY_WALLET_URL
|
||||
import dagger.hilt.android.testing.HiltAndroidTest
|
||||
import io.github.kakaocup.compose.node.element.ComposeScreen
|
||||
import io.github.kakaocup.kakao.intent.KIntent
|
||||
import org.hamcrest.Matchers
|
||||
import org.hamcrest.core.AllOf.allOf
|
||||
import org.junit.Test
|
||||
|
||||
@HiltAndroidTest
|
||||
class StoriesTest : BaseTestCase() {
|
||||
|
||||
@Test
|
||||
fun clickOnOrderButton() =
|
||||
setupHooks().run {
|
||||
ComposeScreen.onComposeScreen<DisclaimerTestScreen>(composeTestRule) {
|
||||
step("Click on \"Accept\" button") {
|
||||
acceptButton.clickWithAssertion()
|
||||
}
|
||||
}
|
||||
ComposeScreen.onComposeScreen<StoriesTestScreen>(composeTestRule) {
|
||||
step("Click on \"Order\" button") {
|
||||
orderButton.clickWithAssertion()
|
||||
}
|
||||
step("Assert: browser opened") {
|
||||
val expectedIntent = KIntent {
|
||||
hasAction(ACTION_VIEW)
|
||||
hasData { toString().startsWith(NEW_BUY_WALLET_URL) }
|
||||
}
|
||||
expectedIntent.intended()
|
||||
device.uiDevice.pressBack()
|
||||
}
|
||||
}
|
||||
fun checkOrderButton() {
|
||||
Intents.init()
|
||||
step("Click Accept on ToS") {
|
||||
DisclaimerPage.acceptButton.click()
|
||||
}
|
||||
step("Click order button ") {
|
||||
StoriesPage.orderButton.click()
|
||||
}
|
||||
step("Assert: browser is opened ") {
|
||||
Intents.intended(allOf(hasAction(ACTION_VIEW), hasData(NEW_BUY_WALLET_URL)))
|
||||
uiDevice.pressBack()
|
||||
Intents.release()
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue