Cotton code
40 lines · 2.4 KB · KotlinRaw
package com.cottondb.messages.warmimport org.junit.Assert.assertTrueimport org.junit.Testimport java.io.File/** * FIRST SYNC in Comms (owner, 26 Nov 2026, from the iPhone): while his copy comes down Chats and Calls say it is * loading, never "No chats yet", "No calls yet", "No mail yet" or "Nobody has written to you"; You's Sync row and its page say the one seen line. */class CommsFirstSyncTest {    private val repo = generateSequence(File("").absoluteFile) { it.parentFile }.first { File(it, "apps/registry.json").isFile }    private fun src(name: String) = File(repo, "apps/android/app/src/messages/kotlin/com/cottondb/messages/warm/$name").readText()    @Test    fun chats_and_calls_say_loading_not_empty() {        val root = src("ChatRoot.kt")        assertTrue(root.contains("val first = com.cottondb.shell.rememberFirstSync(shell)"))        assertTrue(root.split("first = first,").size == 3)        val chats = src("Chats.kt")        assertTrue(chats.contains("val withheld = first != null && list?.empty != null"))        assertTrue(chats.contains("if (withheld && first != null) item(key = \"chat-first-sync\""))        // Said once: the lines over the list stand down while the loading stands in the empty place.        assertTrue(chats.contains("if (loading != null && !withheld)"))        assertTrue(chats.contains("if (syncSeen != null && !withheld)"))        assertTrue(src("Mail.kt").contains("first = com.cottondb.shell.rememberFirstSync(shell),"))        assertTrue(src("Mail.kt").contains("first != null) item(key = \"mail-first-sync\") { FirstSyncNote(first, \"mail-first-sync\") }"))        assertTrue(src("Senders.kt").contains("if (page != null && rows.isEmpty() && first != null) item(key = \"first-sync\") { FirstSyncNote(first, \"senders-first-sync\") }"))        assertTrue(src("Calls.kt").contains("if (page.rows.isEmpty() && first != null) { FirstSyncNote(first, \"calls-first-sync\"); return@Column }"))    }    @Test    fun you_says_the_one_line() {        val root = src("ChatRoot.kt")        assertTrue(root.contains("val seen = com.cottondb.shell.rememberSyncSeen(shell)"))        // The one line, except while changes cannot be sent: the row then says those (UNSENT HEAL, YouGroupedTest).        assertTrue(root.contains("YouRow.of(you).map { syncRow(it, seen?.line, you?.obj(\"sync\")?.obj(\"stuck\")) }"))        assertTrue(root.contains("seen?.line ?: sync?.str(\"title\")"))    }}