package com.cottondb.story import android.app.Application import androidx.compose.ui.semantics.SemanticsProperties import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.onNodeWithTag import androidx.compose.ui.text.font.FontWeight import com.cottondb.story.ink.SceneTitle import com.cottondb.story.ink.timeIn import org.junit.Assert.assertEquals import org.junit.Assert.assertNull import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner import org.robolectric.annotation.Config /** * Time of day is not shown prominently on the scene list (DECISIONS, gate 3): the place stands in the row's weight, * the time in the plain one. The walk found "Lighthouse lamp room · night" all bold (first-run walk, 25 Nov 2026). */ @RunWith(RobolectricTestRunner::class) @Config(sdk = [35], qualifiers = "w411dp-h891dp-mdpi", application = Application::class) class StorySceneTitleTest { @get:Rule val compose = createComposeRule() private val joined = "{place} · {time}" @Test fun the_time_is_found_by_the_cores_own_join() { val title = "Lighthouse lamp room · night" assertEquals(" · night", title.substring(timeIn(title, joined)!!)) // A place holding the join itself: the time is the last part. val dotted = "Kiosk · back room · dawn" assertEquals(" · dawn", dotted.substring(timeIn(dotted, joined)!!)) // A language that says the time first. val first = "nuit — phare" assertEquals("nuit — ", first.substring(timeIn(first, "{time} — {place}")!!)) // A place alone, a time alone: no time part. assertNull(timeIn("Lighthouse lamp room", joined)) } @Test fun the_place_is_semibold_and_the_time_plain() { val title = "Lighthouse lamp room · night" compose.setContent { SceneTitle(title, joined) } val text = compose.onNodeWithTag("story-scene-row-title", useUnmergedTree = true).fetchSemanticsNode().config[SemanticsProperties.Text].single() fun weightAt(i: Int) = text.spanStyles.filter { i in it.start until it.end && it.item.fontWeight != null }.last().item.fontWeight assertEquals(FontWeight.SemiBold, weightAt(title.indexOf("lamp"))) assertEquals(FontWeight.Normal, weightAt(title.indexOf("night"))) } }