package com.cottondb.messages.warm import android.app.Application import androidx.activity.ComponentActivity import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.hasTestTag import androidx.compose.ui.test.junit4.createAndroidComposeRule import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.performScrollToNode import com.cottondb.messages.chat.ChatData import com.cottondb.messages.chat.ChatModel import com.cottondb.messages.chat.Words import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.SupervisorJob 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.RuntimeEnvironment import org.robolectric.annotation.Config /** * Seen on an emulator (21 Nov 2026), sideways at the largest text with the keyboard up: Add people (and New group) * kept the title and the fields fixed, and the people under them had no room at all, so nobody could be seen or * ticked while searching. The fields now scroll with the people, under the title and its button. A short window * stands for the keyboard. Invented numbers. */ @RunWith(RobolectricTestRunner::class) @Config(sdk = [35], qualifiers = "w800dp-h220dp-land-mdpi", application = Application::class) class ChoosePeopleTest { @get:Rule val compose = createAndroidComposeRule() @Test fun people_can_be_reached_under_the_fields_in_a_short_window() { RuntimeEnvironment.setFontScale(2f) val model = ChatModel(ChatData(null, null, Words { set, key -> "$set:$key" }, CoroutineScope(SupervisorJob()), null), CoroutineScope(SupervisorJob())) compose.setContent { WarmTheme(night = false) { ChoosePeople( model, "New group", "Back", "Create", "Who's in it", "What the group is called", onBack = {}, onGo = { _, _ -> }, find = { listOf("+15550100121" to "Asha Example", "+15550100122" to "Bina Example", "+15550100123" to "Chitra Example") }, ) } } compose.waitForIdle() compose.onNodeWithTag("choose-list").performScrollToNode(hasTestTag("choose-+15550100123")) compose.onNodeWithTag("choose-+15550100123").assertIsDisplayed() // Whole: the room the people stand in holds a person's row, not a sliver of it. val room = compose.onNodeWithTag("choose-list").fetchSemanticsNode().boundsInRoot.height val row = compose.onNodeWithTag("choose-+15550100123").fetchSemanticsNode().size.height / compose.density.density assertTrue("the people have ${room}dp, a row needs ${row}dp", room >= row) } }