package com.cottondb.keys import com.cottondb.keys.secrets.kindLine import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Test import java.io.File /** * STORE READY (26 Nov 2026): what the Secrets walk on an emulator found at the largest text, on a small phone and a * tablet, in night and with TalkBack, kept fixed. */ class SecretsStoreReadyTest { 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/keys/kotlin/com/cottondb/keys/secrets/$name").readText() /** The line under a secret's name says its kind once: "Card", not "Card · Card". */ @Test fun the_kind_is_said_once() { assertEquals("Card", kindLine("Card", "Card")) assertEquals("API key", kindLine("API key", "api key ")) assertEquals("Login · asha@example.com", kindLine("Login", "asha@example.com")) assertEquals("Note", kindLine("Note", " ")) assertEquals("Login", kindLine("Login", null)) } /** While a sheet stands, what it covers is out of TalkBack's reach, and the veil over it has a name. */ @Test fun a_sheet_hides_what_it_covers() { val app = src("SecretsApp.kt") assertTrue(app.contains("val covered = state.sheet != null")) assertTrue(app.contains("if (covered) Modifier.clearAndSetSemantics {}")) val host = src("SecretsCardLook.kt") assertTrue(host.contains("semantics { contentDescription = close }")) assertTrue(host.contains("statusBarsPadding()")) } /** A value in clear keeps the window out of screenshots: the edit form once revealed or typed, the generator always. */ @Test fun values_in_clear_are_kept_secure() { assertTrue(src("EditScreen.kt").contains("SecureWhile(fields.any")) assertTrue(src("GeneratorScreen.kt").contains("SecureWhile(true)")) } /** The core's `open_page` opens its page: the About, Help and Privacy rows did nothing before. */ @Test fun open_page_opens_its_page() { val state = src("SecretsState.kt") assertTrue(state.contains(""""open_page" -> platform.str("page")""")) listOf("\"import\" -> Screen.Import", "\"look\" -> Screen.Look", "\"recovery\" -> Screen.Recovery", "in SHARED_PAGES -> Screen.Page(page)").forEach { assertTrue(it, state.contains(it)) } val shared = src("SharedPages.kt") listOf("privacy", "storage", "help", "about").forEach { assertTrue(it, shared.contains("\"$it\"")) } assertTrue(src("SecretsApp.kt").contains("is Screen.Page -> SharedPage(state, screen.id)")) } /** You draws the core's groups as it names them now: Open with (`open_with`), Privacy, Storage, Help, About. */ @Test fun you_draws_every_group() { val places = src("Places.kt") assertTrue(places.contains("""groups["open_with"]""")) listOf("\"privacy\"", "\"storage\", \"help\"", "\"about\"").forEach { assertTrue(it, places.contains(it)) } } /** Look's preview is the core's (`look`'s `preview`), never words written on the phone. */ @Test fun the_look_preview_is_the_cores() { val places = src("Places.kt") assertTrue(places.contains("""answer.obj("preview")""")) assertFalse(places.contains("\"Stripe test key\"")) } /** TalkBack's few words of its own come from the line sets, not English written here. */ @Test fun spoken_words_come_from_lines() { val bits = src("Bits.kt") assertFalse(bits.contains("contentDescription = \"Hidden\"")) assertFalse(bits.contains("control(\"Clear\")")) assertFalse(src("SecretsCardLook.kt").contains("onClickLabel = \"Close\"")) assertTrue(src("SecretsApp.kt").contains("""state.w("a11y.hidden")""")) } /** At the largest text nothing is cut mid-word: values and acts go under their words, rows take two lines. */ @Test fun large_text_moves_things_under() { val bits = src("Bits.kt") assertTrue("PlainRow wraps its value", bits.contains("FlowRow(row, horizontalArrangement = Arrangement.SpaceBetween")) assertTrue("InputBox acts go under", bits.contains("val under = acts != null && LocalDensity.current.fontScale > 1.3f")) assertTrue("SRow end goes under", bits.contains("val under = end != null && !endFixed && LocalDensity.current.fontScale > 1.3f")) assertTrue("group acts wrap", src("Places.kt").contains("FlowRow(rowModifier")) assertTrue("list rows two lines", src("ListScreen.kt").contains("T(title, 17.sp, weight = FontWeight.SemiBold, lines = 2)")) } /** The shell's sheets (Delete account, sign-in) keep Secrets' one side margin, and a tablet keeps a phone's width. */ @Test fun sheets_and_tablets_keep_their_width() { assertTrue(src("SecretsCardLook.kt").contains("override val sheetInset: Dp = 0.dp")) assertTrue(src("SecretsApp.kt").contains("widthIn(max = MOST_WIDE)")) } }