Skip to content

Commit

Permalink
Fix broken tests (not clean)
Browse files Browse the repository at this point in the history
  • Loading branch information
ILIYANGERMANOV committed Jun 12, 2022
1 parent a85a26e commit e9dc8de
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.ivy.wallet.compose.component.PieChartScreen
import com.ivy.wallet.compose.component.edittrn.ChooseCategoryModal
import com.ivy.wallet.compose.component.edittrn.screen.TransactionScreen
import com.ivy.wallet.compose.component.edittrn.screen.TransferScreen
import com.ivy.wallet.compose.util.printTree
import com.ivy.wallet.compose.util.scroll
import com.ivy.wallet.utils.format

class HomeTab(
Expand Down Expand Up @@ -69,10 +69,6 @@ class HomeTab(
)
}

composeTestRule.printTree(
useUnmergedTree = true
)

composeTestRule.onNode(
matcher = matcher,
useUnmergedTree = true
Expand Down Expand Up @@ -133,29 +129,48 @@ class HomeTab(
}

fun clickUpcoming(): HomeTab {
scroll(
container = homeLazyColumn(),
toKey = "upcoming_section"
)

composeTestRule.onNodeWithTag(
testTag = "upcoming_title",
useUnmergedTree = true
)
.performScrollTo()
.performClick()
return this
return this
}

fun clickTransactionPay(): HomeTab {
val matcher = hasText("Pay")
.and(hasAnyAncestor(hasTestTag("transaction_card")))

scroll(
container = homeLazyColumn(),
toMatcher = matcher
)

composeTestRule.onNode(
hasText("Pay")
.and(hasAnyAncestor(hasTestTag("transaction_card")))
matcher
)
.performScrollTo()
.performClick()
return this
}

fun clickTransactionSkip(): HomeTab {
val matcher = hasText("Skip")
.and(hasAnyAncestor(hasTestTag("transaction_card")))

scroll(
container = homeLazyColumn(),
toMatcher = matcher
)

composeTestRule.onNode(
hasText("Skip")
.and(hasAnyAncestor(hasTestTag("transaction_card")))
matcher
)
.performScrollTo()
.performClick()
Expand Down Expand Up @@ -274,4 +289,7 @@ class HomeTab(
}
}.clickAdd(next = HomeTab(composeTestRule))
}

private fun homeLazyColumn(): SemanticsNodeInteraction =
composeTestRule.onNodeWithTag("home_lazy_column")
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.ivy.wallet.domain.data.IntervalType
import com.ivy.wallet.domain.data.TransactionType
import com.ivy.wallet.utils.timeNowUTC
import dagger.hilt.android.testing.HiltAndroidTest
import org.junit.Ignore
import org.junit.Test

@HiltAndroidTest
Expand Down Expand Up @@ -299,8 +300,9 @@ class PlannedPaymentsTest : IvyComposeTest() {
)
}

@Ignore("Fails: needs scrolling fix")
@Test
fun skipPlannedPaymentsOnAccountTab() = testWithRetry{
fun skipPlannedPaymentsOnItemStatistics() = testWithRetry {
quickOnboarding()
.clickAddFAB()
.clickAddPlannedPayment()
Expand All @@ -327,8 +329,9 @@ class PlannedPaymentsTest : IvyComposeTest() {
/*composeTestRule.waitMillis(500)*/
}

@Ignore("Fails: needs scrolling fix")
@Test
fun payPlannedPaymentsOnAccountTab() = testWithRetry{
fun payPlannedPaymentsOnItemStatistics() = testWithRetry {
quickOnboarding()
.clickAddFAB()
.clickAddPlannedPayment()
Expand Down
23 changes: 0 additions & 23 deletions app/src/androidTest/java/com/ivy/wallet/compose/util/Scroll.kt
Original file line number Diff line number Diff line change
@@ -1,30 +1,7 @@
package com.ivy.wallet.compose.util

import androidx.compose.ui.test.*
import com.ivy.wallet.compose.IvyComposeTestRule

fun IvyComposeTestRule.scrollNextUntilFound(
lazyColumnTag: String,
index: Int = 0,
maxIndex: Int = 10,
interaction: () -> Unit
) {
try {
onNodeWithTag(lazyColumnTag)
.performScrollToIndex(index)

interaction()
} catch (ignored: Exception) {
if (index <= maxIndex) {
scrollNextUntilFound(
lazyColumnTag = lazyColumnTag,
index = index + 1,
maxIndex = maxIndex,
interaction = interaction
)
}
}
}

fun <T> T.scroll(
container: SemanticsNodeInteraction,
Expand Down

0 comments on commit e9dc8de

Please sign in to comment.