package com.cottondb.messages.warm import android.app.Application import androidx.compose.foundation.lazy.LazyListState import androidx.compose.ui.test.assertIsDisplayed import androidx.compose.ui.test.assertTextEquals import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithTag import com.cottondb.messages.chat.ThreadPage import com.cottondb.messages.chat.ThreadState import com.cottondb.messages.chat.Words import com.cottondb.shell.core.CottonCore import kotlinx.serialization.json.jsonObject import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner import org.robolectric.annotation.Config /** * "TYPING…" IN THE HEADER (walk, 21 Nov 2026): with both people's Typing switches on, one typed and the other's * conversation showed nothing; the Warm conversation drew no typing at all. While they type, the header's status line * says the kit's "typing…"; otherwise it says the status as before. */ @RunWith(RobolectricTestRunner::class) @Config(sdk = [35], qualifiers = "w400dp-h860dp-xhdpi", application = Application::class) class ConversationTypingTest { @get:Rule val compose = createComposeRule() private val words = Words { set, key -> "$set:$key" } private val threadWords = ThreadWordsWarm("Back", "Call", "Video call", "Not sent", "Try again", "You", "Their page") private fun j(text: String) = CottonCore.json.parseToJsonElement(text).jsonObject private val acts = MessageActs({}, {}, { _, _ -> }, {}, { _, _ -> }, {}, { _, _ -> }, {}, {}, VoicePlayer(kotlinx.coroutines.MainScope())) private fun thread() = ThreadState("t1", ThreadPage.of(j("""{"thread":"t1","header":{"name":"Rose Martin","picture":{"initials":"RM","tint":1},"status":"Disappearing messages: 7 days"}, "items":[{"item":"bubble","message":"m1","mine":false,"kind":"text","text":"Are we still on?","head":true,"tail":true,"time":"19:00","pinned":false,"actions":["reply"]}]}"""), words)) @Test fun while_they_type_the_header_says_so() { compose.setContent { WarmTheme(night = false) { Conversation(thread(), LazyListState(), acts, threadWords, {}, {}, {}, {}, {}, {}, {}, {}, null, {}, {}, typing = "typing…") {} } } compose.waitForIdle() compose.onNodeWithTag("thread-typing", useUnmergedTree = true).assertIsDisplayed().assertTextEquals("typing…") } @Test fun otherwise_the_status_stands() { compose.setContent { WarmTheme(night = false) { Conversation(thread(), LazyListState(), acts, threadWords, {}, {}, {}, {}, {}, {}, {}, {}, null, {}, {}) {} } } compose.waitForIdle() compose.onNodeWithTag("thread-typing", useUnmergedTree = true).assertDoesNotExist() } }