Skip to content

Commit

Permalink
test: date picker
Browse files Browse the repository at this point in the history
  • Loading branch information
SidonieBouthors committed Apr 6, 2024
1 parent d75838a commit c1b350a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,13 @@ class ReceiptScreenTest : TestCase(kaspressoBuilder = Kaspresso.Builder.withComp
assert(tabSelected)
}
}

@Test
fun datePicker() {
with(composeTestRule) {
onNodeWithTag("dateField").performClick()
onNodeWithTag("datePickerDialog").assertIsDisplayed()
onNodeWithTag("datePickerDialogDismiss").performClick()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
import androidx.compose.ui.platform.testTag
import java.time.Instant
import java.time.LocalDate
import java.time.ZoneId
Expand Down Expand Up @@ -61,7 +62,7 @@ fun DatePickerWithDialog(

if (showDialog) {
DatePickerDialog(
modifier = Modifier,
modifier = Modifier.testTag("datePickerDialog"),
onDismissRequest = { showDialog = false },
confirmButton = {
Button(
Expand All @@ -73,7 +74,11 @@ fun DatePickerWithDialog(
}
},
dismissButton = {
Button(modifier = Modifier, onClick = { showDialog = false }) { Text(text = "Cancel") }
Button(
modifier = Modifier.testTag("datePickerDialogDismiss"),
onClick = { showDialog = false }) {
Text(text = "Cancel")
}
}) {
DatePicker(state = datePickerState, showModeToggle = true)
}
Expand Down

0 comments on commit c1b350a

Please sign in to comment.