Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Fix EditTransaction() test
Browse files Browse the repository at this point in the history
  • Loading branch information
ILIYANGERMANOV committed Apr 28, 2022
1 parent 71e812d commit 5098967
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 8 deletions.
38 changes: 30 additions & 8 deletions app/src/androidTest/java/com/ivy/wallet/compose/helpers/HomeTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.activity.ComponentActivity
import androidx.compose.ui.test.*
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.test.ext.junit.rules.ActivityScenarioRule
import com.ivy.wallet.compose.printTree

class HomeTab<A : ComponentActivity>(
private val composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<A>, A>
Expand All @@ -24,25 +25,46 @@ class HomeTab<A : ComponentActivity>(
account: String? = null,
category: String? = null
) {
var matcher = hasTestTag("transaction_card")
.and(hasText(amount))
var matcher = hasTestTag("type_amount_currency")
.and(hasAnyDescendant(hasText(amount)))

if (account != null) {
matcher = matcher.and(hasAnyDescendant(hasText(account)))
matcher = matcher.and(
hasAnySibling(
hasAnyDescendant(
hasText(account)
)
)
)
}

if (category != null) {
matcher = matcher.and(hasAnyDescendant(hasText(category)))
matcher = matcher.and(
hasAnySibling(
hasAnyDescendant(
hasText(category)
)
)
)
}

if (title != null) {
matcher = matcher.and(hasText(title))
matcher = matcher.and(
hasAnySibling(
hasText(title)
)
)
}

composeTestRule.onNode(matcher)
composeTestRule.printTree(
useUnmergedTree = true
)

composeTestRule.onNode(
matcher = matcher,
useUnmergedTree = true
)
.assertIsDisplayed()
.assertHasClickAction()
.performScrollTo()
.performClick()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ fun TypeAmountCurrency(
) {

Row(
modifier = Modifier.testTag("type_amount_currency"),
verticalAlignment = Alignment.CenterVertically
) {
Spacer(Modifier.width(24.dp))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.ivy.design.l0_system.UI
Expand Down Expand Up @@ -76,6 +77,7 @@ fun AmountCurrencyB1(
val shortAmount = shortenBigNumbers && shouldShortAmount(amount)

Text(
modifier = Modifier.testTag("amount_currency_b1"),
text = if (shortAmount) shortenAmount(amount) else amount.format(currency),
style = UI.typo.nB1.style(
fontWeight = amountFontWeight,
Expand Down

0 comments on commit 5098967

Please sign in to comment.