46 lines · 2.0 KB · KotlinRaw
package com.cottondb.storyimport android.app.Applicationimport androidx.compose.foundation.layout.Columnimport androidx.compose.foundation.layout.widthimport androidx.compose.runtime.CompositionLocalProviderimport androidx.compose.ui.Modifierimport androidx.compose.ui.platform.LocalContextimport androidx.compose.ui.test.getBoundsInRootimport androidx.compose.ui.test.junit4.createComposeRuleimport androidx.compose.ui.test.onNodeWithTagimport androidx.compose.ui.unit.dpimport com.cottondb.shell.LocalCardLookimport com.cottondb.story.ink.InkCardLookimport com.cottondb.story.ink.InkThemeimport com.cottondb.story.ink.StorySkinimport com.cottondb.story.ink.inkFontsimport org.junit.Assert.assertTrueimport org.junit.Ruleimport org.junit.Testimport org.junit.runner.RunWithimport org.robolectric.RobolectricTestRunnerimport 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) }}