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 712
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
0626a28
commit 93ffe8f
Showing
5 changed files
with
118 additions
and
7 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
39 changes: 39 additions & 0 deletions
39
app/src/androidTest/java/com/ivy/wallet/compose/helpers/PieChartScreen.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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.ivy.wallet.compose.helpers | ||
|
||
import androidx.activity.ComponentActivity | ||
import androidx.compose.ui.test.* | ||
import androidx.compose.ui.test.junit4.AndroidComposeTestRule | ||
import androidx.test.ext.junit.rules.ActivityScenarioRule | ||
|
||
class PieChartScreen<A : ComponentActivity>( | ||
private val composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<A>, A> | ||
) { | ||
fun assertTitle(title: String) { | ||
composeTestRule.onNodeWithTag("piechart_title") | ||
.assertTextContains(title) | ||
} | ||
|
||
fun assertTotalAmount( | ||
amountInt: String, | ||
decimalPart: String, | ||
currency: String = "USD" | ||
) { | ||
val matchText: (String) -> SemanticsMatcher = { text -> | ||
hasTestTag("piechart_total_amount") | ||
.and( | ||
hasAnyDescendant( | ||
hasText(text) | ||
) | ||
) | ||
} | ||
|
||
composeTestRule.onNode(matchText(amountInt)) | ||
.assertIsDisplayed() | ||
|
||
composeTestRule.onNode(matchText(decimalPart)) | ||
.assertIsDisplayed() | ||
|
||
composeTestRule.onNode(matchText(currency)) | ||
.assertIsDisplayed() | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
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 |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.ivy.wallet.compose.scenario | ||
|
||
import com.ivy.wallet.compose.IvyComposeTest | ||
import com.ivy.wallet.compose.helpers.HomeTab | ||
import com.ivy.wallet.compose.helpers.OnboardingFlow | ||
import com.ivy.wallet.compose.helpers.PieChartScreen | ||
import com.ivy.wallet.compose.helpers.TransactionFlow | ||
import com.ivy.wallet.compose.printTree | ||
import dagger.hilt.android.testing.HiltAndroidTest | ||
import org.junit.Test | ||
|
||
@HiltAndroidTest | ||
class PieChartTest : IvyComposeTest() { | ||
private val onboarding = OnboardingFlow(composeTestRule) | ||
private val homeTab = HomeTab(composeTestRule) | ||
private val transactionFlow = TransactionFlow(composeTestRule) | ||
private val pieChartScreen = PieChartScreen(composeTestRule) | ||
|
||
@Test | ||
fun expensePieChart_realistic() { | ||
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() | ||
|
||
composeTestRule.printTree(useUnmergedTree = false) | ||
|
||
pieChartScreen.assertTitle("Expenses") | ||
pieChartScreen.assertTotalAmount( | ||
amountInt = "280", | ||
decimalPart = ".95", | ||
currency = "USD" | ||
) | ||
} | ||
} |
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
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