Updated on 2026-08-14
This commit is contained in:
parent
37e16f38ea
commit
498718843a
8 changed files with 144 additions and 5 deletions
|
|
@ -11,6 +11,9 @@ plugins {
|
||||||
|
|
||||||
android {
|
android {
|
||||||
namespace = "com.tangem.wallet"
|
namespace = "com.tangem.wallet"
|
||||||
|
testOptions {
|
||||||
|
animationsDisabled = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations.all {
|
configurations.all {
|
||||||
|
|
@ -207,6 +210,11 @@ dependencies {
|
||||||
testImplementation(deps.test.truth)
|
testImplementation(deps.test.truth)
|
||||||
androidTestImplementation(deps.test.junit.android)
|
androidTestImplementation(deps.test.junit.android)
|
||||||
androidTestImplementation(deps.test.espresso)
|
androidTestImplementation(deps.test.espresso)
|
||||||
|
androidTestImplementation(deps.test.espresso.intents)
|
||||||
|
androidTestImplementation(deps.test.kaspresso)
|
||||||
|
androidTestImplementation(deps.test.kaspresso.compose)
|
||||||
|
androidTestImplementation(deps.test.compose.junit)
|
||||||
|
androidTestImplementation(deps.test.hamcrest)
|
||||||
|
|
||||||
/** Chucker */
|
/** Chucker */
|
||||||
debugImplementation(deps.chucker)
|
debugImplementation(deps.chucker)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.tangem.helpers.base
|
||||||
|
|
||||||
|
import android.Manifest
|
||||||
|
import androidx.compose.ui.test.junit4.createAndroidComposeRule
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
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.tap.MainActivity
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
open class BaseAutoTestCase : TestCase(
|
||||||
|
kaspressoBuilder = Kaspresso.Builder.withComposeSupport()
|
||||||
|
) {
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
open val composeTestRule = createAndroidComposeRule<MainActivity>()
|
||||||
|
|
||||||
|
@get: Rule
|
||||||
|
val grantPermissionRule: GrantPermissionRule = GrantPermissionRule.grant(
|
||||||
|
Manifest.permission.POST_NOTIFICATIONS,
|
||||||
|
Manifest.permission.CAMERA
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.tangem.screens
|
||||||
|
|
||||||
|
import androidx.compose.ui.test.SemanticsNodeInteractionsProvider
|
||||||
|
import com.tangem.tap.common.compose.resources.C
|
||||||
|
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 StoriesScreen(semanticsProvider: SemanticsNodeInteractionsProvider) :
|
||||||
|
ComposeScreen<StoriesScreen>(
|
||||||
|
semanticsProvider = semanticsProvider,
|
||||||
|
viewBuilderAction = { hasTestTag(C.Tag.STORIES_SCREEN) }
|
||||||
|
) {
|
||||||
|
|
||||||
|
val scanButton: KNode = child {
|
||||||
|
hasTestTag(C.Tag.STORIES_SCREEN_SCAN_BUTTON)
|
||||||
|
}
|
||||||
|
|
||||||
|
val orderButton: KNode = child {
|
||||||
|
hasTestTag(C.Tag.STORIES_SCREEN_ORDER_BUTTON)
|
||||||
|
}
|
||||||
|
|
||||||
|
val enableNFCAlert: KView = KView {
|
||||||
|
withId(R.id.alertTitle)
|
||||||
|
}
|
||||||
|
|
||||||
|
val cancelButton: KButton = KButton {
|
||||||
|
withId(android.R.id.button2)
|
||||||
|
}
|
||||||
|
}
|
||||||
45
app/src/androidTest/kotlin/com/tangem/tests/StoriesTest.kt
Normal file
45
app/src/androidTest/kotlin/com/tangem/tests/StoriesTest.kt
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.tangem.tests
|
||||||
|
|
||||||
|
import android.content.Intent.ACTION_VIEW
|
||||||
|
import androidx.test.espresso.intent.Intents
|
||||||
|
import com.tangem.helpers.base.BaseAutoTestCase
|
||||||
|
import com.tangem.screens.StoriesScreen
|
||||||
|
import com.tangem.tap.features.home.redux.HomeMiddleware.NEW_BUY_WALLET_URL
|
||||||
|
import io.github.kakaocup.compose.node.element.ComposeScreen
|
||||||
|
import io.github.kakaocup.kakao.intent.KIntent
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class StoriesTest : BaseAutoTestCase() {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun clickOnButtons() = before {
|
||||||
|
Intents.init()
|
||||||
|
}.after {
|
||||||
|
Intents.release()
|
||||||
|
}.run {
|
||||||
|
ComposeScreen.onComposeScreen<StoriesScreen>(composeTestRule) {
|
||||||
|
step("Click on \"Scan\" button") {
|
||||||
|
scanButton {
|
||||||
|
assertIsDisplayed()
|
||||||
|
performClick()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
step("Assert: \"Scan card\" popup opened") {
|
||||||
|
enableNFCAlert.isDisplayed()
|
||||||
|
cancelButton.click()
|
||||||
|
device.uiDevice.pressBack()
|
||||||
|
}
|
||||||
|
step("Click on \"Order\" button") {
|
||||||
|
orderButton.performClick()
|
||||||
|
}
|
||||||
|
step("Assert: browser opened") {
|
||||||
|
val expectedIntent = KIntent {
|
||||||
|
hasAction(ACTION_VIEW)
|
||||||
|
hasData(NEW_BUY_WALLET_URL)
|
||||||
|
}
|
||||||
|
expectedIntent.intended()
|
||||||
|
device.uiDevice.pressBack()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.tangem.tap.common.compose.resources
|
||||||
|
|
||||||
|
object C {
|
||||||
|
object Tag {
|
||||||
|
const val STORIES_SCREEN = "STORIES_SCREEN_CONTAINER"
|
||||||
|
const val STORIES_SCREEN_SCAN_BUTTON = "STORIES_SCREEN_SCAN_BUTTON"
|
||||||
|
const val STORIES_SCREEN_ORDER_BUTTON = "STORIES_SCREEN_ORDER_BUTTON"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -15,11 +15,13 @@ import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
import androidx.compose.ui.input.pointer.pointerInput
|
import androidx.compose.ui.input.pointer.pointerInput
|
||||||
import androidx.compose.ui.layout.ContentScale
|
import androidx.compose.ui.layout.ContentScale
|
||||||
|
import androidx.compose.ui.platform.testTag
|
||||||
import androidx.compose.ui.res.painterResource
|
import androidx.compose.ui.res.painterResource
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||||
import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider
|
import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameterProvider
|
||||||
import com.tangem.core.ui.res.TangemTheme
|
import com.tangem.core.ui.res.TangemTheme
|
||||||
|
import com.tangem.tap.common.compose.resources.C
|
||||||
import com.tangem.tap.features.home.compose.content.*
|
import com.tangem.tap.features.home.compose.content.*
|
||||||
import com.tangem.tap.features.home.compose.views.HomeButtons
|
import com.tangem.tap.features.home.compose.views.HomeButtons
|
||||||
import com.tangem.tap.features.home.compose.views.SearchCurrenciesButton
|
import com.tangem.tap.features.home.compose.views.SearchCurrenciesButton
|
||||||
|
|
@ -55,7 +57,7 @@ fun StoriesScreen(
|
||||||
}
|
}
|
||||||
|
|
||||||
StoriesScreenContent(
|
StoriesScreenContent(
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize().testTag(C.Tag.STORIES_SCREEN),
|
||||||
config = StoriesScreenContentConfig(
|
config = StoriesScreenContentConfig(
|
||||||
storiesSize = state.stories.lastIndex,
|
storiesSize = state.stories.lastIndex,
|
||||||
currentStoryIndex = currentStoryIndex,
|
currentStoryIndex = currentStoryIndex,
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.graphics.Color
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.platform.testTag
|
||||||
import androidx.compose.ui.res.stringResource
|
import androidx.compose.ui.res.stringResource
|
||||||
import androidx.compose.ui.tooling.preview.Preview
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||||
|
|
@ -15,6 +16,7 @@ import androidx.compose.ui.tooling.preview.datasource.CollectionPreviewParameter
|
||||||
import com.tangem.core.ui.components.SpacerW12
|
import com.tangem.core.ui.components.SpacerW12
|
||||||
import com.tangem.core.ui.components.buttons.common.TangemButtonIconPosition
|
import com.tangem.core.ui.components.buttons.common.TangemButtonIconPosition
|
||||||
import com.tangem.core.ui.res.TangemTheme
|
import com.tangem.core.ui.res.TangemTheme
|
||||||
|
import com.tangem.tap.common.compose.resources.C
|
||||||
import com.tangem.wallet.R
|
import com.tangem.wallet.R
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
|
|
@ -29,13 +31,17 @@ internal fun HomeButtons(
|
||||||
modifier = modifier,
|
modifier = modifier,
|
||||||
) {
|
) {
|
||||||
ScanCardButton(
|
ScanCardButton(
|
||||||
modifier = Modifier.weight(weight = 1f),
|
modifier = Modifier
|
||||||
|
.weight(weight = 1f)
|
||||||
|
.testTag(C.Tag.STORIES_SCREEN_SCAN_BUTTON),
|
||||||
showProgress = btnScanStateInProgress,
|
showProgress = btnScanStateInProgress,
|
||||||
onClick = onScanButtonClick,
|
onClick = onScanButtonClick,
|
||||||
)
|
)
|
||||||
SpacerW12()
|
SpacerW12()
|
||||||
OrderCardButton(
|
OrderCardButton(
|
||||||
modifier = Modifier.weight(weight = 1f),
|
modifier = Modifier
|
||||||
|
.weight(weight = 1f)
|
||||||
|
.testTag(C.Tag.STORIES_SCREEN_ORDER_BUTTON),
|
||||||
onClick = onShopButtonClick,
|
onClick = onShopButtonClick,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -97,11 +97,16 @@ detekt = "1.22.0"
|
||||||
# endregion Tools
|
# endregion Tools
|
||||||
|
|
||||||
# region Testing
|
# region Testing
|
||||||
espresso = "3.4.0"
|
espresso = "3.5.1"
|
||||||
|
espresso-intents = "3.5.1"
|
||||||
junit = "4.13.2"
|
junit = "4.13.2"
|
||||||
junitAndroidExt = "1.1.3"
|
junitAndroidExt = "1.1.5"
|
||||||
mockk = "1.13.4"
|
mockk = "1.13.4"
|
||||||
truth = "1.1.3"
|
truth = "1.1.3"
|
||||||
|
kaspresso = "1.5.4"
|
||||||
|
kaspresso-compose = "1.5.4"
|
||||||
|
compose-junit = "1.6.2"
|
||||||
|
hamcrest = "2.2"
|
||||||
# endregion Testing
|
# endregion Testing
|
||||||
|
|
||||||
[plugins]
|
[plugins]
|
||||||
|
|
@ -183,10 +188,15 @@ detekt-formatting = { module = "io.gitlab.arturbosch.detekt:detekt-formatting",
|
||||||
# region Test
|
# region Test
|
||||||
test-coroutine = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutine" }
|
test-coroutine = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-test", version.ref = "coroutine" }
|
||||||
test-espresso = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso" }
|
test-espresso = { module = "androidx.test.espresso:espresso-core", version.ref = "espresso" }
|
||||||
|
test-espresso-intents = { module = "androidx.test.espresso:espresso-intents", version.ref = "espresso-intents" }
|
||||||
test-junit = { module = "junit:junit", version.ref = "junit" }
|
test-junit = { module = "junit:junit", version.ref = "junit" }
|
||||||
test-junit-android = { module = "androidx.test.ext:junit", version.ref = "junitAndroidExt" }
|
test-junit-android = { module = "androidx.test.ext:junit", version.ref = "junitAndroidExt" }
|
||||||
test-truth = { module = "com.google.truth:truth", version.ref = "truth" }
|
test-truth = { module = "com.google.truth:truth", version.ref = "truth" }
|
||||||
test-mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
|
test-mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
|
||||||
|
test-kaspresso = { module = "com.kaspersky.android-components:kaspresso", version.ref = "kaspresso" }
|
||||||
|
test-kaspresso-compose = { module = "com.kaspersky.android-components:kaspresso-compose-support", version.ref = "kaspresso-compose"}
|
||||||
|
test-compose-junit = { module = "androidx.compose.ui:ui-test-junit4", version.ref = "compose-junit" }
|
||||||
|
test-hamcrest = { module = "org.hamcrest:hamcrest", version.ref = "hamcrest" }
|
||||||
# endregion Test
|
# endregion Test
|
||||||
|
|
||||||
# region Other
|
# region Other
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue