package com.cottondb.notes import android.app.Application import androidx.compose.runtime.Composable import androidx.compose.ui.text.font.FontFamily import com.cottondb.settings.SettingsCheck import com.cottondb.shell.OwnRow import com.cottondb.writing.theme.Writing import com.cottondb.writing.theme.WritingTheme import com.cottondb.writing.theme.WritingType import kotlinx.serialization.json.Json import kotlinx.serialization.json.jsonObject import org.junit.Assert.assertEquals 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 /** * Words' Settings, organised as Comms' You (owner, 23 Nov 2026: "Comms' settings are well organised now; the other * three are not"): the profile card, Words' own rows (Look, Type, Import notes, Export), then Sync, Your Claude, * Privacy, Storage, Help and feedback, About, each opening its page; Sign out, Delete account, Sync now, Share a * report and the rest all still reachable; nothing said raw. Before, Settings held the look and type with Account a * button at its foot, and Account one long page of every act and part. Invented answers, the kit's own words. */ @RunWith(RobolectricTestRunner::class) @Config(sdk = [35], qualifiers = "w400dp-h800dp-mdpi", application = Application::class) class WordsSettingsTest { @get:Rule val compose = androidx.compose.ui.test.junit4.createComposeRule() private val theme = WritingTheme.of("linen", "Linen", Json.parseToJsonElement("""{"ground":"#F7F5F0","text":"#2E2E31","heading":"#1C1C1E","secondary":"#8A8A8F","accent":"#D2453A"}""").jsonObject) private val type = WritingType(FontFamily.Default, 17f, 1.5f, 600f, FontFamily.Monospace) private val wrap: @Composable (@Composable () -> Unit) -> Unit = { content -> val c = androidx.compose.ui.platform.LocalContext.current val (face, mono) = NotesLook.faces(c.assets) androidx.compose.runtime.CompositionLocalProvider(com.cottondb.shell.LocalCardLook provides NotesCardLook(NotesLook.standing(c, false), face, mono)) { Writing(theme, type) { content() } } } private val themes = Json.parseToJsonElement( """{"themes":[{"id":"linen","name":"Linen"},{"id":"slate","name":"Slate"}],"fonts":[{"id":"sans","name":"Figtree"}],"words":{"type":"Type"}}""", ).jsonObject private val chosen = Json.parseToJsonElement("""{"light_theme":"linen","dark_theme":"slate","font":"sans","font_size":17}""").jsonObject private fun own(done: SettingsCheck.Done): List = notesOwnRows(SettingsCheck.lines("Words"), themes, chosen, themes["words"]!!.jsonObject, onImport = { done.did += "import" }, onExport = { done.did += "export" }) @Test fun words_own_rows_say_how_they_stand() { val rows = own(SettingsCheck.Done()) assertEquals(listOf("look", "import", "export"), rows.map { it.id }) assertEquals(listOf("Look", "Import notes", "Export"), rows.map { it.label }) assertEquals("Linen ยท Slate", rows[0].line) } @Test fun signed_in_the_card_then_words_own_then_comms_rows_and_every_act_reachable() { val done = SettingsCheck.signedInCheck(compose, "Words", NotesSkin, wrap, listOf("look", "import", "export"), ::own, notifies = false, acting = listOf("import", "export")) assertTrue("Import notes and Export act at once: ${done.did}", done.did.containsAll(listOf("import", "export"))) } // 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, "Words", NotesSkin, wrap, listOf("look", "import", "export"), ::own, notifies = false) @Test fun signed_out_the_card_signs_in() = SettingsCheck.signedOutCheck(compose, "Words", NotesSkin, wrap, ::own) }