Updated on 2026-08-14
This commit is contained in:
parent
37e16f38ea
commit
498718843a
8 changed files with 144 additions and 5 deletions
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue