Updated on 2026-08-14

This commit is contained in:
Tangem 2026-07-16 14:05:08 +03:00
parent bff165de00
commit 62c5b2a557
7 changed files with 48 additions and 12 deletions

View file

@ -13,24 +13,37 @@ fun BaseTestCase.checkSendWarning(
) {
val assertDisplay = if (isDisplayed) "displayed" else "not displayed"
// When we expect the warning to be absent, it may still be finishing its disappear animation right after the
// Confirm screen opens (e.g. after re-entering a valid address), so poll the Compose tree until it is actually
// gone instead of asserting once. When we expect it to be present, assert straight away.
fun assertWarning(block: () -> Unit) {
if (isDisplayed) block() else awaitSuccess(block = block)
}
step("Assert 'Send confirm screen' is displayed") {
onSendConfirmScreen {
appBarTitle.assertIsDisplayed()
}
}
step("Assert warning title is $assertDisplay") {
onSendConfirmScreen {
warningTitle(title).assertVisibility(isDisplayed)
assertWarning {
onSendConfirmScreen {
warningTitle(title).assertVisibility(isDisplayed)
}
}
}
step("Assert warning icon is $assertDisplay") {
onSendConfirmScreen {
sendWarningIcon(message).assertVisibility(isDisplayed)
assertWarning {
onSendConfirmScreen {
sendWarningIcon(message).assertVisibility(isDisplayed)
}
}
}
step("Assert warning message is $assertDisplay") {
onSendConfirmScreen {
sendWarningMessage(message).assertVisibility(isDisplayed)
assertWarning {
onSendConfirmScreen {
sendWarningMessage(message).assertVisibility(isDisplayed)
}
}
}
if (sendButtonIsDisabled)
@ -41,8 +54,10 @@ fun BaseTestCase.checkSendWarning(
}
else
step("Assert 'Send' button is enabled") {
onSendConfirmScreen {
sendButton.assertIsEnabled()
awaitSuccess {
onSendConfirmScreen {
sendButton.assertIsEnabled()
}
}
}
}

View file

@ -164,6 +164,16 @@ fun BaseTestCase.checkStoriesChanges() {
}
}
fun BaseTestCase.skipSwapStories() {
step("Skip 'Swap stories' screen if displayed") {
onSwapStoriesScreen {
if (closeButton.isDisplayedSafely()) {
closeButton.performClick()
}
}
}
}
fun BaseTestCase.selectFeeType(feeType: FeeType, selectedFeeAmount: String) {
step("Click on 'Select fee' icon") {
onSwapTokenScreen { selectFeeIcon.performClick() }

View file

@ -51,6 +51,11 @@ class AddFundsBottomSheetPageObject(semanticsProvider: SemanticsNodeInteractions
useUnmergedTree = true
}
fun titleWithTokenName(tokenTitle: String): KNode = child {
hasText(getResourceString(R.string.get_token_title, tokenTitle))
useUnmergedTree = true
}
fun userTokenWithTitle(tokenTitle: String): KNode = child {
hasTestTag(BuyTokenScreenTestTags.LAZY_LIST_ITEM)
hasAnyDescendant(withTestTag(TokenElementsTestTags.TOKEN_TITLE))

View file

@ -503,6 +503,9 @@ class MainScreenActionButtonsTest : BaseTestCase() {
step("Click on 'Swap' button") {
onMainScreen { swapButton.performClick() }
}
step("Skip stories if displayed") {
skipSwapStories()
}
step("Check 'Action is unavailable' dialog") {
flakySafely(WAIT_UNTIL_TIMEOUT) {
checkActionIsUnavailableDialog()

View file

@ -128,11 +128,14 @@ class TokenDetailsScreenActionButtonsTest : BaseTestCase() {
step("Click on 'Add funds' button") {
onTokenDetailsScreen { addFundsButton.clickWithAssertion() }
}
step("Assert 'Get $tokenTitle' bottom-sheet is displayed") {
onAddFundsBottomSheet { titleWithTokenName(tokenTitle).assertIsDisplayed() }
}
step("Assert 'Buy' button in bottom sheet is enabled") {
onAddFundsBottomSheet { buyButton.assertIsEnabled() }
}
step("Assert 'Swap' button in bottom sheet is not displayed") {
onAddFundsBottomSheet { swapButton.assertIsNotDisplayed() }
step("Assert 'Swap' button in bottom sheet is not enabled") {
onAddFundsBottomSheet { swapButton.assertIsNotEnabled() }
}
step("Assert 'Receive' button in bottom sheet is enabled") {
onAddFundsBottomSheet { receiveButton.assertIsEnabled() }

View file

@ -22,7 +22,7 @@ import org.junit.Test
@HiltAndroidTest
class SolanaWarningsTest : BaseTestCase() {
private val tokenName = "Solana"
private val amountToLeaveLessThanRent = "0.0016941"
private val amountToLeaveLessThanRent = "0.0372"
private val amountToLeaveGreaterThanRent = "0.0000941"
private val amountToLeaveRentOnly = "0.001689338"
private val rentAmount = "SOL 0.00089088"

View file

@ -554,7 +554,7 @@ class SwapTokenScreenWarningsTest : BaseTestCase() {
fun solanaRemainingBalanceLessThanRentAmountTest() {
val tokenTitle = "Solana"
val receiveTokenName = "USDC"
val inputAmount = "0.0016941"
val inputAmount = "0.0372"
val tokensScenarioState = "SolanaUSDC"
val rentAmount = "SOL 0.00089088"
val notificationTitle = getResourceString(R.string.send_notification_invalid_amount_title)