diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/component/account/AccountsTab.kt b/app/src/androidTest/java/com/ivy/wallet/compose/component/account/AccountsTab.kt index 387e5509f7..c6be70d185 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/component/account/AccountsTab.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/component/account/AccountsTab.kt @@ -7,7 +7,7 @@ import com.ivy.wallet.compose.component.ItemStatisticScreen import com.ivy.wallet.compose.component.ReorderModal import com.ivy.wallet.compose.component.home.MainBottomBar import com.ivy.wallet.compose.hideKeyboard -import com.ivy.wallet.compose.printTree +import com.ivy.wallet.compose.util.printTree import com.ivy.wallet.ui.theme.Ivy class AccountsTab( diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/component/home/HomeMoreMenu.kt b/app/src/androidTest/java/com/ivy/wallet/compose/component/home/HomeMoreMenu.kt index 7ae06d6601..20eec86cc7 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/component/home/HomeMoreMenu.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/component/home/HomeMoreMenu.kt @@ -8,7 +8,7 @@ import com.ivy.wallet.compose.component.category.CategoriesScreen import com.ivy.wallet.compose.component.loan.LoansScreen import com.ivy.wallet.compose.component.planned.PlannedPaymentsScreen import com.ivy.wallet.compose.component.settings.SettingsScreen -import com.ivy.wallet.compose.printTree +import com.ivy.wallet.compose.util.printTree class HomeMoreMenu( private val composeTestRule: IvyComposeTestRule diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/component/home/HomeTab.kt b/app/src/androidTest/java/com/ivy/wallet/compose/component/home/HomeTab.kt index 9aa68effe8..b65edddc00 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/component/home/HomeTab.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/component/home/HomeTab.kt @@ -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.printTree +import com.ivy.wallet.compose.util.printTree import com.ivy.wallet.utils.format class HomeTab( diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/component/loan/LoanDetailsScreen.kt b/app/src/androidTest/java/com/ivy/wallet/compose/component/loan/LoanDetailsScreen.kt index 0fad4787f2..57d4f94ce2 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/component/loan/LoanDetailsScreen.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/component/loan/LoanDetailsScreen.kt @@ -4,7 +4,7 @@ import androidx.compose.ui.test.* import com.ivy.wallet.compose.IvyComposeTestRule import com.ivy.wallet.compose.component.DeleteConfirmationModal import com.ivy.wallet.compose.component.DeleteItem -import com.ivy.wallet.compose.printTree +import com.ivy.wallet.compose.util.printTree class LoanDetailsScreen( private val composeTestRule: IvyComposeTestRule diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/ComposeTestExt.kt b/app/src/androidTest/java/com/ivy/wallet/compose/util/Logging.kt similarity index 90% rename from app/src/androidTest/java/com/ivy/wallet/compose/ComposeTestExt.kt rename to app/src/androidTest/java/com/ivy/wallet/compose/util/Logging.kt index d4610187bb..fd2e6c04a8 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/ComposeTestExt.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/util/Logging.kt @@ -1,4 +1,4 @@ -package com.ivy.wallet.compose +package com.ivy.wallet.compose.util import androidx.compose.ui.test.junit4.ComposeTestRule import androidx.compose.ui.test.onRoot diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/util/Scroll.kt b/app/src/androidTest/java/com/ivy/wallet/compose/util/Scroll.kt new file mode 100644 index 0000000000..74c253a65d --- /dev/null +++ b/app/src/androidTest/java/com/ivy/wallet/compose/util/Scroll.kt @@ -0,0 +1,51 @@ +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.scroll( + container: SemanticsNodeInteraction, + toIndex: Int +): T { + container.performScrollToIndex(index = toIndex) + return this +} + +fun T.scroll( + container: SemanticsNodeInteraction, + toKey: String +): T { + container.performScrollToKey(key = toKey) + return this +} + +fun T.scroll( + container: SemanticsNodeInteraction, + toMatcher: SemanticsMatcher +): T { + container.performScrollToNode(toMatcher) + return this +} \ No newline at end of file diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/util/Wait.kt b/app/src/androidTest/java/com/ivy/wallet/compose/util/Wait.kt new file mode 100644 index 0000000000..c1f12c3016 --- /dev/null +++ b/app/src/androidTest/java/com/ivy/wallet/compose/util/Wait.kt @@ -0,0 +1,9 @@ +package com.ivy.wallet.compose.util + +import com.ivy.wallet.compose.IvyComposeTestRule +import com.ivy.wallet.compose.waitSeconds + +fun T.waitSeconds(composeTestRule: IvyComposeTestRule, seconds: Int): T { + composeTestRule.waitSeconds(seconds.toLong()) + return this +} \ No newline at end of file diff --git a/app/src/main/java/com/ivy/wallet/ui/component/transaction/Transactions.kt b/app/src/main/java/com/ivy/wallet/ui/component/transaction/Transactions.kt index f7bd19a1f8..64db8e3433 100644 --- a/app/src/main/java/com/ivy/wallet/ui/component/transaction/Transactions.kt +++ b/app/src/main/java/com/ivy/wallet/ui/component/transaction/Transactions.kt @@ -108,7 +108,9 @@ private fun LazyListScope.upcomingSection( if (upcoming == null) return //guard if (upcoming.trns.isNotEmpty()) { - item { + item( + key = "upcoming_section" + ) { SectionDivider( expanded = upcoming.expanded, setExpanded = setExpanded, @@ -146,7 +148,9 @@ private fun LazyListScope.overdueSection( if (overdue == null) return if (overdue.trns.isNotEmpty()) { - item { + item( + key = "overdue_section" + ) { SectionDivider( expanded = overdue.expanded, setExpanded = setExpanded, diff --git a/app/src/main/java/com/ivy/wallet/ui/home/HomeTab.kt b/app/src/main/java/com/ivy/wallet/ui/home/HomeTab.kt index e73cff7b9c..83ea4f9e2b 100644 --- a/app/src/main/java/com/ivy/wallet/ui/home/HomeTab.kt +++ b/app/src/main/java/com/ivy/wallet/ui/home/HomeTab.kt @@ -12,6 +12,7 @@ import androidx.compose.ui.geometry.Offset import androidx.compose.ui.input.nestedscroll.NestedScrollConnection import androidx.compose.ui.input.nestedscroll.NestedScrollSource import androidx.compose.ui.input.nestedscroll.nestedScroll +import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp @@ -297,7 +298,8 @@ fun HomeLazyColumn( LazyColumn( modifier = Modifier .fillMaxSize() - .nestedScroll(nestedScrollConnection), + .nestedScroll(nestedScrollConnection) + .testTag("home_lazy_column"), state = listState ) { item {