Skip to content

Commit

Permalink
Implement "Delete Budget" test
Browse files Browse the repository at this point in the history
  • Loading branch information
Iliyan Germanov committed Nov 24, 2021
1 parent 62edbee commit bd29c38
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ class BudgetModal<A : ComponentActivity>(
composeTestRule.onNodeWithText("Save")
.performClick()
}

fun clickDelete() {
composeTestRule.onNodeWithTag("modal_delete")
.performClick()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ class BudgetsScreen<A : ComponentActivity>(
appBudget != null && categoryBudget != null -> {
budgetInfoNode.assertTextEquals("Budget info: $categoryBudget $currency for categories / $appBudget $currency app budget")
}
appBudget == null && categoryBudget == null -> {
budgetInfoNode.assertDoesNotExist()
}
else -> error("Unexpected case")
}
}
Expand All @@ -42,4 +45,11 @@ class BudgetsScreen<A : ComponentActivity>(
.performClick()
}

fun assertBudgetDoesNotExist(
budgetName: String
) {
composeTestRule.onNodeWithText(budgetName)
.assertDoesNotExist()
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package com.ivy.wallet.compose.scenario

import com.ivy.wallet.compose.IvyComposeTest
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 com.ivy.wallet.compose.helpers.*
import dagger.hilt.android.testing.HiltAndroidTest
import org.junit.Test

Expand All @@ -15,6 +12,7 @@ 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() {
Expand Down Expand Up @@ -136,7 +134,42 @@ class BudgetsTests : IvyComposeTest() {

@Test
fun DeleteBudget() {
TODO("Implement")
onboardingFlow.quickOnboarding()

homeMoreMenu.clickOpenCloseArrow()
homeMoreMenu.clickBudgets()

budgetsScreen.clickAddBudget()

budgetModal.apply {
enterAmount("2,500")
clickCategory("Food & Drinks")
clickCategory("Bills & Fees")
enterName("Living (must)")
clickAdd()
}

budgetsScreen.assertBudgetsInfo(
appBudget = null,
categoryBudget = "2,500.00"
)

budgetsScreen.clickBudget(
budgetName = "Living (must)"
)

//Delete budget
budgetModal.clickDelete()
deleteConfirmationModal.confirmDelete()

budgetsScreen.assertBudgetsInfo(
appBudget = null,
categoryBudget = null
)

budgetsScreen.assertBudgetDoesNotExist(
budgetName = "Living (must)"
)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.compose.foundation.layout.size
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import com.ivy.wallet.R
Expand Down Expand Up @@ -193,7 +194,9 @@ fun ModalDelete(
onClick: () -> Unit
) {
IvyCircleButton(
modifier = Modifier.size(40.dp),
modifier = Modifier
.size(40.dp)
.testTag("modal_delete"),
icon = R.drawable.ic_delete,
backgroundGradient = GradientRed,
enabled = enabled,
Expand Down

0 comments on commit bd29c38

Please sign in to comment.