This repository has been archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 722
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d0c259e
commit cd186f2
Showing
2 changed files
with
88 additions
and
111 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
192 changes: 83 additions & 109 deletions
192
app/src/androidTest/java/com/ivy/wallet/compose/scenario/PieChartTest.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,138 +1,112 @@ | ||
package com.ivy.wallet.compose.scenario | ||
|
||
import com.ivy.wallet.compose.IvyComposeTest | ||
import com.ivy.wallet.compose.helpers.PieChartScreen | ||
import dagger.hilt.android.testing.HiltAndroidTest | ||
import org.junit.Test | ||
|
||
@HiltAndroidTest | ||
class PieChartTest : IvyComposeTest() { | ||
private val pieChartScreen = PieChartScreen(composeTestRule) | ||
|
||
@Test | ||
fun expensePieChart_realistic() = testWithRetry { | ||
onboarding.quickOnboarding() | ||
|
||
transactionFlow.addExpense( | ||
amount = 50.23 | ||
) | ||
|
||
transactionFlow.addExpense( | ||
amount = 150.72, | ||
category = "Food & Drinks" | ||
) | ||
|
||
transactionFlow.addExpense( | ||
amount = 75.0, | ||
category = "Groceries" | ||
) | ||
|
||
transactionFlow.addExpense( | ||
amount = 5.0, | ||
title = "Bread", | ||
category = "Groceries" | ||
) | ||
//---------------------------------------------------- | ||
|
||
homeTab.clickExpenseCard() | ||
|
||
pieChartScreen.assertTitle("Expenses") | ||
pieChartScreen.assertTotalAmount( | ||
amountInt = "280", | ||
decimalPart = ".95", | ||
currency = "USD" | ||
) | ||
quickOnboarding() | ||
.addExpense( | ||
amount = 50.23 | ||
) | ||
.addExpense( | ||
amount = 150.72, | ||
category = "Food & Drinks" | ||
) | ||
.addExpense( | ||
amount = 75.0, | ||
category = "Groceries" | ||
) | ||
.addExpense( | ||
amount = 5.0, | ||
title = "Bread", | ||
category = "Groceries" | ||
) | ||
//---------------------------------------------------- | ||
.clickExpenseCard() | ||
.assertTitle("Expenses") | ||
.assertTotalAmount( | ||
amountInt = "280", | ||
decimalPart = ".95", | ||
currency = "USD" | ||
) | ||
} | ||
|
||
@Test | ||
fun expensePieChart_empty() = testWithRetry { | ||
onboarding.quickOnboarding() | ||
|
||
transactionFlow.addIncome( | ||
amount = 23.23 | ||
) | ||
|
||
//---------------------------------------------------- | ||
|
||
homeTab.clickExpenseCard() | ||
|
||
pieChartScreen.assertTitle("Expenses") | ||
pieChartScreen.assertTotalAmount( | ||
amountInt = "0", | ||
decimalPart = ".00", | ||
currency = "USD" | ||
) | ||
quickOnboarding() | ||
.addIncome( | ||
amount = 23.23 | ||
) | ||
//---------------------------------------------------- | ||
.clickExpenseCard() | ||
.assertTitle("Expenses") | ||
.assertTotalAmount( | ||
amountInt = "0", | ||
decimalPart = ".00", | ||
currency = "USD" | ||
) | ||
} | ||
|
||
@Test | ||
fun expensePieChart_oneTrn() = testWithRetry { | ||
onboarding.quickOnboarding() | ||
|
||
transactionFlow.addExpense( | ||
amount = 55.01 | ||
) | ||
|
||
//---------------------------------------------------- | ||
|
||
homeTab.clickExpenseCard() | ||
|
||
pieChartScreen.assertTitle("Expenses") | ||
pieChartScreen.assertTotalAmount( | ||
amountInt = "55", | ||
decimalPart = ".01", | ||
currency = "USD" | ||
) | ||
quickOnboarding() | ||
.addExpense( | ||
amount = 55.01 | ||
) | ||
//---------------------------------------------------- | ||
.clickExpenseCard() | ||
.assertTitle("Expenses") | ||
.assertTotalAmount( | ||
amountInt = "55", | ||
decimalPart = ".01", | ||
currency = "USD" | ||
) | ||
} | ||
|
||
@Test | ||
fun incomePieChart_realistic() = testWithRetry { | ||
onboarding.quickOnboarding() | ||
|
||
//To ensure that the code filters expenses | ||
transactionFlow.addExpense( | ||
amount = 10.0 | ||
) | ||
|
||
transactionFlow.addIncome( | ||
amount = 7200.0, | ||
title = "Salary", | ||
category = "Groceries" | ||
) | ||
|
||
transactionFlow.addIncome( | ||
amount = 1.1, | ||
title = "Adjust balance" | ||
) | ||
|
||
//---------------------------------------------------- | ||
|
||
homeTab.clickIncomeCard() | ||
|
||
pieChartScreen.assertTitle("Income") | ||
pieChartScreen.assertTotalAmount( | ||
amountInt = "7,201", | ||
decimalPart = ".10", | ||
currency = "USD" | ||
) | ||
quickOnboarding() | ||
//To ensure that the code filters expenses | ||
.addExpense( | ||
amount = 10.0 | ||
) | ||
.addIncome( | ||
amount = 7200.0, | ||
title = "Salary", | ||
category = "Groceries" | ||
) | ||
.addIncome( | ||
amount = 1.1, | ||
title = "Adjust balance" | ||
) | ||
//---------------------------------------------------- | ||
.clickIncomeCard() | ||
.assertTitle("Income") | ||
.assertTotalAmount( | ||
amountInt = "7,201", | ||
decimalPart = ".10", | ||
currency = "USD" | ||
) | ||
} | ||
|
||
@Test | ||
fun incomePieChart_empty() = testWithRetry { | ||
onboarding.quickOnboarding() | ||
|
||
transactionFlow.addExpense( | ||
amount = 23.23 | ||
) | ||
|
||
//---------------------------------------------------- | ||
|
||
homeTab.clickIncomeCard() | ||
|
||
pieChartScreen.assertTitle("Income") | ||
pieChartScreen.assertTotalAmount( | ||
amountInt = "0", | ||
decimalPart = ".00", | ||
currency = "USD" | ||
) | ||
quickOnboarding() | ||
.addExpense( | ||
amount = 23.23 | ||
) | ||
//---------------------------------------------------- | ||
.clickIncomeCard() | ||
.assertTitle("Income") | ||
.assertTotalAmount( | ||
amountInt = "0", | ||
decimalPart = ".00", | ||
currency = "USD" | ||
) | ||
} | ||
} |