Skip to content

Commit

Permalink
Improve tests stability
Browse files Browse the repository at this point in the history
  • Loading branch information
Iliyan Germanov committed Nov 24, 2021
1 parent cf2c3f7 commit f785bcd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ fun ComposeTestRule.waitMillis(waitMs: Long) {
}
}

fun SemanticsNodeInteraction.performClickWithRetry(
composeTestRule: ComposeTestRule
) {
composeTestRule.clickWithRetry(
node = this,
maxRetries = 3
)
}

fun ComposeTestRule.clickWithRetry(
node: SemanticsNodeInteraction,
retryAttempt: Int = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.test.ext.junit.rules.ActivityScenarioRule
import com.ivy.wallet.compose.clickWithRetry
import com.ivy.wallet.compose.performClickWithRetry

class MainBottomBar<A : ComponentActivity>(
private val composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<A>, A>
Expand All @@ -34,22 +34,24 @@ class MainBottomBar<A : ComponentActivity>(
}

fun clickAddIncome() {
composeTestRule.onNode(hasText("ADD INCOME"))
.performClick()
composeTestRule.clickWithRetry(
node = composeTestRule.onNode(hasText("ADD INCOME")),
maxRetries = 3
)
}

fun clickAddExpense() {
composeTestRule.onNode(hasText("ADD EXPENSE"))
.performClick()
.performClickWithRetry(composeTestRule)
}

fun clickAddTransfer() {
composeTestRule.onNode(hasText("ACCOUNT TRANSFER"))
.performClick()
.performClickWithRetry(composeTestRule)
}

fun clickAddPlannedPayment() {
composeTestRule.onNodeWithText("Add planned payment")
.performClick()
.performClickWithRetry(composeTestRule)
}
}

0 comments on commit f785bcd

Please sign in to comment.