forked from philipplackner/IvyWallet-PL_Version
-
Notifications
You must be signed in to change notification settings - Fork 0
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
5a73203
commit a136fb9
Showing
3 changed files
with
91 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.ivy | ||
|
||
import androidx.compose.ui.test.junit4.AndroidComposeTestRule | ||
import androidx.test.ext.junit.rules.ActivityScenarioRule | ||
import com.ivy.wallet.ui.RootActivity | ||
|
||
typealias IvyComposeRule = AndroidComposeTestRule<ActivityScenarioRule<RootActivity>, RootActivity> |
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,73 @@ | ||
package com.ivy.home | ||
|
||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.junit4.AndroidComposeTestRule | ||
import androidx.compose.ui.test.onNodeWithText | ||
import androidx.compose.ui.test.performClick | ||
import androidx.test.ext.junit.rules.ActivityScenarioRule | ||
import com.ivy.IvyComposeRule | ||
import com.ivy.common.time.provider.TimeProvider | ||
import com.ivy.navigation.Navigator | ||
import com.ivy.navigation.destinations.main.Home | ||
import com.ivy.wallet.ui.RootActivity | ||
import kotlinx.coroutines.runBlocking | ||
|
||
class HomeScreenRobot( | ||
private val composeRule: IvyComposeRule | ||
) { | ||
fun navigateTo(navigator: Navigator): HomeScreenRobot { | ||
runBlocking { | ||
composeRule.awaitIdle() | ||
composeRule.runOnUiThread { | ||
navigator.navigate(Home.route) { | ||
popUpTo(Home.route) { | ||
inclusive = false | ||
} | ||
} | ||
} | ||
} | ||
return this | ||
} | ||
|
||
fun openDateRangeSheet(timeProvider: TimeProvider): HomeScreenRobot { | ||
composeRule | ||
.onNodeWithText(timeProvider.dateNow().month.name, ignoreCase = true) | ||
.performClick() | ||
return this | ||
} | ||
|
||
fun selectMonth(monthName: String): HomeScreenRobot { | ||
composeRule | ||
.onNodeWithText(monthName) | ||
.performClick() | ||
return this | ||
} | ||
|
||
fun assertDateIsDisplayed(day: Int, month: String): HomeScreenRobot { | ||
val paddedDay = day.toString().padStart(2, '0') | ||
composeRule | ||
.onNodeWithText("${month.take(3)}. $paddedDay") | ||
.assertIsDisplayed() | ||
return this | ||
} | ||
|
||
fun clickDone(): HomeScreenRobot { | ||
composeRule.onNodeWithText("Done").performClick() | ||
return this | ||
} | ||
|
||
fun clickUpcoming(): HomeScreenRobot { | ||
composeRule.onNodeWithText("Upcoming").performClick() | ||
return this | ||
} | ||
|
||
fun assertTransactionDoesNotExist(transactionTitle: String): HomeScreenRobot { | ||
composeRule.onNodeWithText(transactionTitle).assertDoesNotExist() | ||
return this | ||
} | ||
|
||
fun assertTransactionIsDisplayed(transactionTitle: String): HomeScreenRobot { | ||
composeRule.onNodeWithText(transactionTitle).assertIsDisplayed() | ||
return this | ||
} | ||
} |
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