-
Notifications
You must be signed in to change notification settings - Fork 573
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1034 from ILIYANGERMANOV/develop
Revamp UI tests
- Loading branch information
Showing
51 changed files
with
2,363 additions
and
2,446 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 43 additions & 15 deletions
58
app/src/androidTest/java/com/ivy/wallet/compose/helpers/AccountModal.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,77 @@ | ||
package com.ivy.wallet.compose.helpers | ||
|
||
import androidx.activity.ComponentActivity | ||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.test.* | ||
import androidx.compose.ui.test.junit4.AndroidComposeTestRule | ||
import androidx.test.ext.junit.rules.ActivityScenarioRule | ||
import com.ivy.wallet.compose.IvyComposeTestRule | ||
|
||
class AccountModal<A : ComponentActivity>( | ||
private val composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<A>, A> | ||
) { | ||
val ivyColorPicker = IvyColorPicker(composeTestRule) | ||
val chooseIconFlow = ChooseIconFlow(composeTestRule) | ||
val currencyPicker = CurrencyPicker(composeTestRule) | ||
class AccountModal( | ||
private val composeTestRule: IvyComposeTestRule | ||
) : ColorPicker<AccountModal>, IconPicker<AccountModal>, | ||
CurrencyPicker<AccountModal>, AmountInput<AccountModal> { | ||
|
||
fun enterTitle( | ||
title: String | ||
) { | ||
): AccountModal { | ||
composeTestRule.onNodeWithTag("base_input") | ||
.performTextReplacement(title) | ||
return this | ||
} | ||
|
||
fun clickBalance() { | ||
private fun clickBalance(): IvyAmountInput { | ||
composeTestRule | ||
.onNode(hasTestTag("amount_balance")) | ||
.performClick() | ||
return IvyAmountInput(composeTestRule) | ||
} | ||
|
||
fun chooseCurrency() { | ||
private fun clickCurrency(): IvyCurrencyPicker { | ||
composeTestRule.onNodeWithTag("account_modal_currency") | ||
.performClick() | ||
return IvyCurrencyPicker(composeTestRule) | ||
} | ||
|
||
fun clickSave() { | ||
fun <N> clickSave(next: N): N { | ||
composeTestRule | ||
.onNode(hasText("Save")) | ||
.performClick() | ||
return next | ||
} | ||
|
||
fun clickAdd() { | ||
fun clickAdd(): AccountsTab { | ||
composeTestRule | ||
.onNode(hasText("Add")) | ||
.performClick() | ||
return AccountsTab(composeTestRule) | ||
} | ||
|
||
fun tapIncludeInBalance() { | ||
fun tapIncludeInBalance(): AccountModal { | ||
composeTestRule.onNodeWithText("Include account") | ||
.performClick() | ||
return this | ||
} | ||
|
||
override fun chooseColor(color: Color): AccountModal { | ||
IvyColorPicker(composeTestRule).chooseColor(color) | ||
return this | ||
} | ||
|
||
override fun chooseIcon(icon: String): AccountModal { | ||
ChooseIconFlow(composeTestRule).chooseIcon(icon) | ||
return this | ||
} | ||
|
||
|
||
override fun chooseCurrency(currencyCode: String): AccountModal { | ||
clickCurrency() | ||
.chooseCurrency(currencyCode) | ||
return this | ||
} | ||
|
||
override fun enterAmount(number: String): AccountModal { | ||
return clickBalance() | ||
.enterNumber( | ||
number = number, | ||
next = this | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
app/src/androidTest/java/com/ivy/wallet/compose/helpers/AddFABMenu.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.ivy.wallet.compose.helpers | ||
|
||
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.performClickWithRetry | ||
|
||
class AddFABMenu( | ||
private val composeTestRule: IvyComposeTestRule | ||
) { | ||
fun clickAddIncome(): TransactionScreen { | ||
composeTestRule.clickWithRetry( | ||
node = composeTestRule.onNode(hasText("ADD INCOME")), | ||
maxRetries = 3 | ||
) | ||
return TransactionScreen(composeTestRule) | ||
} | ||
|
||
fun clickAddExpense(): TransactionScreen { | ||
composeTestRule.onNode(hasText("ADD EXPENSE")) | ||
.performClickWithRetry(composeTestRule) | ||
return TransactionScreen(composeTestRule) | ||
} | ||
|
||
fun clickAddTransfer(): TransactionScreen { | ||
composeTestRule.onNode(hasText("ACCOUNT TRANSFER")) | ||
.performClickWithRetry(composeTestRule) | ||
return TransactionScreen(composeTestRule) | ||
} | ||
|
||
fun clickAddPlannedPayment(): EditPlannedScreen { | ||
composeTestRule.onNodeWithText("Add planned payment") | ||
.performClickWithRetry(composeTestRule) | ||
return EditPlannedScreen(composeTestRule) | ||
} | ||
} |
45 changes: 29 additions & 16 deletions
45
app/src/androidTest/java/com/ivy/wallet/compose/helpers/BudgetModal.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,65 @@ | ||
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 | ||
import com.ivy.wallet.compose.IvyComposeTestRule | ||
|
||
class BudgetModal<A : ComponentActivity>( | ||
private val composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<A>, A> | ||
) { | ||
private val amountInput = AmountInput(composeTestRule) | ||
class BudgetModal( | ||
private val composeTestRule: IvyComposeTestRule | ||
) : AmountInput<BudgetModal>, DeleteItem<BudgetsScreen> { | ||
private val amountInput = IvyAmountInput(composeTestRule) | ||
|
||
fun enterName(budgetName: String) { | ||
fun enterName(budgetName: String): BudgetModal { | ||
composeTestRule.onNodeWithTag("base_input") | ||
.performTextReplacement(budgetName) | ||
return this | ||
} | ||
|
||
fun enterAmount(amount: String) { | ||
private fun clickBudgetAmount(): IvyAmountInput { | ||
composeTestRule.onNodeWithTag("amount_balance") | ||
.performClick() | ||
|
||
amountInput.enterNumber(amount) | ||
return IvyAmountInput(composeTestRule) | ||
} | ||
|
||
fun clickCategory(category: String) { | ||
fun clickCategory(category: String): BudgetModal { | ||
composeTestRule.onNode( | ||
hasText(category) | ||
.and(hasAnyAncestor(hasTestTag("budget_categories_row"))), | ||
useUnmergedTree = true | ||
).performClick() | ||
return this | ||
} | ||
|
||
fun clickAdd() { | ||
fun clickAdd(): BudgetsScreen { | ||
composeTestRule.onNodeWithText("Add") | ||
.performClick() | ||
return BudgetsScreen(composeTestRule) | ||
} | ||
|
||
fun clickSave() { | ||
fun clickSave(): BudgetsScreen { | ||
composeTestRule.onNodeWithText("Save") | ||
.performClick() | ||
return BudgetsScreen(composeTestRule) | ||
} | ||
|
||
fun clickDelete() { | ||
private fun clickDelete(): DeleteConfirmationModal { | ||
composeTestRule.onNodeWithTag("modal_delete") | ||
.performClick() | ||
return DeleteConfirmationModal(composeTestRule) | ||
} | ||
|
||
fun clickClose() { | ||
fun clickClose(): BudgetsScreen { | ||
composeTestRule.onNodeWithContentDescription("close") | ||
.performClick() | ||
return BudgetsScreen(composeTestRule) | ||
} | ||
|
||
override fun enterAmount(number: String): BudgetModal { | ||
return clickBudgetAmount() | ||
.enterNumber(number, next = this) | ||
} | ||
|
||
override fun deleteWithConfirmation(): BudgetsScreen { | ||
return clickDelete() | ||
.confirmDelete(next = BudgetsScreen(composeTestRule)) | ||
} | ||
} |
Oops, something went wrong.