package com.cottondb.story import android.app.Application import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.width import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.ui.Modifier import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.test.getBoundsInRoot import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.unit.dp 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 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 /** * About's facts in Story: a long fact (the database and its server) takes at most half the row, so its label stays * whole. It squeezed "Account" into a column of single letters (emulator-5600 against dev, 24 Nov 2026). Invented host. */ @RunWith(RobolectricTestRunner::class) @Config(sdk = [35], qualifiers = "w400dp-h800dp-mdpi", application = Application::class) class StoryAboutFactTest { @get:Rule val compose = createComposeRule() @Test fun a_long_fact_leaves_its_label_whole() { compose.setContent { InkTheme { CompositionLocalProvider(LocalCardLook provides InkCardLook(inkFonts(LocalContext.current))) { Column(Modifier.width(360.dp)) { StorySkin().Fact("Account", "03e79f00 ยท cottondb-invented-host.example.workers.dev", null, "about-database") } } } } val row = compose.onNodeWithTag("about-database").getBoundsInRoot() val said = compose.onNodeWithTag("about-database-said", useUnmergedTree = true).getBoundsInRoot() assertTrue("the fact takes at most half the row: $said of $row", (said.right - said.left) <= (row.right - row.left) / 2 + 1.dp) } }