Closer/app/src/androidTest/java/app/closer/ui/home/HomeContentRenderSmokeTest.kt

63 lines
2.7 KiB
Kotlin

package app.closer.ui.home
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.test.ext.junit.runners.AndroidJUnit4
import app.closer.ui.theme.CloserTheme
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
/**
* Instrumented render smoke for the Home screen — the on-device net for the "composes fine, crashes
* on first paint" class that JVM unit tests and static scanners can't catch. Created alongside the
* HomeScreen decomposition (1921 -> 614 lines across the ui/home/components package) so any extraction
* or @Immutable change that breaks Home rendering is caught.
*
* Renders the self-contained, VM-free `PairedHomePreviewScreen` (which builds demo HomeUiState and
* calls the private HomeContent) — a successful render exercises HomeContent + every extracted
* cluster (header, status strip, primary card, action feed, pending, category grid). Both light and
* dark are covered (Home has decoupled theme art + per-theme colors).
*
* WARNING: Run on a THROWAWAY emulator only - connectedDebugAndroidTest uninstalls the
* app-under-test, which WIPES fixture data. Never run against the 5554/5556 fixture couple.
* ANDROID_SERIAL=emulator-5558 ./gradlew :app:connectedDebugAndroidTest
*/
@RunWith(AndroidJUnit4::class)
class HomeContentRenderSmokeTest {
@get:Rule
val composeRule = createComposeRule()
@Test
fun pairedHome_rendersHeaderAndStatusStrip_light() {
composeRule.setContent {
CloserTheme(darkTheme = false) { PairedHomePreviewScreen() }
}
composeRule.onNodeWithText("For tonight").assertIsDisplayed() // HomeHeader
composeRule.onNodeWithText("Just for two").assertIsDisplayed() // HomeStatusStrip
}
@Test
fun pairedHome_rendersHeader_dark() {
composeRule.setContent {
CloserTheme(darkTheme = true) { PairedHomePreviewScreen() }
}
composeRule.onNodeWithText("For tonight").assertIsDisplayed()
}
@Test
fun pairedHome_rendersInUnansweredState() {
// Exercises the UNANSWERED daily-question render path (a different primary-card branch); a
// regression that broke composition in this state would throw during setContent. Asserts the
// stable header rather than a specific CTA (demo state differs from the live app).
composeRule.setContent {
CloserTheme(darkTheme = false) {
PairedHomePreviewScreen(dailyQuestionState = DailyQuestionState.UNANSWERED)
}
}
composeRule.onNodeWithText("For tonight").assertIsDisplayed()
}
}