taxi: remember state args in Navigation test composition
- Commit
fce7c844063d94ff119c5b9d7d448bdabf62c0c0- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-08 06:28 UTC (28 days ago)
- Parents
b089be2
What: wrap the two inline mutableStateOf(null) arguments to Navigation in
navigationShowsRideHomeAndTabs with remember { }, plus the remember import.
Why: :taxi:lintDev failed on 2 UnrememberedMutableState errors โ
creating state objects during composition without remember.
Root cause: same family as the office slice-4 fix โ inline state args
are recreated on every recomposition, dropping tab-selection state. This
test does recompose (it clicks between tabs), so the fix is load-bearing,
not just lint-hygiene: without it the Settings-tab click could reset
navigation state mid-test.
Rejected alternatives: hoisting to vals before setContent (loses
parameter-inferred type arguments โ mutableStateOf(null) needs an
explicit type at the call site); lint suppression (hides a real
recomposition hazard).
User-visible effect: none; test-only change.
Verification: :taxi:lint green, :taxi:testDevUnitTest 244/0/0.Diff
taxi/src/test/java/com/vayunmathur/taxi/ui/TaxiPass3ScreensTest.kt
diff --git a/taxi/src/test/java/com/vayunmathur/taxi/ui/TaxiPass3ScreensTest.kt b/taxi/src/test/java/com/vayunmathur/taxi/ui/TaxiPass3ScreensTest.ktindex fb42fd12e2..88bbc1a6b6 100644--- a/taxi/src/test/java/com/vayunmathur/taxi/ui/TaxiPass3ScreensTest.kt+++ b/taxi/src/test/java/com/vayunmathur/taxi/ui/TaxiPass3ScreensTest.kt@@ -2,6 +2,7 @@ package com.vayunmathur.taxi.ui import android.content.Context import androidx.compose.runtime.mutableStateOf+import androidx.compose.runtime.remember import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.performScrollTo import androidx.compose.ui.test.assertIsEnabled@@ -414,8 +415,8 @@ class TaxiPass3ScreensTest { fun navigationShowsRideHomeAndTabs() { rule.setContent { com.vayunmathur.taxi.Navigation(- trackRideId = mutableStateOf(null),- bookingTrip = mutableStateOf(null),+ trackRideId = remember { mutableStateOf(null) },+ bookingTrip = remember { mutableStateOf(null) }, ) } waitForText(str(R.string.nav_ride))