Skip to content

Commit

Permalink
fix: ensure navigation actions pass verification on button click
Browse files Browse the repository at this point in the history
  • Loading branch information
francelu committed Oct 28, 2024
1 parent 076069e commit 470d1b2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ class AlertScreenTest {

// Verify that the navigation action occurs
// This can be done by checking that the current screen is not the AlertScreen
composeTestRule.onNodeWithTag("alertScreen").assertDoesNotExist()
verify(navigationActions).navigateTo(screen = Screen.ALERT_LIST)
composeTestRule.onNodeWithTag("alertListScreen").assertIsDisplayed()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ class CreateProfileTest {
composeTestRule.onNodeWithTag("save_button").assertIsDisplayed().performClick()

// Verify that the navigation action occurs
composeTestRule.onNodeWithTag("createProfileScreen").assertDoesNotExist()
verify(navigationActions).navigateTo(screen = Screen.PROFILE)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fun CreateProfileScreen(navigationActions: NavigationActions) {
}

Scaffold(
modifier = Modifier.fillMaxSize(),
modifier = Modifier.fillMaxSize().testTag("createProfileScreen"),
content = { padding ->
Column(
modifier = Modifier.fillMaxSize().padding(16.dp).padding(padding),
Expand Down Expand Up @@ -195,11 +195,12 @@ private fun validateName(name: String): Boolean {
/** Validates the date is in the format DD/MM/YYYY and is a valid date. */
fun validateDate(date: String): Boolean {
val parts = date.split("/")
val calendar = GregorianCalendar()
val calendar = GregorianCalendar.getInstance()
calendar.isLenient = false
if (parts.size == 3) {
return try {
calendar.set(parts[2].toInt(), parts[1].toInt() - 1, parts[0].toInt(), 0, 0, 0)
calendar.set(parts[2].toInt(), parts[1].toInt() - 1, parts[0].toInt())
calendar.time
true
} catch (e: Exception) {
false
Expand Down

0 comments on commit 470d1b2

Please sign in to comment.