Updated on 2026-08-14

This commit is contained in:
Tangem 2024-10-16 11:59:34 +03:00
parent e77c292230
commit 42806a4d7c
4 changed files with 26 additions and 9 deletions

View file

@ -1,16 +1,22 @@
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.tangem.datasource.local.preferences.AppPreferencesStore
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.Rule
import org.junit.rules.RuleChain
import org.junit.runner.RunWith
@ -24,6 +30,9 @@ abstract class BaseTestCase : TestCase(
@Inject
lateinit var tangemSdkManager: TangemSdkManager
@Inject
lateinit var appPreferencesStore: AppPreferencesStore
@get:Rule
open val composeTestRule = createAndroidComposeRule<MainActivity>()
@ -48,9 +57,22 @@ abstract class BaseTestCase : TestCase(
hiltRule.inject()
Intents.init()
additionalBeforeSection()
runBlocking {
delay(INIT_DELAY)
}
}.after {
runBlocking {
appPreferencesStore.editData { prefs -> prefs.clear() }
}
additionalAfterSection()
Intents.release()
}
companion object {
private const val INIT_DELAY = 1000L
}
}

View file

@ -143,9 +143,6 @@ class DetailsScreenTest : BaseTestCase() {
}
}
ComposeScreen.onComposeScreen<WalletSettingsTestScreen>(composeTestRule) {
step("Assert Link more cards button does not exist") {
linkMoreCardsButton.assertIsNotDisplayed()
}
step("Assert Card Settings button is visible") {
cardSettingsButton.assertIsDisplayed()
}

View file

@ -1,6 +1,7 @@
package com.tangem.tests
import android.content.Intent.ACTION_VIEW
import androidx.test.espresso.intent.matcher.UriMatchers
import com.tangem.common.BaseTestCase
import com.tangem.common.extensions.clickWithAssertion
import com.tangem.screens.DisclaimerTestScreen
@ -9,6 +10,7 @@ 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.junit.Test
@HiltAndroidTest
@ -29,7 +31,7 @@ class StoriesTest : BaseTestCase() {
step("Assert: browser opened") {
val expectedIntent = KIntent {
hasAction(ACTION_VIEW)
hasData(NEW_BUY_WALLET_URL)
hasData { toString().startsWith(NEW_BUY_WALLET_URL) }
}
expectedIntent.intended()
device.uiDevice.pressBack()

View file

@ -39,10 +39,6 @@ internal class DefaultBlockchainSDKFactory(
private val mainScope = CoroutineScope(dispatchers.main)
private val walletManagerFactory: Flow<WalletManagerFactory?> = createWalletManagerFactory()
// TODO: [REDACTED_JIRA]
// private val walletManagerFactory: Flow<WalletManagerFactory?> by lazy(LazyThreadSafetyMode.NONE) {
// createWalletManagerFactory()
// }
override suspend fun init() {
coroutineScope {
@ -59,7 +55,7 @@ internal class DefaultBlockchainSDKFactory(
// flow3 = subscribe on feature toggles changes, TODO: [REDACTED_JIRA]
transform = walletManagerFactoryCreator::create,
)
.stateIn(scope = mainScope, started = SharingStarted.Eagerly, initialValue = null)
.stateIn(scope = mainScope, started = SharingStarted.Lazily, initialValue = null)
}
private fun CoroutineScope.updateBlockchainProviderTypes() {