diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/IvyComposeTest.kt b/app/src/androidTest/java/com/ivy/wallet/compose/IvyComposeTest.kt index a58cdaefae..17a58e6057 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/IvyComposeTest.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/IvyComposeTest.kt @@ -19,6 +19,7 @@ import androidx.work.testing.WorkManagerTestInitHelper import com.ivy.frp.test.TestIdlingResource import com.ivy.frp.test.TestingContext import com.ivy.frp.view.navigation.Navigation +import com.ivy.wallet.compose.helpers.* import com.ivy.wallet.io.network.IvySession import com.ivy.wallet.io.persistence.IvyRoomDatabase import com.ivy.wallet.io.persistence.SharedPrefs @@ -45,6 +46,20 @@ abstract class IvyComposeTest { val composeTestRule = createAndroidComposeRule() // use createAndroidComposeRule() if you need access to an activity + //---------------------------- + protected val onboarding = OnboardingFlow(composeTestRule) + protected val amountInput = AmountInput(composeTestRule) + protected val accountModal = AccountModal(composeTestRule) + protected val mainBottomBar = MainBottomBar(composeTestRule) + protected val transactionFlow = TransactionFlow(composeTestRule) + protected val homeTab = HomeTab(composeTestRule) + protected val accountsTab = AccountsTab(composeTestRule) + protected val editTransactionScreen = TransactionScreen(composeTestRule) + protected val itemStatisticScreen = ItemStatisticScreen(composeTestRule) + protected val reorderModal = ReorderModal(composeTestRule) + protected val deleteConfirmationModal = DeleteConfirmationModal(composeTestRule) + //---------------------------- + private var idlingResource: IdlingResource? = null @Inject @@ -125,10 +140,10 @@ abstract class IvyComposeTest { attempt: Int = 0, maxAttempts: Int = 3, firstFailure: Throwable? = null, - test: () -> Unit + test: OnboardingFlow.() -> Unit ) { try { - test() + onboarding.test() } catch (e: Throwable) { if (attempt < maxAttempts) { //reset state && retry test diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/helpers/DonateScreen.kt b/app/src/androidTest/java/com/ivy/wallet/compose/helpers/DonateScreen.kt new file mode 100644 index 0000000000..00f0fb1649 --- /dev/null +++ b/app/src/androidTest/java/com/ivy/wallet/compose/helpers/DonateScreen.kt @@ -0,0 +1,36 @@ +package com.ivy.wallet.compose.helpers + +import androidx.activity.ComponentActivity +import androidx.compose.ui.test.* +import androidx.compose.ui.test.junit4.AndroidComposeTestRule +import androidx.test.ext.junit.rules.ActivityScenarioRule + +class DonateScreen( + private val composeTestRule: AndroidComposeTestRule, A> +) { + + fun verifyAmount(text: String): DonateScreen { + composeTestRule.onNodeWithTag("donation_amount") + .assertTextEquals(text) + return this + } + + fun clickMinus(): DonateScreen { + composeTestRule.onNodeWithContentDescription("btn_minus") + .performClick() + return this + } + + fun clickPlus(): DonateScreen { + composeTestRule.onNodeWithContentDescription("btn_plus") + .performClick() + return this + } + + fun clickDonate(): DonateScreen { + composeTestRule.onNodeWithTag("btn_donate") + .assertIsDisplayed() + .performClick() + return this + } +} \ No newline at end of file diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/helpers/HomeMoreMenu.kt b/app/src/androidTest/java/com/ivy/wallet/compose/helpers/HomeMoreMenu.kt index eb9ad76e0b..943edd1d77 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/helpers/HomeMoreMenu.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/helpers/HomeMoreMenu.kt @@ -46,9 +46,10 @@ class HomeMoreMenu( ).assertTextContains(amount) } - fun clickSettings() { + fun clickSettings(): SettingsScreen { composeTestRule.onNodeWithText("Settings") .performClick() + return SettingsScreen(composeTestRule) } fun clickLoans() { diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/helpers/HomeTab.kt b/app/src/androidTest/java/com/ivy/wallet/compose/helpers/HomeTab.kt index b254d8bb67..3fd4d130e8 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/helpers/HomeTab.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/helpers/HomeTab.kt @@ -9,6 +9,12 @@ import com.ivy.wallet.compose.printTree class HomeTab( private val composeTestRule: AndroidComposeTestRule, A> ) { + fun openMoreMenu(): HomeMoreMenu { + composeTestRule.onNodeWithTag("home_more_menu_arrow") + .performClick() + return HomeMoreMenu(composeTestRule) + } + fun assertBalance( amount: String, diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/helpers/OnboardingFlow.kt b/app/src/androidTest/java/com/ivy/wallet/compose/helpers/OnboardingFlow.kt index 508df63856..b492d38b01 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/helpers/OnboardingFlow.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/helpers/OnboardingFlow.kt @@ -44,12 +44,13 @@ class OnboardingFlow( ) } - fun quickOnboarding() { + fun quickOnboarding(): HomeTab { chooseOfflineAccount() clickStartFresh() setCurrency() skipAccounts() skipCategories() + return HomeTab(composeTestRule) } fun onboardWith1AccountAnd1Category() { diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/helpers/SettingsScreen.kt b/app/src/androidTest/java/com/ivy/wallet/compose/helpers/SettingsScreen.kt index 5abc152fcc..e54d201ab9 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/helpers/SettingsScreen.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/helpers/SettingsScreen.kt @@ -42,4 +42,14 @@ class SettingsScreen( .performScrollTo() .performClick() } + + fun clickDonate(): DonateScreen { + composeTestRule.onNodeWithTag("settings_lazy_column") + .performScrollToIndex(4) + + composeTestRule.onNodeWithText("Donate") + .performScrollTo() + .performClick() + return DonateScreen(composeTestRule) + } } \ No newline at end of file diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/scenario/AccountsTest.kt b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/AccountsTest.kt index d673804769..0f859a4e49 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/scenario/AccountsTest.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/AccountsTest.kt @@ -2,7 +2,6 @@ package com.ivy.wallet.compose.scenario import android.icu.util.Currency import com.ivy.wallet.compose.IvyComposeTest -import com.ivy.wallet.compose.helpers.* import com.ivy.wallet.ui.theme.Blue import com.ivy.wallet.ui.theme.Purple1 import com.ivy.wallet.ui.theme.Purple2 @@ -13,23 +12,6 @@ import org.junit.Test @HiltAndroidTest class AccountsTest : IvyComposeTest() { - private val onboarding = OnboardingFlow(composeTestRule) - private val amountInput = AmountInput(composeTestRule) - private val accountModal = AccountModal(composeTestRule) - private val mainBottomBar = MainBottomBar(composeTestRule) - private val transactionFlow = TransactionFlow(composeTestRule) - private val homeTab = HomeTab(composeTestRule) - private val accountsTab = AccountsTab(composeTestRule) - private val editTransactionScreen = TransactionScreen(composeTestRule) - private val itemStatisticScreen = ItemStatisticScreen(composeTestRule) - private val reorderModal = ReorderModal(composeTestRule) - private val deleteConfirmationModal = DeleteConfirmationModal(composeTestRule) - - - @Test - fun contextLoads() { - } - @Test fun CreateAccount() = testWithRetry { onboarding.quickOnboarding() diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/scenario/BudgetsTests.kt b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/BudgetsTests.kt index 255a226a88..6aea00040f 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/scenario/BudgetsTests.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/BudgetsTests.kt @@ -1,7 +1,10 @@ package com.ivy.wallet.compose.scenario import com.ivy.wallet.compose.IvyComposeTest -import com.ivy.wallet.compose.helpers.* +import com.ivy.wallet.compose.helpers.BudgetModal +import com.ivy.wallet.compose.helpers.BudgetsScreen +import com.ivy.wallet.compose.helpers.HomeMoreMenu +import com.ivy.wallet.compose.helpers.OnboardingFlow import dagger.hilt.android.testing.HiltAndroidTest import org.junit.Test @@ -12,7 +15,6 @@ class BudgetsTests : IvyComposeTest() { private val homeMoreMenu = HomeMoreMenu(composeTestRule) private val budgetsScreen = BudgetsScreen(composeTestRule) private val budgetModal = BudgetModal(composeTestRule) - private val deleteConfirmationModal = DeleteConfirmationModal(composeTestRule) @Test fun CreateGlobalBudget() = testWithRetry { diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/scenario/CalculatorTest.kt b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/CalculatorTest.kt index 5aee0aec5e..6b5b6c2de1 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/scenario/CalculatorTest.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/CalculatorTest.kt @@ -1,16 +1,12 @@ package com.ivy.wallet.compose.scenario import com.ivy.wallet.compose.IvyComposeTest -import com.ivy.wallet.compose.helpers.* +import com.ivy.wallet.compose.helpers.TransactionScreen import dagger.hilt.android.testing.HiltAndroidTest import org.junit.Test @HiltAndroidTest class CalculatorTest : IvyComposeTest() { - private val onboarding = OnboardingFlow(composeTestRule) - private val homeTab = HomeTab(composeTestRule) - private val mainBottomBar = MainBottomBar(composeTestRule) - private val amountInput = AmountInput(composeTestRule) private val transactionScreen = TransactionScreen(composeTestRule) diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/scenario/CategoriesTest.kt b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/CategoriesTest.kt index 4a0ee18f35..b78dc08d77 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/scenario/CategoriesTest.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/CategoriesTest.kt @@ -3,7 +3,10 @@ package com.ivy.wallet.compose.scenario import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick import com.ivy.wallet.compose.IvyComposeTest -import com.ivy.wallet.compose.helpers.* +import com.ivy.wallet.compose.helpers.CategoriesScreen +import com.ivy.wallet.compose.helpers.CategoryModal +import com.ivy.wallet.compose.helpers.HomeMoreMenu +import com.ivy.wallet.compose.helpers.OnboardingFlow import com.ivy.wallet.ui.theme.Blue import com.ivy.wallet.ui.theme.Blue2 import com.ivy.wallet.ui.theme.Ivy @@ -17,9 +20,6 @@ class CategoriesTest : IvyComposeTest() { private val homeMoreMenu = HomeMoreMenu(composeTestRule) private val categoryModal = CategoryModal(composeTestRule) private val categoryScreen = CategoriesScreen(composeTestRule) - private val itemStatisticScreen = ItemStatisticScreen(composeTestRule) - private val deleteConfirmationModal = DeleteConfirmationModal(composeTestRule) - private val reorderModal = ReorderModal(composeTestRule) @Test fun contextLoads() = testWithRetry { diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/scenario/DonateTest.kt b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/DonateTest.kt new file mode 100644 index 0000000000..cd452b140a --- /dev/null +++ b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/DonateTest.kt @@ -0,0 +1,18 @@ +package com.ivy.wallet.compose.scenario + +import com.ivy.wallet.compose.IvyComposeTest +import dagger.hilt.android.testing.HiltAndroidTest +import org.junit.Test + +@HiltAndroidTest +class DonateTest : IvyComposeTest() { + @Test + fun openDonateFromSettings_donate() = testWithRetry { + quickOnboarding() + .openMoreMenu() + .clickSettings() + .clickDonate() + .verifyAmount("$5") + .clickDonate() + } +} \ No newline at end of file diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/scenario/LoansTest.kt b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/LoansTest.kt index b29a396b22..33944dc92e 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/scenario/LoansTest.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/LoansTest.kt @@ -12,12 +12,10 @@ import org.junit.Test @HiltAndroidTest class LoansTest : IvyComposeTest() { - private val onboarding = OnboardingFlow(composeTestRule) private val homeMoreMenu = HomeMoreMenu(composeTestRule) private val loansScreen = LoansScreen(composeTestRule) private val loanModal = LoanModal(composeTestRule) private val loanDetailsScreen = LoanDetailsScreen(composeTestRule) - private val deleteConfirmationModal = DeleteConfirmationModal(composeTestRule) private val loanRecordModal = LoanRecordModal(composeTestRule) @Test diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/scenario/OnboardingTest.kt b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/OnboardingTest.kt index c3d717e57c..f0fa050ea2 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/scenario/OnboardingTest.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/OnboardingTest.kt @@ -4,24 +4,14 @@ import android.icu.util.Currency import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.hasText import com.ivy.wallet.compose.IvyComposeTest -import com.ivy.wallet.compose.helpers.AccountsTab import com.ivy.wallet.compose.helpers.CurrencyPicker -import com.ivy.wallet.compose.helpers.MainBottomBar -import com.ivy.wallet.compose.helpers.OnboardingFlow import dagger.hilt.android.testing.HiltAndroidTest import org.junit.Test @HiltAndroidTest class OnboardingTest : IvyComposeTest() { - private val onboarding = OnboardingFlow(composeTestRule) private val currencyPicker = CurrencyPicker(composeTestRule) - private val mainBottomBar = MainBottomBar(composeTestRule) - private val accountsTab = AccountsTab(composeTestRule) - - @Test - fun contextLoads() { - } @Test fun OnboardingShortestPath() = testWithRetry { diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/scenario/OperationsCoreTest.kt b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/OperationsCoreTest.kt index 526d92f267..4db5f3d584 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/scenario/OperationsCoreTest.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/OperationsCoreTest.kt @@ -5,28 +5,12 @@ import androidx.compose.ui.test.hasText import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.performClick import com.ivy.wallet.compose.IvyComposeTest -import com.ivy.wallet.compose.helpers.* import dagger.hilt.android.testing.HiltAndroidTest import org.junit.Test @HiltAndroidTest class OperationsCoreTest : IvyComposeTest() { - private val onboarding = OnboardingFlow(composeTestRule) - private val amountInput = AmountInput(composeTestRule) - private val accountModal = AccountModal(composeTestRule) - private val mainBottomBar = MainBottomBar(composeTestRule) - private val transactionFlow = TransactionFlow(composeTestRule) - private val homeTab = HomeTab(composeTestRule) - private val accountsTab = AccountsTab(composeTestRule) - private val editTransactionScreen = TransactionScreen(composeTestRule) - private val itemStatisticScreen = ItemStatisticScreen(composeTestRule) - private val deleteConfirmationModal = DeleteConfirmationModal(composeTestRule) - - @Test - fun contextLoads() { - } - @Test fun OnboardAndAdjustBalance() = testWithRetry { onboarding.quickOnboarding() diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/scenario/OperationsSecondaryTest.kt b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/OperationsSecondaryTest.kt index f7b3ad97c8..c6ed095cc2 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/scenario/OperationsSecondaryTest.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/OperationsSecondaryTest.kt @@ -10,7 +10,6 @@ import org.junit.Test @HiltAndroidTest class OperationsSecondaryTest : IvyComposeTest() { private val onboardingFlow = OnboardingFlow(composeTestRule) - private val homeTab = HomeTab(composeTestRule) private val homeMoreMenu = HomeMoreMenu(composeTestRule) private val savingsGoalModal = SavingsGoalModal(composeTestRule) private val settingsScreen = SettingsScreen(composeTestRule) diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/scenario/PieChartTest.kt b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/PieChartTest.kt index 91fe7e9e99..9b78b87831 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/scenario/PieChartTest.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/PieChartTest.kt @@ -1,18 +1,12 @@ package com.ivy.wallet.compose.scenario import com.ivy.wallet.compose.IvyComposeTest -import com.ivy.wallet.compose.helpers.HomeTab -import com.ivy.wallet.compose.helpers.OnboardingFlow import com.ivy.wallet.compose.helpers.PieChartScreen -import com.ivy.wallet.compose.helpers.TransactionFlow import dagger.hilt.android.testing.HiltAndroidTest import org.junit.Test @HiltAndroidTest class PieChartTest : IvyComposeTest() { - private val onboarding = OnboardingFlow(composeTestRule) - private val homeTab = HomeTab(composeTestRule) - private val transactionFlow = TransactionFlow(composeTestRule) private val pieChartScreen = PieChartScreen(composeTestRule) @Test diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/scenario/PlannedPaymentsTest.kt b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/PlannedPaymentsTest.kt index 96642a71aa..1f849c98e9 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/scenario/PlannedPaymentsTest.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/PlannedPaymentsTest.kt @@ -3,7 +3,10 @@ package com.ivy.wallet.compose.scenario import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.performClick import com.ivy.wallet.compose.IvyComposeTest -import com.ivy.wallet.compose.helpers.* +import com.ivy.wallet.compose.helpers.EditPlannedScreen +import com.ivy.wallet.compose.helpers.HomeMoreMenu +import com.ivy.wallet.compose.helpers.OnboardingFlow +import com.ivy.wallet.compose.helpers.PlannedPaymentsScreen import com.ivy.wallet.domain.data.IntervalType import com.ivy.wallet.domain.data.TransactionType import com.ivy.wallet.utils.timeNowUTC @@ -14,11 +17,7 @@ import org.junit.Test class PlannedPaymentsTest : IvyComposeTest() { private val onboardingFlow = OnboardingFlow(composeTestRule) - private val transactionFlow = TransactionFlow(composeTestRule) private val editPlannedScreen = EditPlannedScreen(composeTestRule) - private val homeTab = HomeTab(composeTestRule) - private val mainBottomBar = MainBottomBar(composeTestRule) - private val deleteConfirmationModal = DeleteConfirmationModal(composeTestRule) private val homeMoreMenu = HomeMoreMenu(composeTestRule) private val plannedPaymentsScreen = PlannedPaymentsScreen(composeTestRule) diff --git a/app/src/main/java/com/ivy/wallet/ui/donate/DonateScreen.kt b/app/src/main/java/com/ivy/wallet/ui/donate/DonateScreen.kt index 5785b82eb9..819706e4c1 100644 --- a/app/src/main/java/com/ivy/wallet/ui/donate/DonateScreen.kt +++ b/app/src/main/java/com/ivy/wallet/ui/donate/DonateScreen.kt @@ -14,6 +14,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.platform.LocalView +import androidx.compose.ui.platform.testTag import androidx.compose.ui.res.painterResource import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.tooling.preview.Preview @@ -141,6 +142,7 @@ private fun DonateOptionPicker( SpacerHor(width = 12.dp) IvyText( + modifier = Modifier.testTag("donation_amount"), text = "$${ when (option) { DonateOption.DONATE_2 -> 2 @@ -265,7 +267,8 @@ private fun BoxWithConstraintsScope.DonateButton( bottom = true, start = false, end = false ) .padding(horizontal = 20.dp) - .padding(bottom = 16.dp), + .padding(bottom = 16.dp) + .testTag("btn_donate"), iconStart = R.drawable.ic_donate_crown, wrapContentMode = false, iconTint = UI.colors.pure, diff --git a/app/src/main/java/com/ivy/wallet/ui/settings/SettingsScreen.kt b/app/src/main/java/com/ivy/wallet/ui/settings/SettingsScreen.kt index 2b8a2bc6fc..a3a53c05e6 100644 --- a/app/src/main/java/com/ivy/wallet/ui/settings/SettingsScreen.kt +++ b/app/src/main/java/com/ivy/wallet/ui/settings/SettingsScreen.kt @@ -167,6 +167,7 @@ private fun BoxWithConstraintsScope.UI( .fillMaxSize() .statusBarsPadding() .navigationBarsPadding() + .testTag("settings_lazy_column") ) { stickyHeader { val nav = navigation()