package com.cottondb.story import android.app.Application import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableIntStateOf import androidx.compose.runtime.setValue import androidx.compose.ui.test.junit4.createComposeRule import com.cottondb.story.ink.Current import com.cottondb.story.ink.InkState 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 /** * A Story that said "Nothing here yet" asks again when a change lands. On the emulator (21 Nov 2026) a phone signed in * again and opened with its recovery code kept "Nothing here yet" over the person's invented 180-scene script until * Story was closed and opened again. */ @RunWith(RobolectricTestRunner::class) @Config(sdk = [35], qualifiers = "w400dp-h800dp-mdpi", application = Application::class) class StoryAskAgainTest { @get:Rule val compose = createComposeRule() @Test fun a_script_that_becomes_readable_comes_home_on_the_next_change() { val state = InkState() state.come(Current(story = null, arriving = null)) var answer = Current(story = null, arriving = null) var revision by mutableIntStateOf(0) compose.setContent { AskWhileNoScript(state, revision) { answer } } compose.waitForIdle() assertNull(state.story) // The key opens and the core can read the script: the next change that lands brings it home. answer = Current(story = "invented-harbour", arriving = null) compose.runOnIdle { revision++ } compose.waitForIdle() assertEquals("invented-harbour", state.story) } }