Files
aiturk-mobil/app/src/androidTest/java/com/m57/hermescontrol/BottomNavigationLayoutTest.kt
T
M57andM57 e18b25d065 fix(ux): keep Settings highlighted in bottom nav on drill-down sub-pages (issue #637) (#643)
* fix(ux): keep Settings highlighted in bottom nav on drill-down sub-pages (issue #637)

Map Settings drill-down destinations (SettingsConnection, SettingsAppearance, SettingsChat, SettingsNavBar, SettingsBehavior, SettingsAbout) back to SettingsScreen for bottom-nav selection only - navigation is unaffected.

- Add selectedBottomNavDestination() helper in Navigation.kt
- Extract bar-height logic into Modifier.bottomNavigationHeight() (ICON_AND_TEXT now uses heightIn(min=80.dp) so the standard bar can grow)
- BottomNavigationSelectionTest (JVM): selection mapping logic
- BottomNavigationLayoutTest (androidTest): per-mode bar height assertions

* docs(navigation): warn that new Settings sub-pages must be added to settingsDestinations

Addresses agy review (PR #643): documents the fragility of the hardcoded settingsDestinations set so future Settings drill-down screens don't silently drop the bottom-nav highlight. The sealed-class/marker-interface refactor was declined as scope creep (issue #637 explicitly scopes Settings-only; keys are flat data objects).

* fix: language selector

---------

Co-authored-by: M57 <Hy4ri@users.noreply.github.com>
2026-07-20 18:26:05 +03:00

61 lines
2.2 KiB
Kotlin

package com.m57.hermescontrol
import androidx.compose.foundation.layout.Box
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.testTag
import androidx.compose.ui.test.assertHeightIsAtLeast
import androidx.compose.ui.test.assertHeightIsEqualTo
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.unit.dp
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.MediumTest
import com.m57.hermescontrol.theme.BottomNavDisplayMode
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
/**
* Instrumented tests for [Modifier.bottomNavigationHeight].
*
* Each compact bottom-nav display mode maps to a specific bar height:
* - [BottomNavDisplayMode.ICON_ONLY] -> 56.dp (fixed)
* - [BottomNavDisplayMode.TEXT_ONLY] -> 44.dp (fixed)
* - [BottomNavDisplayMode.ICON_AND_TEXT] -> min 80.dp (can grow)
*
* We apply the modifier to a tagged [Box] and assert the resulting height on
* a real Compose host (this requires the instrumentation test runner, hence
* androidTest rather than the Robolectric-free JVM test source set).
*/
@RunWith(AndroidJUnit4::class)
@MediumTest
class BottomNavigationLayoutTest {
@get:Rule
val composeTestRule = createComposeRule()
@Test
fun iconOnly_barHeightIs56dp() {
composeTestRule.setContent {
Box(Modifier.testTag("bar").bottomNavigationHeight(BottomNavDisplayMode.ICON_ONLY))
}
composeTestRule.onNodeWithTag("bar").assertHeightIsEqualTo(56.dp)
}
@Test
fun textOnly_barHeightIs44dp() {
composeTestRule.setContent {
Box(Modifier.testTag("bar").bottomNavigationHeight(BottomNavDisplayMode.TEXT_ONLY))
}
composeTestRule.onNodeWithTag("bar").assertHeightIsEqualTo(44.dp)
}
@Test
fun iconAndText_barHeightIsAtLeast80dp() {
composeTestRule.setContent {
Box(Modifier.testTag("bar").bottomNavigationHeight(BottomNavDisplayMode.ICON_AND_TEXT))
}
// heightIn(min = 80.dp) — assert the measured height meets the minimum.
composeTestRule.onNodeWithTag("bar").assertHeightIsAtLeast(80.dp)
}
}