package com.cottondb.mailimport kotlinx.serialization.json.Jsonimport kotlinx.serialization.json.jsonObjectimport kotlinx.serialization.json.jsonPrimitiveimport org.junit.Assert.assertEqualsimport org.junit.Assert.assertTrueimport org.junit.Testimport java.io.File/** * FIRST SYNC in Post (owner, 26 Nov 2026, from the iPhone): while his copy comes down Post says it is loading, never * "No mail here yet", a count of nothing or "None yet"; and You's Sync says the one seen line, not "Signed in · syncing". */classPostFirstSyncTest {privateval repo = generateSequence(File("").absoluteFile) { it.parentFile }.first { File(it, "apps/registry.json").isFile }privatefun src(name: String) = File(repo, "apps/android/app/src/mail/kotlin/com/cottondb/mail/$name").readText()privateval words by lazy { Json.parseToJsonElement(File(repo, "crates/cotton-core/kits/shell/lines/post.json").readText()).jsonObject }privatefun word(path: String) = path.split(".").fold(words as kotlinx.serialization.json.JsonElement) { o, k -> o.jsonObject[k]!! }.jsonPrimitive.content/** Every empty state follows the one first-sync reading PostApp provides: the loading in its place, never the fact. */ @Testfun no_empty_state_stands_while_the_copy_comes_down() { assertTrue(src("PostApp.kt").contains("val first = com.cottondb.shell.rememberFirstSync(shell)")) assertTrue(src("PostApp.kt").contains("LocalFirstSync provides first,"))val bits = src("Bits.kt") assertTrue(bits.contains("LocalFirstSync.current?.let { FirstSyncNote(it); return }")) assertTrue(bits.contains("com.cottondb.shell.LoadingLine(loading, c.ink"))// The places that draw the core's empty line by other means follow it too. assertTrue(src("Domains.kt").contains("LocalFirstSync.current?.let { FirstSyncNote(it) } ?: Lead(line)")) assertTrue(src("Files.kt").contains("LocalFirstSync.current?.let { FirstSyncNote(it) } ?: Refused(it)")) }/** Home: the search box says what it searches, not a count of what has come; the loading is said once. */ @Testfun home_says_loading_once_and_no_count() {val home = src("Home.kt") assertTrue(home.contains("home.obj(\"search\")?.str(\"hint\")?.takeIf { first == null } ?: state.w(\"search.hint\")")) assertTrue(home.contains("if (first == null || answer?.str(\"empty\") == null)")) assertTrue(home.contains("com.cottondb.shell.LoadingLine(com.cottondb.shell.Loading.of(state.shell.home)")) assertEquals("Search mail, people, files", word("search.hint")) }/** * You: Sync says the seen line; the first sync is the core's, said once on the card, and the rows say what the phone * holds or a dash, never "None yet" mid-sync (the core's mail.you since 73ce5697b6; PostTabsTest). */ @Testfun you_says_the_one_line_and_no_count_of_nothing() {val you = src("You.kt") assertTrue(you.contains("val seen = com.cottondb.shell.rememberSyncSeen(state.shell)")) assertTrue(you.contains("id == \"sync\" && seen != null && words != state.w(\"you.sync\") -> seen.line")) assertTrue(you.contains("val unreached = YouSaid.unreached(answer)")) assertEquals("None yet", word("you.accounts_none")) assertEquals("None yet", word("you.domains_none")) assertTrue(word("you.count").contains("{n}"))// The Sync page already says the seen line. assertTrue(src("SharedPages.kt").contains("com.cottondb.shell.rememberSyncSeen(shell)?.line ?: opened")) }}