package com.cottondb.messages.warm import androidx.compose.foundation.layout.Column import androidx.compose.foundation.text.BasicTextField import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.setValue import androidx.compose.ui.Modifier import androidx.compose.ui.platform.testTag import androidx.compose.ui.test.assertIsFocused import androidx.compose.ui.test.assertIsNotFocused import androidx.compose.ui.test.assertTextEquals import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.test.performClick import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner import org.robolectric.annotation.Config /** * FEEDBACK-4 B1 (owner on iPhone, Comms 26, 23 Nov 2026): a held message's menu was cut off by the message box. On * Android the menu is a sheet from the foot, but the keyboard stayed up under it and hid its last acts. Holding a * message now puts the keyboard down (the field loses its focus); what was written stays. */ @RunWith(RobolectricTestRunner::class) @Config(sdk = [35], application = android.app.Application::class) class HeldMenuKeyboardTest { @get:Rule val compose = createComposeRule() @Test fun holding_a_message_puts_the_keyboard_down() { var held by mutableStateOf(null) compose.setContent { var words by androidx.compose.runtime.remember { mutableStateOf("Half a reply") } Column { BasicTextField(words, { words = it }, Modifier.testTag("field")) held?.let { KeyboardDown(it) } } } compose.onNodeWithTag("field").performClick().assertIsFocused() compose.runOnIdle { held = "m1" } compose.onNodeWithTag("field").assertIsNotFocused().assertTextEquals("Half a reply") } }