Cotton code
45 lines · 1.9 KB · KotlinRaw
package com.cottondb.messages.warmimport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.text.BasicTextFieldimport androidx.compose.runtime.getValueimport androidx.compose.runtime.mutableStateOfimport androidx.compose.runtime.setValueimport androidx.compose.ui.Modifierimport androidx.compose.ui.platform.testTagimport androidx.compose.ui.test.assertIsFocusedimport androidx.compose.ui.test.assertIsNotFocusedimport androidx.compose.ui.test.assertTextEqualsimport androidx.compose.ui.test.junit4.createComposeRuleimport androidx.compose.ui.test.onNodeWithTagimport androidx.compose.ui.test.performClickimport org.junit.Ruleimport org.junit.Testimport org.junit.runner.RunWithimport org.robolectric.RobolectricTestRunnerimport 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<String?>(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")    }}