package com.cottondb.story import android.app.Application import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.platform.LocalContext import com.cottondb.settings.SettingsCheck import com.cottondb.shell.LocalCardLook import com.cottondb.story.ink.InkCardLook import com.cottondb.story.ink.InkTheme import com.cottondb.story.ink.StorySkin import com.cottondb.story.ink.inkFonts import com.cottondb.story.ink.storyOwnRows import org.junit.Assert.assertEquals import kotlinx.serialization.json.jsonObject import org.junit.Assert.assertTrue import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner import org.robolectric.annotation.Config /** * Story's Settings, organised as Comms' You (owner, 23 Nov 2026): the card, Story's own row (Text size), then Sync, * Your Claude, Privacy, Storage, Help and feedback (with Write to us) and About, each opening its page; Sign out, * Delete account, Sync now, Share a report and the rest all still reachable; nothing said raw. Before, one long page * held who you are, the account's acts, Text size, Your people, the recovery code, passkeys, the assistant, Delete * account, Storage, Help and About in a row. Invented answers, the kit's own words. */ @RunWith(RobolectricTestRunner::class) @Config(sdk = [35], qualifiers = "w400dp-h800dp-mdpi", application = Application::class) class StorySettingsTest { @get:Rule val compose = androidx.compose.ui.test.junit4.createComposeRule() private val wrap: @Composable (@Composable () -> Unit) -> Unit = { content -> InkTheme { CompositionLocalProvider(LocalCardLook provides InkCardLook(inkFonts(LocalContext.current))) { content() } } } private val look = kotlinx.serialization.json.Json.parseToJsonElement("""{"line":"Grey · Blue"}""").jsonObject private fun own(@Suppress("UNUSED_PARAMETER") done: SettingsCheck.Done) = storyOwnRows(SettingsCheck.lines("Story"), look) /** Look is Story's one own row: it holds the size, so Text size is gone (coordinator, 24 Nov 2026). */ @Test fun storys_own_row_is_look_and_there_is_no_text_size() { val rows = own(SettingsCheck.Done()) assertEquals(listOf("look"), rows.map { it.id }) assertEquals("Grey · Blue", rows[0].line) } @Test fun signed_in_the_card_then_storys_own_then_comms_rows_and_every_act_reachable() { SettingsCheck.signedInCheck(compose, "Story", StorySkin(), wrap, listOf("look"), ::own, notifies = false) } // Owner, build 24: the card drew first and the rows a second or two later. @Test fun every_row_stands_on_the_first_frame_and_fills_in_place() = SettingsCheck.firstFrameCheck(compose, "Story", StorySkin(), wrap, listOf("look"), ::own, notifies = false) @Test fun signed_out_the_card_signs_in() = SettingsCheck.signedOutCheck(compose, "Story", StorySkin(), wrap, ::own) /** Story's copy may have no person yet after signing in: the card said only the number while Your name said * "Mira Walktest" below it (emulator-5558, 23 Nov 2026). The name given at sign-in stands in until the copy has one. */ @Test fun the_card_names_you_with_the_name_given_at_sign_in_until_the_copy_has_one() { val answer = kotlinx.serialization.json.Json.parseToJsonElement("""{"profile":{"signed_in":true}}""") as kotlinx.serialization.json.JsonObject assertEquals(com.cottondb.shell.SettingsWho("Mira Walktest", "+15550190001", true), com.cottondb.shell.settingsWho(answer, "+15550190001", "Mira Walktest")) val named = kotlinx.serialization.json.Json.parseToJsonElement("""{"profile":{"signed_in":true,"name":"Mira W."}}""") as kotlinx.serialization.json.JsonObject assertEquals("Mira W.", com.cottondb.shell.settingsWho(named, "+15550190001", "Mira Walktest").name) assertEquals(com.cottondb.shell.SettingsWho("+15550190001", null, true), com.cottondb.shell.settingsWho(answer, "+15550190001")) } }