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

Commit

Permalink
Add test for removing description
Browse files Browse the repository at this point in the history
  • Loading branch information
ILIYANGERMANOV committed May 24, 2022
1 parent c49dfd9 commit 6bce2db
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TransactionFlow<A : ComponentActivity>(
title = title,
category = category,
account = account,
description = null,
description = description,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ 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.hideKeyboard

class TransactionScreen<A : ComponentActivity>(
private val composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<A>, A>
Expand Down Expand Up @@ -46,6 +47,26 @@ class TransactionScreen<A : ComponentActivity>(
.performTextReplacement(newTitle)
}

fun removeDescription() {
composeTestRule.hideKeyboard()

composeTestRule.onNodeWithTag("trn_description")
.performClick()

composeTestRule.onNodeWithTag("modal_desc_delete")
.performClick()
}

fun assertDescription(desc: String) {
composeTestRule.onNodeWithTag("trn_description", useUnmergedTree = true)
.assertTextEquals(desc)
}

fun assertAddDescriptionButtonVisible() {
composeTestRule.onNodeWithText("Add description")
.assertIsDisplayed()
}

fun clickClose() {
composeTestRule.onNodeWithContentDescription("close")
.performClick()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,41 @@ class OperationsCoreTest : IvyComposeTest() {
category = "Groceries"
)

composeTestRule.onNodeWithTag("trn_description", useUnmergedTree = true)
.assertTextEquals("Tablet for learning purposes.")
editTransactionScreen.assertDescription("Tablet for learning purposes.")
}

@Test
fun AddTransaction_thenRemoveDescription() = testWithRetry {
onboarding.quickOnboarding()

transactionFlow.addIncome(
amount = 123.0,
title = "Income",
description = "-a\n-b\n-c\n-d"
)

homeTab.assertBalance(
"123",
amountDecimal = ".00"
)

homeTab.dismissPrompt()

homeTab.clickTransaction(
amount = "123.00",
title = "Income",
)

editTransactionScreen.assertDescription("-a\n-b\n-c\n-d")

// No remove desc ---------------------------------------------------------------
editTransactionScreen.removeDescription()
editTransactionScreen.save()

homeTab.clickTransaction(
amount = "123.00",
title = "Income",
)
editTransactionScreen.assertAddDescriptionButtonVisible()
}
}

0 comments on commit 6bce2db

Please sign in to comment.