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

Commit

Permalink
Merge pull request #1064 from ILIYANGERMANOV/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ILIYANGERMANOV authored Jun 25, 2022
2 parents 2845f7c + d386713 commit 8db7727
Show file tree
Hide file tree
Showing 63 changed files with 832 additions and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +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.OnboardingFlow
import com.ivy.wallet.compose.component.OnboardingFlow
import com.ivy.wallet.io.network.IvySession
import com.ivy.wallet.io.persistence.IvyRoomDatabase
import com.ivy.wallet.io.persistence.SharedPrefs
Expand Down Expand Up @@ -123,6 +123,10 @@ abstract class IvyComposeTest {
return InstrumentationRegistry.getInstrumentation().targetContext
}

protected fun testDebug(
test: OnboardingFlow.() -> Unit
) = testWithRetry(maxAttempts = 0, test = test)

protected fun testWithRetry(
attempt: Int = 0,
maxAttempts: Int = 3,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ivy.wallet.compose.helpers
package com.ivy.wallet.compose.component

import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ivy.wallet.compose.helpers
package com.ivy.wallet.compose.component

import androidx.compose.ui.test.*
import com.ivy.wallet.compose.IvyComposeTestRule
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.ivy.wallet.compose.component

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

open class ItemStatisticScreen(
protected val composeTestRule: IvyComposeTestRule
) {

private fun clickDelete(): DeleteConfirmationModal {
composeTestRule.onNodeWithTag("delete_button")
.performClick()
return DeleteConfirmationModal(composeTestRule)
}

fun <N> clickEdit(next: N): N {
composeTestRule.onNodeWithText("Edit")
.performClick()
return next
}

fun <N> clickClose(next: N): N {
composeTestRule.onNodeWithTag("toolbar_close")
.performScrollTo()
.performClick()
return next
}

fun clickUpcoming(): ItemStatisticScreen {
composeTestRule.onNodeWithTag(
testTag = "upcoming_title",
useUnmergedTree = true
).performClick()
return this
}

fun clickTransactionSkip(): ItemStatisticScreen =
scrollNextUntilFound(itemStatsLazyColumn()) {
composeTestRule.onNode(
hasText("Skip")
.and(hasAnyAncestor(hasTestTag("transaction_card")))
)
.performScrollTo()
.performClick()

this
}

fun clickTransactionPay(): ItemStatisticScreen =
scrollNextUntilFound(itemStatsLazyColumn()) {
composeTestRule.onNode(
hasText("Pay")
.and(hasAnyAncestor(hasTestTag("transaction_card")))
)
.performScrollTo()
.performClick()

this
}

fun assertBalance(
balance: String,
balanceDecimal: String,
currency: String
): ItemStatisticScreen {
composeTestRule.onNodeWithTag("balance")
.assertTextEquals(currency, balance, balanceDecimal)
return this
}

fun <T> deleteItem(next: T): T {
return clickDelete()
.confirmDelete(next = next)
}

fun itemStatsLazyColumn() = composeTestRule.onNodeWithTag("item_stats_lazy_column")
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.ivy.wallet.compose.helpers
package com.ivy.wallet.compose.component

import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import com.ivy.wallet.compose.IvyComposeTestRule
import com.ivy.wallet.compose.clickWithRetry
import com.ivy.wallet.compose.component.home.HomeTab

class OnboardingFlow(
private val composeTestRule: IvyComposeTestRule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ivy.wallet.compose.helpers
package com.ivy.wallet.compose.component

import androidx.compose.ui.test.*
import com.ivy.wallet.compose.IvyComposeTestRule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ivy.wallet.compose.helpers
package com.ivy.wallet.compose.component

import androidx.compose.ui.test.*
import com.ivy.wallet.compose.IvyComposeTestRule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.ivy.wallet.compose.helpers
package com.ivy.wallet.compose.component.account

import androidx.compose.ui.graphics.Color
import androidx.compose.ui.test.*
import com.ivy.wallet.compose.IvyComposeTestRule
import com.ivy.wallet.compose.component.amountinput.AmountInput
import com.ivy.wallet.compose.component.amountinput.IvyAmountInput
import com.ivy.wallet.compose.component.picker.*

class AccountModal(
private val composeTestRule: IvyComposeTestRule
Expand Down Expand Up @@ -56,7 +59,7 @@ class AccountModal(
}

override fun chooseIcon(icon: String): AccountModal {
ChooseIconFlow(composeTestRule).chooseIcon(icon)
IvyIconPicker(composeTestRule).chooseIcon(icon)
return this
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.ivy.wallet.compose.helpers
package com.ivy.wallet.compose.component.account

import androidx.compose.ui.graphics.Color
import androidx.compose.ui.test.*
import com.ivy.wallet.compose.IvyComposeTestRule
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(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ivy.wallet.compose.helpers
package com.ivy.wallet.compose.component.amountinput

import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ivy.wallet.compose.helpers
package com.ivy.wallet.compose.component.amountinput

import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.hasText
Expand All @@ -10,13 +10,13 @@ open class IvyAmountInput(
protected val composeTestRule: IvyComposeTestRule
) {
//TODO: Refactor this method
open fun <T> enterNumber(
open fun <N> enterNumber(
number: String,
next: T,
next: N,

onCalculator: Boolean = false,
autoPressNonCalculator: Boolean = true,
): T {
): N {
composeTestRule.waitForIdle()

for (char in number) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package com.ivy.wallet.compose.helpers
package com.ivy.wallet.compose.component.budget

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.component.amountinput.AmountInput
import com.ivy.wallet.compose.component.amountinput.IvyAmountInput

class BudgetModal(
private val composeTestRule: IvyComposeTestRule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ivy.wallet.compose.helpers
package com.ivy.wallet.compose.component.budget

import androidx.compose.ui.test.*
import com.ivy.wallet.compose.IvyComposeTestRule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package com.ivy.wallet.compose.helpers
package com.ivy.wallet.compose.component.category

import androidx.compose.ui.graphics.Color
import androidx.compose.ui.test.*
import com.ivy.wallet.compose.IvyComposeTestRule
import com.ivy.wallet.compose.component.ItemStatisticScreen
import com.ivy.wallet.compose.component.ReorderModal

class CategoriesScreen(
private val composeTestRule: IvyComposeTestRule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package com.ivy.wallet.compose.helpers
package com.ivy.wallet.compose.component.category

import androidx.compose.ui.graphics.Color
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performTextReplacement
import com.ivy.wallet.compose.IvyComposeTestRule
import com.ivy.wallet.compose.component.picker.ColorPicker
import com.ivy.wallet.compose.component.picker.IconPicker
import com.ivy.wallet.compose.component.picker.IvyColorPicker
import com.ivy.wallet.compose.component.picker.IvyIconPicker

class CategoryModal(
private val composeTestRule: IvyComposeTestRule
Expand Down Expand Up @@ -38,7 +42,7 @@ class CategoryModal(
}

override fun chooseIcon(icon: String): CategoryModal {
ChooseIconFlow(composeTestRule).chooseIcon(icon)
IvyIconPicker(composeTestRule).chooseIcon(icon)
return this
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ivy.wallet.compose.helpers
package com.ivy.wallet.compose.component.edittrn

import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.hasText
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.ivy.wallet.compose.helpers
package com.ivy.wallet.compose.component.edittrn

import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.performClick
import com.ivy.wallet.compose.IvyComposeTestRule
import com.ivy.wallet.compose.component.amountinput.IvyAmountInput

open class TransactionAmountInput(
composeTestRule: IvyComposeTestRule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.ivy.wallet.compose.helpers
package com.ivy.wallet.compose.component.edittrn.screen

import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import com.ivy.wallet.compose.IvyComposeTestRule
import com.ivy.wallet.compose.component.edittrn.ChooseCategoryModal

class IncomeExpenseScreen(
composeTestRule: IvyComposeTestRule
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package com.ivy.wallet.compose.helpers
package com.ivy.wallet.compose.component.edittrn.screen

import androidx.compose.ui.test.*
import com.ivy.wallet.compose.IvyComposeTestRule
import com.ivy.wallet.compose.component.DeleteConfirmationModal
import com.ivy.wallet.compose.component.amountinput.IvyAmountInput
import com.ivy.wallet.compose.component.edittrn.TransactionAmountInput
import com.ivy.wallet.compose.hideKeyboard

open class TransactionScreen(
abstract class TransactionScreen(
protected val composeTestRule: IvyComposeTestRule
) {
fun editAmount(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ivy.wallet.compose.helpers
package com.ivy.wallet.compose.component.edittrn.screen

import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.hasText
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.ivy.wallet.compose.component.external

import com.ivy.wallet.compose.IvyComposeTestRule
import com.ivy.wallet.compose.util.printTree

class CalendarDialog(
private val composeTestRule: IvyComposeTestRule
) {
//TODO: Find a way to pick a date from the material Calendar dialog

fun print() {
composeTestRule.printTree(useUnmergedTree = true)
}
}
Original file line number Diff line number Diff line change
@@ -1,32 +1,35 @@
package com.ivy.wallet.compose.helpers
package com.ivy.wallet.compose.component.home

import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.onNodeWithText
import com.ivy.wallet.compose.IvyComposeTestRule
import com.ivy.wallet.compose.clickWithRetry
import com.ivy.wallet.compose.component.edittrn.screen.IncomeExpenseScreen
import com.ivy.wallet.compose.component.edittrn.screen.TransferScreen
import com.ivy.wallet.compose.component.planned.EditPlannedScreen
import com.ivy.wallet.compose.performClickWithRetry

class AddFABMenu(
private val composeTestRule: IvyComposeTestRule
) {
fun clickAddIncome(): TransactionScreen {
fun clickAddIncome(): IncomeExpenseScreen {
composeTestRule.clickWithRetry(
node = composeTestRule.onNode(hasText("ADD INCOME")),
maxRetries = 3
)
return TransactionScreen(composeTestRule)
return IncomeExpenseScreen(composeTestRule)
}

fun clickAddExpense(): TransactionScreen {
fun clickAddExpense(): IncomeExpenseScreen {
composeTestRule.onNode(hasText("ADD EXPENSE"))
.performClickWithRetry(composeTestRule)
return TransactionScreen(composeTestRule)
return IncomeExpenseScreen(composeTestRule)
}

fun clickAddTransfer(): TransactionScreen {
fun clickAddTransfer(): TransferScreen {
composeTestRule.onNode(hasText("ACCOUNT TRANSFER"))
.performClickWithRetry(composeTestRule)
return TransactionScreen(composeTestRule)
return TransferScreen(composeTestRule)
}

fun clickAddPlannedPayment(): EditPlannedScreen {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package com.ivy.wallet.compose.helpers
package com.ivy.wallet.compose.component.home

import androidx.compose.ui.test.*
import com.ivy.wallet.compose.IvyComposeTestRule
import com.ivy.wallet.compose.printTree
import com.ivy.wallet.compose.component.DonateScreen
import com.ivy.wallet.compose.component.budget.BudgetsScreen
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.util.printTree

class HomeMoreMenu(
private val composeTestRule: IvyComposeTestRule
Expand Down
Loading

0 comments on commit 8db7727

Please sign in to comment.