package com.cottondb.days import android.app.Application import androidx.compose.foundation.gestures.scrollBy import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.PaddingValues import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyListState import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.material3.Text import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag import androidx.compose.ui.test.getBoundsInRoot import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.click import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.performTouchInput import androidx.compose.ui.unit.dp import kotlinx.coroutines.runBlocking import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner import org.robolectric.annotation.Config /** * Sometime's sixty invented to-dos under a foot taller than the fixed 96 dp the lists used to leave (the foot at the * largest text, or the adding bar with the keyboard): scrolled to its end, the last row stands wholly above the foot. * On the emulator it stood under the foot and could not be scrolled out (21 Nov 2026). And a tap on the foot stays on * the foot, never reaching a row scrolled under it. */ @RunWith(RobolectricTestRunner::class) @Config(sdk = [35], qualifiers = "w400dp-h700dp-mdpi", application = Application::class) class DaysFootTest { @get:Rule val compose = createComposeRule() private fun check(footHeight: Int) { lateinit var list: LazyListState compose.setContent { Box(Modifier.fillMaxSize()) { Footed(Modifier.fillMaxSize(), content = { room -> list = rememberLazyListState() LazyColumn(Modifier.fillMaxSize(), state = list, contentPadding = PaddingValues(bottom = room)) { items((1..60).toList()) { Text("Invented task $it", Modifier.fillMaxWidth().height(48.dp).testTag("row-$it")) } } }) { Box(Modifier.fillMaxWidth().height(footHeight.dp).testTag("foot-body")) } } } compose.waitForIdle() compose.runOnIdle { runBlocking { list.scrollToItem(59) } } compose.runOnIdle { runBlocking { list.scrollBy(100_000f) } } compose.waitForIdle() val last = compose.onNodeWithTag("row-60").getBoundsInRoot() val foot = compose.onNodeWithTag("days-foot").getBoundsInRoot() assertTrue("the last row ($last) stands above the foot ($foot)", last.bottom <= foot.top) } @Test fun the_last_row_clears_a_tall_foot() = check(footHeight = 180) @Test fun the_last_row_clears_the_adding_bar_and_keyboard() = check(footHeight = 420) /** On the emulator a tap beside the switch ticked "Invented chore 31", scrolled under the foot (21 Nov 2026). */ @Test fun a_tap_on_the_foot_reaches_no_row_under_it() { var tapped = 0 compose.setContent { Footed(Modifier.fillMaxSize(), content = { room -> LazyColumn(Modifier.fillMaxSize(), contentPadding = PaddingValues(bottom = room)) { items((1..60).toList()) { Text("Invented chore $it", Modifier.fillMaxWidth().height(48.dp).clickable { tapped++ }) } } }) { Box(Modifier.fillMaxWidth().height(90.dp).testTag("foot-body")) } } compose.onNodeWithTag("days-foot").performTouchInput { click(androidx.compose.ui.geometry.Offset(20f, centerY)) } compose.waitForIdle() assertEquals("no row under the foot was tapped", 0, tapped) } }