Skip to content

Commit

Permalink
Add DeleteTransaction test
Browse files Browse the repository at this point in the history
  • Loading branch information
Iliyan Germanov committed Nov 24, 2021
1 parent 34a1da8 commit 1e09cfe
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ class EditTransactionScreen<A : ComponentActivity>(
.performTextInput(newTitle)
}

fun clickClose() {
composeTestRule.onNodeWithContentDescription("close")
.performClick()
}

fun clickDelete() {
composeTestRule.onNodeWithTag("delete_button")
.performClick()
}

fun save() {
composeTestRule.onNodeWithText("Save")
.performClick()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ 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.printTree

class HomeTab<A : ComponentActivity>(
private val composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<A>, A>
Expand All @@ -25,9 +24,6 @@ class HomeTab<A : ComponentActivity>(
account: String? = null,
category: String? = null
) {
//TODO: Implement account, category, title selectors
composeTestRule.printTree()

var matcher = hasTestTag("transaction_card")
.and(hasText(amount))

Expand All @@ -49,4 +45,13 @@ class HomeTab<A : ComponentActivity>(
.performScrollTo()
.performClick()
}

fun assertTransactionNotExists(
amount: String
) {
composeTestRule.onNode(
hasTestTag("transaction_card")
.and(hasText(amount))
).assertDoesNotExist()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class OperationsCoreTest : IvyComposeTest() {
private val accountsTab = AccountsTab(composeTestRule)
private val editTransactionScreen = EditTransactionScreen(composeTestRule)
private val itemStatisticScreen = ItemStatisticScreen(composeTestRule)
private val deleteConfirmationModal = DeleteConfirmationModal(composeTestRule)

@Test
fun contextLoads() {
Expand Down Expand Up @@ -178,5 +179,36 @@ class OperationsCoreTest : IvyComposeTest() {
)
}

//TODO: Delete transaction
@Test
fun DeleteTransaction() {
onboarding.quickOnboarding()

transactionFlow.addExpense(
amount = 249.75,
title = "Food",
category = "Groceries"
)

homeTab.assertBalance(
"-249",
amountDecimal = ".75"
)

homeTab.clickTransaction(
amount = "249.75",
title = "Food",
category = "Groceries"
)
editTransactionScreen.clickDelete()
deleteConfirmationModal.confirmDelete()

homeTab.assertTransactionNotExists(
amount = "249.75"
)

homeTab.assertBalance(
amount = "0",
amountDecimal = ".00"
)
}
}

0 comments on commit 1e09cfe

Please sign in to comment.