travel: await room after stay-detail reload settles
- Commit
8d5f201aef5c93e9f111700b8be9c38c31f7db72- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-17 02:44 UTC (19 days ago)
- Parents
5d53206
StayDetailPage reloads rates in a LaunchedEffect on entry, overwriting the seeded state with loading then an error; on a loaded box that reload could land after the test's runOnIdle re-seed and wipe it again before the assert. Wait until Deluxe King is observed, re-seeding if the reload landed last. Product behaviour unchanged. Verified: TZ=UTC stayDetail_withRates_showsRoom green.
Diff
travel/src/test/java/com/vayunmathur/travel/ui/TravelInteractionsTest.kt
diff --git a/travel/src/test/java/com/vayunmathur/travel/ui/TravelInteractionsTest.kt b/travel/src/test/java/com/vayunmathur/travel/ui/TravelInteractionsTest.ktindex 81b5d53721..35cfd420c9 100644--- a/travel/src/test/java/com/vayunmathur/travel/ui/TravelInteractionsTest.kt+++ b/travel/src/test/java/com/vayunmathur/travel/ui/TravelInteractionsTest.kt@@ -105,6 +105,19 @@ class TravelInteractionsTest { v.stayRatesMutable.value = StayRatesState(rates = StayRatesDto(name = "Grand Hotel", rooms = listOf(StayRoomDto(name = "Deluxe King", rates = listOf(StayRateDto(id = "r1", boardType = "breakfast", totalAmount = "180.00", cancellation = "Free cancellation")))))) rule.setContent { StayDetailPage(stack(), v, Route.StayDetail("sr_1", "Grand Hotel")) } rule.runOnIdle { v.stayRatesMutable.value = StayRatesState(rates = StayRatesDto(name = "Grand Hotel", rooms = listOf(StayRoomDto(name = "Deluxe King", rates = listOf(StayRateDto(id = "r1", boardType = "breakfast", totalAmount = "180.00", cancellation = "Free cancellation")))))) }+ // StayDetailPage's LaunchedEffect reloads rates on entry and+ // overwrites the seeded state (loading, then an error with no+ // network); on a loaded box that reload can land after the+ // runOnIdle re-seed above and wipe it again. Wait until the room+ // is actually observed, re-seeding if the reload landed last.+ rule.waitUntil(20_000) {+ if (rule.onAllNodesWithText("Deluxe King").fetchSemanticsNodes().isEmpty()) {+ rule.runOnIdle {+ v.stayRatesMutable.value = StayRatesState(rates = StayRatesDto(name = "Grand Hotel", rooms = listOf(StayRoomDto(name = "Deluxe King", rates = listOf(StayRateDto(id = "r1", boardType = "breakfast", totalAmount = "180.00", cancellation = "Free cancellation"))))))+ }+ }+ rule.onAllNodesWithText("Deluxe King").fetchSemanticsNodes().isNotEmpty()+ } rule.onAllNodesWithText("Grand Hotel")[0].assertIsDisplayed() rule.onNodeWithText("Deluxe King").assertExists() }