From 46e81578a44bde0272a4dad2c3dbcb41eef98f8a Mon Sep 17 00:00:00 2001 From: Iliyan Germanov Date: Fri, 29 Apr 2022 15:39:41 +0300 Subject: [PATCH] WIP: CalculatorTest.kt --- .../ivy/wallet/compose/helpers/AmountInput.kt | 12 ++- .../wallet/compose/scenario/CalculatorTest.kt | 78 ++++++++++++++++++- 2 files changed, 86 insertions(+), 4 deletions(-) diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/helpers/AmountInput.kt b/app/src/androidTest/java/com/ivy/wallet/compose/helpers/AmountInput.kt index b6cb570b6f..81b67f45d1 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/helpers/AmountInput.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/helpers/AmountInput.kt @@ -13,7 +13,8 @@ class AmountInput( ) { fun enterNumber( number: String, - onCalculator: Boolean = false + onCalculator: Boolean = false, + autoPressNonCalculator: Boolean = true, ) { composeTestRule.waitForIdle() @@ -32,7 +33,7 @@ class AmountInput( } } - if (!onCalculator) { + if (!onCalculator && autoPressNonCalculator) { clickSet() } } @@ -78,7 +79,7 @@ class AmountInput( } fun pressDivision() { - composeTestRule.onNodeWithTag("key_-") + composeTestRule.onNodeWithTag("key_/") .performClick() } @@ -92,6 +93,11 @@ class AmountInput( .performClick() } + fun pressCalcEqual() { + composeTestRule.onNodeWithTag("key_=") + .performClick() + } + fun clickCalcSet() { composeTestRule.onNodeWithTag("calc_set") .performClick() diff --git a/app/src/androidTest/java/com/ivy/wallet/compose/scenario/CalculatorTest.kt b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/CalculatorTest.kt index f6218af33a..f9491a3162 100644 --- a/app/src/androidTest/java/com/ivy/wallet/compose/scenario/CalculatorTest.kt +++ b/app/src/androidTest/java/com/ivy/wallet/compose/scenario/CalculatorTest.kt @@ -60,12 +60,88 @@ class CalculatorTest : IvyComposeTest() { @Test fun setAmount_withAddition() { + onboarding.quickOnboarding() + mainBottomBar.clickAddFAB() + mainBottomBar.clickAddIncome() + + amountInput.enterNumber( + number = "38.16", + autoPressNonCalculator = false + ) + amountInput.clickCalculator() + + //--------------------------- + amountInput.pressPlus() + amountInput.enterNumber( + number = "80.74", + onCalculator = true + ) + + amountInput.clickCalcSet() + amountInput.clickSet() + + transactionScreen.skipCategory() + transactionScreen.editTitle("Calc 2") + transactionScreen.clickAdd() + + //---------------------------- + + //38.16 + 80.74 = 118.90 + homeTab.assertBalance( + amount = "118", + amountDecimal = ".90" + ) + + homeTab.clickTransaction( + amount = "118.90", + title = "Calc 2" + ) } @Test fun calcAmount_viaDivision() { + onboarding.quickOnboarding() + mainBottomBar.clickAddFAB() + mainBottomBar.clickAddExpense() + amountInput.clickCalculator() + + //--------------------------- + + amountInput.enterNumber( + number = "72.50", + onCalculator = true + ) + + amountInput.pressDivision() + + amountInput.enterNumber( + number = "3", + onCalculator = true + ) + + amountInput.pressCalcEqual() + + amountInput.clickCalcSet() + amountInput.clickSet() + + transactionScreen.skipCategory() + transactionScreen.editTitle("Calc 3") + + transactionScreen.clickAdd() + //---------------------------------------- + + //72.50 / 3 = 24.17 + homeTab.assertBalance( + amount = "-24", + amountDecimal = ".17" + ) + + homeTab.clickTransaction( + amount = "24.17", + title = "Calc 3" + ) } @Test @@ -74,7 +150,7 @@ class CalculatorTest : IvyComposeTest() { } @Test - fun calcComplexExpression() { + fun calcAmount_complexExpression() { } } \ No newline at end of file