From f2fc1b7b28975b12cea3e499c894e4882740316b Mon Sep 17 00:00:00 2001 From: atsunatsu Date: Tue, 22 Sep 2026 14:49:04 +0800 Subject: [PATCH] test(mutual): portrait-size Robolectric + NavDisplay entry scenario Run the scroll tests at 411x891dp portrait (device-like layout) and add a NavDisplay entryProvider scenario that composes MutualScreen the way the app does, so the prefill scroll is exercised end-to-end. --- feature/mutual/build.gradle.kts | 1 + .../mutual/MutualMatchPrefillScrollTest.kt | 33 +++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/feature/mutual/build.gradle.kts b/feature/mutual/build.gradle.kts index dc5a884f..1f23c4ac 100644 --- a/feature/mutual/build.gradle.kts +++ b/feature/mutual/build.gradle.kts @@ -18,5 +18,6 @@ dependencies { testImplementation(libs.robolectric) testImplementation(libs.androidx.test.core) testImplementation(libs.compose.ui.test.junit4) + testImplementation(libs.compose.navigation3) debugImplementation(libs.compose.debug.manifest) } diff --git a/feature/mutual/src/test/java/com/rtbishop/look4sat/feature/mutual/MutualMatchPrefillScrollTest.kt b/feature/mutual/src/test/java/com/rtbishop/look4sat/feature/mutual/MutualMatchPrefillScrollTest.kt index 59d00e51..3cfa3ff2 100644 --- a/feature/mutual/src/test/java/com/rtbishop/look4sat/feature/mutual/MutualMatchPrefillScrollTest.kt +++ b/feature/mutual/src/test/java/com/rtbishop/look4sat/feature/mutual/MutualMatchPrefillScrollTest.kt @@ -12,6 +12,10 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithText +import androidx.navigation3.runtime.entryProvider +import androidx.navigation3.runtime.rememberNavBackStack +import androidx.navigation3.ui.NavDisplay +import com.rtbishop.look4sat.core.presentation.Screen import org.junit.Assert.assertTrue import org.junit.Rule import org.junit.Test @@ -38,7 +42,7 @@ import org.robolectric.annotation.GraphicsMode */ @RunWith(RobolectricTestRunner::class) @GraphicsMode(GraphicsMode.Mode.NATIVE) -@Config(sdk = [34]) +@Config(sdk = [34], qualifiers = "w411dp-h891dp-port") class MutualMatchPrefillScrollTest { @get:Rule @@ -114,8 +118,7 @@ class MutualMatchPrefillScrollTest { fun prefillAutoStartsQueryAndFillsState() { val vm = MutualViewModel(FakeSatelliteRepo(), FakeSettingsRepo()) vm.prefillMatchFromGrid("OL62") - val s = vm.uiState.value - // Query auto-started: with the empty-satellite fake the query reaches + val s = vm.uiState.value // Query auto-started: with the empty-satellite fake the query reaches // the "no satellite data" guard (rather than never being triggered), // proving prefillMatchFromGrid kicks off queryMutualPasses. assertTrue( @@ -127,4 +130,28 @@ class MutualMatchPrefillScrollTest { org.junit.Assert.assertEquals("OL62", s.stationBGrid) org.junit.Assert.assertEquals(24, s.hoursAhead) } + + @Test + fun navDisplayEntryAfterPrefill_scrollsToTimeRange() { + // Closest to the real device path: the Mutual screen composed inside a + // NavDisplay entry (back stack [Mutual]) right after prefillMatchFromGrid. + val vm = MutualViewModel(FakeSatelliteRepo(), FakeSettingsRepo()) + vm.prefillMatchFromGrid("OL62") + composeRule.setContent { + val backStack = rememberNavBackStack(Screen.Mutual) + MaterialTheme { + Surface(modifier = Modifier.fillMaxSize()) { + NavDisplay( + backStack = backStack, + onBack = { backStack.removeLastOrNull() }, + entryProvider = entryProvider { + entry { MutualScreen(viewModel = vm) } + } + ) + } + } + } + composeRule.waitForIdle() + composeRule.onNodeWithText("Time range").assertIsDisplayed() + } }