package com.cottondb.story import android.app.Application import androidx.compose.ui.test.assertIsEnabled import androidx.compose.ui.test.hasClickAction import androidx.compose.ui.test.hasText import androidx.compose.ui.test.junit4.createComposeRule import androidx.compose.ui.test.performClick import androidx.compose.ui.text.font.FontFamily import com.cottondb.story.ink.InkCardLook import com.cottondb.story.ink.InkType 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 /** * The shell's yes-or-no cards over Story (the microphone's reason before the phone's ask): Not now closes the card, * and Continue goes on (drawn as the main button, filled in the ballpoint blue: seen on the emulator). On the emulator (first-run walk, 25 Nov 2026) Not now * was drawn greyed and did nothing, so only Back closed the card, and Continue was outlined. */ @RunWith(RobolectricTestRunner::class) @Config(sdk = [35], qualifiers = "w411dp-h891dp-mdpi", application = Application::class) class StoryConfirmCardTest { @get:Rule val compose = createComposeRule() private val why = "Story uses the microphone only while you dictate, to write down what you say." @Test fun not_now_closes_the_card() { var dismissed = 0 var went = 0 compose.setContent { InkCardLook(InkType(FontFamily.Monospace, FontFamily.Monospace)).Confirm(why, "Continue", "voice-mic-go-on", onYes = { went++ }, onDismiss = { dismissed++ }, no = "Not now") } compose.onNode(hasText("Not now") and hasClickAction(), useUnmergedTree = true).assertIsEnabled().performClick() compose.runOnIdle { assertEquals(1, dismissed); assertEquals(0, went) } } @Test fun continue_goes_on() { var went = 0 compose.setContent { InkCardLook(InkType(FontFamily.Monospace, FontFamily.Monospace)).Confirm(why, "Continue", "voice-mic-go-on", onYes = { went++ }, onDismiss = {}, no = "Not now") } compose.onNode(hasText("Continue") and hasClickAction(), useUnmergedTree = true).performClick() compose.runOnIdle { assertEquals(1, went) } } }