68 lines · 3.9 KB · KotlinRaw
package com.cottondb.messages.warmimport android.app.Applicationimport androidx.compose.ui.test.assertIsDisplayedimport androidx.compose.ui.test.junit4.createComposeRuleimport androidx.compose.ui.test.onNodeWithTextimport com.cottondb.messages.chat.ChatDataimport com.cottondb.messages.chat.ChatModelimport com.cottondb.messages.chat.ThreadPageimport com.cottondb.messages.chat.Wordsimport com.cottondb.shell.core.CottonCoreimport kotlinx.coroutines.CoroutineScopeimport kotlinx.coroutines.SupervisorJobimport kotlinx.coroutines.runBlockingimport kotlinx.serialization.json.jsonObjectimport org.junit.Ruleimport org.junit.Testimport org.junit.runner.RunWithimport org.robolectric.RobolectricTestRunnerimport org.robolectric.annotation.Config/** * Seen on an emulator (21 Nov 2026): Meera set Disappearing messages to 24 hours from Kabir's page and went Back: the * header said "Disappearing messages: 24 hours", but "You turned on disappearing messages…" stood below the screen, * found only by scrolling down, though the conversation had stood at its foot. Invented numbers and words. */@RunWith(RobolectricTestRunner::class)@Config(sdk = [35], qualifiers = "w400dp-h860dp-xhdpi", application = Application::class)class LineAtFootTest { @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 val acts = MessageActs({}, {}, { _, _ -> }, {}, { _, _ -> }, {}, { _, _ -> }, {}, {}, VoicePlayer(kotlinx.coroutines.MainScope())) private val line = "You turned on disappearing messages. New messages will disappear 24 hours after they're sent." private fun page(foot: String) = ThreadPage.of(CottonCore.json.parseToJsonElement(""" {"thread":"t1","header":{"name":"+15550100123","picture":{"initials":"","tint":1},"source":"cotton","status":"","calls":[]}, "items":[${(1..24).joinToString(",") { """{"item":"bubble","message":"m$it","mine":${it % 2 == 0},"kind":"text","text":"Invented words $it","head":true,"tail":true,"time":"20:0${it % 10}","pinned":false,"actions":["reply"]}""" }}$foot]} """).jsonObject, words) @Test fun a_line_set_from_the_page_stands_at_the_foot_on_going_back() { val model = ChatModel(ChatData(null, null, words, CoroutineScope(SupervisorJob()), null), CoroutineScope(SupervisorJob())) model.prefetched["t1"] = page("") model.open("t1", unread = false) compose.setContent { WarmTheme(night = false) { Conversation(model.thread!!, model.threadList, acts, threadWords, {}, {}, {}, {}, {}, {}, {}, {}, null, {}, {}) {} } } compose.waitForIdle() compose.onNodeWithText("Invented words 24").assertIsDisplayed() runBlocking { model.actOn("t1", work = {}, read = { page(""",{"item":"event","message":"e1","text":"$line"}""") }) } compose.waitForIdle() compose.onNodeWithText(line).assertIsDisplayed() } // Seen on two emulators (21 Nov 2026): Tara called Meera, who declined: Tara's conversation, at its foot, had the // line "Voice call · Declined" below the screen, found only by closing and opening it again. @Test fun a_call_ended_puts_its_line_at_the_foot_in_sight() { val model = ChatModel(ChatData(null, null, words, CoroutineScope(SupervisorJob()), null), CoroutineScope(SupervisorJob())) model.prefetched["t1"] = page("") model.open("t1", unread = false) compose.setContent { WarmTheme(night = false) { Conversation(model.thread!!, model.threadList, acts, threadWords, {}, {}, {}, {}, {}, {}, {}, {}, null, {}, {}) {} } } compose.waitForIdle() runBlocking { model.callEnded { page(""",{"item":"event","message":"c1","text":"Voice call · Declined"}""") } } compose.waitForIdle() compose.onNodeWithText("Voice call · Declined").assertIsDisplayed() }}