50 lines · 2.7 KB · KotlinRaw
package com.cottondb.messages.warmimport android.app.Applicationimport androidx.compose.foundation.lazy.LazyListStateimport androidx.compose.ui.test.assertIsDisplayedimport androidx.compose.ui.test.assertTextEqualsimport androidx.compose.ui.test.junit4.createComposeRuleimport androidx.compose.ui.test.onNodeWithTagimport com.cottondb.messages.chat.ThreadPageimport com.cottondb.messages.chat.ThreadStateimport com.cottondb.messages.chat.Wordsimport com.cottondb.shell.core.CottonCoreimport kotlinx.serialization.json.jsonObjectimport org.junit.Ruleimport org.junit.Testimport org.junit.runner.RunWithimport org.robolectric.RobolectricTestRunnerimport 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() }}