57 lines · 2.7 KB · KotlinRaw
package com.cottondb.messages.warmimport android.app.Applicationimport androidx.activity.ComponentActivityimport androidx.compose.foundation.layout.Boximport androidx.compose.foundation.layout.fillMaxWidthimport androidx.compose.foundation.layout.heightimport androidx.compose.foundation.lazy.LazyListStateimport androidx.compose.ui.Modifierimport androidx.compose.ui.platform.testTagimport androidx.compose.ui.test.assertIsDisplayedimport androidx.compose.ui.test.junit4.createAndroidComposeRuleimport androidx.compose.ui.test.onNodeWithTagimport androidx.compose.ui.test.performScrollToKeyimport androidx.compose.ui.unit.dpimport com.cottondb.messages.chat.ChatListimport 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/** * Sideways, a slip standing (the recovery code, a device to approve) and the chips left Chats' rows no room at all: * they now scroll with the rows, so the rows come into view under them. Invented chats. */@RunWith(RobolectricTestRunner::class)@Config(sdk = [35], qualifiers = "w731dp-h411dp-land-mdpi", application = Application::class)class ChatsRoomTest { @get:Rule val compose = createAndroidComposeRule<ComponentActivity>() private fun row(i: Int) = """{"thread":"t$i","name":"Invented Example $i","group":false,"source":"whatsapp","picture":{"initials":"IE","tint":1}, "lastLine":{"text":"See you at seven","mine":false},"when":"Tue","unread":0,"markedUnread":false,"pinned":false,"muted":false, "archived":false,"leading":[],"trailing":[]}""" @Test fun sideways_with_a_slip_the_rows_scroll_into_view() { val list = ChatList.of(CottonCore.json.parseToJsonElement("""{"words":{"title":"Chats","search":"Search"}, "filters":[{"id":"all","label":"All","on":true},{"id":"waiting","label":"Waiting on you","count":2,"on":false},{"id":"groups","label":"Groups","on":false}], "rows":[${(1..30).joinToString(",") { row(it) }}]}""").jsonObject, Words { set, key -> "$set:$key" }) compose.setContent { WarmTheme(night = false) { ChatsPlace( list, LazyListState(), "", ChatsWords("New chat", "You", "Muted", "Pinned", "Unread", "More"), {}, {}, {}, { _, _ -> }, {}, {}, {}, slips = { Box(Modifier.fillMaxWidth().height(260.dp).testTag("a-slip")) }, ) } } compose.waitForIdle() compose.onNodeWithTag("chat-list").performScrollToKey("t3") compose.waitForIdle() compose.onNodeWithTag("chat-row-t3").assertIsDisplayed() }}