calendar: pin timezone and scroll to the timed event in hourly grid test (305 tests)
- Commit
971a4aee0646da1ea8c1a10da120ca40a999d5b9- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-15 19:17 UTC (20 days ago)
- Parents
55fa17f
EditEventComposeTest 'hourly grid shows timed event and click fires' failed in CI (TZ=UTC) with 'Team standup' not displayed, and passed on the host (America/Los_Angeles). Timed instances render in the system zone by design, and the fixtures build their instants in UTC: at 09:00 UTC the chip lands at 02:00 in Los Angeles (visible), 05:00 in New York (visible) and 09:00 in UTC, where 24 rows of 56dp push it below the fold of the scrollable grid, so assertIsDisplayed failed without any product defect. Pin the default timezone to UTC for the class so wall times are the same on every host, and scroll the 09:00 chip into view before asserting it is displayed and clicking it. The click + callback assertions are unchanged. Reproduced at TZ=UTC before the fix (single-module and merged CI-like runs); verified green 3x under TZ=UTC and TZ=America/New_York.
Diff
calendar/src/test/java/com/vayunmathur/calendar/ui/EditEventComposeTest.kt
diff --git a/calendar/src/test/java/com/vayunmathur/calendar/ui/EditEventComposeTest.kt b/calendar/src/test/java/com/vayunmathur/calendar/ui/EditEventComposeTest.ktindex 2e12615e4a..57c173d766 100644--- a/calendar/src/test/java/com/vayunmathur/calendar/ui/EditEventComposeTest.kt+++ b/calendar/src/test/java/com/vayunmathur/calendar/ui/EditEventComposeTest.kt@@ -9,6 +9,7 @@ import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onAllNodesWithText import androidx.compose.ui.test.onNodeWithText import androidx.compose.ui.test.performClick+import androidx.compose.ui.test.performScrollTo import androidx.compose.ui.test.performTextInput import androidx.test.core.app.ApplicationProvider import com.vayunmathur.calendar.CalendarTestData as D@@ -42,6 +43,23 @@ class EditEventComposeTest { @get:Rule val rule = createComposeRule() + // Timed instances render in the system zone by design, and the test+ // data's instants are built in UTC: pin the default zone so the wall+ // times (and the hourly grid's vertical positions) are the same on+ // every host instead of depending on where the suite runs.+ private lateinit var defaultTimeZone: java.util.TimeZone++ @kotlin.test.BeforeTest+ fun pinTimeZone() {+ defaultTimeZone = java.util.TimeZone.getDefault()+ java.util.TimeZone.setDefault(java.util.TimeZone.getTimeZone("UTC"))+ }++ @kotlin.test.AfterTest+ fun restoreTimeZone() {+ java.util.TimeZone.setDefault(defaultTimeZone)+ }+ private val context: Context get() = ApplicationProvider.getApplicationContext() private fun backStack() = NavBackStack<Route>(arrayOf(Route.Calendar)) @@ -313,12 +331,15 @@ class EditEventComposeTest { var clicked: com.vayunmathur.calendar.data.Instance? = null val inst = D.instance() val timed = mapOf(D.TODAY to mapOf(9 to listOf(inst)))- rule.mainClock.autoAdvance = false rule.setContent { HourlyGrid(context, timed, listOf(D.TODAY), shrinkEmptyHours = false, onEventClick = { clicked = it }, innerPadding = androidx.compose.foundation.layout.PaddingValues(0.dp)) } rule.mainClock.advanceTimeBy(500)- rule.onNodeWithText("Team standup").assertIsDisplayed()+ // The 09:00 chip sits below the fold of the 24-hour scrollable grid+ // (24 rows x 56dp); scroll it into view before asserting display.+ rule.onNodeWithText("Team standup")+ .performScrollTo()+ .assertIsDisplayed() rule.onNodeWithText("Team standup").performClick() assertEquals(inst, clicked) }