package com.cottondb.days import android.app.Application import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import com.cottondb.days.pen.DaysCardLook import com.cottondb.days.pen.PenTheme import com.cottondb.days.ui.DaysSettings import com.cottondb.days.ui.DaysSkin import com.cottondb.days.ui.daysOwnRows import com.cottondb.settings.SettingsCheck import com.cottondb.shell.LocalCardLook import com.cottondb.shell.core.CottonCore import kotlinx.serialization.json.jsonObject import org.junit.Assert.assertEquals import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner import org.robolectric.annotation.Config /** * Days' Settings, organised as Comms' You (owner, 23 Nov 2026): the profile card, Days' own rows (Google calendars, * Week starts on), then Sync, Your Claude, Privacy, Notifications (with Days' alerts), Storage, Help and feedback and * About, each opening its page; every act a person had still reachable; nothing said raw. Before, one long page held * the calendars, the week, the account and its acts, 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 DaysSettingsTest { @get:Rule val compose = androidx.compose.ui.test.junit4.createComposeRule() private val wrap: @Composable (@Composable () -> Unit) -> Unit = { content -> PenTheme { CompositionLocalProvider(LocalCardLook provides DaysCardLook(com.cottondb.days.pen.penType())) { content() } } } private val google = CottonCore.json.parseToJsonElement("""{"accounts":[{"email":"pema.walktest@example.com","says":"Last brought in today at 9:05 ยท 12 events"}]}""").jsonObject private fun own(@Suppress("UNUSED_PARAMETER") done: SettingsCheck.Done) = daysOwnRows(SettingsCheck.lines("Days"), google, DaysSettings(weekStart = 1)) @Test fun days_own_rows_say_how_they_stand() { val rows = daysOwnRows(SettingsCheck.lines("Days"), google, DaysSettings(weekStart = 7)) assertEquals(listOf("google", "week", "export"), rows.map { it.id }) assertEquals(listOf("Google calendars", "Week starts on", "Export"), rows.map { it.label }) assertEquals(listOf("pema.walktest@example.com", "Sunday", "Your events and to-dos as a calendar file."), rows.map { it.line }) assertEquals("No Google calendar connected.", daysOwnRows(SettingsCheck.lines("Days"), null, DaysSettings(1))[0].line) } @Test fun signed_in_the_card_then_days_own_then_comms_rows_and_every_act_reachable() { SettingsCheck.signedInCheck(compose, "Days", DaysSkin(null), wrap, listOf("google", "week", "export"), ::own, notifies = true) } // 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, "Days", DaysSkin(null), wrap, listOf("google", "week", "export"), ::own, notifies = true) @Test fun signed_out_the_card_signs_in() = SettingsCheck.signedOutCheck(compose, "Days", DaysSkin(null), wrap, ::own) }